Reviewers: jarin, Michael Starzinger, rossberg,
Message:
Hey Michi, Andreas, Jaro,
As discussed offline. We'll use this as an intermediate step to make
progress.
We can still do eager typing if someone comes up with a solution that works
and
benefits us.
Please take a look.
Thanks,
Benedikt
Description:
[turbofan] Fix life time and use of the Typer.
Currently the Typer is installed on the Graph, no matter if we actually
use the types or not (read: even in the generic pipeline). Also the
Typer tries hard to eagerly type nodes during graph building, which
takes time, just to remove those types later again, and retype
everything from scratch. Plus this is inconsistent, since it only
applies to the outermost graph, not the inlined graphs (which are
eagerly typed once the nodes are copied). So in summary, what's
currently implemented is neither useful nor well defined, so for now we
stick to the full typing approach until a proper design for eager typing
is available that will actually benefit us.
[email protected],[email protected],[email protected]
Please review this at https://codereview.chromium.org/1192553002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+19, -32 lines):
M src/compiler/pipeline.cc
M src/compiler/typer.h
M src/compiler/typer.cc
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index
7b74592cdca6d48188aface5e091dd48a2b963d3..04bac780c62399d90c57b61a00dd301e842000d0
100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -79,7 +79,6 @@ class PipelineData {
javascript_(nullptr),
jsgraph_(nullptr),
js_type_feedback_(nullptr),
- typer_(nullptr),
schedule_(nullptr),
instruction_zone_scope_(zone_pool_),
instruction_zone_(instruction_zone_scope_.zone()),
@@ -98,7 +97,6 @@ class PipelineData {
javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_);
jsgraph_ = new (graph_zone_)
JSGraph(isolate_, graph_, common_, javascript_, machine_);
- typer_.Reset(new Typer(isolate_, graph_, info_->context()));
}
// For machine graph testing entry point.
@@ -121,7 +119,6 @@ class PipelineData {
javascript_(nullptr),
jsgraph_(nullptr),
js_type_feedback_(nullptr),
- typer_(nullptr),
schedule_(schedule),
instruction_zone_scope_(zone_pool_),
instruction_zone_(instruction_zone_scope_.zone()),
@@ -150,7 +147,6 @@ class PipelineData {
javascript_(nullptr),
jsgraph_(nullptr),
js_type_feedback_(nullptr),
- typer_(nullptr),
schedule_(nullptr),
instruction_zone_scope_(zone_pool_),
instruction_zone_(sequence->zone()),
@@ -194,7 +190,6 @@ class PipelineData {
void set_js_type_feedback(JSTypeFeedbackTable* js_type_feedback) {
js_type_feedback_ = js_type_feedback;
}
- Typer* typer() const { return typer_.get(); }
LoopAssignmentAnalysis* loop_assignment() const { return
loop_assignment_; }
void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) {
@@ -220,7 +215,6 @@ class PipelineData {
void DeleteGraphZone() {
// Destroy objects with destructors first.
source_positions_.Reset(nullptr);
- typer_.Reset(nullptr);
if (graph_zone_ == nullptr) return;
// Destroy zone and clear pointers.
graph_zone_scope_.Destroy();
@@ -292,7 +286,6 @@ class PipelineData {
JSGraph* jsgraph_;
JSTypeFeedbackTable* js_type_feedback_;
// TODO(dcarney): make this into a ZoneObject.
- SmartPointer<Typer> typer_;
Schedule* schedule_;
// All objects in the following group of fields are allocated in
@@ -524,7 +517,11 @@ struct InliningPhase {
struct TyperPhase {
static const char* phase_name() { return "typer"; }
- void Run(PipelineData* data, Zone* temp_zone) { data->typer()->Run(); }
+ void Run(PipelineData* data, Zone* temp_zone, Typer* typer) {
+ NodeVector roots(temp_zone);
+ data->jsgraph()->GetCachedNodes(&roots);
+ typer->Run(roots);
+ }
};
@@ -1058,9 +1055,11 @@ Handle<Code> Pipeline::GenerateCode() {
// Bailout here in case target architecture is not supported.
if (!SupportedTarget()) return Handle<Code>::null();
+ SmartPointer<Typer> typer;
if (info()->is_typing_enabled()) {
// Type the graph.
- Run<TyperPhase>();
+ typer.Reset(new Typer(isolate(), data.graph(), info()->context()));
+ Run<TyperPhase>(typer.get());
RunPrintAndVerify("Typed");
}
@@ -1073,7 +1072,7 @@ Handle<Code> Pipeline::GenerateCode() {
if (FLAG_turbo_stress_loop_peeling) {
Run<StressLoopPeelingPhase>();
- RunPrintAndVerify("Loop peeled", true);
+ RunPrintAndVerify("Loop peeled");
}
if (info()->is_osr()) {
@@ -1107,7 +1106,7 @@ Handle<Code> Pipeline::GenerateCode() {
if (info()->is_osr()) {
Run<OsrDeconstructionPhase>();
if (info()->bailout_reason() != kNoReason) return
Handle<Code>::null();
- RunPrintAndVerify("OSR deconstruction");
+ RunPrintAndVerify("OSR deconstruction", true);
}
}
@@ -1124,6 +1123,9 @@ Handle<Code> Pipeline::GenerateCode() {
data.source_positions()->RemoveDecorator();
+ // Kill the Typer and thereby uninstall the decorator (if any).
+ typer.Reset(nullptr);
+
return ScheduleAndGenerateCode(
Linkage::ComputeIncoming(data.instruction_zone(), info()));
}
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index
f7b3a1dc3315899d9f66870307738466ec717ec3..6311fd6ee095ad84b6864e82ea77971c929cab04
100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -429,31 +429,14 @@ class Typer::Visitor : public Reducer {
};
-void Typer::Run() {
- {
- // TODO(titzer): this is a hack. Reset types for interior nodes first.
- NodeDeque deque(zone());
- NodeMarker<bool> marked(graph(), 2);
- deque.push_front(graph()->end());
- marked.Set(graph()->end(), true);
- while (!deque.empty()) {
- Node* node = deque.front();
- deque.pop_front();
- // TODO(titzer): there shouldn't be a need to retype constants.
- if (node->op()->ValueOutputCount() > 0)
- NodeProperties::RemoveBounds(node);
- for (Node* input : node->inputs()) {
- if (!marked.Get(input)) {
- marked.Set(input, true);
- deque.push_back(input);
- }
- }
- }
- }
+void Typer::Run() { Run(NodeVector(zone())); }
+
+void Typer::Run(const NodeVector& roots) {
Visitor visitor(this);
GraphReducer graph_reducer(zone(), graph());
graph_reducer.AddReducer(&visitor);
+ for (Node* const root : roots) graph_reducer.ReduceNode(root);
graph_reducer.ReduceGraph();
}
Index: src/compiler/typer.h
diff --git a/src/compiler/typer.h b/src/compiler/typer.h
index
4c04ddb973b3404b85a2522fc9c75003041d0b10..68d1a4dd29203343dd8869d2b5e6c7e692c664e4
100644
--- a/src/compiler/typer.h
+++ b/src/compiler/typer.h
@@ -21,7 +21,9 @@ class Typer {
Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context);
~Typer();
+ // TODO(bmeurer,jarin): Remove this once we have a notion of "roots" on
Graph.
void Run();
+ void Run(const ZoneVector<Node*>& roots);
Graph* graph() { return graph_; }
MaybeHandle<Context> context() { return context_; }
--
--
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.