Chromium Code Reviews| Index: src/runtime/runtime-object.cc |
| diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
| index ee607259b903e34fe303c18de7d2abedec4f489d..2adbb579062e167c2b4055c605de3b4fb5dda64e 100644 |
| --- a/src/runtime/runtime-object.cc |
| +++ b/src/runtime/runtime-object.cc |
| @@ -418,26 +418,26 @@ RUNTIME_FUNCTION(Runtime_ObjectSeal) { |
| } |
| -RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { |
| - HandleScope scope(isolate); |
| - DCHECK_EQ(2, args.length()); |
| - CONVERT_SMI_ARG_CHECKED(slot, 0); |
| - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| +namespace { |
| +Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Object> value, |
| + LanguageMode language_mode) { |
| // Go up context chain to the script context. |
| Handle<Context> script_context(isolate->context()->script_context(), isolate); |
| DCHECK(script_context->IsScriptContext()); |
| DCHECK(script_context->get(slot)->IsPropertyCell()); |
| // Lookup the named property on the global object. |
| + Handle<ScopeInfo> scope_info(ScopeInfo::cast(script_context->extension()), |
| + isolate); |
| + Handle<Name> name(scope_info->ContextSlotName(slot), isolate); |
| Handle<GlobalObject> global_object(script_context->global_object(), isolate); |
| LookupIterator it(global_object, name, LookupIterator::HIDDEN); |
| - |
| // Switch to fast mode only if there is a data property and it's not on |
| // a hidden prototype. |
| - if (it.state() == LookupIterator::DATA && |
| + if (LookupIterator::DATA == it.state() && !it.IsReadOnly() && |
| it.GetHolder<Object>()->IsJSGlobalObject()) { |
| - // Now update the cell in the script context. |
| + // Now update cell in the script context. |
| Handle<PropertyCell> cell = it.GetPropertyCell(); |
| script_context->set(slot, *cell); |
| } else { |
| @@ -447,29 +447,38 @@ RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { |
| } |
| Handle<Object> result; |
| - ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); |
| + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| + isolate, result, |
| + Object::SetProperty(&it, value, language_mode, |
| + Object::CERTAINLY_NOT_STORE_FROM_KEYED)); |
| return *result; |
| } |
| +} // namespace |
| -namespace { |
| -Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Name> name, |
| - Handle<Object> value, |
| - LanguageMode language_mode) { |
| +RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { |
|
Igor Sheludko
2015/07/27 18:54:49
Why did you change the order of functions?
Benedikt Meurer
2015/07/28 05:14:12
Leftover from unrelated change.
|
| + HandleScope scope(isolate); |
| + DCHECK_EQ(1, args.length()); |
| + CONVERT_SMI_ARG_CHECKED(slot, 0); |
| + |
| // Go up context chain to the script context. |
| Handle<Context> script_context(isolate->context()->script_context(), isolate); |
| DCHECK(script_context->IsScriptContext()); |
| DCHECK(script_context->get(slot)->IsPropertyCell()); |
| // Lookup the named property on the global object. |
| + Handle<ScopeInfo> scope_info(ScopeInfo::cast(script_context->extension()), |
| + isolate); |
| + Handle<Name> name(scope_info->ContextSlotName(slot), isolate); |
| Handle<GlobalObject> global_object(script_context->global_object(), isolate); |
| LookupIterator it(global_object, name, LookupIterator::HIDDEN); |
| + |
| // Switch to fast mode only if there is a data property and it's not on |
| // a hidden prototype. |
| if (LookupIterator::DATA == it.state() && !it.IsReadOnly() && |
| it.GetHolder<Object>()->IsJSGlobalObject()) { |
| - // Now update cell in the script context. |
| + // Now update the cell in the script context. |
| Handle<PropertyCell> cell = it.GetPropertyCell(); |
| script_context->set(slot, *cell); |
| } else { |
| @@ -479,35 +488,28 @@ Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Name> name, |
| } |
| Handle<Object> result; |
| - ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| - isolate, result, |
| - Object::SetProperty(&it, value, language_mode, |
| - Object::CERTAINLY_NOT_STORE_FROM_KEYED)); |
| + ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); |
| return *result; |
| } |
| -} // namespace |
| - |
| RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Sloppy) { |
| HandleScope scope(isolate); |
| - DCHECK_EQ(3, args.length()); |
| + DCHECK_EQ(2, args.length()); |
| CONVERT_SMI_ARG_CHECKED(slot, 0); |
| - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| - CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| + CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| - return StoreGlobalViaContext(isolate, slot, name, value, SLOPPY); |
| + return StoreGlobalViaContext(isolate, slot, value, SLOPPY); |
| } |
| RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Strict) { |
| HandleScope scope(isolate); |
| - DCHECK_EQ(3, args.length()); |
| + DCHECK_EQ(2, args.length()); |
| CONVERT_SMI_ARG_CHECKED(slot, 0); |
| - CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| - CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| + CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
| - return StoreGlobalViaContext(isolate, slot, name, value, STRICT); |
| + return StoreGlobalViaContext(isolate, slot, value, STRICT); |
| } |