OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/ast-loop-assignment-analyzer.h" | 9 #include "src/compiler/ast-loop-assignment-analyzer.h" |
10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // Initialize control scope. | 532 // Initialize control scope. |
533 ControlScope control(this); | 533 ControlScope control(this); |
534 | 534 |
535 // TODO(mstarzinger): For now we cannot assume that the {this} parameter is | 535 // TODO(mstarzinger): For now we cannot assume that the {this} parameter is |
536 // not {the_hole}, because for derived classes {this} has a TDZ and the | 536 // not {the_hole}, because for derived classes {this} has a TDZ and the |
537 // JSConstructStubForDerived magically passes {the_hole} as a receiver. | 537 // JSConstructStubForDerived magically passes {the_hole} as a receiver. |
538 if (scope->has_this_declaration() && scope->receiver()->is_const_mode()) { | 538 if (scope->has_this_declaration() && scope->receiver()->is_const_mode()) { |
539 env.RawParameterBind(0, jsgraph()->TheHoleConstant()); | 539 env.RawParameterBind(0, jsgraph()->TheHoleConstant()); |
540 } | 540 } |
541 | 541 |
542 // Build local context only if there are context allocated variables. | 542 if (scope->NeedsContext()) { |
543 if (scope->num_heap_slots() > 0) { | |
544 // Push a new inner context scope for the current activation. | 543 // Push a new inner context scope for the current activation. |
545 Node* inner_context = BuildLocalActivationContext(GetFunctionContext()); | 544 Node* inner_context = BuildLocalActivationContext(GetFunctionContext()); |
546 ContextScope top_context(this, scope, inner_context); | 545 ContextScope top_context(this, scope, inner_context); |
547 CreateGraphBody(stack_check); | 546 CreateGraphBody(stack_check); |
548 } else { | 547 } else { |
549 // Simply use the outer function context in building the graph. | 548 // Simply use the outer function context in building the graph. |
550 CreateGraphBody(stack_check); | 549 CreateGraphBody(stack_check); |
551 } | 550 } |
552 | 551 |
553 // Finish the basic structure of the graph. | 552 // Finish the basic structure of the graph. |
(...skipping 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 // Sentinel for {TryLoadDynamicVariable} disabling inline checks. | 3077 // Sentinel for {TryLoadDynamicVariable} disabling inline checks. |
3079 const uint32_t kFullCheckRequired = -1; | 3078 const uint32_t kFullCheckRequired = -1; |
3080 | 3079 |
3081 } // namespace | 3080 } // namespace |
3082 | 3081 |
3083 | 3082 |
3084 uint32_t AstGraphBuilder::ComputeBitsetForDynamicGlobal(Variable* variable) { | 3083 uint32_t AstGraphBuilder::ComputeBitsetForDynamicGlobal(Variable* variable) { |
3085 DCHECK_EQ(DYNAMIC_GLOBAL, variable->mode()); | 3084 DCHECK_EQ(DYNAMIC_GLOBAL, variable->mode()); |
3086 uint32_t check_depths = 0; | 3085 uint32_t check_depths = 0; |
3087 for (Scope* s = current_scope(); s != nullptr; s = s->outer_scope()) { | 3086 for (Scope* s = current_scope(); s != nullptr; s = s->outer_scope()) { |
3088 if (s->num_heap_slots() <= 0) continue; | 3087 if (!s->NeedsContext()) continue; |
3089 if (!s->calls_sloppy_eval()) continue; | 3088 if (!s->calls_sloppy_eval()) continue; |
3090 int depth = current_scope()->ContextChainLength(s); | 3089 int depth = current_scope()->ContextChainLength(s); |
3091 if (depth > kMaxCheckDepth) return kFullCheckRequired; | 3090 if (depth > kMaxCheckDepth) return kFullCheckRequired; |
3092 check_depths |= 1 << depth; | 3091 check_depths |= 1 << depth; |
3093 } | 3092 } |
3094 return check_depths; | 3093 return check_depths; |
3095 } | 3094 } |
3096 | 3095 |
3097 | 3096 |
3098 uint32_t AstGraphBuilder::ComputeBitsetForDynamicContext(Variable* variable) { | 3097 uint32_t AstGraphBuilder::ComputeBitsetForDynamicContext(Variable* variable) { |
3099 DCHECK_EQ(DYNAMIC_LOCAL, variable->mode()); | 3098 DCHECK_EQ(DYNAMIC_LOCAL, variable->mode()); |
3100 uint32_t check_depths = 0; | 3099 uint32_t check_depths = 0; |
3101 for (Scope* s = current_scope(); s != nullptr; s = s->outer_scope()) { | 3100 for (Scope* s = current_scope(); s != nullptr; s = s->outer_scope()) { |
3102 if (s->num_heap_slots() <= 0) continue; | 3101 if (!s->NeedsContext()) continue; |
3103 if (!s->calls_sloppy_eval() && s != variable->scope()) continue; | 3102 if (!s->calls_sloppy_eval() && s != variable->scope()) continue; |
3104 int depth = current_scope()->ContextChainLength(s); | 3103 int depth = current_scope()->ContextChainLength(s); |
3105 if (depth > kMaxCheckDepth) return kFullCheckRequired; | 3104 if (depth > kMaxCheckDepth) return kFullCheckRequired; |
3106 check_depths |= 1 << depth; | 3105 check_depths |= 1 << depth; |
3107 if (s == variable->scope()) break; | 3106 if (s == variable->scope()) break; |
3108 } | 3107 } |
3109 return check_depths; | 3108 return check_depths; |
3110 } | 3109 } |
3111 | 3110 |
3112 | 3111 |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4323 // Phi does not exist yet, introduce one. | 4322 // Phi does not exist yet, introduce one. |
4324 value = NewPhi(inputs, value, control); | 4323 value = NewPhi(inputs, value, control); |
4325 value->ReplaceInput(inputs - 1, other); | 4324 value->ReplaceInput(inputs - 1, other); |
4326 } | 4325 } |
4327 return value; | 4326 return value; |
4328 } | 4327 } |
4329 | 4328 |
4330 } // namespace compiler | 4329 } // namespace compiler |
4331 } // namespace internal | 4330 } // namespace internal |
4332 } // namespace v8 | 4331 } // namespace v8 |
OLD | NEW |