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

Unified Diff: src/compiler/ast-graph-builder.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/compiler/ast-graph-builder.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index d04fc62c71dc060cc321b5cb8fe3f3c8ad08875a..6aae85bc9b4a76c8b58b8b683778e850374bcbc6 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -3264,9 +3264,23 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED: {
// Global var, const, or let variable.
+ Node* script_context = current_context();
+ int slot_index = -1;
+ if (variable->index() > 0) {
+ DCHECK(variable->IsStaticGlobalObjectProperty());
+ // Each var occupies two slots in the context: for reads and writes.
+ slot_index = variable->index();
+ int depth = current_scope()->ContextChainLength(variable->scope());
+ if (depth > 0) {
+ const Operator* op = javascript()->LoadContext(
+ depth - 1, Context::PREVIOUS_INDEX, true);
+ script_context = NewNode(op, current_context());
+ }
+ }
Node* global = BuildLoadGlobalObject();
Handle<Name> name = variable->name();
- Node* value = BuildGlobalLoad(global, name, feedback, contextual_mode);
+ Node* value = BuildGlobalLoad(script_context, global, name, feedback,
+ contextual_mode, slot_index);
states.AddToNode(value, bailout_id, combine);
return value;
}
@@ -3404,10 +3418,24 @@ Node* AstGraphBuilder::BuildVariableAssignment(
case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED: {
// Global var, const, or let variable.
+ Node* script_context = current_context();
+ int slot_index = -1;
+ if (variable->index() > 0) {
+ DCHECK(variable->IsStaticGlobalObjectProperty());
+ // Each var occupies two slots in the context: for reads and writes.
+ slot_index = variable->index();
+ int depth = current_scope()->ContextChainLength(variable->scope());
+ if (depth > 0) {
+ const Operator* op = javascript()->LoadContext(
+ depth - 1, Context::PREVIOUS_INDEX, true);
+ script_context = NewNode(op, current_context());
+ }
+ }
Node* global = BuildLoadGlobalObject();
Handle<Name> name = variable->name();
- Node* store = BuildGlobalStore(global, name, value, feedback,
- TypeFeedbackId::None());
+ Node* store =
+ BuildGlobalStore(script_context, global, name, value, feedback,
+ TypeFeedbackId::None(), slot_index);
states.AddToNode(store, bailout_id, combine);
return store;
}
@@ -3611,23 +3639,25 @@ Node* AstGraphBuilder::BuildNamedSuperStore(Node* receiver, Node* home_object,
}
-Node* AstGraphBuilder::BuildGlobalLoad(Node* object, Handle<Name> name,
+Node* AstGraphBuilder::BuildGlobalLoad(Node* script_context, Node* global,
+ Handle<Name> name,
const VectorSlotPair& feedback,
- ContextualMode mode) {
+ ContextualMode mode, int slot_index) {
const Operator* op =
- javascript()->LoadGlobal(MakeUnique(name), feedback, mode);
- Node* node = NewNode(op, object, BuildLoadFeedbackVector());
+ javascript()->LoadGlobal(MakeUnique(name), feedback, mode, slot_index);
+ Node* node = NewNode(op, script_context, global, BuildLoadFeedbackVector());
return Record(js_type_feedback_, node, feedback.slot());
}
-Node* AstGraphBuilder::BuildGlobalStore(Node* object, Handle<Name> name,
- Node* value,
+Node* AstGraphBuilder::BuildGlobalStore(Node* script_context, Node* global,
+ Handle<Name> name, Node* value,
const VectorSlotPair& feedback,
- TypeFeedbackId id) {
- const Operator* op =
- javascript()->StoreGlobal(language_mode(), MakeUnique(name), feedback);
- Node* node = NewNode(op, object, value, BuildLoadFeedbackVector());
+ TypeFeedbackId id, int slot_index) {
+ const Operator* op = javascript()->StoreGlobal(
+ language_mode(), MakeUnique(name), feedback, slot_index);
+ Node* node =
+ NewNode(op, script_context, global, value, BuildLoadFeedbackVector());
if (FLAG_vector_stores) {
return Record(js_type_feedback_, node, feedback.slot());
}
@@ -3921,7 +3951,7 @@ Node** AstGraphBuilder::EnsureInputBufferSize(int size) {
Node* AstGraphBuilder::MakeNode(const Operator* op, int value_input_count,
Node** value_inputs, bool incomplete) {
- DCHECK(op->ValueInputCount() == value_input_count);
+ DCHECK_EQ(op->ValueInputCount(), value_input_count);
bool has_context = OperatorProperties::HasContextInput(op);
int frame_state_count = OperatorProperties::GetFrameStateInputCount(op);
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698