Chromium Code Reviews| Index: src/compiler/bytecode-graph-builder.cc |
| diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc |
| index c07aa742cc11cb36ccc15599c646455c61523abb..198574a931b6c19d5a5184b3dc7eeeaed78cab86 100644 |
| --- a/src/compiler/bytecode-graph-builder.cc |
| +++ b/src/compiler/bytecode-graph-builder.cc |
| @@ -896,8 +896,6 @@ BytecodeGraphBuilder::Environment* BytecodeGraphBuilder::CheckContextExtensions( |
| // Output environment where the context has an extension |
| Environment* slow_environment = nullptr; |
| - DCHECK_GT(depth, 0u); |
| - |
| // We only need to check up to the last-but-one depth, because the an eval in |
| // the same scope as the variable itself has no way of shadowing it. |
| for (uint32_t d = 0; d < depth; d++) { |
| @@ -931,7 +929,9 @@ BytecodeGraphBuilder::Environment* BytecodeGraphBuilder::CheckContextExtensions( |
| } |
| } |
| - DCHECK_NOT_NULL(slow_environment); |
| + // The depth can be zero, in which case no slow-path checks are built, and the |
| + // slow path environment can be null. |
| + DCHECK(depth == 0 || slow_environment != nullptr); |
| return slow_environment; |
| } |
| @@ -951,26 +951,30 @@ void BytecodeGraphBuilder::BuildLdaLookupContextSlot(TypeofMode typeof_mode) { |
| environment()->BindAccumulator(NewNode(op, context)); |
| NewMerge(); |
|
Michael Starzinger
2016/10/04 09:43:10
nit: Shouldn't we only create the singleton merge
Leszek Swirski
2016/10/04 10:46:55
Done.
|
| } |
| - Environment* fast_environment = environment(); |
| - // Slow path, do a runtime load lookup. |
| - set_environment(slow_environment); |
| - { |
| - FrameStateBeforeAndAfter states(this); |
| + // Only build the slow path if there were any slow-path checks. |
| + if (slow_environment != nullptr) { |
| + Environment* fast_environment = environment(); |
| + |
| + // Slow path, do a runtime load lookup. |
| + set_environment(slow_environment); |
| + { |
| + FrameStateBeforeAndAfter states(this); |
| - Node* name = |
| - jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
| + Node* name = jsgraph()->Constant( |
| + bytecode_iterator().GetConstantForIndexOperand(0)); |
| - const Operator* op = |
| - javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF |
| - ? Runtime::kLoadLookupSlot |
| - : Runtime::kLoadLookupSlotInsideTypeof); |
| - Node* value = NewNode(op, name); |
| - environment()->BindAccumulator(value, &states); |
| - } |
| + const Operator* op = |
| + javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF |
| + ? Runtime::kLoadLookupSlot |
| + : Runtime::kLoadLookupSlotInsideTypeof); |
| + Node* value = NewNode(op, name); |
| + environment()->BindAccumulator(value, &states); |
| + } |
| - fast_environment->Merge(environment()); |
| - set_environment(fast_environment); |
| + fast_environment->Merge(environment()); |
| + set_environment(fast_environment); |
| + } |
| } |
| void BytecodeGraphBuilder::VisitLdaLookupContextSlot() { |
| @@ -996,26 +1000,30 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) { |
| NewMerge(); |
|
Michael Starzinger
2016/10/04 09:43:10
nit: Likewise.
Leszek Swirski
2016/10/04 10:46:55
Done.
|
| } |
| - Environment* fast_environment = environment(); |
| - // Slow path, do a runtime load lookup. |
| - set_environment(slow_environment); |
| - { |
| - FrameStateBeforeAndAfter states(this); |
| + // Only build the slow path if there were any slow-path checks. |
| + if (slow_environment != nullptr) { |
| + Environment* fast_environment = environment(); |
| - Node* name = |
| - jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
| + // Slow path, do a runtime load lookup. |
| + set_environment(slow_environment); |
| + { |
| + FrameStateBeforeAndAfter states(this); |
| - const Operator* op = |
| - javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF |
| - ? Runtime::kLoadLookupSlot |
| - : Runtime::kLoadLookupSlotInsideTypeof); |
| - Node* value = NewNode(op, name); |
| - environment()->BindAccumulator(value, &states); |
| - } |
| + Node* name = jsgraph()->Constant( |
| + bytecode_iterator().GetConstantForIndexOperand(0)); |
| - fast_environment->Merge(environment()); |
| - set_environment(fast_environment); |
| + const Operator* op = |
| + javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF |
| + ? Runtime::kLoadLookupSlot |
| + : Runtime::kLoadLookupSlotInsideTypeof); |
| + Node* value = NewNode(op, name); |
| + environment()->BindAccumulator(value, &states); |
| + } |
| + |
| + fast_environment->Merge(environment()); |
| + set_environment(fast_environment); |
| + } |
| } |
| void BytecodeGraphBuilder::VisitLdaLookupGlobalSlot() { |