Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1419823003: Remove support for "loads and stores to global vars through property cell shortcuts inst… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@disable-shortcuts
Patch Set: Addressing comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/bytecode-graph-builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3294 matching lines...) Expand 10 before | Expand all | Expand 10 after
3305 case VariableLocation::GLOBAL: 3305 case VariableLocation::GLOBAL:
3306 case VariableLocation::UNALLOCATED: { 3306 case VariableLocation::UNALLOCATED: {
3307 // Global var, const, or let variable. 3307 // Global var, const, or let variable.
3308 Handle<Name> name = variable->name(); 3308 Handle<Name> name = variable->name();
3309 Handle<Object> constant_value = 3309 Handle<Object> constant_value =
3310 jsgraph()->isolate()->factory()->GlobalConstantFor(name); 3310 jsgraph()->isolate()->factory()->GlobalConstantFor(name);
3311 if (!constant_value.is_null()) { 3311 if (!constant_value.is_null()) {
3312 // Optimize global constants like "undefined", "Infinity", and "NaN". 3312 // Optimize global constants like "undefined", "Infinity", and "NaN".
3313 return jsgraph()->Constant(constant_value); 3313 return jsgraph()->Constant(constant_value);
3314 } 3314 }
3315 Node* script_context = current_context(); 3315 Node* value = BuildGlobalLoad(name, feedback, typeof_mode);
3316 int slot_index = -1;
3317 if (variable->index() > 0) {
3318 DCHECK(variable->IsStaticGlobalObjectProperty());
3319 slot_index = variable->index();
3320 int depth = current_scope()->ContextChainLength(variable->scope());
3321 if (depth > 0) {
3322 const Operator* op = javascript()->LoadContext(
3323 depth - 1, Context::PREVIOUS_INDEX, true);
3324 script_context = NewNode(op, current_context());
3325 }
3326 }
3327 Node* global = BuildLoadGlobalObject();
3328 Node* value = BuildGlobalLoad(script_context, global, name, feedback,
3329 typeof_mode, slot_index);
3330 states.AddToNode(value, bailout_id, combine); 3316 states.AddToNode(value, bailout_id, combine);
3331 return value; 3317 return value;
3332 } 3318 }
3333 case VariableLocation::PARAMETER: 3319 case VariableLocation::PARAMETER:
3334 case VariableLocation::LOCAL: { 3320 case VariableLocation::LOCAL: {
3335 // Local var, const, or let variable. 3321 // Local var, const, or let variable.
3336 Node* value = environment()->Lookup(variable); 3322 Node* value = environment()->Lookup(variable);
3337 if (mode == CONST_LEGACY) { 3323 if (mode == CONST_LEGACY) {
3338 // Perform check for uninitialized legacy const variables. 3324 // Perform check for uninitialized legacy const variables.
3339 if (value->op() == the_hole->op()) { 3325 if (value->op() == the_hole->op()) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3454 Node* AstGraphBuilder::BuildVariableAssignment( 3440 Node* AstGraphBuilder::BuildVariableAssignment(
3455 Variable* variable, Node* value, Token::Value op, 3441 Variable* variable, Node* value, Token::Value op,
3456 const VectorSlotPair& feedback, BailoutId bailout_id, 3442 const VectorSlotPair& feedback, BailoutId bailout_id,
3457 FrameStateBeforeAndAfter& states, OutputFrameStateCombine combine) { 3443 FrameStateBeforeAndAfter& states, OutputFrameStateCombine combine) {
3458 Node* the_hole = jsgraph()->TheHoleConstant(); 3444 Node* the_hole = jsgraph()->TheHoleConstant();
3459 VariableMode mode = variable->mode(); 3445 VariableMode mode = variable->mode();
3460 switch (variable->location()) { 3446 switch (variable->location()) {
3461 case VariableLocation::GLOBAL: 3447 case VariableLocation::GLOBAL:
3462 case VariableLocation::UNALLOCATED: { 3448 case VariableLocation::UNALLOCATED: {
3463 // Global var, const, or let variable. 3449 // Global var, const, or let variable.
3464 Node* script_context = current_context();
3465 int slot_index = -1;
3466 if (variable->index() > 0) {
3467 DCHECK(variable->IsStaticGlobalObjectProperty());
3468 slot_index = variable->index();
3469 int depth = current_scope()->ContextChainLength(variable->scope());
3470 if (depth > 0) {
3471 const Operator* op = javascript()->LoadContext(
3472 depth - 1, Context::PREVIOUS_INDEX, true);
3473 script_context = NewNode(op, current_context());
3474 }
3475 }
3476 Node* global = BuildLoadGlobalObject();
3477 Handle<Name> name = variable->name(); 3450 Handle<Name> name = variable->name();
3478 Node* store = 3451 Node* store =
3479 BuildGlobalStore(script_context, global, name, value, feedback, 3452 BuildGlobalStore(name, value, feedback, TypeFeedbackId::None());
3480 TypeFeedbackId::None(), slot_index);
3481 states.AddToNode(store, bailout_id, combine); 3453 states.AddToNode(store, bailout_id, combine);
3482 return store; 3454 return store;
3483 } 3455 }
3484 case VariableLocation::PARAMETER: 3456 case VariableLocation::PARAMETER:
3485 case VariableLocation::LOCAL: 3457 case VariableLocation::LOCAL:
3486 // Local var, const, or let variable. 3458 // Local var, const, or let variable.
3487 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { 3459 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
3488 // Perform an initialization check for legacy const variables. 3460 // Perform an initialization check for legacy const variables.
3489 Node* current = environment()->Lookup(variable); 3461 Node* current = environment()->Lookup(variable);
3490 if (current->op() != the_hole->op()) { 3462 if (current->op() != the_hole->op()) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3694 Node* name_node = jsgraph()->Constant(name); 3666 Node* name_node = jsgraph()->Constant(name);
3695 Runtime::FunctionId function_id = is_strict(language_mode()) 3667 Runtime::FunctionId function_id = is_strict(language_mode())
3696 ? Runtime::kStoreToSuper_Strict 3668 ? Runtime::kStoreToSuper_Strict
3697 : Runtime::kStoreToSuper_Sloppy; 3669 : Runtime::kStoreToSuper_Sloppy;
3698 const Operator* op = javascript()->CallRuntime(function_id, 4); 3670 const Operator* op = javascript()->CallRuntime(function_id, 4);
3699 Node* node = NewNode(op, receiver, home_object, name_node, value); 3671 Node* node = NewNode(op, receiver, home_object, name_node, value);
3700 return Record(js_type_feedback_, node, id); 3672 return Record(js_type_feedback_, node, id);
3701 } 3673 }
3702 3674
3703 3675
3704 Node* AstGraphBuilder::BuildGlobalLoad(Node* script_context, Node* global, 3676 Node* AstGraphBuilder::BuildGlobalLoad(Handle<Name> name,
3705 Handle<Name> name,
3706 const VectorSlotPair& feedback, 3677 const VectorSlotPair& feedback,
3707 TypeofMode typeof_mode, int slot_index) { 3678 TypeofMode typeof_mode) {
3708 const Operator* op = 3679 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode);
3709 javascript()->LoadGlobal(name, feedback, typeof_mode, slot_index); 3680 Node* node = NewNode(op, BuildLoadFeedbackVector());
3710 Node* node = NewNode(op, script_context, global, BuildLoadFeedbackVector());
3711 return Record(js_type_feedback_, node, feedback.slot()); 3681 return Record(js_type_feedback_, node, feedback.slot());
3712 } 3682 }
3713 3683
3714 3684
3715 Node* AstGraphBuilder::BuildGlobalStore(Node* script_context, Node* global, 3685 Node* AstGraphBuilder::BuildGlobalStore(Handle<Name> name, Node* value,
3716 Handle<Name> name, Node* value,
3717 const VectorSlotPair& feedback, 3686 const VectorSlotPair& feedback,
3718 TypeFeedbackId id, int slot_index) { 3687 TypeFeedbackId id) {
3719 const Operator* op = 3688 const Operator* op =
3720 javascript()->StoreGlobal(language_mode(), name, feedback, slot_index); 3689 javascript()->StoreGlobal(language_mode(), name, feedback);
3721 Node* node = 3690 Node* node = NewNode(op, value, BuildLoadFeedbackVector());
3722 NewNode(op, script_context, global, value, BuildLoadFeedbackVector());
3723 if (FLAG_vector_stores) { 3691 if (FLAG_vector_stores) {
3724 return Record(js_type_feedback_, node, feedback.slot()); 3692 return Record(js_type_feedback_, node, feedback.slot());
3725 } 3693 }
3726 return Record(js_type_feedback_, node, id); 3694 return Record(js_type_feedback_, node, id);
3727 } 3695 }
3728 3696
3729 3697
3730 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { 3698 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) {
3731 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, 3699 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object,
3732 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); 3700 jsgraph()->IntPtrConstant(offset - kHeapObjectTag));
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
4300 // Phi does not exist yet, introduce one. 4268 // Phi does not exist yet, introduce one.
4301 value = NewPhi(inputs, value, control); 4269 value = NewPhi(inputs, value, control);
4302 value->ReplaceInput(inputs - 1, other); 4270 value->ReplaceInput(inputs - 1, other);
4303 } 4271 }
4304 return value; 4272 return value;
4305 } 4273 }
4306 4274
4307 } // namespace compiler 4275 } // namespace compiler
4308 } // namespace internal 4276 } // namespace internal
4309 } // namespace v8 4277 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/bytecode-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698