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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 1218873005: [turbofan] Context specialization is the job of the JSContextSpecialization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 89373a37bca255dfad94d1bb0d2eae11685375d9..723a14b3ef8e45416edd81a9dec0d6ac93d1afc3 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -483,31 +483,18 @@ Node* AstGraphBuilder::GetFunctionClosure() {
}
-void AstGraphBuilder::CreateFunctionContext(bool constant_context) {
- function_context_.set(constant_context
- ? jsgraph()->HeapConstant(info()->context())
- : NewOuterContextParam());
-}
-
-
-Node* AstGraphBuilder::NewOuterContextParam() {
- // Parameter (arity + 1) is special for the outer context of the function
- const Operator* op =
- common()->Parameter(info()->num_parameters_including_this(), "%context");
- return NewNode(op, graph()->start());
-}
-
-
-Node* AstGraphBuilder::NewCurrentContextOsrValue() {
- // TODO(titzer): use a real OSR value here; a parameter works by accident.
- // Parameter (arity + 1) is special for the outer context of the function
- const Operator* op = common()->Parameter(
- info()->num_parameters_including_this(), "%osr-context");
- return NewNode(op, graph()->start());
+Node* AstGraphBuilder::GetFunctionContext() {
+ if (!function_context_.is_set()) {
+ const Operator* op = common()->Parameter(
+ info()->num_parameters_including_this(), "%context");
+ Node* node = NewNode(op, graph()->start());
+ function_context_.set(node);
+ }
+ return function_context_.get();
}
-bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) {
+bool AstGraphBuilder::CreateGraph(bool stack_check) {
Scope* scope = info()->scope();
DCHECK(graph() != NULL);
@@ -526,8 +513,7 @@ bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) {
}
// Initialize the incoming context.
- CreateFunctionContext(constant_context);
- ContextScope incoming(this, scope, function_context_.get());
+ ContextScope incoming(this, scope, GetFunctionContext());
// Initialize control scope.
ControlScope control(this);
@@ -547,7 +533,7 @@ bool AstGraphBuilder::CreateGraph(bool constant_context, bool stack_check) {
if (info()->num_heap_slots() > 0) {
// Push a new inner context scope for the function.
Node* inner_context =
- BuildLocalFunctionContext(function_context_.get(), patched_receiver);
+ BuildLocalFunctionContext(GetFunctionContext(), patched_receiver);
ContextScope top_context(this, scope, inner_context);
CreateGraphBody(stack_check);
} else {
@@ -3630,7 +3616,7 @@ Node* AstGraphBuilder::BuildLoadBuiltinsObject() {
Node* AstGraphBuilder::BuildLoadGlobalObject() {
const Operator* load_op =
javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true);
- return NewNode(load_op, function_context_.get());
+ return NewNode(load_op, GetFunctionContext());
}
@@ -4091,7 +4077,7 @@ void AstGraphBuilder::Environment::PrepareForLoop(BitVector* assigned,
for (int i = last; i >= 0; i--) {
Node* val = contexts()->at(i);
if (!IrOpcode::IsConstantOpcode(val->opcode())) {
- osr_context = (i == last) ? builder_->NewCurrentContextOsrValue()
+ osr_context = (i == last) ? builder_->GetFunctionContext()
: graph->NewNode(op, osr_context, osr_context,
osr_loop_entry);
contexts()->at(i) = builder_->MergeValue(val, osr_context, control);

Powered by Google App Engine
This is Rietveld 408576698