From 574cfbccecb39221da623407201522cc2ebff249 Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Mon, 28 Apr 2014 06:47:05 +0000 Subject: [PATCH] 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 --- src/assert-scope.h | 11 ++++++++++- src/objects-inl.h | 1 + src/objects.cc | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/assert-scope.h b/src/assert-scope.h index 428e6d0..2bb4623 100644 --- a/src/assert-scope.h +++ b/src/assert-scope.h @@ -50,7 +50,8 @@ enum PerThreadAssertType { enum PerIsolateAssertType { JAVASCRIPT_EXECUTION_ASSERT, JAVASCRIPT_EXECUTION_THROWS, - ALLOCATION_FAILURE_ASSERT + ALLOCATION_FAILURE_ASSERT, + DEOPTIMIZATION_ASSERT }; @@ -268,6 +269,14 @@ typedef PerIsolateAssertScopeDebugOnly typedef PerIsolateAssertScopeDebugOnly AllowAllocationFailure; +// Scope to document where we do not expect deoptimization. +typedef PerIsolateAssertScopeDebugOnly + DisallowDeoptimization; + +// Scope to introduce an exception to DisallowDeoptimization. +typedef PerIsolateAssertScopeDebugOnly + AllowDeoptimization; + } } // namespace v8::internal #endif // V8_ASSERT_SCOPE_H_ diff --git a/src/objects-inl.h b/src/objects-inl.h index 6aff6a2..36b6ae7 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -4679,6 +4679,7 @@ bool Code::marked_for_deoptimization() { void Code::set_marked_for_deoptimization(bool flag) { ASSERT(kind() == OPTIMIZED_FUNCTION); + ASSERT(!flag || AllowDeoptimization::IsAllowed(GetIsolate())); int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); int updated = MarkedForDeoptimizationField::update(previous, flag); WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); diff --git a/src/objects.cc b/src/objects.cc index 38409d1..98e0436 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -2781,6 +2781,7 @@ MaybeHandle Map::CurrentMapForDeprecated(Handle map) { // static MaybeHandle Map::CurrentMapForDeprecatedInternal(Handle old_map) { DisallowHeapAllocation no_allocation; + DisallowDeoptimization no_deoptimization(old_map->GetIsolate()); if (!old_map->is_deprecated()) return old_map; @@ -3940,7 +3941,9 @@ void JSObject::MigrateInstance(Handle object) { // static bool JSObject::TryMigrateInstance(Handle object) { - Handle original_map(object->map()); + Isolate* isolate = object->GetIsolate(); + DisallowDeoptimization no_deoptimization(isolate); + Handle original_map(object->map(), isolate); Handle new_map; if (!Map::CurrentMapForDeprecatedInternal(original_map).ToHandle(&new_map)) { return false; -- 2.7.4