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

Unified Diff: src/ic/ic.cc

Issue 705663004: harmony_scoping: Implement lexical bindings at top level (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased patch for landing Created 6 years, 1 month 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/heap/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic/ic.cc
diff --git a/src/ic/ic.cc b/src/ic/ic.cc
index a9369ed4e008f8b543c696ade112e3750a4edbd9..e83a4b217d4f0b53c1aa8f9f081f1e68a9570291 100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -661,6 +661,21 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
bool use_ic = MigrateDeprecated(object) ? false : FLAG_use_ic;
+ if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) {
+ // Look up in global context table.
+ Handle<String> str_name = Handle<String>::cast(name);
+ Handle<GlobalObject> global = Handle<GlobalObject>::cast(object);
+ Handle<GlobalContextTable> global_contexts(
+ global->native_context()->global_context_table());
+
+ GlobalContextTable::LookupResult lookup_result;
+ if (GlobalContextTable::Lookup(global_contexts, str_name, &lookup_result)) {
+ return FixedArray::get(GlobalContextTable::GetContext(
+ global_contexts, lookup_result.context_index),
+ lookup_result.slot_index);
+ }
+ }
+
// Named lookup in the object.
LookupIterator it(object, name);
LookupForRead(&it);
@@ -1363,6 +1378,25 @@ bool StoreIC::LookupForWrite(LookupIterator* it, Handle<Object> value,
MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
Handle<Object> value,
JSReceiver::StoreFromKeyed store_mode) {
+ if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) {
+ // Look up in global context table.
+ Handle<String> str_name = Handle<String>::cast(name);
+ Handle<GlobalObject> global = Handle<GlobalObject>::cast(object);
+ Handle<GlobalContextTable> global_contexts(
+ global->native_context()->global_context_table());
+
+ GlobalContextTable::LookupResult lookup_result;
+ if (GlobalContextTable::Lookup(global_contexts, str_name, &lookup_result)) {
+ Handle<Context> global_context = GlobalContextTable::GetContext(
+ global_contexts, lookup_result.context_index);
+ if (lookup_result.mode == CONST) {
+ return TypeError("harmony_const_assign", object, name);
+ }
+ global_context->set(lookup_result.slot_index, *value);
+ return value;
+ }
+ }
+
// TODO(verwaest): Let SetProperty do the migration, since storing a property
// might deprecate the current map again, if value does not fit.
if (MigrateDeprecated(object) || object->IsJSProxy()) {
« no previous file with comments | « src/heap/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698