Skip to content

Commit 574cfbc

Browse files
author
bmeurer@chromium.org
committed
Introduce DisallowDeoptimization scope.
R=yangguo@chromium.org Review URL: https://codereview.chromium.org/254763007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20998 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
1 parent b922b0d commit 574cfbc

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/assert-scope.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ enum PerThreadAssertType {
5050
enum PerIsolateAssertType {
5151
JAVASCRIPT_EXECUTION_ASSERT,
5252
JAVASCRIPT_EXECUTION_THROWS,
53-
ALLOCATION_FAILURE_ASSERT
53+
ALLOCATION_FAILURE_ASSERT,
54+
DEOPTIMIZATION_ASSERT
5455
};
5556

5657

@@ -268,6 +269,14 @@ typedef PerIsolateAssertScopeDebugOnly<ALLOCATION_FAILURE_ASSERT, false>
268269
typedef PerIsolateAssertScopeDebugOnly<ALLOCATION_FAILURE_ASSERT, true>
269270
AllowAllocationFailure;
270271

272+
// Scope to document where we do not expect deoptimization.
273+
typedef PerIsolateAssertScopeDebugOnly<DEOPTIMIZATION_ASSERT, false>
274+
DisallowDeoptimization;
275+
276+
// Scope to introduce an exception to DisallowDeoptimization.
277+
typedef PerIsolateAssertScopeDebugOnly<DEOPTIMIZATION_ASSERT, true>
278+
AllowDeoptimization;
279+
271280
} } // namespace v8::internal
272281

273282
#endif // V8_ASSERT_SCOPE_H_

src/objects-inl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4679,6 +4679,7 @@ bool Code::marked_for_deoptimization() {
46794679

46804680
void Code::set_marked_for_deoptimization(bool flag) {
46814681
ASSERT(kind() == OPTIMIZED_FUNCTION);
4682+
ASSERT(!flag || AllowDeoptimization::IsAllowed(GetIsolate()));
46824683
int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
46834684
int updated = MarkedForDeoptimizationField::update(previous, flag);
46844685
WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);

src/objects.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2781,6 +2781,7 @@ MaybeHandle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) {
27812781
// static
27822782
MaybeHandle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> old_map) {
27832783
DisallowHeapAllocation no_allocation;
2784+
DisallowDeoptimization no_deoptimization(old_map->GetIsolate());
27842785

27852786
if (!old_map->is_deprecated()) return old_map;
27862787

@@ -3940,7 +3941,9 @@ void JSObject::MigrateInstance(Handle<JSObject> object) {
39403941

39413942
// static
39423943
bool JSObject::TryMigrateInstance(Handle<JSObject> object) {
3943-
Handle<Map> original_map(object->map());
3944+
Isolate* isolate = object->GetIsolate();
3945+
DisallowDeoptimization no_deoptimization(isolate);
3946+
Handle<Map> original_map(object->map(), isolate);
39443947
Handle<Map> new_map;
39453948
if (!Map::CurrentMapForDeprecatedInternal(original_map).ToHandle(&new_map)) {
39463949
return false;

0 commit comments

Comments
 (0)