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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 1150723005: [turbofan] Optimized lowering of DYNAMIC_GLOBAL lookup slot loads. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 7 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/js-typed-lowering.h ('k') | src/compiler/operator-properties.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 4a4bcbfd6516c8d4c992afc4b84544d530e83f87..987f73fd83c6ae4ce616cb1e184db429e651f7fa 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -924,6 +924,64 @@ Reduction JSTypedLowering::ReduceJSStoreContext(Node* node) {
}
+Reduction JSTypedLowering::ReduceJSLoadDynamicGlobal(Node* node) {
+ DCHECK_EQ(IrOpcode::kJSLoadDynamicGlobal, node->opcode());
+ DynamicGlobalAccess const& access = DynamicGlobalAccessOf(node->op());
+ Node* const context = NodeProperties::GetContextInput(node);
+ Node* const state1 = NodeProperties::GetFrameStateInput(node, 0);
+ Node* const state2 = NodeProperties::GetFrameStateInput(node, 1);
+ Node* const effect = NodeProperties::GetEffectInput(node);
+ Node* const control = NodeProperties::GetControlInput(node);
+ if (access.RequiresFullCheck()) return NoChange();
+
+ // Perform checks whether the fast mode applies, by looking for any extension
+ // object which might shadow the optimistic declaration.
+ uint32_t bitset = access.check_bitset();
+ Node* check_true = control;
+ Node* check_false = graph()->NewNode(common()->Merge(0));
+ for (int depth = 0; bitset != 0; bitset >>= 1, depth++) {
+ if ((bitset & 1) == 0) continue;
+ Node* load = graph()->NewNode(
+ javascript()->LoadContext(depth, Context::EXTENSION_INDEX, false),
+ context, context, effect);
+ Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), load);
+ Node* branch = graph()->NewNode(common()->Branch(BranchHint::kTrue), check,
+ check_true);
+ Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
+ Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
+ check_false->set_op(common()->Merge(check_false->InputCount() + 1));
+ check_false->AppendInput(graph()->zone(), if_false);
+ check_true = if_true;
+ }
+
+ // Fast case, because variable is not shadowed. Perform global object load.
+ Unique<Name> name = Unique<Name>::CreateUninitialized(access.name());
+ Node* global = graph()->NewNode(
+ javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), context,
+ context, effect);
+ Node* fast = graph()->NewNode(
+ javascript()->LoadNamed(name, access.feedback(), access.mode()), global,
+ context, state1, state2, global, check_true);
+
+ // Slow case, because variable potentially shadowed. Perform dynamic lookup.
+ uint32_t check_bitset = DynamicGlobalAccess::kFullCheckRequired;
+ Node* slow = graph()->NewNode(
+ javascript()->LoadDynamicGlobal(access.name(), check_bitset,
+ access.feedback(), access.mode()),
+ context, context, state1, state2, effect, check_false);
+
+ // Replace value, effect and control uses accordingly.
+ Node* new_control =
+ graph()->NewNode(common()->Merge(2), check_true, check_false);
+ Node* new_effect =
+ graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control);
+ Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast,
+ slow, new_control);
+ ReplaceWithValue(node, new_value, new_effect, new_control);
+ return Changed(new_value);
+}
+
+
Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode());
CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
@@ -1429,6 +1487,8 @@ Reduction JSTypedLowering::Reduce(Node* node) {
return ReduceJSLoadContext(node);
case IrOpcode::kJSStoreContext:
return ReduceJSStoreContext(node);
+ case IrOpcode::kJSLoadDynamicGlobal:
+ return ReduceJSLoadDynamicGlobal(node);
case IrOpcode::kJSCreateClosure:
return ReduceJSCreateClosure(node);
case IrOpcode::kJSCreateLiteralArray:
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/operator-properties.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698