Chromium Code Reviews| Index: src/runtime/runtime-object.cc |
| diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
| index 0bdde7482c509df9aed274e94738e701c3fb5935..94af43844bbebf925aac0a8a9e16a24fa8b1dbad 100644 |
| --- a/src/runtime/runtime-object.cc |
| +++ b/src/runtime/runtime-object.cc |
| @@ -423,62 +423,60 @@ RUNTIME_FUNCTION(Runtime_ObjectSeal) { |
| RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { |
| HandleScope scope(isolate); |
| - DCHECK(args.length() == 3); |
| - CONVERT_ARG_HANDLE_CHECKED(Context, script_context, 0); |
| - CONVERT_SMI_ARG_CHECKED(index, 1); |
| - CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
| + DCHECK_EQ(2, args.length()); |
| + CONVERT_SMI_ARG_CHECKED(slot, 0); |
| + CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| + |
| + // 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(index)->IsPropertyCell()); |
| + DCHECK(script_context->get(slot)->IsPropertyCell()); |
| - Handle<GlobalObject> global(script_context->global_object()); |
| + // Lookup the named property on the global object. |
| + Handle<GlobalObject> global_object(script_context->global_object(), isolate); |
| + LookupIterator it(global_object, name, LookupIterator::HIDDEN); |
| - LookupIterator it(global, 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() && |
| + if (it.state() == LookupIterator::DATA && |
| it.GetHolder<Object>()->IsJSGlobalObject()) { |
| - // Now update cell in the script context. |
| - Handle<PropertyCell> cell = it.GetPropertyCell(); |
| - script_context->set(index, *cell); |
| + // Now update the cell in the script context. |
| + script_context->set(slot, *it.GetPropertyCell()); |
|
Igor Sheludko
2015/07/18 20:52:44
GC mole will complain about this change.
Benedikt Meurer
2015/07/24 05:18:29
Done.
|
| } else { |
| // This is not a fast case, so keep this access in a slow mode. |
| // Store empty_property_cell here to release the outdated property cell. |
| - script_context->set(index, isolate->heap()->empty_property_cell()); |
| + script_context->set(slot, isolate->heap()->empty_property_cell()); |
| } |
| Handle<Object> result; |
| ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); |
| - |
| return *result; |
| } |
| -RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext) { |
| - HandleScope scope(isolate); |
| - DCHECK(args.length() == 5); |
| - CONVERT_ARG_HANDLE_CHECKED(Context, script_context, 0); |
| - CONVERT_SMI_ARG_CHECKED(index, 1); |
| - CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
| - CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); |
| - CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 4); |
| - DCHECK(script_context->IsScriptContext()); |
| - DCHECK(script_context->get(index)->IsPropertyCell()); |
| - LanguageMode language_mode = language_mode_arg; |
| +namespace { |
| - Handle<GlobalObject> global(script_context->global_object()); |
| +Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Name> name, |
| + 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()); |
| - LookupIterator it(global, name, LookupIterator::HIDDEN); |
| + // Lookup the named property on the global object. |
| + 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.GetHolder<Object>()->IsJSGlobalObject()) { |
| // Now update cell in the script context. |
| - Handle<PropertyCell> cell = it.GetPropertyCell(); |
| - script_context->set(index, *cell); |
| + script_context->set(slot, *it.GetPropertyCell()); |
|
Igor Sheludko
2015/07/18 20:52:44
GC mole will complain about this change.
Benedikt Meurer
2015/07/24 05:18:29
Done.
|
| } else { |
| // This is not a fast case, so keep this access in a slow mode. |
| // Store empty_property_cell here to release the outdated property cell. |
| - script_context->set(index, isolate->heap()->empty_property_cell()); |
| + script_context->set(slot, isolate->heap()->empty_property_cell()); |
| } |
| Handle<Object> result; |
| @@ -486,10 +484,33 @@ RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext) { |
| isolate, result, |
| Object::SetProperty(&it, value, language_mode, |
| Object::CERTAINLY_NOT_STORE_FROM_KEYED)); |
| - |
| return *result; |
| } |
| +} // namespace |
| + |
| + |
| +RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Sloppy) { |
| + HandleScope scope(isolate); |
| + DCHECK_EQ(3, args.length()); |
| + CONVERT_SMI_ARG_CHECKED(slot, 0); |
| + CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| + CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| + |
| + return StoreGlobalViaContext(isolate, slot, name, value, SLOPPY); |
| +} |
| + |
| + |
| +RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Strict) { |
| + HandleScope scope(isolate); |
| + DCHECK_EQ(3, args.length()); |
| + CONVERT_SMI_ARG_CHECKED(slot, 0); |
| + CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| + CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| + |
| + return StoreGlobalViaContext(isolate, slot, name, value, STRICT); |
| +} |
| + |
| RUNTIME_FUNCTION(Runtime_GetProperty) { |
| HandleScope scope(isolate); |