From 5a52b9fe9f803931e4362b1cc18be112649e6732 Mon Sep 17 00:00:00 2001 From: verwaest Date: Tue, 14 Jul 2015 07:57:23 -0700 Subject: [PATCH] Remove duplicate flattening. Defining accessors doesn't call out, so don't assert that the context doesn't change. BUG=v8:4137 LOG=n Review URL: https://codereview.chromium.org/1233073003 Cr-Commit-Position: refs/heads/master@{#29650} --- src/objects.cc | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/objects.cc b/src/objects.cc index 07156be..eb11561 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -6252,13 +6252,6 @@ MaybeHandle JSObject::DefineAccessor(Handle object, PropertyAttributes attributes) { Isolate* isolate = object->GetIsolate(); - // Make sure that the top context does not change when doing callbacks or - // interceptor calls. - AssertNoContextChange ncc(isolate); - - // Try to flatten before operating on the string. - if (name->IsString()) name = String::Flatten(Handle::cast(name)); - LookupIterator it = LookupIterator::PropertyOrElement( isolate, object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); @@ -6302,6 +6295,8 @@ MaybeHandle JSObject::DefineAccessor(Handle object, } if (is_observed) { + // Make sure the top context isn't changed. + AssertNoContextChange ncc(isolate); const char* type = preexists ? "reconfigure" : "add"; RETURN_ON_EXCEPTION( isolate, EnqueueChangeRecord(object, type, name, old_value), Object); @@ -6314,14 +6309,7 @@ MaybeHandle JSObject::DefineAccessor(Handle object, MaybeHandle JSObject::SetAccessor(Handle object, Handle info) { Isolate* isolate = object->GetIsolate(); - - // Make sure that the top context does not change when doing callbacks or - // interceptor calls. - AssertNoContextChange ncc(isolate); - - // Try to flatten before operating on the string. - Handle name(Name::cast(info->name())); - if (name->IsString()) name = String::Flatten(Handle::cast(name)); + Handle name(Name::cast(info->name()), isolate); LookupIterator it = LookupIterator::PropertyOrElement( isolate, object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); @@ -6340,6 +6328,12 @@ MaybeHandle JSObject::SetAccessor(Handle object, it.Next(); } + // Ignore accessors on typed arrays. + if (it.IsElement() && (object->HasFixedTypedArrayElements() || + object->HasExternalArrayElements())) { + return it.factory()->undefined_value(); + } + CHECK(GetPropertyAttributes(&it).IsJust()); // ES5 forbids turning a property into an accessor if it's not @@ -6348,12 +6342,6 @@ MaybeHandle JSObject::SetAccessor(Handle object, return it.factory()->undefined_value(); } - // Ignore accessors on typed arrays. - if (it.IsElement() && (object->HasFixedTypedArrayElements() || - object->HasExternalArrayElements())) { - return it.factory()->undefined_value(); - } - it.TransitionToAccessorPair(info, info->property_attributes()); return object; -- 2.7.4