Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index dd7a38fe9715be79b92d66e1a149af7b9ca0d4b5..0a8c697284c0243ecc26c2adbdb81f2774041d04 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -1660,6 +1660,11 @@ MaybeObject* JSObject::SetPropertyPostInterceptor( |
| // found. Use set property to handle all these cases. |
| return SetProperty(&result, name, value, attributes, strict_mode); |
| } |
| + bool found; |
| + MaybeObject* result_object; |
| + result_object = SetPropertyInPrototypes(name, value, attributes, |
| + &found, strict_mode); |
|
Vyacheslav Egorov (Chromium)
2011/09/26 13:52:07
We usually use one-arguments-per-line formatting f
ulan
2011/09/26 14:17:57
Done.
|
| + if (found) return result_object; |
|
Vyacheslav Egorov (Chromium)
2011/09/26 13:52:07
Some compilers will complain that found can be uni
ulan
2011/09/26 14:17:57
Done.
|
| // Add a new real property. |
| return AddProperty(name, value, attributes, strict_mode); |
| } |
| @@ -1984,6 +1989,57 @@ MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes( |
| return heap->the_hole_value(); |
| } |
| +MaybeObject* JSObject::SetPropertyInPrototypes(String* name, |
| + Object* value, |
| + PropertyAttributes attributes, |
| + bool* found, |
| + StrictModeFlag strict_mode) { |
| + LookupResult result; |
| + LookupCallbackSetterInPrototypes(name, &result); |
| + Heap* heap = GetHeap(); |
| + if (result.IsFound()) { |
| + *found = true; |
| + if (result.type() == CALLBACKS) { |
| + return SetPropertyWithCallback(result.GetCallbackObject(), |
| + name, |
|
Rico
2011/09/26 10:37:36
indention
ulan
2011/09/26 12:56:07
Done.
|
| + value, |
| + result.holder(), |
| + strict_mode); |
| + } else if (result.type() == HANDLER) { |
| + // We could not find a local property so let's check whether there is an |
| + // accessor that wants to handle the property. |
| + LookupResult accessor_result; |
| + LookupCallbackSetterInPrototypes(name, &accessor_result); |
| + if (accessor_result.IsFound()) { |
| + if (accessor_result.type() == CALLBACKS) { |
| + return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
| + name, |
| + value, |
| + accessor_result.holder(), |
| + strict_mode); |
| + } else if (accessor_result.type() == HANDLER) { |
| + // There is a proxy in the prototype chain. Invoke its |
| + // getOwnPropertyDescriptor trap. |
| + bool found = false; |
| + Handle<JSObject> self(this); |
| + Handle<String> hname(name); |
| + Handle<Object> hvalue(value); |
| + MaybeObject* result = |
| + accessor_result.proxy()->SetPropertyWithHandlerIfDefiningSetter( |
| + name, value, attributes, strict_mode, &found); |
| + if (found) return result; |
| + // The proxy does not define the property as an accessor. |
| + // Consequently, it has no effect on setting the receiver. |
| + // Make sure to use the handlified references at this point! |
| + return self->AddProperty(*hname, *hvalue, attributes, strict_mode); |
| + } |
| + } |
| + } |
| + } |
| + *found = false; |
| + return heap->the_hole_value(); |
| +} |
| + |
| void JSObject::LookupInDescriptor(String* name, LookupResult* result) { |
| DescriptorArray* descriptors = map()->instance_descriptors(); |
| @@ -2526,34 +2582,11 @@ MaybeObject* JSObject::SetPropertyForResult(LookupResult* result, |
| } |
| if (!result->IsProperty() && !IsJSContextExtensionObject()) { |
| - // We could not find a local property so let's check whether there is an |
| - // accessor that wants to handle the property. |
| - LookupResult accessor_result; |
| - LookupCallbackSetterInPrototypes(name, &accessor_result); |
| - if (accessor_result.IsFound()) { |
| - if (accessor_result.type() == CALLBACKS) { |
| - return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
| - name, |
| - value, |
| - accessor_result.holder(), |
| - strict_mode); |
| - } else if (accessor_result.type() == HANDLER) { |
| - // There is a proxy in the prototype chain. Invoke its |
| - // getOwnPropertyDescriptor trap. |
| - bool found = false; |
| - Handle<JSObject> self(this); |
| - Handle<String> hname(name); |
| - Handle<Object> hvalue(value); |
| - MaybeObject* result = |
| - accessor_result.proxy()->SetPropertyWithHandlerIfDefiningSetter( |
| - name, value, attributes, strict_mode, &found); |
| - if (found) return result; |
| - // The proxy does not define the property as an accessor. |
| - // Consequently, it has no effect on setting the receiver. |
| - // Make sure to use the handlified references at this point! |
| - return self->AddProperty(*hname, *hvalue, attributes, strict_mode); |
| - } |
| - } |
| + bool found; |
| + MaybeObject* result_object; |
| + result_object = SetPropertyInPrototypes(name, value, attributes, |
|
Vyacheslav Egorov (Chromium)
2011/09/26 13:52:07
ditto
ulan
2011/09/26 14:17:57
Done.
|
| + &found, strict_mode); |
| + if (found) return result_object; |
| } |
| // At this point, no GC should have happened, as this would invalidate |