Index: src/runtime/runtime-object.cc |
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
index 0e5c66fc07b6ee4ec22b49b6716c020d9a23fa65..ebaf006a4ffe748a5f86803acd8bfe854aca9f6c 100644 |
--- a/src/runtime/runtime-object.cc |
+++ b/src/runtime/runtime-object.cc |
@@ -420,62 +420,62 @@ 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. |
+ // Now update the cell in the script context. |
Handle<PropertyCell> cell = it.GetPropertyCell(); |
- script_context->set(index, *cell); |
+ script_context->set(slot, *cell); |
} 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, *cell); |
} 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; |
@@ -483,10 +483,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); |