Commit d1b5aa07 authored by svenpanne's avatar svenpanne Committed by Commit bot

Removed most of the bogus CompilationInfo constructor calls.

A CompilationInfo constructed from just an Isolate* and a Zone* is in
weird an inconsistent state (calling e.g. flags() on it will crash),
so we need to avoid them. This CL removes almost all of them, the
remaining 2 call sites in (for testing only) will be handled in a
separate CL. Things which have been changed:

  * Linkage is basically a decorator for CallDescriptor now.

  * ChangeLowering doesn't need Linkage at all.

  * JSGenericLowering doesn't need a full CompilationInfo*, just a
    single flag.

  * JSContextSpecializer doesn't need the full CompilationInfo, just a
    Context.

  * Removed unused CompilationInfo from SimplifiedLoweringTester.

This nicely decouples things already a bit more, but there's still
work to do...

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

Cr-Commit-Position: refs/heads/master@{#26580}
parent 505b6020
...@@ -73,8 +73,9 @@ Node* ChangeLowering::AllocateHeapNumberWithValue(Node* value, Node* control) { ...@@ -73,8 +73,9 @@ Node* ChangeLowering::AllocateHeapNumberWithValue(Node* value, Node* control) {
// The AllocateHeapNumberStub does not use the context, so we can safely pass // The AllocateHeapNumberStub does not use the context, so we can safely pass
// in Smi zero here. // in Smi zero here.
Callable callable = CodeFactory::AllocateHeapNumber(isolate()); Callable callable = CodeFactory::AllocateHeapNumber(isolate());
CallDescriptor* descriptor = linkage()->GetStubCallDescriptor( CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
callable.descriptor(), 0, CallDescriptor::kNoFlags); isolate(), jsgraph()->zone(), callable.descriptor(), 0,
CallDescriptor::kNoFlags);
Node* target = jsgraph()->HeapConstant(callable.code()); Node* target = jsgraph()->HeapConstant(callable.code());
Node* context = jsgraph()->NoContextConstant(); Node* context = jsgraph()->NoContextConstant();
Node* effect = graph()->NewNode(common()->ValueEffect(1), value); Node* effect = graph()->NewNode(common()->ValueEffect(1), value);
......
...@@ -19,8 +19,7 @@ class MachineOperatorBuilder; ...@@ -19,8 +19,7 @@ class MachineOperatorBuilder;
class ChangeLowering FINAL : public Reducer { class ChangeLowering FINAL : public Reducer {
public: public:
ChangeLowering(JSGraph* jsgraph, Linkage* linkage) explicit ChangeLowering(JSGraph* jsgraph) : jsgraph_(jsgraph) {}
: jsgraph_(jsgraph), linkage_(linkage) {}
~ChangeLowering() FINAL; ~ChangeLowering() FINAL;
Reduction Reduce(Node* node) FINAL; Reduction Reduce(Node* node) FINAL;
...@@ -52,12 +51,10 @@ class ChangeLowering FINAL : public Reducer { ...@@ -52,12 +51,10 @@ class ChangeLowering FINAL : public Reducer {
Graph* graph() const; Graph* graph() const;
Isolate* isolate() const; Isolate* isolate() const;
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
Linkage* linkage() const { return linkage_; }
CommonOperatorBuilder* common() const; CommonOperatorBuilder* common() const;
MachineOperatorBuilder* machine() const; MachineOperatorBuilder* machine() const;
JSGraph* jsgraph_; JSGraph* jsgraph_;
Linkage* linkage_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -16,7 +16,7 @@ namespace compiler { ...@@ -16,7 +16,7 @@ namespace compiler {
Reduction JSContextSpecializer::Reduce(Node* node) { Reduction JSContextSpecializer::Reduce(Node* node) {
if (node == context_) { if (node == context_) {
Node* constant = jsgraph_->Constant(info_->context()); Node* constant = jsgraph_->Constant(ctx_);
NodeProperties::ReplaceWithValue(node, constant); NodeProperties::ReplaceWithValue(node, constant);
return Replace(constant); return Replace(constant);
} }
...@@ -56,12 +56,13 @@ Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) { ...@@ -56,12 +56,13 @@ Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) {
const Operator* op = jsgraph_->javascript()->LoadContext( const Operator* op = jsgraph_->javascript()->LoadContext(
0, access.index(), access.immutable()); 0, access.index(), access.immutable());
node->set_op(op); node->set_op(op);
Handle<Object> context_handle = Handle<Object>(context, info_->isolate()); Handle<Object> context_handle =
Handle<Object>(context, jsgraph_->isolate());
node->ReplaceInput(0, jsgraph_->Constant(context_handle)); node->ReplaceInput(0, jsgraph_->Constant(context_handle));
return Changed(node); return Changed(node);
} }
Handle<Object> value = Handle<Object>( Handle<Object> value = Handle<Object>(
context->get(static_cast<int>(access.index())), info_->isolate()); context->get(static_cast<int>(access.index())), jsgraph_->isolate());
// Even though the context slot is immutable, the context might have escaped // Even though the context slot is immutable, the context might have escaped
// before the function to which it belongs has initialized the slot. // before the function to which it belongs has initialized the slot.
...@@ -104,7 +105,8 @@ Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) { ...@@ -104,7 +105,8 @@ Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) {
const Operator* op = jsgraph_->javascript()->StoreContext(0, access.index()); const Operator* op = jsgraph_->javascript()->StoreContext(0, access.index());
node->set_op(op); node->set_op(op);
Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate()); Handle<Object> new_context_handle =
Handle<Object>(context, jsgraph_->isolate());
node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); node->ReplaceInput(0, jsgraph_->Constant(new_context_handle));
return Changed(node); return Changed(node);
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "src/compiler/js-graph.h" #include "src/compiler/js-graph.h"
#include "src/contexts.h" #include "src/contexts.h"
#include "src/compiler.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
...@@ -17,8 +19,8 @@ namespace compiler { ...@@ -17,8 +19,8 @@ namespace compiler {
// some {LoadContext} nodes or strength reducing some {StoreContext} nodes. // some {LoadContext} nodes or strength reducing some {StoreContext} nodes.
class JSContextSpecializer : public Reducer { class JSContextSpecializer : public Reducer {
public: public:
JSContextSpecializer(CompilationInfo* info, JSGraph* jsgraph, Node* context) JSContextSpecializer(Handle<Context> ctx, JSGraph* jsgraph, Node* context)
: info_(info), jsgraph_(jsgraph), context_(context) {} : ctx_(ctx), jsgraph_(jsgraph), context_(context) {}
Reduction Reduce(Node* node) OVERRIDE; Reduction Reduce(Node* node) OVERRIDE;
...@@ -27,7 +29,7 @@ class JSContextSpecializer : public Reducer { ...@@ -27,7 +29,7 @@ class JSContextSpecializer : public Reducer {
Reduction ReduceJSStoreContext(Node* node); Reduction ReduceJSStoreContext(Node* node);
private: private:
CompilationInfo* info_; Handle<Context> ctx_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
Node* context_; Node* context_;
}; };
......
...@@ -17,10 +17,8 @@ namespace v8 { ...@@ -17,10 +17,8 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph) JSGenericLowering::JSGenericLowering(bool is_typing_enabled, JSGraph* jsgraph)
: info_(info), : is_typing_enabled_(is_typing_enabled), jsgraph_(jsgraph) {}
jsgraph_(jsgraph),
linkage_(new (jsgraph->zone()) Linkage(jsgraph->zone(), info)) {}
void JSGenericLowering::PatchOperator(Node* node, const Operator* op) { void JSGenericLowering::PatchOperator(Node* node, const Operator* op) {
...@@ -45,7 +43,7 @@ Reduction JSGenericLowering::Reduce(Node* node) { ...@@ -45,7 +43,7 @@ Reduction JSGenericLowering::Reduce(Node* node) {
// TODO(mstarzinger): If typing is enabled then simplified lowering will // TODO(mstarzinger): If typing is enabled then simplified lowering will
// have inserted the correct ChangeBoolToBit, otherwise we need to perform // have inserted the correct ChangeBoolToBit, otherwise we need to perform
// poor-man's representation inference here and insert manual change. // poor-man's representation inference here and insert manual change.
if (!info()->is_typing_enabled()) { if (!is_typing_enabled_) {
Node* condition = node->InputAt(0); Node* condition = node->InputAt(0);
if (condition->opcode() != IrOpcode::kAlways) { if (condition->opcode() != IrOpcode::kAlways) {
Node* test = graph()->NewNode(machine()->WordEqual(), condition, Node* test = graph()->NewNode(machine()->WordEqual(), condition,
...@@ -130,8 +128,8 @@ static CallDescriptor::Flags FlagsForNode(Node* node) { ...@@ -130,8 +128,8 @@ static CallDescriptor::Flags FlagsForNode(Node* node) {
void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token) { void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token) {
Callable callable = CodeFactory::CompareIC(isolate(), token); Callable callable = CodeFactory::CompareIC(isolate(), token);
bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op()); bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op());
CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor( CallDescriptor* desc_compare = Linkage::GetStubCallDescriptor(
callable.descriptor(), 0, isolate(), zone(), callable.descriptor(), 0,
CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node)); CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node));
NodeVector inputs(zone()); NodeVector inputs(zone());
inputs.reserve(node->InputCount() + 1); inputs.reserve(node->InputCount() + 1);
...@@ -172,8 +170,9 @@ void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token) { ...@@ -172,8 +170,9 @@ void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token) {
void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable, void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
CallDescriptor::Flags flags) { CallDescriptor::Flags flags) {
Operator::Properties properties = node->op()->properties(); Operator::Properties properties = node->op()->properties();
CallDescriptor* desc = linkage()->GetStubCallDescriptor( CallDescriptor* desc =
callable.descriptor(), 0, flags | FlagsForNode(node), properties); Linkage::GetStubCallDescriptor(isolate(), zone(), callable.descriptor(),
0, flags | FlagsForNode(node), properties);
Node* stub_code = jsgraph()->HeapConstant(callable.code()); Node* stub_code = jsgraph()->HeapConstant(callable.code());
PatchInsertInput(node, 0, stub_code); PatchInsertInput(node, 0, stub_code);
PatchOperator(node, common()->Call(desc)); PatchOperator(node, common()->Call(desc));
...@@ -186,8 +185,9 @@ void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, ...@@ -186,8 +185,9 @@ void JSGenericLowering::ReplaceWithBuiltinCall(Node* node,
Operator::Properties properties = node->op()->properties(); Operator::Properties properties = node->op()->properties();
Callable callable = Callable callable =
CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS);
CallDescriptor* desc = linkage()->GetStubCallDescriptor( CallDescriptor* desc =
callable.descriptor(), nargs, FlagsForNode(node), properties); Linkage::GetStubCallDescriptor(isolate(), zone(), callable.descriptor(),
nargs, FlagsForNode(node), properties);
Node* global_object = graph()->NewNode( Node* global_object = graph()->NewNode(
machine()->Load(kMachAnyTagged), NodeProperties::GetContextInput(node), machine()->Load(kMachAnyTagged), NodeProperties::GetContextInput(node),
jsgraph()->IntPtrConstant( jsgraph()->IntPtrConstant(
...@@ -216,7 +216,7 @@ void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, ...@@ -216,7 +216,7 @@ void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
const Runtime::Function* fun = Runtime::FunctionForId(f); const Runtime::Function* fun = Runtime::FunctionForId(f);
int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
CallDescriptor* desc = CallDescriptor* desc =
linkage()->GetRuntimeCallDescriptor(f, nargs, properties); Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties);
Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate()));
Node* arity = jsgraph()->Int32Constant(nargs); Node* arity = jsgraph()->Int32Constant(nargs);
PatchInsertInput(node, 0, jsgraph()->CEntryStubConstant(fun->result_size)); PatchInsertInput(node, 0, jsgraph()->CEntryStubConstant(fun->result_size));
...@@ -318,8 +318,8 @@ void JSGenericLowering::LowerJSInstanceOf(Node* node) { ...@@ -318,8 +318,8 @@ void JSGenericLowering::LowerJSInstanceOf(Node* node) {
InstanceofStub::kArgsInRegisters); InstanceofStub::kArgsInRegisters);
InstanceofStub stub(isolate(), flags); InstanceofStub stub(isolate(), flags);
CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
CallDescriptor* desc = CallDescriptor* desc = Linkage::GetStubCallDescriptor(isolate(), zone(), d, 0,
linkage()->GetStubCallDescriptor(d, 0, FlagsForNode(node)); FlagsForNode(node));
Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); Node* stub_code = jsgraph()->HeapConstant(stub.GetCode());
PatchInsertInput(node, 0, stub_code); PatchInsertInput(node, 0, stub_code);
PatchOperator(node, common()->Call(desc)); PatchOperator(node, common()->Call(desc));
...@@ -374,8 +374,8 @@ void JSGenericLowering::LowerJSCallConstruct(Node* node) { ...@@ -374,8 +374,8 @@ void JSGenericLowering::LowerJSCallConstruct(Node* node) {
int arity = OpParameter<int>(node); int arity = OpParameter<int>(node);
CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS); CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS);
CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
CallDescriptor* desc = CallDescriptor* desc = Linkage::GetStubCallDescriptor(
linkage()->GetStubCallDescriptor(d, arity, FlagsForNode(node)); isolate(), zone(), d, arity, FlagsForNode(node));
Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); Node* stub_code = jsgraph()->HeapConstant(stub.GetCode());
Node* construct = NodeProperties::GetValueInput(node, 0); Node* construct = NodeProperties::GetValueInput(node, 0);
PatchInsertInput(node, 0, stub_code); PatchInsertInput(node, 0, stub_code);
...@@ -418,8 +418,8 @@ bool JSGenericLowering::TryLowerDirectJSCall(Node* node) { ...@@ -418,8 +418,8 @@ bool JSGenericLowering::TryLowerDirectJSCall(Node* node) {
context = jsgraph()->HeapConstant(Handle<Context>(function->context())); context = jsgraph()->HeapConstant(Handle<Context>(function->context()));
} }
node->ReplaceInput(index, context); node->ReplaceInput(index, context);
CallDescriptor* desc = CallDescriptor* desc = Linkage::GetJSCallDescriptor(
linkage()->GetJSCallDescriptor(1 + arg_count, FlagsForNode(node)); zone(), false, 1 + arg_count, FlagsForNode(node));
PatchOperator(node, common()->Call(desc)); PatchOperator(node, common()->Call(desc));
return true; return true;
} }
...@@ -434,8 +434,9 @@ void JSGenericLowering::LowerJSCallFunction(Node* node) { ...@@ -434,8 +434,9 @@ void JSGenericLowering::LowerJSCallFunction(Node* node) {
int arg_count = static_cast<int>(p.arity() - 2); int arg_count = static_cast<int>(p.arity() - 2);
CallFunctionStub stub(isolate(), arg_count, p.flags()); CallFunctionStub stub(isolate(), arg_count, p.flags());
CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
CallDescriptor* desc = linkage()->GetStubCallDescriptor( CallDescriptor* desc = Linkage::GetStubCallDescriptor(
d, static_cast<int>(p.arity() - 1), FlagsForNode(node)); isolate(), zone(), d, static_cast<int>(p.arity() - 1),
FlagsForNode(node));
Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); Node* stub_code = jsgraph()->HeapConstant(stub.GetCode());
PatchInsertInput(node, 0, stub_code); PatchInsertInput(node, 0, stub_code);
PatchOperator(node, common()->Call(desc)); PatchOperator(node, common()->Call(desc));
......
...@@ -26,7 +26,7 @@ class Linkage; ...@@ -26,7 +26,7 @@ class Linkage;
// Lowers JS-level operators to runtime and IC calls in the "generic" case. // Lowers JS-level operators to runtime and IC calls in the "generic" case.
class JSGenericLowering FINAL : public Reducer { class JSGenericLowering FINAL : public Reducer {
public: public:
JSGenericLowering(CompilationInfo* info, JSGraph* graph); JSGenericLowering(bool is_typing_enabled, JSGraph* graph);
~JSGenericLowering() FINAL {} ~JSGenericLowering() FINAL {}
Reduction Reduce(Node* node) FINAL; Reduction Reduce(Node* node) FINAL;
...@@ -51,18 +51,15 @@ class JSGenericLowering FINAL : public Reducer { ...@@ -51,18 +51,15 @@ class JSGenericLowering FINAL : public Reducer {
bool TryLowerDirectJSCall(Node* node); bool TryLowerDirectJSCall(Node* node);
Zone* zone() const { return graph()->zone(); } Zone* zone() const { return graph()->zone(); }
Isolate* isolate() const { return info_->isolate(); } Isolate* isolate() const { return jsgraph()->isolate(); }
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
Graph* graph() const { return jsgraph()->graph(); } Graph* graph() const { return jsgraph()->graph(); }
Linkage* linkage() const { return linkage_; }
CompilationInfo* info() const { return info_; }
CommonOperatorBuilder* common() const { return jsgraph()->common(); } CommonOperatorBuilder* common() const { return jsgraph()->common(); }
MachineOperatorBuilder* machine() const { return jsgraph()->machine(); } MachineOperatorBuilder* machine() const { return jsgraph()->machine(); }
private: private:
CompilationInfo* info_; bool is_typing_enabled_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
Linkage* linkage_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -94,27 +94,6 @@ FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame, ...@@ -94,27 +94,6 @@ FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame,
} }
CallDescriptor* Linkage::GetJSCallDescriptor(
int parameter_count, CallDescriptor::Flags flags) const {
return GetJSCallDescriptor(zone_, false, parameter_count, flags);
}
CallDescriptor* Linkage::GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Properties properties) const {
return GetRuntimeCallDescriptor(zone_, function, parameter_count, properties);
}
CallDescriptor* Linkage::GetStubCallDescriptor(
const CallInterfaceDescriptor& descriptor, int stack_parameter_count,
CallDescriptor::Flags flags, Operator::Properties properties) const {
return GetStubCallDescriptor(isolate_, zone_, descriptor,
stack_parameter_count, flags, properties);
}
// static // static
bool Linkage::NeedsFrameState(Runtime::FunctionId function) { bool Linkage::NeedsFrameState(Runtime::FunctionId function) {
if (!FLAG_turbo_deoptimization) { if (!FLAG_turbo_deoptimization) {
......
...@@ -172,38 +172,24 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k); ...@@ -172,38 +172,24 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k);
// Call[Runtime] CEntryStub, arg 1, arg 2, arg 3, [...], fun, #arg, context // Call[Runtime] CEntryStub, arg 1, arg 2, arg 3, [...], fun, #arg, context
class Linkage : public ZoneObject { class Linkage : public ZoneObject {
public: public:
Linkage(Zone* zone, CompilationInfo* info) explicit Linkage(CallDescriptor* incoming) : incoming_(incoming) {}
: isolate_(info->isolate()),
zone_(zone),
incoming_(ComputeIncoming(zone, info)) {}
Linkage(Isolate* isolate, Zone* zone, CallDescriptor* incoming)
: isolate_(isolate), zone_(zone), incoming_(incoming) {}
static CallDescriptor* ComputeIncoming(Zone* zone, CompilationInfo* info); static CallDescriptor* ComputeIncoming(Zone* zone, CompilationInfo* info);
// The call descriptor for this compilation unit describes the locations // The call descriptor for this compilation unit describes the locations
// of incoming parameters and the outgoing return value(s). // of incoming parameters and the outgoing return value(s).
CallDescriptor* GetIncomingDescriptor() const { return incoming_; } CallDescriptor* GetIncomingDescriptor() const { return incoming_; }
CallDescriptor* GetJSCallDescriptor(int parameter_count,
CallDescriptor::Flags flags) const;
static CallDescriptor* GetJSCallDescriptor(Zone* zone, bool is_osr, static CallDescriptor* GetJSCallDescriptor(Zone* zone, bool is_osr,
int parameter_count, int parameter_count,
CallDescriptor::Flags flags); CallDescriptor::Flags flags);
CallDescriptor* GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Properties properties) const;
static CallDescriptor* GetRuntimeCallDescriptor( static CallDescriptor* GetRuntimeCallDescriptor(
Zone* zone, Runtime::FunctionId function, int parameter_count, Zone* zone, Runtime::FunctionId function, int parameter_count,
Operator::Properties properties); Operator::Properties properties);
CallDescriptor* GetStubCallDescriptor(
const CallInterfaceDescriptor& descriptor, int stack_parameter_count = 0,
CallDescriptor::Flags flags = CallDescriptor::kNoFlags,
Operator::Properties properties = Operator::kNoProperties) const;
static CallDescriptor* GetStubCallDescriptor( static CallDescriptor* GetStubCallDescriptor(
Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor,
int stack_parameter_count, CallDescriptor::Flags flags, int stack_parameter_count, CallDescriptor::Flags flags,
Operator::Properties properties); Operator::Properties properties = Operator::kNoProperties);
// Creates a call descriptor for simplified C calls that is appropriate // Creates a call descriptor for simplified C calls that is appropriate
// for the host platform. This simplified calling convention only supports // for the host platform. This simplified calling convention only supports
...@@ -246,8 +232,6 @@ class Linkage : public ZoneObject { ...@@ -246,8 +232,6 @@ class Linkage : public ZoneObject {
static const int kJSFunctionCallClosureParamIndex = -1; static const int kJSFunctionCallClosureParamIndex = -1;
private: private:
Isolate* isolate_;
Zone* const zone_;
CallDescriptor* const incoming_; CallDescriptor* const incoming_;
DISALLOW_COPY_AND_ASSIGN(Linkage); DISALLOW_COPY_AND_ASSIGN(Linkage);
......
...@@ -415,7 +415,7 @@ struct ContextSpecializerPhase { ...@@ -415,7 +415,7 @@ struct ContextSpecializerPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(), SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown()); SourcePosition::Unknown());
JSContextSpecializer spec(data->info(), data->jsgraph(), JSContextSpecializer spec(data->info()->context(), data->jsgraph(),
data->context_node()); data->context_node());
GraphReducer graph_reducer(data->graph(), temp_zone); GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &spec); AddReducer(data, &graph_reducer, &spec);
...@@ -512,10 +512,9 @@ struct ChangeLoweringPhase { ...@@ -512,10 +512,9 @@ struct ChangeLoweringPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(), SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown()); SourcePosition::Unknown());
Linkage linkage(data->graph_zone(), data->info());
ValueNumberingReducer vn_reducer(temp_zone); ValueNumberingReducer vn_reducer(temp_zone);
SimplifiedOperatorReducer simple_reducer(data->jsgraph()); SimplifiedOperatorReducer simple_reducer(data->jsgraph());
ChangeLowering lowering(data->jsgraph(), &linkage); ChangeLowering lowering(data->jsgraph());
MachineOperatorReducer machine_reducer(data->jsgraph()); MachineOperatorReducer machine_reducer(data->jsgraph());
CommonOperatorReducer common_reducer; CommonOperatorReducer common_reducer;
GraphReducer graph_reducer(data->graph(), temp_zone); GraphReducer graph_reducer(data->graph(), temp_zone);
...@@ -571,7 +570,8 @@ struct GenericLoweringPhase { ...@@ -571,7 +570,8 @@ struct GenericLoweringPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(), SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown()); SourcePosition::Unknown());
JSGenericLowering generic(data->info(), data->jsgraph()); JSGenericLowering generic(data->info()->is_typing_enabled(),
data->jsgraph());
SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common()); SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common());
GraphReducer graph_reducer(data->graph(), temp_zone); GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &generic); AddReducer(data, &graph_reducer, &generic);
...@@ -954,7 +954,7 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -954,7 +954,7 @@ Handle<Code> Pipeline::GenerateCode() {
{ {
// Generate optimized code. // Generate optimized code.
Linkage linkage(data.instruction_zone(), info()); Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info()));
GenerateCode(&linkage); GenerateCode(&linkage);
} }
Handle<Code> code = data.code(); Handle<Code> code = data.code();
...@@ -1026,7 +1026,7 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, ...@@ -1026,7 +1026,7 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info,
TraceSchedule(schedule); TraceSchedule(schedule);
} }
Linkage linkage(info->isolate(), info->zone(), call_descriptor); Linkage linkage(call_descriptor);
pipeline.GenerateCode(&linkage); pipeline.GenerateCode(&linkage);
Handle<Code> code = data.code(); Handle<Code> code = data.code();
......
...@@ -126,11 +126,9 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -126,11 +126,9 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
void LowerChange(Node* change) { void LowerChange(Node* change) {
// Run the graph reducer with changes lowering on a single node. // Run the graph reducer with changes lowering on a single node.
CompilationInfo info(this->isolate(), this->zone()); Typer typer(this->isolate(), this->graph(), Handle<Context>());
Linkage linkage(this->zone(), &info);
Typer typer(this->isolate(), this->graph(), info.context());
typer.Run(); typer.Run();
ChangeLowering change_lowering(&jsgraph, &linkage); ChangeLowering change_lowering(&jsgraph);
SelectLowering select_lowering(this->graph(), this->common()); SelectLowering select_lowering(this->graph(), this->common());
GraphReducer reducer(this->graph(), this->zone()); GraphReducer reducer(this->graph(), this->zone());
reducer.AddReducer(&change_lowering); reducer.AddReducer(&change_lowering);
......
...@@ -31,7 +31,7 @@ class InstructionTester : public HandleAndZoneScope { ...@@ -31,7 +31,7 @@ class InstructionTester : public HandleAndZoneScope {
graph(zone()), graph(zone()),
schedule(zone()), schedule(zone()),
info(static_cast<HydrogenCodeStub*>(NULL), main_isolate()), info(static_cast<HydrogenCodeStub*>(NULL), main_isolate()),
linkage(zone(), &info), linkage(Linkage::ComputeIncoming(zone(), &info)),
common(zone()), common(zone()),
machine(zone()), machine(zone()),
code(NULL) {} code(NULL) {}
......
...@@ -24,15 +24,13 @@ class ContextSpecializationTester : public HandleAndZoneScope, ...@@ -24,15 +24,13 @@ class ContextSpecializationTester : public HandleAndZoneScope,
javascript_(main_zone()), javascript_(main_zone()),
machine_(main_zone()), machine_(main_zone()),
simplified_(main_zone()), simplified_(main_zone()),
jsgraph_(main_isolate(), graph(), common(), &javascript_, &machine_), jsgraph_(main_isolate(), graph(), common(), &javascript_, &machine_) {}
info_(main_isolate(), main_zone()) {}
Factory* factory() { return main_isolate()->factory(); } Factory* factory() { return main_isolate()->factory(); }
CommonOperatorBuilder* common() { return &common_; } CommonOperatorBuilder* common() { return &common_; }
JSOperatorBuilder* javascript() { return &javascript_; } JSOperatorBuilder* javascript() { return &javascript_; }
SimplifiedOperatorBuilder* simplified() { return &simplified_; } SimplifiedOperatorBuilder* simplified() { return &simplified_; }
JSGraph* jsgraph() { return &jsgraph_; } JSGraph* jsgraph() { return &jsgraph_; }
CompilationInfo* info() { return &info_; }
private: private:
CommonOperatorBuilder common_; CommonOperatorBuilder common_;
...@@ -40,7 +38,6 @@ class ContextSpecializationTester : public HandleAndZoneScope, ...@@ -40,7 +38,6 @@ class ContextSpecializationTester : public HandleAndZoneScope,
MachineOperatorBuilder machine_; MachineOperatorBuilder machine_;
SimplifiedOperatorBuilder simplified_; SimplifiedOperatorBuilder simplified_;
JSGraph jsgraph_; JSGraph jsgraph_;
CompilationInfo info_;
}; };
...@@ -63,7 +60,7 @@ TEST(ReduceJSLoadContext) { ...@@ -63,7 +60,7 @@ TEST(ReduceJSLoadContext) {
Node* const_context = t.jsgraph()->Constant(native); Node* const_context = t.jsgraph()->Constant(native);
Node* deep_const_context = t.jsgraph()->Constant(subcontext2); Node* deep_const_context = t.jsgraph()->Constant(subcontext2);
Node* param_context = t.NewNode(t.common()->Parameter(0), start); Node* param_context = t.NewNode(t.common()->Parameter(0), start);
JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); JSContextSpecializer spec(Handle<Context>(), t.jsgraph(), const_context);
{ {
// Mutable slot, constant context, depth = 0 => do nothing. // Mutable slot, constant context, depth = 0 => do nothing.
...@@ -135,7 +132,7 @@ TEST(ReduceJSStoreContext) { ...@@ -135,7 +132,7 @@ TEST(ReduceJSStoreContext) {
Node* const_context = t.jsgraph()->Constant(native); Node* const_context = t.jsgraph()->Constant(native);
Node* deep_const_context = t.jsgraph()->Constant(subcontext2); Node* deep_const_context = t.jsgraph()->Constant(subcontext2);
Node* param_context = t.NewNode(t.common()->Parameter(0), start); Node* param_context = t.NewNode(t.common()->Parameter(0), start);
JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); JSContextSpecializer spec(Handle<Context>(), t.jsgraph(), const_context);
{ {
// Mutable slot, constant context, depth = 0 => do nothing. // Mutable slot, constant context, depth = 0 => do nothing.
...@@ -197,11 +194,10 @@ TEST(SpecializeToContext) { ...@@ -197,11 +194,10 @@ TEST(SpecializeToContext) {
Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!"); Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!");
const int slot = Context::GLOBAL_OBJECT_INDEX; const int slot = Context::GLOBAL_OBJECT_INDEX;
native->set(slot, *expected); native->set(slot, *expected);
t.info()->SetContext(native);
Node* const_context = t.jsgraph()->Constant(native); Node* const_context = t.jsgraph()->Constant(native);
Node* param_context = t.NewNode(t.common()->Parameter(0), start); Node* param_context = t.NewNode(t.common()->Parameter(0), start);
JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); JSContextSpecializer spec(native, t.jsgraph(), const_context);
{ {
// Check that specialization replaces values and forwards effects // Check that specialization replaces values and forwards effects
......
...@@ -44,7 +44,8 @@ TEST(TestLinkageCreate) { ...@@ -44,7 +44,8 @@ TEST(TestLinkageCreate) {
InitializedHandleScope handles; InitializedHandleScope handles;
Handle<JSFunction> function = Compile("a + b"); Handle<JSFunction> function = Compile("a + b");
CompilationInfoWithZone info(function); CompilationInfoWithZone info(function);
Linkage linkage(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor);
} }
...@@ -59,9 +60,7 @@ TEST(TestLinkageJSFunctionIncoming) { ...@@ -59,9 +60,7 @@ TEST(TestLinkageJSFunctionIncoming) {
Handle<JSFunction> function = v8::Utils::OpenHandle( Handle<JSFunction> function = v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(CompileRun(sources[i]))); *v8::Handle<v8::Function>::Cast(CompileRun(sources[i])));
CompilationInfoWithZone info(function); CompilationInfoWithZone info(function);
Linkage linkage(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CallDescriptor* descriptor = linkage.GetIncomingDescriptor();
CHECK(descriptor); CHECK(descriptor);
CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount())); CHECK_EQ(1 + i, static_cast<int>(descriptor->JSParameterCount()));
...@@ -75,10 +74,10 @@ TEST(TestLinkageJSFunctionIncoming) { ...@@ -75,10 +74,10 @@ TEST(TestLinkageJSFunctionIncoming) {
TEST(TestLinkageCodeStubIncoming) { TEST(TestLinkageCodeStubIncoming) {
Isolate* isolate = CcTest::InitIsolateOnce(); Isolate* isolate = CcTest::InitIsolateOnce();
CompilationInfoWithZone info(static_cast<CodeStub*>(NULL), isolate); CompilationInfoWithZone info(static_cast<CodeStub*>(NULL), isolate);
Linkage linkage(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
// TODO(titzer): test linkage creation with a bonafide code stub. // TODO(titzer): test linkage creation with a bonafide code stub.
// this just checks current behavior. // this just checks current behavior.
CHECK(!linkage.GetIncomingDescriptor()); CHECK(!descriptor);
} }
...@@ -86,11 +85,10 @@ TEST(TestLinkageJSCall) { ...@@ -86,11 +85,10 @@ TEST(TestLinkageJSCall) {
HandleAndZoneScope handles; HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + c"); Handle<JSFunction> function = Compile("a + c");
CompilationInfoWithZone info(function); CompilationInfoWithZone info(function);
Linkage linkage(info.zone(), &info);
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
CallDescriptor* descriptor = CallDescriptor* descriptor = Linkage::GetJSCallDescriptor(
linkage.GetJSCallDescriptor(i, CallDescriptor::kNoFlags); info.zone(), false, i, CallDescriptor::kNoFlags);
CHECK(descriptor); CHECK(descriptor);
CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount())); CHECK_EQ(i, static_cast<int>(descriptor->JSParameterCount()));
CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount())); CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount()));
......
...@@ -61,11 +61,7 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -61,11 +61,7 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
typer.Run(); typer.Run();
lowering.LowerAllNodes(); lowering.LowerAllNodes();
Zone* zone = this->zone(); ChangeLowering lowering(&jsgraph);
CompilationInfo info(this->isolate(), zone);
Linkage linkage(this->isolate(), zone, Linkage::GetSimplifiedCDescriptor(
zone, this->machine_sig_));
ChangeLowering lowering(&jsgraph, &linkage);
GraphReducer reducer(this->graph(), this->zone()); GraphReducer reducer(this->graph(), this->zone());
reducer.AddReducer(&lowering); reducer.AddReducer(&lowering);
reducer.ReduceGraph(); reducer.ReduceGraph();
......
...@@ -67,9 +67,7 @@ class ChangeLoweringTest : public GraphTest { ...@@ -67,9 +67,7 @@ class ChangeLoweringTest : public GraphTest {
MachineOperatorBuilder machine(zone(), WordRepresentation()); MachineOperatorBuilder machine(zone(), WordRepresentation());
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine); JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine);
CompilationInfo info(isolate(), zone()); ChangeLowering reducer(&jsgraph);
Linkage linkage(zone(), &info);
ChangeLowering reducer(&jsgraph, &linkage);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -36,7 +36,7 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( ...@@ -36,7 +36,7 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build(
} }
size_t const node_count = graph()->NodeCount(); size_t const node_count = graph()->NodeCount();
EXPECT_NE(0u, node_count); EXPECT_NE(0u, node_count);
Linkage linkage(test_->isolate(), test_->zone(), call_descriptor()); Linkage linkage(call_descriptor());
InstructionBlocks* instruction_blocks = InstructionBlocks* instruction_blocks =
InstructionSequence::InstructionBlocksFor(test_->zone(), schedule); InstructionSequence::InstructionBlocksFor(test_->zone(), schedule);
InstructionSequence sequence(test_->isolate(), test_->zone(), InstructionSequence sequence(test_->isolate(), test_->zone(),
......
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