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

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

Issue 1250413002: [stubs] Further optimize Load/StoreGlobalViaContext stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix REBASE typo. 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/scopeinfo.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 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) {
+ 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);
}
« no previous file with comments | « src/runtime/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698