Index: src/compiler/js-inlining.cc |
diff --git a/src/compiler/js-inlining.cc b/src/compiler/js-inlining.cc |
index d5e1af984f5c649c32c2bb5fd1729b93b83984fc..a28bb0a934395e9808c4aa6fa0c044c6383f7a03 100644 |
--- a/src/compiler/js-inlining.cc |
+++ b/src/compiler/js-inlining.cc |
@@ -10,6 +10,10 @@ |
#include "src/compiler/all-nodes.h" |
#include "src/compiler/ast-graph-builder.h" |
#include "src/compiler/common-operator.h" |
+#include "src/compiler/common-operator-reducer.h" |
+#include "src/compiler/dead-code-elimination.h" |
+#include "src/compiler/graph-reducer.h" |
+#include "src/compiler/js-global-specialization.h" |
#include "src/compiler/js-operator.h" |
#include "src/compiler/node-matchers.h" |
#include "src/compiler/node-properties.h" |
@@ -253,6 +257,19 @@ Reduction JSInliner::Reduce(Node* node) { |
} |
+namespace { |
+ |
+// TODO(mstarzinger): This will disappear once we unify the native context |
+// specialization with the Pipeline. |
+class JSGraphReducer final : public GraphReducer { |
+ public: |
+ JSGraphReducer(JSGraph* jsgraph, Zone* zone) |
+ : GraphReducer(zone, jsgraph->graph(), jsgraph->Dead()) {} |
Michael Starzinger
2015/10/14 11:28:57
As discussed offline: Let's use the GraphReducer d
Benedikt Meurer
2015/10/14 11:29:13
Done.
|
+ ~JSGraphReducer() final {} |
+}; |
+ |
+} // namespace |
+ |
Reduction JSInliner::ReduceJSCallFunction(Node* node, |
Handle<JSFunction> function) { |
DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); |
@@ -310,7 +327,15 @@ Reduction JSInliner::ReduceJSCallFunction(Node* node, |
Zone zone; |
ParseInfo parse_info(&zone, function); |
CompilationInfo info(&parse_info); |
- if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled(); |
+ if (info_->is_deoptimization_enabled()) { |
+ info.MarkAsDeoptimizationEnabled(); |
+ } |
+ if (info_->is_native_context_specializing()) { |
+ info.MarkAsNativeContextSpecializing(); |
+ } |
+ if (info_->is_typing_enabled()) { |
+ info.MarkAsTypingEnabled(); |
+ } |
if (!Compiler::ParseAndAnalyze(info.parse_info())) { |
TRACE("Not inlining %s into %s because parsing failed\n", |
@@ -339,6 +364,30 @@ Reduction JSInliner::ReduceJSCallFunction(Node* node, |
AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); |
graph_builder.CreateGraph(false); |
+ // TODO(mstarzinger): Unify this with the Pipeline once JSInliner refactoring |
+ // starts. |
+ if (info.is_native_context_specializing()) { |
+ JSGraphReducer graph_reducer(&jsgraph, local_zone_); |
+ DeadCodeElimination dead_code_elimination(&graph_reducer, &graph, |
+ jsgraph.common()); |
+ CommonOperatorReducer common_reducer(&graph_reducer, &graph, |
+ jsgraph.common(), jsgraph.machine()); |
+ JSGlobalSpecialization::Flags flags = JSGlobalSpecialization::kNoFlags; |
+ if (info.is_deoptimization_enabled()) { |
+ flags |= JSGlobalSpecialization::kDeoptimizationEnabled; |
+ } |
+ if (info.is_typing_enabled()) { |
+ flags |= JSGlobalSpecialization::kTypingEnabled; |
+ } |
+ JSGlobalSpecialization global_specialization( |
+ &graph_reducer, &jsgraph, flags, |
+ handle(info.global_object(), info.isolate()), info_->dependencies()); |
+ graph_reducer.AddReducer(&dead_code_elimination); |
+ graph_reducer.AddReducer(&common_reducer); |
+ graph_reducer.AddReducer(&global_specialization); |
+ graph_reducer.ReduceGraph(); |
+ } |
+ |
// The inlinee specializes to the context from the JSFunction object. |
// TODO(turbofan): We might want to load the context from the JSFunction at |
// runtime in case we only know the SharedFunctionInfo once we have dynamic |