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

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

Issue 1384953002: [turbofan] Move global constant optimization to AstGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | src/compiler/js-type-feedback.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 3271 matching lines...) Expand 10 before | Expand all | Expand 10 after
3282 FrameStateBeforeAndAfter& states, 3282 FrameStateBeforeAndAfter& states,
3283 const VectorSlotPair& feedback, 3283 const VectorSlotPair& feedback,
3284 OutputFrameStateCombine combine, 3284 OutputFrameStateCombine combine,
3285 TypeofMode typeof_mode) { 3285 TypeofMode typeof_mode) {
3286 Node* the_hole = jsgraph()->TheHoleConstant(); 3286 Node* the_hole = jsgraph()->TheHoleConstant();
3287 VariableMode mode = variable->mode(); 3287 VariableMode mode = variable->mode();
3288 switch (variable->location()) { 3288 switch (variable->location()) {
3289 case VariableLocation::GLOBAL: 3289 case VariableLocation::GLOBAL:
3290 case VariableLocation::UNALLOCATED: { 3290 case VariableLocation::UNALLOCATED: {
3291 // Global var, const, or let variable. 3291 // Global var, const, or let variable.
3292 Handle<Name> name = variable->name();
3293 Handle<Object> constant_value =
3294 jsgraph()->isolate()->factory()->GlobalConstantFor(name);
3295 if (!constant_value.is_null()) {
3296 // Optimize global constants like "undefined", "Infinity", and "NaN".
3297 return jsgraph()->Constant(constant_value);
3298 }
3292 Node* script_context = current_context(); 3299 Node* script_context = current_context();
3293 int slot_index = -1; 3300 int slot_index = -1;
3294 if (variable->index() > 0) { 3301 if (variable->index() > 0) {
3295 DCHECK(variable->IsStaticGlobalObjectProperty()); 3302 DCHECK(variable->IsStaticGlobalObjectProperty());
3296 slot_index = variable->index(); 3303 slot_index = variable->index();
3297 int depth = current_scope()->ContextChainLength(variable->scope()); 3304 int depth = current_scope()->ContextChainLength(variable->scope());
3298 if (depth > 0) { 3305 if (depth > 0) {
3299 const Operator* op = javascript()->LoadContext( 3306 const Operator* op = javascript()->LoadContext(
3300 depth - 1, Context::PREVIOUS_INDEX, true); 3307 depth - 1, Context::PREVIOUS_INDEX, true);
3301 script_context = NewNode(op, current_context()); 3308 script_context = NewNode(op, current_context());
3302 } 3309 }
3303 } 3310 }
3304 Node* global = BuildLoadGlobalObject(); 3311 Node* global = BuildLoadGlobalObject();
3305 Handle<Name> name = variable->name();
3306 Node* value = BuildGlobalLoad(script_context, global, name, feedback, 3312 Node* value = BuildGlobalLoad(script_context, global, name, feedback,
3307 typeof_mode, slot_index); 3313 typeof_mode, slot_index);
3308 states.AddToNode(value, bailout_id, combine); 3314 states.AddToNode(value, bailout_id, combine);
3309 return value; 3315 return value;
3310 } 3316 }
3311 case VariableLocation::PARAMETER: 3317 case VariableLocation::PARAMETER:
3312 case VariableLocation::LOCAL: { 3318 case VariableLocation::LOCAL: {
3313 // Local var, const, or let variable. 3319 // Local var, const, or let variable.
3314 Node* value = environment()->Lookup(variable); 3320 Node* value = environment()->Lookup(variable);
3315 if (mode == CONST_LEGACY) { 3321 if (mode == CONST_LEGACY) {
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
4272 // Phi does not exist yet, introduce one. 4278 // Phi does not exist yet, introduce one.
4273 value = NewPhi(inputs, value, control); 4279 value = NewPhi(inputs, value, control);
4274 value->ReplaceInput(inputs - 1, other); 4280 value->ReplaceInput(inputs - 1, other);
4275 } 4281 }
4276 return value; 4282 return value;
4277 } 4283 }
4278 4284
4279 } // namespace compiler 4285 } // namespace compiler
4280 } // namespace internal 4286 } // namespace internal
4281 } // namespace v8 4287 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-type-feedback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698