Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: src/runtime/runtime-object.cc

Issue 1224793002: Loads and stores to global vars are now made via property cell shortcuts installed into parent scri… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index da1ec4977be36f1965f86e60cbfd5e08c8e02fdd..3d935165f97bfcfcafe195b220be78945672cb97 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -448,6 +448,70 @@ 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);
+ if (LookupIterator::DATA == it.state()) {
+ // 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.
+ // Store empty_property_cell here to release the outdated property cell.
+ script_context->set(index, 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;
+
+ Handle<GlobalObject> global(script_context->global_object());
+
+ LookupIterator it(global, name, LookupIterator::OWN);
+ if (LookupIterator::DATA == it.state()) {
+ // 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.
+ // Store empty_property_cell here to release the outdated property cell.
+ script_context->set(index, isolate->heap()->empty_property_cell());
+ }
+
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Object::SetProperty(&it, value, language_mode,
+ Object::CERTAINLY_NOT_STORE_FROM_KEYED));
+
+ return *result;
+}
+
+
RUNTIME_FUNCTION(Runtime_GetProperty) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
« no previous file with comments | « src/runtime/runtime.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698