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 3215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3226 const VectorSlotPair& feedback, | 3226 const VectorSlotPair& feedback, |
3227 OutputFrameStateCombine combine, | 3227 OutputFrameStateCombine combine, |
3228 ContextualMode contextual_mode) { | 3228 ContextualMode contextual_mode) { |
3229 Node* the_hole = jsgraph()->TheHoleConstant(); | 3229 Node* the_hole = jsgraph()->TheHoleConstant(); |
3230 VariableMode mode = variable->mode(); | 3230 VariableMode mode = variable->mode(); |
3231 switch (variable->location()) { | 3231 switch (variable->location()) { |
3232 case Variable::UNALLOCATED: { | 3232 case Variable::UNALLOCATED: { |
3233 // Global var, const, or let variable. | 3233 // Global var, const, or let variable. |
3234 Node* global = BuildLoadGlobalObject(); | 3234 Node* global = BuildLoadGlobalObject(); |
3235 Handle<Name> name = variable->name(); | 3235 Handle<Name> name = variable->name(); |
3236 Node* value = BuildNamedLoad(global, name, feedback, contextual_mode); | 3236 Node* value = BuildGlobalLoad(global, name, feedback, contextual_mode); |
3237 states.AddToNode(value, bailout_id, combine); | 3237 states.AddToNode(value, bailout_id, combine); |
3238 return value; | 3238 return value; |
3239 } | 3239 } |
3240 case Variable::PARAMETER: | 3240 case Variable::PARAMETER: |
3241 case Variable::LOCAL: { | 3241 case Variable::LOCAL: { |
3242 // Local var, const, or let variable. | 3242 // Local var, const, or let variable. |
3243 Node* value = environment()->Lookup(variable); | 3243 Node* value = environment()->Lookup(variable); |
3244 if (mode == CONST_LEGACY) { | 3244 if (mode == CONST_LEGACY) { |
3245 // Perform check for uninitialized legacy const variables. | 3245 // Perform check for uninitialized legacy const variables. |
3246 if (value->op() == the_hole->op()) { | 3246 if (value->op() == the_hole->op()) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3360 Variable* variable, Node* value, Token::Value op, | 3360 Variable* variable, Node* value, Token::Value op, |
3361 const VectorSlotPair& feedback, BailoutId bailout_id, | 3361 const VectorSlotPair& feedback, BailoutId bailout_id, |
3362 FrameStateBeforeAndAfter& states, OutputFrameStateCombine combine) { | 3362 FrameStateBeforeAndAfter& states, OutputFrameStateCombine combine) { |
3363 Node* the_hole = jsgraph()->TheHoleConstant(); | 3363 Node* the_hole = jsgraph()->TheHoleConstant(); |
3364 VariableMode mode = variable->mode(); | 3364 VariableMode mode = variable->mode(); |
3365 switch (variable->location()) { | 3365 switch (variable->location()) { |
3366 case Variable::UNALLOCATED: { | 3366 case Variable::UNALLOCATED: { |
3367 // Global var, const, or let variable. | 3367 // Global var, const, or let variable. |
3368 Node* global = BuildLoadGlobalObject(); | 3368 Node* global = BuildLoadGlobalObject(); |
3369 Handle<Name> name = variable->name(); | 3369 Handle<Name> name = variable->name(); |
3370 Node* store = BuildNamedStore(global, name, value, feedback, | 3370 Node* store = BuildGlobalStore(global, name, value, feedback, |
3371 TypeFeedbackId::None()); | 3371 TypeFeedbackId::None()); |
3372 states.AddToNode(store, bailout_id, combine); | 3372 states.AddToNode(store, bailout_id, combine); |
3373 return store; | 3373 return store; |
3374 } | 3374 } |
3375 case Variable::PARAMETER: | 3375 case Variable::PARAMETER: |
3376 case Variable::LOCAL: | 3376 case Variable::LOCAL: |
3377 // Local var, const, or let variable. | 3377 // Local var, const, or let variable. |
3378 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { | 3378 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { |
3379 // Perform an initialization check for legacy const variables. | 3379 // Perform an initialization check for legacy const variables. |
3380 Node* current = environment()->Lookup(variable); | 3380 Node* current = environment()->Lookup(variable); |
3381 if (current->op() != the_hole->op()) { | 3381 if (current->op() != the_hole->op()) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3484 | 3484 |
3485 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, | 3485 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, |
3486 const VectorSlotPair& feedback) { | 3486 const VectorSlotPair& feedback) { |
3487 const Operator* op = javascript()->LoadProperty(feedback); | 3487 const Operator* op = javascript()->LoadProperty(feedback); |
3488 Node* node = NewNode(op, object, key, BuildLoadFeedbackVector()); | 3488 Node* node = NewNode(op, object, key, BuildLoadFeedbackVector()); |
3489 return Record(js_type_feedback_, node, feedback.slot()); | 3489 return Record(js_type_feedback_, node, feedback.slot()); |
3490 } | 3490 } |
3491 | 3491 |
3492 | 3492 |
3493 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, | 3493 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, |
3494 const VectorSlotPair& feedback, | 3494 const VectorSlotPair& feedback) { |
3495 ContextualMode mode) { | 3495 const Operator* op = javascript()->LoadNamed(MakeUnique(name), feedback); |
3496 const Operator* op = | |
3497 javascript()->LoadNamed(MakeUnique(name), feedback, mode); | |
3498 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); | 3496 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); |
3499 return Record(js_type_feedback_, node, feedback.slot()); | 3497 return Record(js_type_feedback_, node, feedback.slot()); |
3500 } | 3498 } |
3501 | 3499 |
3502 | 3500 |
3503 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value, | 3501 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value, |
3504 const VectorSlotPair& feedback, | 3502 const VectorSlotPair& feedback, |
3505 TypeFeedbackId id) { | 3503 TypeFeedbackId id) { |
3506 const Operator* op = javascript()->StoreProperty(language_mode(), feedback); | 3504 const Operator* op = javascript()->StoreProperty(language_mode(), feedback); |
3507 Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); | 3505 Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3564 Node* name_node = jsgraph()->Constant(name); | 3562 Node* name_node = jsgraph()->Constant(name); |
3565 Runtime::FunctionId function_id = is_strict(language_mode()) | 3563 Runtime::FunctionId function_id = is_strict(language_mode()) |
3566 ? Runtime::kStoreToSuper_Strict | 3564 ? Runtime::kStoreToSuper_Strict |
3567 : Runtime::kStoreToSuper_Sloppy; | 3565 : Runtime::kStoreToSuper_Sloppy; |
3568 const Operator* op = javascript()->CallRuntime(function_id, 4); | 3566 const Operator* op = javascript()->CallRuntime(function_id, 4); |
3569 Node* node = NewNode(op, receiver, home_object, name_node, value); | 3567 Node* node = NewNode(op, receiver, home_object, name_node, value); |
3570 return Record(js_type_feedback_, node, id); | 3568 return Record(js_type_feedback_, node, id); |
3571 } | 3569 } |
3572 | 3570 |
3573 | 3571 |
| 3572 Node* AstGraphBuilder::BuildGlobalLoad(Node* object, Handle<Name> name, |
| 3573 const VectorSlotPair& feedback, |
| 3574 ContextualMode mode) { |
| 3575 const Operator* op = |
| 3576 javascript()->LoadGlobal(MakeUnique(name), feedback, mode); |
| 3577 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); |
| 3578 return Record(js_type_feedback_, node, feedback.slot()); |
| 3579 } |
| 3580 |
| 3581 |
| 3582 Node* AstGraphBuilder::BuildGlobalStore(Node* object, Handle<Name> name, |
| 3583 Node* value, |
| 3584 const VectorSlotPair& feedback, |
| 3585 TypeFeedbackId id) { |
| 3586 const Operator* op = |
| 3587 javascript()->StoreGlobal(language_mode(), MakeUnique(name), feedback); |
| 3588 Node* node = NewNode(op, object, value, BuildLoadFeedbackVector()); |
| 3589 if (FLAG_vector_stores) { |
| 3590 return Record(js_type_feedback_, node, feedback.slot()); |
| 3591 } |
| 3592 return Record(js_type_feedback_, node, id); |
| 3593 } |
| 3594 |
| 3595 |
3574 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { | 3596 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { |
3575 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, | 3597 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, |
3576 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); | 3598 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); |
3577 } | 3599 } |
3578 | 3600 |
3579 | 3601 |
3580 Node* AstGraphBuilder::BuildLoadImmutableObjectField(Node* object, int offset) { | 3602 Node* AstGraphBuilder::BuildLoadImmutableObjectField(Node* object, int offset) { |
3581 return graph()->NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, | 3603 return graph()->NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, |
3582 jsgraph()->IntPtrConstant(offset - kHeapObjectTag), | 3604 jsgraph()->IntPtrConstant(offset - kHeapObjectTag), |
3583 graph()->start(), graph()->start()); | 3605 graph()->start(), graph()->start()); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4134 // Phi does not exist yet, introduce one. | 4156 // Phi does not exist yet, introduce one. |
4135 value = NewPhi(inputs, value, control); | 4157 value = NewPhi(inputs, value, control); |
4136 value->ReplaceInput(inputs - 1, other); | 4158 value->ReplaceInput(inputs - 1, other); |
4137 } | 4159 } |
4138 return value; | 4160 return value; |
4139 } | 4161 } |
4140 | 4162 |
4141 } // namespace compiler | 4163 } // namespace compiler |
4142 } // namespace internal | 4164 } // namespace internal |
4143 } // namespace v8 | 4165 } // namespace v8 |
OLD | NEW |