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

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

Issue 1090303004: [turbofan] Add a debug_name to Parameter operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/common-operator.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/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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 state_values_cache_(jsgraph), 403 state_values_cache_(jsgraph),
404 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()), 404 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()),
405 local_zone), 405 local_zone),
406 js_type_feedback_(js_type_feedback) { 406 js_type_feedback_(js_type_feedback) {
407 InitializeAstVisitor(info->isolate(), local_zone); 407 InitializeAstVisitor(info->isolate(), local_zone);
408 } 408 }
409 409
410 410
411 Node* AstGraphBuilder::GetFunctionClosure() { 411 Node* AstGraphBuilder::GetFunctionClosure() {
412 if (!function_closure_.is_set()) { 412 if (!function_closure_.is_set()) {
413 const Operator* op = 413 const Operator* op = common()->Parameter(
414 common()->Parameter(Linkage::kJSFunctionCallClosureParamIndex); 414 Linkage::kJSFunctionCallClosureParamIndex, "%closure");
415 Node* node = NewNode(op, graph()->start()); 415 Node* node = NewNode(op, graph()->start());
416 function_closure_.set(node); 416 function_closure_.set(node);
417 } 417 }
418 return function_closure_.get(); 418 return function_closure_.get();
419 } 419 }
420 420
421 421
422 void AstGraphBuilder::CreateFunctionContext(bool constant_context) { 422 void AstGraphBuilder::CreateFunctionContext(bool constant_context) {
423 function_context_.set(constant_context 423 function_context_.set(constant_context
424 ? jsgraph()->HeapConstant(info()->context()) 424 ? jsgraph()->HeapConstant(info()->context())
425 : NewOuterContextParam()); 425 : NewOuterContextParam());
426 } 426 }
427 427
428 428
429 Node* AstGraphBuilder::NewOuterContextParam() { 429 Node* AstGraphBuilder::NewOuterContextParam() {
430 // Parameter (arity + 1) is special for the outer context of the function 430 // Parameter (arity + 1) is special for the outer context of the function
431 const Operator* op = common()->Parameter(info()->num_parameters() + 1); 431 const Operator* op =
432 common()->Parameter(info()->num_parameters() + 1, "%context");
432 return NewNode(op, graph()->start()); 433 return NewNode(op, graph()->start());
433 } 434 }
434 435
435 436
436 Node* AstGraphBuilder::NewCurrentContextOsrValue() { 437 Node* AstGraphBuilder::NewCurrentContextOsrValue() {
437 // TODO(titzer): use a real OSR value here; a parameter works by accident. 438 // TODO(titzer): use a real OSR value here; a parameter works by accident.
438 // Parameter (arity + 1) is special for the outer context of the function 439 // Parameter (arity + 1) is special for the outer context of the function
439 const Operator* op = common()->Parameter(info()->num_parameters() + 1); 440 const Operator* op =
441 common()->Parameter(info()->num_parameters() + 1, "%osr-context");
440 return NewNode(op, graph()->start()); 442 return NewNode(op, graph()->start());
441 } 443 }
442 444
443 445
444 bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) { 446 bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) {
445 Scope* scope = info()->scope(); 447 Scope* scope = info()->scope();
446 DCHECK(graph() != NULL); 448 DCHECK(graph() != NULL);
447 449
448 // Set up the basic structure of the graph. 450 // Set up the basic structure of the graph.
449 int parameter_count = info()->num_parameters(); 451 int parameter_count = info()->num_parameters();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 Property* property = expr->AsProperty(); 570 Property* property = expr->AsProperty();
569 DCHECK(expr->IsValidReferenceExpression()); 571 DCHECK(expr->IsValidReferenceExpression());
570 LhsKind lhs_kind = 572 LhsKind lhs_kind =
571 (property == NULL) ? VARIABLE : (property->key()->IsPropertyName()) 573 (property == NULL) ? VARIABLE : (property->key()->IsPropertyName())
572 ? NAMED_PROPERTY 574 ? NAMED_PROPERTY
573 : KEYED_PROPERTY; 575 : KEYED_PROPERTY;
574 return lhs_kind; 576 return lhs_kind;
575 } 577 }
576 578
577 579
580 static const char* GetDebugParameterName(Zone* zone, Scope* scope, int index) {
581 #if DEBUG
582 const AstRawString* name = scope->parameter(index)->raw_name();
583 if (name && name->length() > 0) {
584 char* data = zone->NewArray<char>(name->length() + 1);
585 data[name->length()] = 0;
586 memcpy(data, name->raw_data(), name->length());
587 return data;
588 }
589 #endif
590 return nullptr;
591 }
592
593
578 AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder, 594 AstGraphBuilder::Environment::Environment(AstGraphBuilder* builder,
579 Scope* scope, 595 Scope* scope,
580 Node* control_dependency) 596 Node* control_dependency)
581 : builder_(builder), 597 : builder_(builder),
582 parameters_count_(scope->num_parameters() + 1), 598 parameters_count_(scope->num_parameters() + 1),
583 locals_count_(scope->num_stack_slots()), 599 locals_count_(scope->num_stack_slots()),
584 liveness_block_(builder_->liveness_analyzer()->NewBlock()), 600 liveness_block_(builder_->liveness_analyzer()->NewBlock()),
585 values_(builder_->local_zone()), 601 values_(builder_->local_zone()),
586 contexts_(builder_->local_zone()), 602 contexts_(builder_->local_zone()),
587 control_dependency_(control_dependency), 603 control_dependency_(control_dependency),
588 effect_dependency_(control_dependency), 604 effect_dependency_(control_dependency),
589 parameters_node_(nullptr), 605 parameters_node_(nullptr),
590 locals_node_(nullptr), 606 locals_node_(nullptr),
591 stack_node_(nullptr) { 607 stack_node_(nullptr) {
592 DCHECK_EQ(scope->num_parameters() + 1, parameters_count()); 608 DCHECK_EQ(scope->num_parameters() + 1, parameters_count());
593 609
594 // Bind the receiver variable. 610 // Bind the receiver variable.
595 Node* receiver = builder->graph()->NewNode(common()->Parameter(0), 611 Node* receiver = builder->graph()->NewNode(common()->Parameter(0, "%this"),
596 builder->graph()->start()); 612 builder->graph()->start());
597 values()->push_back(receiver); 613 values()->push_back(receiver);
598 614
599 // Bind all parameter variables. The parameter indices are shifted by 1 615 // Bind all parameter variables. The parameter indices are shifted by 1
600 // (receiver is parameter index -1 but environment index 0). 616 // (receiver is parameter index -1 but environment index 0).
601 for (int i = 0; i < scope->num_parameters(); ++i) { 617 for (int i = 0; i < scope->num_parameters(); ++i) {
602 Node* parameter = builder->graph()->NewNode(common()->Parameter(i + 1), 618 const char* debug_name = GetDebugParameterName(graph()->zone(), scope, i);
603 builder->graph()->start()); 619 Node* parameter = builder->graph()->NewNode(
620 common()->Parameter(i + 1, debug_name), builder->graph()->start());
604 values()->push_back(parameter); 621 values()->push_back(parameter);
605 } 622 }
606 623
607 // Bind all local variables to undefined. 624 // Bind all local variables to undefined.
608 Node* undefined_constant = builder->jsgraph()->UndefinedConstant(); 625 Node* undefined_constant = builder->jsgraph()->UndefinedConstant();
609 values()->insert(values()->end(), locals_count(), undefined_constant); 626 values()->insert(values()->end(), locals_count(), undefined_constant);
610 } 627 }
611 628
612 629
613 AstGraphBuilder::Environment::Environment(AstGraphBuilder::Environment* copy) 630 AstGraphBuilder::Environment::Environment(AstGraphBuilder::Environment* copy)
(...skipping 2936 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 // Phi does not exist yet, introduce one. 3567 // Phi does not exist yet, introduce one.
3551 value = NewPhi(inputs, value, control); 3568 value = NewPhi(inputs, value, control);
3552 value->ReplaceInput(inputs - 1, other); 3569 value->ReplaceInput(inputs - 1, other);
3553 } 3570 }
3554 return value; 3571 return value;
3555 } 3572 }
3556 3573
3557 } // namespace compiler 3574 } // namespace compiler
3558 } // namespace internal 3575 } // namespace internal
3559 } // namespace v8 3576 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/common-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698