| Index: src/compiler/js-typed-lowering.cc
|
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
|
| index 61f23ca82ac7c7b897f841b3622886472f8f94f8..457ba3c61d85be57dbb0b79ec6cb56bf0f6ee7f8 100644
|
| --- a/src/compiler/js-typed-lowering.cc
|
| +++ b/src/compiler/js-typed-lowering.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "src/code-factory.h"
|
| #include "src/compiler/access-builder.h"
|
| +#include "src/compiler/diamond.h"
|
| #include "src/compiler/js-graph.h"
|
| #include "src/compiler/js-typed-lowering.h"
|
| #include "src/compiler/linkage.h"
|
| @@ -924,6 +925,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(node);
|
| +}
|
| +
|
| +
|
| Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) {
|
| DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode());
|
| CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
|
| @@ -1429,6 +1488,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:
|
|
|