Reviewers: Yang, jarin,
Message:
Yang: This is the change I was talking about to make your context based
builtins
work nicely with TurboFan inlining. Basically, you cannot run context
specialization w/o inlining or vice versa. Both need to run at the same time
(which is now possible since both are regular reducers, yeah)!
Jaro: Please also take a look.
Description:
[turbofan] Context specialization and inlining need to run together.
Context specialization enables inlining (at least currently it is the
only enabler for inlining), but inlining enables more possibilities for
context specialization. So we really need to run them together.
This is especially important with the "module based builtins" that we're
working towards.
BUG=v8:3952
LOG=n
Please review this at https://codereview.chromium.org/988423004/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+38, -45 lines):
M src/compiler/pipeline.cc
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index
a96e6bd34f74ebf0cad023926a2ccb19d2bee25a..a6d9a41f1974d1aa30add6a2acfcd85221c8d2a6
100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -360,8 +360,8 @@ class SourcePositionWrapper : public Reducer {
};
-static void AddReducer(PipelineData* data, GraphReducer* graph_reducer,
- Reducer* reducer) {
+void AddReducer(PipelineData* data, GraphReducer* graph_reducer,
+ Reducer* reducer) {
if (FLAG_turbo_source_positions) {
void* buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper));
SourcePositionWrapper* wrapper =
@@ -371,7 +371,7 @@ static void AddReducer(PipelineData* data,
GraphReducer* graph_reducer,
graph_reducer->AddReducer(reducer);
}
}
-} // namespace
+
class PipelineRunScope {
public:
@@ -389,22 +389,6 @@ class PipelineRunScope {
};
-template <typename Phase>
-void Pipeline::Run() {
- PipelineRunScope scope(this->data_, Phase::phase_name());
- Phase phase;
- phase.Run(this->data_, scope.zone());
-}
-
-
-template <typename Phase, typename Arg0>
-void Pipeline::Run(Arg0 arg_0) {
- PipelineRunScope scope(this->data_, Phase::phase_name());
- Phase phase;
- phase.Run(this->data_, scope.zone(), arg_0);
-}
-
-
struct LoopAssignmentAnalysisPhase {
static const char* phase_name() { return "loop assignment analysis"; }
@@ -430,32 +414,25 @@ struct GraphBuilderPhase {
};
-struct ContextSpecializerPhase {
- static const char* phase_name() { return "context specializing"; }
-
- void Run(PipelineData* data, Zone* temp_zone) {
- SourcePositionTable::Scope pos(data->source_positions(),
- SourcePosition::Unknown());
- JSContextSpecializer spec(data->jsgraph());
- GraphReducer graph_reducer(data->graph(), temp_zone);
- AddReducer(data, &graph_reducer, &spec);
- graph_reducer.ReduceGraph();
- }
-};
-
-
-struct InliningPhase {
- static const char* phase_name() { return "inlining"; }
+struct ContextSpecializerAndInlinerPhase {
+ static const char* phase_name() { return "context spec. and inlining"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
+ JSContextSpecializer context_specializer(data->jsgraph());
JSInliner inliner(data->info()->is_inlining_enabled()
? JSInliner::kGeneralInlining
: JSInliner::kBuiltinsInlining,
temp_zone, data->info(), data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
- AddReducer(data, &graph_reducer, &inliner);
+ if (data->info()->is_context_specializing()) {
+ AddReducer(data, &graph_reducer, &context_specializer);
+ }
+ if (data->info()->is_builtin_inlining_enabled() ||
+ data->info()->is_inlining_enabled()) {
+ AddReducer(data, &graph_reducer, &inliner);
+ }
graph_reducer.ReduceGraph();
}
};
@@ -810,6 +787,24 @@ struct VerifyGraphPhase {
}
};
+} // namespace
+
+
+template <typename Phase>
+void Pipeline::Run() {
+ PipelineRunScope scope(this->data_, Phase::phase_name());
+ Phase phase;
+ phase.Run(this->data_, scope.zone());
+}
+
+
+template <typename Phase, typename Arg0>
+void Pipeline::Run(Arg0 arg_0) {
+ PipelineRunScope scope(this->data_, Phase::phase_name());
+ Phase phase;
+ phase.Run(this->data_, scope.zone(), arg_0);
+}
+
void Pipeline::BeginPhaseKind(const char* phase_kind_name) {
if (data_->pipeline_statistics() != NULL) {
@@ -912,15 +907,13 @@ Handle<Code> Pipeline::GenerateCode() {
Run<EarlyControlReductionPhase>();
RunPrintAndVerify("Early Control reduced", true);
- if (info()->is_context_specializing()) {
- // Specialize the code to the context as aggressively as possible.
- Run<ContextSpecializerPhase>();
- RunPrintAndVerify("Context specialized", true);
- }
-
- if (info()->is_builtin_inlining_enabled() ||
info()->is_inlining_enabled()) {
- Run<InliningPhase>();
- RunPrintAndVerify("Inlined", true);
+ if (info()->is_builtin_inlining_enabled() ||
+ info()->is_context_specializing() || info()->is_inlining_enabled()) {
+ // Specialize the code to the context as aggressively as possible, and
try
+ // to inline at the same time, because context specialization might
enable
+ // inlining and inlining might enable further context specialization.
+ Run<ContextSpecializerAndInlinerPhase>();
+ RunPrintAndVerify("Context specialized and inlined", true);
}
if (FLAG_print_turbo_replay) {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.