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

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

Issue 2212383003: Revert of Separate Scope into DeclarationScope and Scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/ast-loop-assignment-analyzer.h » ('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/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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()), 434 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()),
435 local_zone), 435 local_zone),
436 frame_state_function_info_(common()->CreateFrameStateFunctionInfo( 436 frame_state_function_info_(common()->CreateFrameStateFunctionInfo(
437 FrameStateType::kJavaScriptFunction, info->num_parameters() + 1, 437 FrameStateType::kJavaScriptFunction, info->num_parameters() + 1,
438 info->scope()->num_stack_slots(), info->shared_info())) { 438 info->scope()->num_stack_slots(), info->shared_info())) {
439 InitializeAstVisitor(info->isolate()); 439 InitializeAstVisitor(info->isolate());
440 } 440 }
441 441
442 442
443 Node* AstGraphBuilder::GetFunctionClosureForContext() { 443 Node* AstGraphBuilder::GetFunctionClosureForContext() {
444 DeclarationScope* closure_scope = current_scope()->GetClosureScope(); 444 Scope* closure_scope = current_scope()->ClosureScope();
445 if (closure_scope->is_script_scope() || 445 if (closure_scope->is_script_scope() ||
446 closure_scope->is_module_scope()) { 446 closure_scope->is_module_scope()) {
447 // Contexts nested in the native context have a canonical empty function as 447 // Contexts nested in the native context have a canonical empty function as
448 // their closure, not the anonymous closure containing the global code. 448 // their closure, not the anonymous closure containing the global code.
449 return BuildLoadNativeContextField(Context::CLOSURE_INDEX); 449 return BuildLoadNativeContextField(Context::CLOSURE_INDEX);
450 } else if (closure_scope->is_eval_scope()) { 450 } else if (closure_scope->is_eval_scope()) {
451 // Contexts nested inside eval code have the same closure as the context 451 // Contexts nested inside eval code have the same closure as the context
452 // calling eval, not the anonymous closure containing the eval code. 452 // calling eval, not the anonymous closure containing the eval code.
453 const Operator* op = 453 const Operator* op =
454 javascript()->LoadContext(0, Context::CLOSURE_INDEX, false); 454 javascript()->LoadContext(0, Context::CLOSURE_INDEX, false);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 Node* node = graph()->NewNode( 501 Node* node = graph()->NewNode(
502 op, jsgraph()->EmptyStateValues(), jsgraph()->EmptyStateValues(), 502 op, jsgraph()->EmptyStateValues(), jsgraph()->EmptyStateValues(),
503 jsgraph()->EmptyStateValues(), jsgraph()->NoContextConstant(), 503 jsgraph()->EmptyStateValues(), jsgraph()->NoContextConstant(),
504 jsgraph()->UndefinedConstant(), graph()->start()); 504 jsgraph()->UndefinedConstant(), graph()->start());
505 empty_frame_state_.set(node); 505 empty_frame_state_.set(node);
506 } 506 }
507 return empty_frame_state_.get(); 507 return empty_frame_state_.get();
508 } 508 }
509 509
510 bool AstGraphBuilder::CreateGraph(bool stack_check) { 510 bool AstGraphBuilder::CreateGraph(bool stack_check) {
511 DeclarationScope* scope = info()->scope(); 511 Scope* scope = info()->scope();
512 DCHECK_NOT_NULL(graph()); 512 DCHECK_NOT_NULL(graph());
513 513
514 // Set up the basic structure of the graph. Outputs for {Start} are the formal 514 // Set up the basic structure of the graph. Outputs for {Start} are the formal
515 // parameters (including the receiver) plus new target, number of arguments, 515 // parameters (including the receiver) plus new target, number of arguments,
516 // context and closure. 516 // context and closure.
517 int actual_parameter_count = info()->num_parameters_including_this() + 4; 517 int actual_parameter_count = info()->num_parameters_including_this() + 4;
518 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); 518 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count)));
519 519
520 // Initialize the top-level environment. 520 // Initialize the top-level environment.
521 Environment env(this, scope, graph()->start()); 521 Environment env(this, scope, graph()->start());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // Compute local variable liveness information and use it to relax 561 // Compute local variable liveness information and use it to relax
562 // frame states. 562 // frame states.
563 ClearNonLiveSlotsInFrameStates(); 563 ClearNonLiveSlotsInFrameStates();
564 564
565 // Failures indicated by stack overflow. 565 // Failures indicated by stack overflow.
566 return !HasStackOverflow(); 566 return !HasStackOverflow();
567 } 567 }
568 568
569 569
570 void AstGraphBuilder::CreateGraphBody(bool stack_check) { 570 void AstGraphBuilder::CreateGraphBody(bool stack_check) {
571 DeclarationScope* scope = info()->scope(); 571 Scope* scope = info()->scope();
572 572
573 // Build the arguments object if it is used. 573 // Build the arguments object if it is used.
574 BuildArgumentsObject(scope->arguments()); 574 BuildArgumentsObject(scope->arguments());
575 575
576 // Build rest arguments array if it is used. 576 // Build rest arguments array if it is used.
577 int rest_index; 577 int rest_index;
578 Variable* rest_parameter = scope->rest_parameter(&rest_index); 578 Variable* rest_parameter = scope->rest_parameter(&rest_index);
579 BuildRestArgumentsArray(rest_parameter, rest_index); 579 BuildRestArgumentsArray(rest_parameter, rest_index);
580 580
581 // Build assignment to {.this_function} variable if it is used. 581 // Build assignment to {.this_function} variable if it is used.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 } 627 }
628 628
629 629
630 // Gets the bailout id just before reading a variable proxy, but only for 630 // Gets the bailout id just before reading a variable proxy, but only for
631 // unallocated variables. 631 // unallocated variables.
632 static BailoutId BeforeId(VariableProxy* proxy) { 632 static BailoutId BeforeId(VariableProxy* proxy) {
633 return proxy->var()->IsUnallocatedOrGlobalSlot() ? proxy->BeforeId() 633 return proxy->var()->IsUnallocatedOrGlobalSlot() ? proxy->BeforeId()
634 : BailoutId::None(); 634 : BailoutId::None();
635 } 635 }
636 636
637 static const char* GetDebugParameterName(Zone* zone, DeclarationScope* scope, 637
638 int index) { 638 static const char* GetDebugParameterName(Zone* zone, Scope* scope, int index) {
639 #if DEBUG 639 #if DEBUG
640 const AstRawString* name = scope->parameter(index)->raw_name(); 640 const AstRawString* name = scope->parameter(index)->raw_name();
641 if (name && name->length() > 0) { 641 if (name && name->length() > 0) {
642 char* data = zone->NewArray<char>(name->length() + 1); 642 char* data = zone->NewArray<char>(name->length() + 1);
643 data[name->length()] = 0; 643 data[name->length()] = 0;
644 memcpy(data, name->raw_data(), name->length()); 644 memcpy(data, name->raw_data(), name->length());
645 return data; 645 return data;
646 } 646 }
647 #endif 647 #endif
648 return nullptr; 648 return nullptr;
649 } 649 }
650 650
651
651 AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder, 652 AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder,
652 DeclarationScope* scope, 653 Scope* scope,
653 Node* control_dependency) 654 Node* control_dependency)
654 : builder_(builder), 655 : builder_(builder),
655 parameters_count_(scope->num_parameters() + 1), 656 parameters_count_(scope->num_parameters() + 1),
656 locals_count_(scope->num_stack_slots()), 657 locals_count_(scope->num_stack_slots()),
657 liveness_block_(IsLivenessAnalysisEnabled() 658 liveness_block_(IsLivenessAnalysisEnabled()
658 ? builder_->liveness_analyzer()->NewBlock() 659 ? builder_->liveness_analyzer()->NewBlock()
659 : nullptr), 660 : nullptr),
660 values_(builder_->local_zone()), 661 values_(builder_->local_zone()),
661 contexts_(builder_->local_zone()), 662 contexts_(builder_->local_zone()),
662 control_dependency_(control_dependency), 663 control_dependency_(control_dependency),
(...skipping 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after
3121 Node** all = info()->zone()->NewArray<Node*>(arity); 3122 Node** all = info()->zone()->NewArray<Node*>(arity);
3122 for (int i = arity - 1; i >= 0; --i) { 3123 for (int i = arity - 1; i >= 0; --i) {
3123 all[i] = environment()->Pop(); 3124 all[i] = environment()->Pop();
3124 } 3125 }
3125 Node* value = NewNode(op, arity, all); 3126 Node* value = NewNode(op, arity, all);
3126 return value; 3127 return value;
3127 } 3128 }
3128 3129
3129 3130
3130 Node* AstGraphBuilder::BuildLocalActivationContext(Node* context) { 3131 Node* AstGraphBuilder::BuildLocalActivationContext(Node* context) {
3131 DeclarationScope* scope = info()->scope(); 3132 Scope* scope = info()->scope();
3132 3133
3133 // Allocate a new local context. 3134 // Allocate a new local context.
3134 Node* local_context = scope->is_script_scope() 3135 Node* local_context = scope->is_script_scope()
3135 ? BuildLocalScriptContext(scope) 3136 ? BuildLocalScriptContext(scope)
3136 : BuildLocalFunctionContext(scope); 3137 : BuildLocalFunctionContext(scope);
3137 3138
3138 if (scope->has_this_declaration() && scope->receiver()->IsContextSlot()) { 3139 if (scope->has_this_declaration() && scope->receiver()->IsContextSlot()) {
3139 Node* receiver = environment()->RawParameterLookup(0); 3140 Node* receiver = environment()->RawParameterLookup(0);
3140 // Context variable (at bottom of the context chain). 3141 // Context variable (at bottom of the context chain).
3141 Variable* variable = scope->receiver(); 3142 Variable* variable = scope->receiver();
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4319 // Phi does not exist yet, introduce one. 4320 // Phi does not exist yet, introduce one.
4320 value = NewPhi(inputs, value, control); 4321 value = NewPhi(inputs, value, control);
4321 value->ReplaceInput(inputs - 1, other); 4322 value->ReplaceInput(inputs - 1, other);
4322 } 4323 }
4323 return value; 4324 return value;
4324 } 4325 }
4325 4326
4326 } // namespace compiler 4327 } // namespace compiler
4327 } // namespace internal 4328 } // namespace internal
4328 } // namespace v8 4329 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/ast-loop-assignment-analyzer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698