Commit 0e16150d authored by rossberg@chromium.org's avatar rossberg@chromium.org

Better typing and type verification

- Extend verifier to check types of JS and Simplified nodes.
- Untyped nodes now contain NULL as types, enforcing hard failure.
- Typer immediately installs itself as a decorator; remove explicit decorator installation.
- Decorator eagerly types all nodes that have typed inputs
  (subsumes typing of constant cache, removing its typing
  side-channel and various spurious dependencies on the typer).
- Cut down typer interface to prevent inconsistently typed graphs.
- Remove verification from start, since it caused too much trouble
  with semi-wellformed nodes.
- Fix a couple of bugs on the way that got uncovered.

To do: verifying machine operators. Also, various conditions in the
verifier are currently commented out, because they don't yet hold.

BUG=
R=jarin@chromium.org,titzer@chromium.org

Review URL: https://codereview.chromium.org/658543002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24626 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 46db2f9b
...@@ -23,7 +23,8 @@ GenericNode<B, S>::GenericNode(GenericGraphBase* graph, int input_count) ...@@ -23,7 +23,8 @@ GenericNode<B, S>::GenericNode(GenericGraphBase* graph, int input_count)
use_count_(0), use_count_(0),
first_use_(NULL), first_use_(NULL),
last_use_(NULL) { last_use_(NULL) {
inputs_.static_ = reinterpret_cast<Input*>(this + 1), AssignUniqueID(graph); inputs_.static_ = reinterpret_cast<Input*>(this + 1);
AssignUniqueID(graph);
} }
template <class B, class S> template <class B, class S>
......
...@@ -167,7 +167,7 @@ Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { ...@@ -167,7 +167,7 @@ Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
Node** buffer = local_zone()->NewArray<Node*>(count + 1); Node** buffer = local_zone()->NewArray<Node*>(count + 1);
MemsetPointer(buffer, input, count); MemsetPointer(buffer, input, count);
buffer[count] = control; buffer[count] = control;
return graph()->NewNode(phi_op, count + 1, buffer); return graph()->NewNode(phi_op, count + 1, buffer, true);
} }
...@@ -178,7 +178,7 @@ Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input, ...@@ -178,7 +178,7 @@ Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input,
Node** buffer = local_zone()->NewArray<Node*>(count + 1); Node** buffer = local_zone()->NewArray<Node*>(count + 1);
MemsetPointer(buffer, input, count); MemsetPointer(buffer, input, count);
buffer[count] = control; buffer[count] = control;
return graph()->NewNode(phi_op, count + 1, buffer); return graph()->NewNode(phi_op, count + 1, buffer, true);
} }
......
...@@ -299,7 +299,7 @@ void GraphVisualizer::AnnotateNode(Node* node) { ...@@ -299,7 +299,7 @@ void GraphVisualizer::AnnotateNode(Node* node) {
} }
os_ << "}"; os_ << "}";
if (FLAG_trace_turbo_types && !NodeProperties::IsControl(node)) { if (FLAG_trace_turbo_types && NodeProperties::IsTyped(node)) {
Bounds bounds = NodeProperties::GetBounds(node); Bounds bounds = NodeProperties::GetBounds(node);
std::ostringstream upper; std::ostringstream upper;
bounds.upper->PrintTo(upper); bounds.upper->PrintTo(upper);
......
...@@ -21,14 +21,20 @@ namespace compiler { ...@@ -21,14 +21,20 @@ namespace compiler {
Graph::Graph(Zone* zone) : GenericGraph<Node>(zone), decorators_(zone) {} Graph::Graph(Zone* zone) : GenericGraph<Node>(zone), decorators_(zone) {}
Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs) { void Graph::Decorate(Node* node) {
DCHECK_LE(op->InputCount(), input_count);
Node* result = Node::New(this, input_count, inputs);
result->Initialize(op);
for (ZoneVector<GraphDecorator*>::iterator i = decorators_.begin(); for (ZoneVector<GraphDecorator*>::iterator i = decorators_.begin();
i != decorators_.end(); ++i) { i != decorators_.end(); ++i) {
(*i)->Decorate(result); (*i)->Decorate(node);
} }
}
Node* Graph::NewNode(
const Operator* op, int input_count, Node** inputs, bool incomplete) {
DCHECK_LE(op->InputCount(), input_count);
Node* result = Node::New(this, input_count, inputs);
result->Initialize(op);
if (!incomplete) Decorate(result);
return result; return result;
} }
......
...@@ -25,7 +25,8 @@ class Graph : public GenericGraph<Node> { ...@@ -25,7 +25,8 @@ class Graph : public GenericGraph<Node> {
explicit Graph(Zone* zone); explicit Graph(Zone* zone);
// Base implementation used by all factory methods. // Base implementation used by all factory methods.
Node* NewNode(const Operator* op, int input_count, Node** inputs); Node* NewNode(const Operator* op, int input_count, Node** inputs,
bool incomplete = false);
// Factories for nodes with static input counts. // Factories for nodes with static input counts.
Node* NewNode(const Operator* op) { Node* NewNode(const Operator* op) {
...@@ -64,6 +65,8 @@ class Graph : public GenericGraph<Node> { ...@@ -64,6 +65,8 @@ class Graph : public GenericGraph<Node> {
template <class Visitor> template <class Visitor>
void VisitNodeInputsFromEnd(Visitor* visitor); void VisitNodeInputsFromEnd(Visitor* visitor);
void Decorate(Node* node);
void AddDecorator(GraphDecorator* decorator) { void AddDecorator(GraphDecorator* decorator) {
decorators_.push_back(decorator); decorators_.push_back(decorator);
} }
......
...@@ -12,14 +12,7 @@ namespace compiler { ...@@ -12,14 +12,7 @@ namespace compiler {
Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) { Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) {
Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(object); Unique<HeapObject> unique = Unique<HeapObject>::CreateImmovable(object);
return NewNode(common()->HeapConstant(unique)); return graph()->NewNode(common()->HeapConstant(unique));
}
Node* JSGraph::NewNode(const Operator* op) {
Node* node = graph()->NewNode(op);
typer_->Init(node);
return node;
} }
...@@ -95,7 +88,7 @@ Node* JSGraph::NaNConstant() { ...@@ -95,7 +88,7 @@ Node* JSGraph::NaNConstant() {
Node* JSGraph::HeapConstant(Unique<HeapObject> value) { Node* JSGraph::HeapConstant(Unique<HeapObject> value) {
// TODO(turbofan): canonicalize heap constants using Unique<T> // TODO(turbofan): canonicalize heap constants using Unique<T>
return NewNode(common()->HeapConstant(value)); return graph()->NewNode(common()->HeapConstant(value));
} }
...@@ -151,7 +144,7 @@ Node* JSGraph::Constant(int32_t value) { ...@@ -151,7 +144,7 @@ Node* JSGraph::Constant(int32_t value) {
Node* JSGraph::Int32Constant(int32_t value) { Node* JSGraph::Int32Constant(int32_t value) {
Node** loc = cache_.FindInt32Constant(value); Node** loc = cache_.FindInt32Constant(value);
if (*loc == NULL) { if (*loc == NULL) {
*loc = NewNode(common()->Int32Constant(value)); *loc = graph()->NewNode(common()->Int32Constant(value));
} }
return *loc; return *loc;
} }
...@@ -160,7 +153,7 @@ Node* JSGraph::Int32Constant(int32_t value) { ...@@ -160,7 +153,7 @@ Node* JSGraph::Int32Constant(int32_t value) {
Node* JSGraph::Int64Constant(int64_t value) { Node* JSGraph::Int64Constant(int64_t value) {
Node** loc = cache_.FindInt64Constant(value); Node** loc = cache_.FindInt64Constant(value);
if (*loc == NULL) { if (*loc == NULL) {
*loc = NewNode(common()->Int64Constant(value)); *loc = graph()->NewNode(common()->Int64Constant(value));
} }
return *loc; return *loc;
} }
...@@ -169,7 +162,7 @@ Node* JSGraph::Int64Constant(int64_t value) { ...@@ -169,7 +162,7 @@ Node* JSGraph::Int64Constant(int64_t value) {
Node* JSGraph::NumberConstant(double value) { Node* JSGraph::NumberConstant(double value) {
Node** loc = cache_.FindNumberConstant(value); Node** loc = cache_.FindNumberConstant(value);
if (*loc == NULL) { if (*loc == NULL) {
*loc = NewNode(common()->NumberConstant(value)); *loc = graph()->NewNode(common()->NumberConstant(value));
} }
return *loc; return *loc;
} }
...@@ -177,14 +170,14 @@ Node* JSGraph::NumberConstant(double value) { ...@@ -177,14 +170,14 @@ Node* JSGraph::NumberConstant(double value) {
Node* JSGraph::Float32Constant(float value) { Node* JSGraph::Float32Constant(float value) {
// TODO(turbofan): cache float32 constants. // TODO(turbofan): cache float32 constants.
return NewNode(common()->Float32Constant(value)); return graph()->NewNode(common()->Float32Constant(value));
} }
Node* JSGraph::Float64Constant(double value) { Node* JSGraph::Float64Constant(double value) {
Node** loc = cache_.FindFloat64Constant(value); Node** loc = cache_.FindFloat64Constant(value);
if (*loc == NULL) { if (*loc == NULL) {
*loc = NewNode(common()->Float64Constant(value)); *loc = graph()->NewNode(common()->Float64Constant(value));
} }
return *loc; return *loc;
} }
...@@ -193,7 +186,7 @@ Node* JSGraph::Float64Constant(double value) { ...@@ -193,7 +186,7 @@ Node* JSGraph::Float64Constant(double value) {
Node* JSGraph::ExternalConstant(ExternalReference reference) { Node* JSGraph::ExternalConstant(ExternalReference reference) {
Node** loc = cache_.FindExternalConstant(reference); Node** loc = cache_.FindExternalConstant(reference);
if (*loc == NULL) { if (*loc == NULL) {
*loc = NewNode(common()->ExternalConstant(reference)); *loc = graph()->NewNode(common()->ExternalConstant(reference));
} }
return *loc; return *loc;
} }
......
...@@ -24,12 +24,10 @@ class Typer; ...@@ -24,12 +24,10 @@ class Typer;
class JSGraph : public ZoneObject { class JSGraph : public ZoneObject {
public: public:
JSGraph(Graph* graph, CommonOperatorBuilder* common, JSGraph(Graph* graph, CommonOperatorBuilder* common,
JSOperatorBuilder* javascript, Typer* typer, JSOperatorBuilder* javascript, MachineOperatorBuilder* machine)
MachineOperatorBuilder* machine)
: graph_(graph), : graph_(graph),
common_(common), common_(common),
javascript_(javascript), javascript_(javascript),
typer_(typer),
machine_(machine), machine_(machine),
cache_(zone()) {} cache_(zone()) {}
...@@ -109,7 +107,6 @@ class JSGraph : public ZoneObject { ...@@ -109,7 +107,6 @@ class JSGraph : public ZoneObject {
Graph* graph_; Graph* graph_;
CommonOperatorBuilder* common_; CommonOperatorBuilder* common_;
JSOperatorBuilder* javascript_; JSOperatorBuilder* javascript_;
Typer* typer_;
MachineOperatorBuilder* machine_; MachineOperatorBuilder* machine_;
SetOncePointer<Node> c_entry_stub_constant_; SetOncePointer<Node> c_entry_stub_constant_;
...@@ -126,7 +123,6 @@ class JSGraph : public ZoneObject { ...@@ -126,7 +123,6 @@ class JSGraph : public ZoneObject {
Node* ImmovableHeapConstant(Handle<HeapObject> value); Node* ImmovableHeapConstant(Handle<HeapObject> value);
Node* NumberConstant(double value); Node* NumberConstant(double value);
Node* NewNode(const Operator* op);
Factory* factory() { return isolate()->factory(); } Factory* factory() { return isolate()->factory(); }
}; };
......
...@@ -410,8 +410,7 @@ void JSInliner::TryInlineCall(Node* call_node) { ...@@ -410,8 +410,7 @@ void JSInliner::TryInlineCall(Node* call_node) {
} }
Graph graph(info.zone()); Graph graph(info.zone());
Typer typer(info.zone()); JSGraph jsgraph(&graph, jsgraph_->common(), jsgraph_->javascript(),
JSGraph jsgraph(&graph, jsgraph_->common(), jsgraph_->javascript(), &typer,
jsgraph_->machine()); jsgraph_->machine());
AstGraphBuilder graph_builder(&info, &jsgraph); AstGraphBuilder graph_builder(&info, &jsgraph);
......
...@@ -602,11 +602,12 @@ static Reduction ReplaceWithReduction(Node* node, Reduction reduction) { ...@@ -602,11 +602,12 @@ static Reduction ReplaceWithReduction(Node* node, Reduction reduction) {
Reduction JSTypedLowering::Reduce(Node* node) { Reduction JSTypedLowering::Reduce(Node* node) {
// Check if the output type is a singleton. In that case we already know the // Check if the output type is a singleton. In that case we already know the
// result value and can simply replace the node unless there are effects. // result value and can simply replace the node unless there are effects.
if (node->bounds().upper->IsConstant() && if (NodeProperties::IsTyped(node) &&
NodeProperties::GetBounds(node).upper->IsConstant() &&
!IrOpcode::IsLeafOpcode(node->opcode()) && !IrOpcode::IsLeafOpcode(node->opcode()) &&
!OperatorProperties::HasEffectOutput(node->op())) { !OperatorProperties::HasEffectOutput(node->op())) {
return ReplaceEagerly(node, jsgraph()->Constant( return ReplaceEagerly(node, jsgraph()->Constant(
node->bounds().upper->AsConstant()->Value())); NodeProperties::GetBounds(node).upper->AsConstant()->Value()));
// TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...? // TODO(neis): Extend this to Range(x,x), NaN, MinusZero, ...?
} }
switch (node->opcode()) { switch (node->opcode()) {
......
...@@ -198,12 +198,30 @@ inline void NodeProperties::ReplaceWithValue(Node* node, Node* value, ...@@ -198,12 +198,30 @@ inline void NodeProperties::ReplaceWithValue(Node* node, Node* value,
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Type Bounds. // Type Bounds.
inline Bounds NodeProperties::GetBounds(Node* node) { return node->bounds(); } inline bool NodeProperties::IsTyped(Node* node) {
Bounds bounds = node->bounds();
DCHECK((bounds.lower == NULL) == (bounds.upper == NULL));
return bounds.upper != NULL;
}
inline Bounds NodeProperties::GetBounds(Node* node) {
DCHECK(IsTyped(node));
return node->bounds();
}
inline void NodeProperties::SetBounds(Node* node, Bounds b) { inline void NodeProperties::SetBounds(Node* node, Bounds b) {
DCHECK(b.lower != NULL && b.upper != NULL);
node->set_bounds(b); node->set_bounds(b);
} }
inline bool NodeProperties::AllValueInputsAreTyped(Node* node) {
int input_count = OperatorProperties::GetValueInputCount(node->op());
for (int i = 0; i < input_count; ++i) {
if (!IsTyped(GetValueInput(node, i))) return false;
}
return true;
}
} }
} }
......
...@@ -40,8 +40,10 @@ class NodeProperties { ...@@ -40,8 +40,10 @@ class NodeProperties {
static inline void ReplaceWithValue(Node* node, Node* value, static inline void ReplaceWithValue(Node* node, Node* value,
Node* effect = NULL); Node* effect = NULL);
static inline bool IsTyped(Node* node);
static inline Bounds GetBounds(Node* node); static inline Bounds GetBounds(Node* node);
static inline void SetBounds(Node* node, Bounds bounds); static inline void SetBounds(Node* node, Bounds bounds);
static inline bool AllValueInputsAreTyped(Node* node);
static inline int FirstValueIndex(Node* node); static inline int FirstValueIndex(Node* node);
static inline int FirstContextIndex(Node* node); static inline int FirstContextIndex(Node* node);
......
...@@ -31,14 +31,13 @@ class NodeData { ...@@ -31,14 +31,13 @@ class NodeData {
return static_cast<IrOpcode::Value>(op_->opcode()); return static_cast<IrOpcode::Value>(op_->opcode());
} }
Bounds bounds() { return bounds_; }
protected: protected:
const Operator* op_; const Operator* op_;
Bounds bounds_; Bounds bounds_;
explicit NodeData(Zone* zone) : bounds_(Bounds(Type::None(zone))) {} explicit NodeData(Zone* zone) {}
friend class NodeProperties; friend class NodeProperties;
Bounds bounds() { return bounds_; }
void set_bounds(Bounds b) { bounds_ = b; } void set_bounds(Bounds b) { bounds_ = b; }
}; };
......
...@@ -105,7 +105,8 @@ void Pipeline::OpenTurboCfgFile(std::ofstream* stream) { ...@@ -105,7 +105,8 @@ void Pipeline::OpenTurboCfgFile(std::ofstream* stream) {
} }
void Pipeline::VerifyAndPrintGraph(Graph* graph, const char* phase) { void Pipeline::VerifyAndPrintGraph(
Graph* graph, const char* phase, bool untyped) {
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
char buffer[256]; char buffer[256];
Vector<char> filename(buffer, sizeof(buffer)); Vector<char> filename(buffer, sizeof(buffer));
...@@ -143,7 +144,10 @@ void Pipeline::VerifyAndPrintGraph(Graph* graph, const char* phase) { ...@@ -143,7 +144,10 @@ void Pipeline::VerifyAndPrintGraph(Graph* graph, const char* phase) {
os << "-- " << phase << " graph printed to file " << filename.start() os << "-- " << phase << " graph printed to file " << filename.start()
<< "\n"; << "\n";
} }
if (VerifyGraphs()) Verifier::Run(graph); if (VerifyGraphs()) {
Verifier::Run(graph,
FLAG_turbo_types && !untyped ? Verifier::TYPED : Verifier::UNTYPED);
}
} }
...@@ -231,11 +235,11 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -231,11 +235,11 @@ Handle<Code> Pipeline::GenerateCode() {
// TODO(turbofan): there is no need to type anything during initial graph // TODO(turbofan): there is no need to type anything during initial graph
// construction. This is currently only needed for the node cache, which the // construction. This is currently only needed for the node cache, which the
// typer could sweep over later. // typer could sweep over later.
Typer typer(zone()); Typer typer(&graph, info()->context());
MachineOperatorBuilder machine; MachineOperatorBuilder machine;
CommonOperatorBuilder common(zone()); CommonOperatorBuilder common(zone());
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(&graph, &common, &javascript, &typer, &machine); JSGraph jsgraph(&graph, &common, &javascript, &machine);
Node* context_node; Node* context_node;
{ {
PhaseStats graph_builder_stats(info(), PhaseStats::CREATE_GRAPH, PhaseStats graph_builder_stats(info(), PhaseStats::CREATE_GRAPH,
...@@ -257,7 +261,7 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -257,7 +261,7 @@ Handle<Code> Pipeline::GenerateCode() {
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
} }
VerifyAndPrintGraph(&graph, "Initial untyped"); VerifyAndPrintGraph(&graph, "Initial untyped", true);
if (info()->is_context_specializing()) { if (info()->is_context_specializing()) {
SourcePositionTable::Scope pos(&source_positions, SourcePositionTable::Scope pos(&source_positions,
...@@ -265,7 +269,7 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -265,7 +269,7 @@ Handle<Code> Pipeline::GenerateCode() {
// Specialize the code to the context as aggressively as possible. // Specialize the code to the context as aggressively as possible.
JSContextSpecializer spec(info(), &jsgraph, context_node); JSContextSpecializer spec(info(), &jsgraph, context_node);
spec.SpecializeToContext(); spec.SpecializeToContext();
VerifyAndPrintGraph(&graph, "Context specialized"); VerifyAndPrintGraph(&graph, "Context specialized", true);
} }
if (info()->is_inlining_enabled()) { if (info()->is_inlining_enabled()) {
...@@ -273,7 +277,7 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -273,7 +277,7 @@ Handle<Code> Pipeline::GenerateCode() {
SourcePosition::Unknown()); SourcePosition::Unknown());
JSInliner inliner(info(), &jsgraph); JSInliner inliner(info(), &jsgraph);
inliner.Inline(); inliner.Inline();
VerifyAndPrintGraph(&graph, "Inlined"); VerifyAndPrintGraph(&graph, "Inlined", true);
} }
// Print a replay of the initial graph. // Print a replay of the initial graph.
...@@ -288,11 +292,9 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -288,11 +292,9 @@ Handle<Code> Pipeline::GenerateCode() {
{ {
// Type the graph. // Type the graph.
PhaseStats typer_stats(info(), PhaseStats::CREATE_GRAPH, "typer"); PhaseStats typer_stats(info(), PhaseStats::CREATE_GRAPH, "typer");
typer.Run(&graph, info()->context()); typer.Run();
VerifyAndPrintGraph(&graph, "Typed"); VerifyAndPrintGraph(&graph, "Typed");
} }
// All new nodes must be typed.
typer.DecorateGraph(&graph);
{ {
// Lower JSOperators where we can determine types. // Lower JSOperators where we can determine types.
PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH, PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH,
...@@ -336,7 +338,8 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -336,7 +338,8 @@ Handle<Code> Pipeline::GenerateCode() {
graph_reducer.AddReducer(&mach_reducer); graph_reducer.AddReducer(&mach_reducer);
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
VerifyAndPrintGraph(&graph, "Lowered changes"); // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
VerifyAndPrintGraph(&graph, "Lowered changes", true);
} }
} }
...@@ -351,7 +354,8 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -351,7 +354,8 @@ Handle<Code> Pipeline::GenerateCode() {
graph_reducer.AddReducer(&lowering); graph_reducer.AddReducer(&lowering);
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
VerifyAndPrintGraph(&graph, "Lowered generic"); // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
VerifyAndPrintGraph(&graph, "Lowered generic", true);
} }
source_positions.RemoveDecorator(); source_positions.RemoveDecorator();
...@@ -396,7 +400,8 @@ Handle<Code> Pipeline::GenerateCodeForMachineGraph(Linkage* linkage, ...@@ -396,7 +400,8 @@ Handle<Code> Pipeline::GenerateCodeForMachineGraph(Linkage* linkage,
Schedule* schedule) { Schedule* schedule) {
CHECK(SupportedBackend()); CHECK(SupportedBackend());
if (schedule == NULL) { if (schedule == NULL) {
VerifyAndPrintGraph(graph, "Machine"); // TODO(rossberg): Should this really be untyped?
VerifyAndPrintGraph(graph, "Machine", true);
schedule = ComputeSchedule(graph); schedule = ComputeSchedule(graph);
} }
TraceSchedule(schedule); TraceSchedule(schedule);
......
...@@ -58,7 +58,8 @@ class Pipeline { ...@@ -58,7 +58,8 @@ class Pipeline {
const SourcePositionTable* positions, const SourcePositionTable* positions,
const InstructionSequence* instructions); const InstructionSequence* instructions);
void PrintAllocator(const char* phase, const RegisterAllocator* allocator); void PrintAllocator(const char* phase, const RegisterAllocator* allocator);
void VerifyAndPrintGraph(Graph* graph, const char* phase); void VerifyAndPrintGraph(Graph* graph, const char* phase,
bool untyped = false);
Handle<Code> GenerateCode(Linkage* linkage, Graph* graph, Schedule* schedule, Handle<Code> GenerateCode(Linkage* linkage, Graph* graph, Schedule* schedule,
SourcePositionTable* source_positions); SourcePositionTable* source_positions);
}; };
......
...@@ -274,7 +274,7 @@ std::ostream& operator<<(std::ostream& os, const Schedule& s) { ...@@ -274,7 +274,7 @@ std::ostream& operator<<(std::ostream& os, const Schedule& s) {
++j) { ++j) {
Node* node = *j; Node* node = *j;
os << " " << *node; os << " " << *node;
if (!NodeProperties::IsControl(node)) { if (NodeProperties::IsTyped(node)) {
Bounds bounds = NodeProperties::GetBounds(node); Bounds bounds = NodeProperties::GetBounds(node);
os << " : "; os << " : ";
bounds.lower->PrintTo(os); bounds.lower->PrintTo(os);
......
This diff is collapsed.
...@@ -17,23 +17,27 @@ namespace compiler { ...@@ -17,23 +17,27 @@ namespace compiler {
class Typer { class Typer {
public: public:
explicit Typer(Zone* zone); explicit Typer(Graph* graph, MaybeHandle<Context> context);
~Typer();
void Init(Node* node); void Run();
void Run(Graph* graph, MaybeHandle<Context> context); void Narrow(Node* node);
void Narrow(Graph* graph, Node* node, MaybeHandle<Context> context);
void Widen(Graph* graph, Node* node, MaybeHandle<Context> context);
void DecorateGraph(Graph* graph); Graph* graph() { return graph_; }
MaybeHandle<Context> context() { return context_; }
Zone* zone() { return zone_; } Zone* zone() { return graph_->zone(); }
Isolate* isolate() { return zone_->isolate(); } Isolate* isolate() { return zone()->isolate(); }
private: private:
class Visitor; class Visitor;
class RunVisitor; class RunVisitor;
class NarrowVisitor; class NarrowVisitor;
class WidenVisitor; class WidenVisitor;
class Decorator;
Graph* graph_;
MaybeHandle<Context> context_;
Decorator* decorator_;
Zone* zone_; Zone* zone_;
Type* negative_signed32; Type* negative_signed32;
......
This diff is collapsed.
...@@ -18,7 +18,9 @@ class Schedule; ...@@ -18,7 +18,9 @@ class Schedule;
// each node, etc. // each node, etc.
class Verifier { class Verifier {
public: public:
static void Run(Graph* graph); enum Typing { TYPED, UNTYPED };
static void Run(Graph* graph, Typing typing = TYPED);
private: private:
class Visitor; class Visitor;
......
...@@ -54,6 +54,13 @@ bool TypeImpl<Config>::NowContains(i::Object* value) { ...@@ -54,6 +54,13 @@ bool TypeImpl<Config>::NowContains(i::Object* value) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ZoneTypeConfig // ZoneTypeConfig
// static
template<class T>
T* ZoneTypeConfig::null_handle() {
return NULL;
}
// static // static
template<class T> template<class T>
T* ZoneTypeConfig::handle(T* type) { T* ZoneTypeConfig::handle(T* type) {
...@@ -197,6 +204,13 @@ void ZoneTypeConfig::struct_set_value( ...@@ -197,6 +204,13 @@ void ZoneTypeConfig::struct_set_value(
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// HeapTypeConfig // HeapTypeConfig
// static
template<class T>
i::Handle<T> HeapTypeConfig::null_handle() {
return i::Handle<T>();
}
// static // static
template<class T> template<class T>
i::Handle<T> HeapTypeConfig::handle(T* type) { i::Handle<T> HeapTypeConfig::handle(T* type) {
......
...@@ -247,6 +247,7 @@ TypeImpl<Config>::BitsetType::Lub(i::Map* map) { ...@@ -247,6 +247,7 @@ TypeImpl<Config>::BitsetType::Lub(i::Map* map) {
case SHARED_FUNCTION_INFO_TYPE: case SHARED_FUNCTION_INFO_TYPE:
case ACCESSOR_PAIR_TYPE: case ACCESSOR_PAIR_TYPE:
case FIXED_ARRAY_TYPE: case FIXED_ARRAY_TYPE:
case BYTE_ARRAY_TYPE:
case FOREIGN_TYPE: case FOREIGN_TYPE:
case CODE_TYPE: case CODE_TYPE:
return kInternal & kTaggedPtr; return kInternal & kTaggedPtr;
...@@ -436,6 +437,7 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) { ...@@ -436,6 +437,7 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
Contains(that->AsRange(), *this->AsConstant()->Value())); Contains(that->AsRange(), *this->AsConstant()->Value()));
} }
if (this->IsRange()) return false; if (this->IsRange()) return false;
return this->SimplyEquals(that); return this->SimplyEquals(that);
} }
......
...@@ -219,8 +219,9 @@ namespace internal { ...@@ -219,8 +219,9 @@ namespace internal {
V(Detectable, kDetectableReceiver | kNumber | kName) \ V(Detectable, kDetectableReceiver | kNumber | kName) \
V(Object, kDetectableObject | kUndetectable) \ V(Object, kDetectableObject | kUndetectable) \
V(Receiver, kObject | kProxy) \ V(Receiver, kObject | kProxy) \
V(NonNumber, kBoolean | kName | kNull | kReceiver | \ V(Unique, kBoolean | kUniqueName | kNull | kUndefined | \
kUndefined | kInternal) \ kReceiver) \
V(NonNumber, kUnique | kString | kInternal) \
V(Any, 0xfffffffeu) V(Any, 0xfffffffeu)
/* /*
...@@ -265,6 +266,7 @@ namespace internal { ...@@ -265,6 +266,7 @@ namespace internal {
// typedef Struct; // typedef Struct;
// typedef Region; // typedef Region;
// template<class> struct Handle { typedef type; } // No template typedefs... // template<class> struct Handle { typedef type; } // No template typedefs...
// template<class T> static Handle<T>::type null_handle();
// template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t) // template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t)
// template<class T> static Handle<T>::type cast(Handle<Type>::type); // template<class T> static Handle<T>::type cast(Handle<Type>::type);
// static bool is_bitset(Type*); // static bool is_bitset(Type*);
...@@ -375,6 +377,12 @@ class TypeImpl : public Config::Base { ...@@ -375,6 +377,12 @@ class TypeImpl : public Config::Base {
static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg); static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg);
static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg); static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg);
static TypeImpl* Union(TypeImpl* type1, TypeImpl* type2) {
return BitsetType::New(type1->AsBitset() | type2->AsBitset());
}
static TypeImpl* Intersect(TypeImpl* type1, TypeImpl* type2) {
return BitsetType::New(type1->AsBitset() & type2->AsBitset());
}
static TypeHandle Of(double value, Region* region) { static TypeHandle Of(double value, Region* region) {
return Config::from_bitset(BitsetType::Lub(value), region); return Config::from_bitset(BitsetType::Lub(value), region);
...@@ -912,6 +920,7 @@ struct ZoneTypeConfig { ...@@ -912,6 +920,7 @@ struct ZoneTypeConfig {
typedef i::Zone Region; typedef i::Zone Region;
template<class T> struct Handle { typedef T* type; }; template<class T> struct Handle { typedef T* type; };
template<class T> static inline T* null_handle();
template<class T> static inline T* handle(T* type); template<class T> static inline T* handle(T* type);
template<class T> static inline T* cast(Type* type); template<class T> static inline T* cast(Type* type);
...@@ -954,6 +963,7 @@ struct HeapTypeConfig { ...@@ -954,6 +963,7 @@ struct HeapTypeConfig {
typedef i::Isolate Region; typedef i::Isolate Region;
template<class T> struct Handle { typedef i::Handle<T> type; }; template<class T> struct Handle { typedef i::Handle<T> type; };
template<class T> static inline i::Handle<T> null_handle();
template<class T> static inline i::Handle<T> handle(T* type); template<class T> static inline i::Handle<T> handle(T* type);
template<class T> static inline i::Handle<T> cast(i::Handle<Type> type); template<class T> static inline i::Handle<T> cast(i::Handle<Type> type);
...@@ -1002,7 +1012,9 @@ struct BoundsImpl { ...@@ -1002,7 +1012,9 @@ struct BoundsImpl {
TypeHandle lower; TypeHandle lower;
TypeHandle upper; TypeHandle upper;
BoundsImpl() {} BoundsImpl() : // Make sure accessing uninitialized bounds crashes big-time.
lower(Config::template null_handle<Type>()),
upper(Config::template null_handle<Type>()) {}
explicit BoundsImpl(TypeHandle t) : lower(t), upper(t) {} explicit BoundsImpl(TypeHandle t) : lower(t), upper(t) {}
BoundsImpl(TypeHandle l, TypeHandle u) : lower(l), upper(u) { BoundsImpl(TypeHandle l, TypeHandle u) : lower(l), upper(u) {
DCHECK(lower->Is(upper)); DCHECK(lower->Is(upper));
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "src/compiler/js-graph.h" #include "src/compiler/js-graph.h"
#include "src/compiler/node-properties-inl.h" #include "src/compiler/node-properties-inl.h"
#include "src/compiler/pipeline.h" #include "src/compiler/pipeline.h"
#include "src/compiler/typer.h" #include "src/compiler/simplified-lowering.h"
#include "src/compiler/verifier.h" #include "src/compiler/verifier.h"
#include "src/execution.h" #include "src/execution.h"
#include "src/globals.h" #include "src/globals.h"
...@@ -31,13 +31,10 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -31,13 +31,10 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
public: public:
explicit ChangesLoweringTester(MachineType p0 = kMachNone) explicit ChangesLoweringTester(MachineType p0 = kMachNone)
: GraphBuilderTester<ReturnType>(p0), : GraphBuilderTester<ReturnType>(p0),
typer(this->zone()),
javascript(this->zone()), javascript(this->zone()),
jsgraph(this->graph(), this->common(), &javascript, &typer, jsgraph(this->graph(), this->common(), &javascript, this->machine()),
this->machine()),
function(Handle<JSFunction>::null()) {} function(Handle<JSFunction>::null()) {}
Typer typer;
JSOperatorBuilder javascript; JSOperatorBuilder javascript;
JSGraph jsgraph; JSGraph jsgraph;
Handle<JSFunction> function; Handle<JSFunction> function;
...@@ -133,7 +130,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -133,7 +130,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
GraphReducer reducer(this->graph()); GraphReducer reducer(this->graph());
reducer.AddReducer(&lowering); reducer.AddReducer(&lowering);
reducer.ReduceNode(change); reducer.ReduceNode(change);
Verifier::Run(this->graph()); Verifier::Run(this->graph(), Verifier::UNTYPED);
} }
Factory* factory() { return this->isolate()->factory(); } Factory* factory() { return this->isolate()->factory(); }
......
...@@ -20,7 +20,7 @@ class JSCacheTesterHelper { ...@@ -20,7 +20,7 @@ class JSCacheTesterHelper {
: main_graph_(zone), : main_graph_(zone),
main_common_(zone), main_common_(zone),
main_javascript_(zone), main_javascript_(zone),
main_typer_(zone), main_typer_(&main_graph_, MaybeHandle<Context>()),
main_machine_() {} main_machine_() {}
Graph main_graph_; Graph main_graph_;
CommonOperatorBuilder main_common_; CommonOperatorBuilder main_common_;
...@@ -36,8 +36,12 @@ class JSConstantCacheTester : public HandleAndZoneScope, ...@@ -36,8 +36,12 @@ class JSConstantCacheTester : public HandleAndZoneScope,
public: public:
JSConstantCacheTester() JSConstantCacheTester()
: JSCacheTesterHelper(main_zone()), : JSCacheTesterHelper(main_zone()),
JSGraph(&main_graph_, &main_common_, &main_javascript_, &main_typer_, JSGraph(&main_graph_, &main_common_, &main_javascript_,
&main_machine_) {} &main_machine_) {
main_graph_.SetStart(main_graph_.NewNode(common()->Start(0)));
main_graph_.SetEnd(main_graph_.NewNode(common()->End()));
main_typer_.Run();
}
Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; } Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "src/compiler/node-matchers.h" #include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties-inl.h" #include "src/compiler/node-properties-inl.h"
#include "src/compiler/source-position.h" #include "src/compiler/source-position.h"
#include "src/compiler/typer.h"
#include "test/cctest/cctest.h" #include "test/cctest/cctest.h"
#include "test/cctest/compiler/function-tester.h" #include "test/cctest/compiler/function-tester.h"
#include "test/cctest/compiler/graph-builder-tester.h" #include "test/cctest/compiler/graph-builder-tester.h"
...@@ -24,8 +23,7 @@ class ContextSpecializationTester : public HandleAndZoneScope, ...@@ -24,8 +23,7 @@ class ContextSpecializationTester : public HandleAndZoneScope,
javascript_(main_zone()), javascript_(main_zone()),
machine_(), machine_(),
simplified_(main_zone()), simplified_(main_zone()),
typer_(main_zone()), jsgraph_(graph(), common(), &javascript_, &machine_),
jsgraph_(graph(), common(), &javascript_, &typer_, &machine_),
info_(main_isolate(), main_zone()) {} info_(main_isolate(), main_zone()) {}
Factory* factory() { return main_isolate()->factory(); } Factory* factory() { return main_isolate()->factory(); }
...@@ -40,7 +38,6 @@ class ContextSpecializationTester : public HandleAndZoneScope, ...@@ -40,7 +38,6 @@ class ContextSpecializationTester : public HandleAndZoneScope,
JSOperatorBuilder javascript_; JSOperatorBuilder javascript_;
MachineOperatorBuilder machine_; MachineOperatorBuilder machine_;
SimplifiedOperatorBuilder simplified_; SimplifiedOperatorBuilder simplified_;
Typer typer_;
JSGraph jsgraph_; JSGraph jsgraph_;
CompilationInfo info_; CompilationInfo info_;
}; };
......
...@@ -24,11 +24,11 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -24,11 +24,11 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
simplified(main_zone()), simplified(main_zone()),
common(main_zone()), common(main_zone()),
graph(main_zone()), graph(main_zone()),
typer(main_zone()), typer(&graph, MaybeHandle<Context>()),
context_node(NULL) { context_node(NULL) {
typer.DecorateGraph(&graph); graph.SetStart(graph.NewNode(common.Start(num_parameters)));
Node* s = graph.NewNode(common.Start(num_parameters)); graph.SetEnd(graph.NewNode(common.End()));
graph.SetStart(s); typer.Run();
} }
Isolate* isolate; Isolate* isolate;
...@@ -74,7 +74,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -74,7 +74,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
} }
Node* reduce(Node* node) { Node* reduce(Node* node) {
JSGraph jsgraph(&graph, &common, &javascript, &typer, &machine); JSGraph jsgraph(&graph, &common, &javascript, &machine);
JSTypedLowering reducer(&jsgraph); JSTypedLowering reducer(&jsgraph);
Reduction reduction = reducer.Reduce(node); Reduction reduction = reducer.Reduce(node);
if (reduction.Changed()) return reduction.replacement(); if (reduction.Changed()) return reduction.replacement();
......
...@@ -57,8 +57,8 @@ class ReducerTester : public HandleAndZoneScope { ...@@ -57,8 +57,8 @@ class ReducerTester : public HandleAndZoneScope {
common(main_zone()), common(main_zone()),
graph(main_zone()), graph(main_zone()),
javascript(main_zone()), javascript(main_zone()),
typer(main_zone()), typer(&graph, MaybeHandle<Context>()),
jsgraph(&graph, &common, &javascript, &typer, &machine), jsgraph(&graph, &common, &javascript, &machine),
maxuint32(Constant<int32_t>(kMaxUInt32)) { maxuint32(Constant<int32_t>(kMaxUInt32)) {
Node* s = graph.NewNode(common.Start(num_parameters)); Node* s = graph.NewNode(common.Start(num_parameters));
graph.SetStart(s); graph.SetStart(s);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "src/compiler/node-matchers.h" #include "src/compiler/node-matchers.h"
#include "src/compiler/representation-change.h" #include "src/compiler/representation-change.h"
#include "src/compiler/typer.h"
using namespace v8::internal; using namespace v8::internal;
using namespace v8::internal::compiler; using namespace v8::internal::compiler;
...@@ -25,16 +24,13 @@ class RepresentationChangerTester : public HandleAndZoneScope, ...@@ -25,16 +24,13 @@ class RepresentationChangerTester : public HandleAndZoneScope,
public: public:
explicit RepresentationChangerTester(int num_parameters = 0) explicit RepresentationChangerTester(int num_parameters = 0)
: GraphAndBuilders(main_zone()), : GraphAndBuilders(main_zone()),
typer_(main_zone()),
javascript_(main_zone()), javascript_(main_zone()),
jsgraph_(main_graph_, &main_common_, &javascript_, &typer_, jsgraph_(main_graph_, &main_common_, &javascript_, &main_machine_),
&main_machine_),
changer_(&jsgraph_, &main_simplified_, main_isolate()) { changer_(&jsgraph_, &main_simplified_, main_isolate()) {
Node* s = graph()->NewNode(common()->Start(num_parameters)); Node* s = graph()->NewNode(common()->Start(num_parameters));
graph()->SetStart(s); graph()->SetStart(s);
} }
Typer typer_;
JSOperatorBuilder javascript_; JSOperatorBuilder javascript_;
JSGraph jsgraph_; JSGraph jsgraph_;
RepresentationChanger changer_; RepresentationChanger changer_;
......
...@@ -37,10 +37,9 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -37,10 +37,9 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
MachineType p3 = kMachNone, MachineType p3 = kMachNone,
MachineType p4 = kMachNone) MachineType p4 = kMachNone)
: GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4), : GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4),
typer(this->zone()), typer(this->graph(), MaybeHandle<Context>()),
javascript(this->zone()), javascript(this->zone()),
jsgraph(this->graph(), this->common(), &javascript, &typer, jsgraph(this->graph(), this->common(), &javascript, this->machine()),
this->machine()),
lowering(&jsgraph) {} lowering(&jsgraph) {}
Typer typer; Typer typer;
...@@ -50,12 +49,13 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -50,12 +49,13 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
void LowerAllNodes() { void LowerAllNodes() {
this->End(); this->End();
typer.Run();
lowering.LowerAllNodes(); lowering.LowerAllNodes();
} }
void LowerAllNodesAndLowerChanges() { void LowerAllNodesAndLowerChanges() {
this->End(); this->End();
typer.Run(jsgraph.graph(), MaybeHandle<Context>()); typer.Run();
lowering.LowerAllNodes(); lowering.LowerAllNodes();
Zone* zone = this->zone(); Zone* zone = this->zone();
...@@ -674,9 +674,9 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { ...@@ -674,9 +674,9 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None(), explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None(),
Type* p2_type = Type::None()) Type* p2_type = Type::None())
: GraphAndBuilders(main_zone()), : GraphAndBuilders(main_zone()),
typer(main_zone()), typer(graph(), MaybeHandle<Context>()),
javascript(main_zone()), javascript(main_zone()),
jsgraph(graph(), common(), &javascript, &typer, machine()) { jsgraph(graph(), common(), &javascript, machine()) {
start = graph()->NewNode(common()->Start(2)); start = graph()->NewNode(common()->Start(2));
graph()->SetStart(start); graph()->SetStart(start);
ret = ret =
...@@ -686,6 +686,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { ...@@ -686,6 +686,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
p0 = graph()->NewNode(common()->Parameter(0), start); p0 = graph()->NewNode(common()->Parameter(0), start);
p1 = graph()->NewNode(common()->Parameter(1), start); p1 = graph()->NewNode(common()->Parameter(1), start);
p2 = graph()->NewNode(common()->Parameter(2), start); p2 = graph()->NewNode(common()->Parameter(2), start);
typer.Run();
NodeProperties::SetBounds(p0, Bounds(p0_type)); NodeProperties::SetBounds(p0, Bounds(p0_type));
NodeProperties::SetBounds(p1, Bounds(p1_type)); NodeProperties::SetBounds(p1, Bounds(p1_type));
NodeProperties::SetBounds(p2, Bounds(p2_type)); NodeProperties::SetBounds(p2, Bounds(p2_type));
...@@ -706,8 +707,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { ...@@ -706,8 +707,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
} }
void Lower() { void Lower() {
SimplifiedLowering lowering(&jsgraph); SimplifiedLowering(&jsgraph).LowerAllNodes();
lowering.LowerAllNodes();
} }
// Inserts the node as the return value of the graph. // Inserts the node as the return value of the graph.
...@@ -1540,10 +1540,11 @@ TEST(UpdatePhi) { ...@@ -1540,10 +1540,11 @@ TEST(UpdatePhi) {
TestingGraph t(Type::Any(), Type::Signed32()); TestingGraph t(Type::Any(), Type::Signed32());
static const MachineType kMachineTypes[] = {kMachInt32, kMachUint32, static const MachineType kMachineTypes[] = {kMachInt32, kMachUint32,
kMachFloat64}; kMachFloat64};
Type* kTypes[] = {Type::Signed32(), Type::Unsigned32(), Type::Number()};
for (size_t i = 0; i < arraysize(kMachineTypes); i++) { for (size_t i = 0; i < arraysize(kMachineTypes); i++) {
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Handle<Name>::null(), Type::Any(), kMachineTypes[i]}; Handle<Name>::null(), kTypes[i], kMachineTypes[i]};
Node* load0 = Node* load0 =
t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start);
......
...@@ -26,7 +26,7 @@ class TyperTester : public HandleAndZoneScope, public GraphAndBuilders { ...@@ -26,7 +26,7 @@ class TyperTester : public HandleAndZoneScope, public GraphAndBuilders {
public: public:
TyperTester() TyperTester()
: GraphAndBuilders(main_zone()), : GraphAndBuilders(main_zone()),
typer_(main_zone()), typer_(graph(), MaybeHandle<Context>()),
javascript_(main_zone()) { javascript_(main_zone()) {
Node* s = graph()->NewNode(common()->Start(3)); Node* s = graph()->NewNode(common()->Start(3));
graph()->SetStart(s); graph()->SetStart(s);
...@@ -79,7 +79,6 @@ class TyperTester : public HandleAndZoneScope, public GraphAndBuilders { ...@@ -79,7 +79,6 @@ class TyperTester : public HandleAndZoneScope, public GraphAndBuilders {
NodeProperties::SetBounds(p1, Bounds(rhs)); NodeProperties::SetBounds(p1, Bounds(rhs));
Node* n = graph()->NewNode( Node* n = graph()->NewNode(
op, p0, p1, context_node_, graph()->start(), graph()->start()); op, p0, p1, context_node_, graph()->start(), graph()->start());
typer_.Init(n);
return NodeProperties::GetBounds(n).upper; return NodeProperties::GetBounds(n).upper;
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "src/compiler/js-graph.h" #include "src/compiler/js-graph.h"
#include "src/compiler/node-properties-inl.h" #include "src/compiler/node-properties-inl.h"
#include "src/compiler/simplified-operator.h" #include "src/compiler/simplified-operator.h"
#include "src/compiler/typer.h"
#include "test/unittests/compiler/compiler-test-utils.h" #include "test/unittests/compiler/compiler-test-utils.h"
#include "test/unittests/compiler/graph-unittest.h" #include "test/unittests/compiler/graph-unittest.h"
#include "testing/gmock-support.h" #include "testing/gmock-support.h"
...@@ -65,10 +64,9 @@ class ChangeLoweringTest : public GraphTest { ...@@ -65,10 +64,9 @@ class ChangeLoweringTest : public GraphTest {
} }
Reduction Reduce(Node* node) { Reduction Reduce(Node* node) {
Typer typer(zone());
MachineOperatorBuilder machine(WordRepresentation()); MachineOperatorBuilder machine(WordRepresentation());
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine); JSGraph jsgraph(graph(), common(), &javascript, &machine);
CompilationInfo info(isolate(), zone()); CompilationInfo info(isolate(), zone());
Linkage linkage(&info); Linkage linkage(&info);
ChangeLowering reducer(&jsgraph, &linkage); ChangeLowering reducer(&jsgraph, &linkage);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "src/compiler/common-operator.h" #include "src/compiler/common-operator.h"
#include "src/compiler/graph.h" #include "src/compiler/graph.h"
#include "src/compiler/machine-operator.h" #include "src/compiler/machine-operator.h"
#include "src/compiler/typer.h"
#include "test/unittests/test-utils.h" #include "test/unittests/test-utils.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
...@@ -64,6 +65,20 @@ class GraphTest : public TestWithContext, public TestWithZone { ...@@ -64,6 +65,20 @@ class GraphTest : public TestWithContext, public TestWithZone {
}; };
class TypedGraphTest : public GraphTest {
public:
explicit TypedGraphTest(int parameters = 1)
: GraphTest(parameters),
typer_(graph(), MaybeHandle<Context>()) {}
protected:
Typer* typer() { return &typer_; }
private:
Typer typer_;
};
Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher, Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
const Matcher<Node*>& control_matcher); const Matcher<Node*>& control_matcher);
Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher, Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
......
...@@ -16,15 +16,14 @@ namespace v8 { ...@@ -16,15 +16,14 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
class JSBuiltinReducerTest : public GraphTest { class JSBuiltinReducerTest : public TypedGraphTest {
public: public:
JSBuiltinReducerTest() : javascript_(zone()) {} JSBuiltinReducerTest() : javascript_(zone()) {}
protected: protected:
Reduction Reduce(Node* node) { Reduction Reduce(Node* node) {
Typer typer(zone());
MachineOperatorBuilder machine; MachineOperatorBuilder machine;
JSGraph jsgraph(graph(), common(), javascript(), &typer, &machine); JSGraph jsgraph(graph(), common(), javascript(), &machine);
JSBuiltinReducer reducer(&jsgraph); JSBuiltinReducer reducer(&jsgraph);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -31,16 +31,15 @@ const StrictMode kStrictModes[] = {SLOPPY, STRICT}; ...@@ -31,16 +31,15 @@ const StrictMode kStrictModes[] = {SLOPPY, STRICT};
} // namespace } // namespace
class JSTypedLoweringTest : public GraphTest { class JSTypedLoweringTest : public TypedGraphTest {
public: public:
JSTypedLoweringTest() : GraphTest(3), javascript_(zone()) {} JSTypedLoweringTest() : TypedGraphTest(3), javascript_(zone()) {}
virtual ~JSTypedLoweringTest() {} virtual ~JSTypedLoweringTest() {}
protected: protected:
Reduction Reduce(Node* node) { Reduction Reduce(Node* node) {
Typer typer(zone());
MachineOperatorBuilder machine; MachineOperatorBuilder machine;
JSGraph jsgraph(graph(), common(), javascript(), &typer, &machine); JSGraph jsgraph(graph(), common(), javascript(), &machine);
JSTypedLowering reducer(&jsgraph); JSTypedLowering reducer(&jsgraph);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -18,16 +18,15 @@ namespace v8 { ...@@ -18,16 +18,15 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
class MachineOperatorReducerTest : public GraphTest { class MachineOperatorReducerTest : public TypedGraphTest {
public: public:
explicit MachineOperatorReducerTest(int num_parameters = 2) explicit MachineOperatorReducerTest(int num_parameters = 2)
: GraphTest(num_parameters) {} : TypedGraphTest(num_parameters) {}
protected: protected:
Reduction Reduce(Node* node) { Reduction Reduce(Node* node) {
Typer typer(zone());
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine_); JSGraph jsgraph(graph(), common(), &javascript, &machine_);
MachineOperatorReducer reducer(&jsgraph); MachineOperatorReducer reducer(&jsgraph);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "src/compiler/js-graph.h" #include "src/compiler/js-graph.h"
#include "src/compiler/simplified-operator.h" #include "src/compiler/simplified-operator.h"
#include "src/compiler/simplified-operator-reducer.h" #include "src/compiler/simplified-operator-reducer.h"
#include "src/compiler/typer.h"
#include "src/conversions.h" #include "src/conversions.h"
#include "test/unittests/compiler/graph-unittest.h" #include "test/unittests/compiler/graph-unittest.h"
...@@ -21,10 +20,9 @@ class SimplifiedOperatorReducerTest : public GraphTest { ...@@ -21,10 +20,9 @@ class SimplifiedOperatorReducerTest : public GraphTest {
protected: protected:
Reduction Reduce(Node* node) { Reduction Reduce(Node* node) {
Typer typer(zone());
MachineOperatorBuilder machine; MachineOperatorBuilder machine;
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine); JSGraph jsgraph(graph(), common(), &javascript, &machine);
SimplifiedOperatorReducer reducer(&jsgraph); SimplifiedOperatorReducer reducer(&jsgraph);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment