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/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
(...skipping 3316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3327 Node* the_hole = jsgraph()->TheHoleConstant(); | 3327 Node* the_hole = jsgraph()->TheHoleConstant(); |
3328 VariableMode mode = variable->mode(); | 3328 VariableMode mode = variable->mode(); |
3329 switch (variable->location()) { | 3329 switch (variable->location()) { |
3330 case VariableLocation::GLOBAL: | 3330 case VariableLocation::GLOBAL: |
3331 case VariableLocation::UNALLOCATED: { | 3331 case VariableLocation::UNALLOCATED: { |
3332 // Global var, const, or let variable. | 3332 // Global var, const, or let variable. |
3333 Node* script_context = current_context(); | 3333 Node* script_context = current_context(); |
3334 int slot_index = -1; | 3334 int slot_index = -1; |
3335 if (variable->index() > 0) { | 3335 if (variable->index() > 0) { |
3336 DCHECK(variable->IsStaticGlobalObjectProperty()); | 3336 DCHECK(variable->IsStaticGlobalObjectProperty()); |
3337 // Each var occupies two slots in the context: for reads and writes. | |
3338 slot_index = variable->index(); | 3337 slot_index = variable->index(); |
3339 int depth = current_scope()->ContextChainLength(variable->scope()); | 3338 int depth = current_scope()->ContextChainLength(variable->scope()); |
3340 if (depth > 0) { | 3339 if (depth > 0) { |
3341 const Operator* op = javascript()->LoadContext( | 3340 const Operator* op = javascript()->LoadContext( |
3342 depth - 1, Context::PREVIOUS_INDEX, true); | 3341 depth - 1, Context::PREVIOUS_INDEX, true); |
3343 script_context = NewNode(op, current_context()); | 3342 script_context = NewNode(op, current_context()); |
3344 } | 3343 } |
3345 } | 3344 } |
3346 Node* global = BuildLoadGlobalObject(); | 3345 Node* global = BuildLoadGlobalObject(); |
3347 Handle<Name> name = variable->name(); | 3346 Handle<Name> name = variable->name(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3478 Node* the_hole = jsgraph()->TheHoleConstant(); | 3477 Node* the_hole = jsgraph()->TheHoleConstant(); |
3479 VariableMode mode = variable->mode(); | 3478 VariableMode mode = variable->mode(); |
3480 switch (variable->location()) { | 3479 switch (variable->location()) { |
3481 case VariableLocation::GLOBAL: | 3480 case VariableLocation::GLOBAL: |
3482 case VariableLocation::UNALLOCATED: { | 3481 case VariableLocation::UNALLOCATED: { |
3483 // Global var, const, or let variable. | 3482 // Global var, const, or let variable. |
3484 Node* script_context = current_context(); | 3483 Node* script_context = current_context(); |
3485 int slot_index = -1; | 3484 int slot_index = -1; |
3486 if (variable->index() > 0) { | 3485 if (variable->index() > 0) { |
3487 DCHECK(variable->IsStaticGlobalObjectProperty()); | 3486 DCHECK(variable->IsStaticGlobalObjectProperty()); |
3488 // Each var occupies two slots in the context: for reads and writes. | |
3489 slot_index = variable->index(); | 3487 slot_index = variable->index(); |
3490 int depth = current_scope()->ContextChainLength(variable->scope()); | 3488 int depth = current_scope()->ContextChainLength(variable->scope()); |
3491 if (depth > 0) { | 3489 if (depth > 0) { |
3492 const Operator* op = javascript()->LoadContext( | 3490 const Operator* op = javascript()->LoadContext( |
3493 depth - 1, Context::PREVIOUS_INDEX, true); | 3491 depth - 1, Context::PREVIOUS_INDEX, true); |
3494 script_context = NewNode(op, current_context()); | 3492 script_context = NewNode(op, current_context()); |
3495 } | 3493 } |
3496 } | 3494 } |
3497 Node* global = BuildLoadGlobalObject(); | 3495 Node* global = BuildLoadGlobalObject(); |
3498 Handle<Name> name = variable->name(); | 3496 Handle<Name> name = variable->name(); |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4316 // Phi does not exist yet, introduce one. | 4314 // Phi does not exist yet, introduce one. |
4317 value = NewPhi(inputs, value, control); | 4315 value = NewPhi(inputs, value, control); |
4318 value->ReplaceInput(inputs - 1, other); | 4316 value->ReplaceInput(inputs - 1, other); |
4319 } | 4317 } |
4320 return value; | 4318 return value; |
4321 } | 4319 } |
4322 | 4320 |
4323 } // namespace compiler | 4321 } // namespace compiler |
4324 } // namespace internal | 4322 } // namespace internal |
4325 } // namespace v8 | 4323 } // namespace v8 |
OLD | NEW |