Chromium Code Reviews| Index: src/runtime/runtime-object.cc |
| diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
| index da1ec4977be36f1965f86e60cbfd5e08c8e02fdd..ae8d72e7fa829a10ee6a2a0a6a79a8d7a5b6f306 100644 |
| --- a/src/runtime/runtime-object.cc |
| +++ b/src/runtime/runtime-object.cc |
| @@ -448,6 +448,68 @@ 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(script_context->IsScriptContext()); |
| + DCHECK(script_context->get(index)->IsPropertyCell()); |
| + |
| + Handle<GlobalObject> global(script_context->global_object()); |
| + |
| + LookupIterator it(global, name, LookupIterator::OWN); |
| + |
| + Handle<Object> result; |
| + ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); |
| + |
| + if (LookupIterator::DATA == it.state()) { |
|
Toon Verwaest
2015/07/10 16:46:11
You should probably do this check before GetProper
Igor Sheludko
2015/07/13 08:34:51
Done.
|
| + // Now update cell in the script context. |
| + Handle<PropertyCell> cell = it.GetPropertyCell(); |
| + script_context->set(index, *cell); |
| + } else { |
| + // This is not a fast case, so keep this access in a slow mode. |
|
Toon Verwaest
2015/07/10 16:46:11
Add comment that you're doing this just to release
Igor Sheludko
2015/07/13 08:34:51
Done.
|
| + script_context->set(index, isolate->heap()->empty_property_cell()); |
| + } |
| + 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; |
| + |
| + Handle<GlobalObject> global(script_context->global_object()); |
| + |
| + LookupIterator it(global, name, LookupIterator::OWN); |
| + |
| + Handle<Object> result; |
| + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| + isolate, result, |
| + Object::SetProperty(&it, value, language_mode, |
| + Object::CERTAINLY_NOT_STORE_FROM_KEYED)); |
| + |
| + if (LookupIterator::DATA == it.state()) { |
|
Toon Verwaest
2015/07/10 16:46:11
Same as above.
Igor Sheludko
2015/07/13 08:34:51
Done.
|
| + // Now update cell in the script context. |
| + Handle<PropertyCell> cell = it.GetPropertyCell(); |
| + script_context->set(index, *cell); |
| + } else { |
| + // This is not a fast case, so keep this access in a slow mode. |
| + script_context->set(index, isolate->heap()->empty_property_cell()); |
| + } |
| + return *result; |
| +} |
| + |
| + |
| RUNTIME_FUNCTION(Runtime_GetProperty) { |
| HandleScope scope(isolate); |
| DCHECK(args.length() == 2); |