Make implicit HandleScope of AssertNoContextChange explicit.

R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/23694011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16437 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0c64d5e9
...@@ -1414,12 +1414,30 @@ class SaveContext BASE_EMBEDDED { ...@@ -1414,12 +1414,30 @@ class SaveContext BASE_EMBEDDED {
class AssertNoContextChange BASE_EMBEDDED { class AssertNoContextChange BASE_EMBEDDED {
#ifdef DEBUG #ifdef DEBUG
public: public:
AssertNoContextChange() : AssertNoContextChange() : context_(Isolate::Current()->context()) { }
~AssertNoContextChange() {
ASSERT(Isolate::Current()->context() == *context_);
}
private:
Handle<Context> context_;
#else
public:
AssertNoContextChange() { }
#endif
};
// TODO(mstarzinger): Depracate as soon as everything is handlified.
class AssertNoContextChangeWithHandleScope BASE_EMBEDDED {
#ifdef DEBUG
public:
AssertNoContextChangeWithHandleScope() :
scope_(Isolate::Current()), scope_(Isolate::Current()),
context_(Isolate::Current()->context(), Isolate::Current()) { context_(Isolate::Current()->context(), Isolate::Current()) {
} }
~AssertNoContextChange() { ~AssertNoContextChangeWithHandleScope() {
ASSERT(Isolate::Current()->context() == *context_); ASSERT(Isolate::Current()->context() == *context_);
} }
...@@ -1428,7 +1446,7 @@ class AssertNoContextChange BASE_EMBEDDED { ...@@ -1428,7 +1446,7 @@ class AssertNoContextChange BASE_EMBEDDED {
Handle<Context> context_; Handle<Context> context_;
#else #else
public: public:
AssertNoContextChange() { } AssertNoContextChangeWithHandleScope() { }
#endif #endif
}; };
......
...@@ -828,7 +828,8 @@ MaybeObject* Object::GetProperty(Object* receiver, ...@@ -828,7 +828,8 @@ MaybeObject* Object::GetProperty(Object* receiver,
PropertyAttributes* attributes) { PropertyAttributes* attributes) {
// Make sure that the top context does not change when doing // Make sure that the top context does not change when doing
// callbacks or interceptor calls. // callbacks or interceptor calls.
AssertNoContextChange ncc; AssertNoContextChangeWithHandleScope ncc;
Isolate* isolate = name->GetIsolate(); Isolate* isolate = name->GetIsolate();
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
...@@ -3878,9 +3879,10 @@ MaybeObject* JSObject::SetPropertyForResult(LookupResult* lookup, ...@@ -3878,9 +3879,10 @@ MaybeObject* JSObject::SetPropertyForResult(LookupResult* lookup,
StoreFromKeyed store_mode) { StoreFromKeyed store_mode) {
Heap* heap = GetHeap(); Heap* heap = GetHeap();
Isolate* isolate = heap->isolate(); Isolate* isolate = heap->isolate();
// Make sure that the top context does not change when doing callbacks or // Make sure that the top context does not change when doing callbacks or
// interceptor calls. // interceptor calls.
AssertNoContextChange ncc; AssertNoContextChangeWithHandleScope ncc;
// Optimization for 2-byte strings often used as keys in a decompression // Optimization for 2-byte strings often used as keys in a decompression
// dictionary. We internalize these short keys to avoid constantly // dictionary. We internalize these short keys to avoid constantly
...@@ -4039,7 +4041,7 @@ MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( ...@@ -4039,7 +4041,7 @@ MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
ExtensibilityCheck extensibility_check) { ExtensibilityCheck extensibility_check) {
// Make sure that the top context does not change when doing callbacks or // Make sure that the top context does not change when doing callbacks or
// interceptor calls. // interceptor calls.
AssertNoContextChange ncc; AssertNoContextChangeWithHandleScope ncc;
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
LookupResult lookup(isolate); LookupResult lookup(isolate);
LocalLookup(name_raw, &lookup, true); LocalLookup(name_raw, &lookup, true);
...@@ -4183,12 +4185,12 @@ PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor( ...@@ -4183,12 +4185,12 @@ PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor(
if (name->IsSymbol()) return ABSENT; if (name->IsSymbol()) return ABSENT;
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
HandleScope scope(isolate);
// Make sure that the top context does not change when doing // Make sure that the top context does not change when doing
// callbacks or interceptor calls. // callbacks or interceptor calls.
AssertNoContextChange ncc; AssertNoContextChange ncc;
HandleScope scope(isolate);
Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
Handle<JSObject> receiver_handle(receiver); Handle<JSObject> receiver_handle(receiver);
Handle<JSObject> holder_handle(this); Handle<JSObject> holder_handle(this);
...@@ -4318,10 +4320,12 @@ PropertyAttributes JSObject::GetElementAttributeWithReceiver( ...@@ -4318,10 +4320,12 @@ PropertyAttributes JSObject::GetElementAttributeWithReceiver(
PropertyAttributes JSObject::GetElementAttributeWithInterceptor( PropertyAttributes JSObject::GetElementAttributeWithInterceptor(
JSReceiver* receiver, uint32_t index, bool continue_search) { JSReceiver* receiver, uint32_t index, bool continue_search) {
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
HandleScope scope(isolate);
// Make sure that the top context does not change when doing // Make sure that the top context does not change when doing
// callbacks or interceptor calls. // callbacks or interceptor calls.
AssertNoContextChange ncc; AssertNoContextChange ncc;
HandleScope scope(isolate);
Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
Handle<JSReceiver> hreceiver(receiver); Handle<JSReceiver> hreceiver(receiver);
Handle<JSObject> holder(this); Handle<JSObject> holder(this);
...@@ -5030,10 +5034,12 @@ Handle<Object> JSObject::DeletePropertyWithInterceptor(Handle<JSObject> object, ...@@ -5030,10 +5034,12 @@ Handle<Object> JSObject::DeletePropertyWithInterceptor(Handle<JSObject> object,
MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) { MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) {
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
HandleScope scope(isolate);
// Make sure that the top context does not change when doing // Make sure that the top context does not change when doing
// callbacks or interceptor calls. // callbacks or interceptor calls.
AssertNoContextChange ncc; AssertNoContextChange ncc;
HandleScope scope(isolate);
Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
if (interceptor->deleter()->IsUndefined()) return heap->false_value(); if (interceptor->deleter()->IsUndefined()) return heap->false_value();
v8::IndexedPropertyDeleterCallback deleter = v8::IndexedPropertyDeleterCallback deleter =
...@@ -6144,7 +6150,7 @@ void JSObject::DefineAccessor(Handle<JSObject> object, ...@@ -6144,7 +6150,7 @@ void JSObject::DefineAccessor(Handle<JSObject> object,
// Make sure that the top context does not change when doing callbacks or // Make sure that the top context does not change when doing callbacks or
// interceptor calls. // interceptor calls.
AssertNoContextChange ncc; AssertNoContextChangeWithHandleScope ncc;
// Try to flatten before operating on the string. // Try to flatten before operating on the string.
if (name->IsString()) String::cast(*name)->TryFlatten(); if (name->IsString()) String::cast(*name)->TryFlatten();
...@@ -6327,7 +6333,7 @@ MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) { ...@@ -6327,7 +6333,7 @@ MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
// Make sure that the top context does not change when doing callbacks or // Make sure that the top context does not change when doing callbacks or
// interceptor calls. // interceptor calls.
AssertNoContextChange ncc; AssertNoContextChangeWithHandleScope ncc;
// Try to flatten before operating on the string. // Try to flatten before operating on the string.
if (name->IsString()) String::cast(name)->TryFlatten(); if (name->IsString()) String::cast(name)->TryFlatten();
...@@ -6395,7 +6401,7 @@ MaybeObject* JSObject::LookupAccessor(Name* name, AccessorComponent component) { ...@@ -6395,7 +6401,7 @@ MaybeObject* JSObject::LookupAccessor(Name* name, AccessorComponent component) {
// Make sure that the top context does not change when doing callbacks or // Make sure that the top context does not change when doing callbacks or
// interceptor calls. // interceptor calls.
AssertNoContextChange ncc; AssertNoContextChangeWithHandleScope ncc;
// Check access rights if needed. // Check access rights if needed.
if (IsAccessCheckNeeded() && if (IsAccessCheckNeeded() &&
...@@ -11543,10 +11549,12 @@ MaybeObject* JSObject::SetElementWithInterceptor(uint32_t index, ...@@ -11543,10 +11549,12 @@ MaybeObject* JSObject::SetElementWithInterceptor(uint32_t index,
bool check_prototype, bool check_prototype,
SetPropertyMode set_mode) { SetPropertyMode set_mode) {
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
HandleScope scope(isolate);
// Make sure that the top context does not change when doing // Make sure that the top context does not change when doing
// callbacks or interceptor calls. // callbacks or interceptor calls.
AssertNoContextChange ncc; AssertNoContextChange ncc;
HandleScope scope(isolate);
Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
Handle<JSObject> this_handle(this); Handle<JSObject> this_handle(this);
Handle<Object> value_handle(value, isolate); Handle<Object> value_handle(value, isolate);
...@@ -12553,10 +12561,12 @@ MaybeObject* JSArray::JSArrayUpdateLengthFromIndex(uint32_t index, ...@@ -12553,10 +12561,12 @@ MaybeObject* JSArray::JSArrayUpdateLengthFromIndex(uint32_t index,
MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver, MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver,
uint32_t index) { uint32_t index) {
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
HandleScope scope(isolate);
// Make sure that the top context does not change when doing // Make sure that the top context does not change when doing
// callbacks or interceptor calls. // callbacks or interceptor calls.
AssertNoContextChange ncc; AssertNoContextChange ncc;
HandleScope scope(isolate);
Handle<InterceptorInfo> interceptor(GetIndexedInterceptor(), isolate); Handle<InterceptorInfo> interceptor(GetIndexedInterceptor(), isolate);
Handle<Object> this_handle(receiver, isolate); Handle<Object> this_handle(receiver, isolate);
Handle<JSObject> holder_handle(this, isolate); Handle<JSObject> holder_handle(this, isolate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment