[compiler] Remove CodeStub from CompilationInfo

The motivation for this is that CompilationInfo really shouldn't
explicitly know anything about CodeStubs. This is evident in
the TurboFan stubs pipeline, which only needs to pass down
information about Code::Flags to the code generator and not
any of the CallInterfaceDescriptor silliness that Hydrogen has
to push around, since TF has the Linkage class that
encapsulates everything that is needed for the stub ABI. So,
instead of threading CodeStub machinery through the TF stub
pipeline, it is now removed from CompilationInfo and replaced
by only the explicit bits needed both by the Crankshaft and
TF pipelines in code generation.

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

Cr-Commit-Position: refs/heads/master@{#33410}
This commit is contained in:
danno 2016-01-20 07:17:39 -08:00 committed by Commit bot
parent d8cddade5e
commit d1d0196473
26 changed files with 115 additions and 133 deletions

View File

@ -34,11 +34,12 @@ static LChunk* OptimizeGraph(HGraph* graph) {
class CodeStubGraphBuilderBase : public HGraphBuilder {
public:
explicit CodeStubGraphBuilderBase(CompilationInfo* info)
: HGraphBuilder(info),
explicit CodeStubGraphBuilderBase(CompilationInfo* info, CodeStub* code_stub)
: HGraphBuilder(info, code_stub->GetCallInterfaceDescriptor()),
arguments_length_(NULL),
info_(info),
descriptor_(info->code_stub()),
code_stub_(code_stub),
descriptor_(code_stub),
context_(NULL) {
int parameter_count = GetParameterCount();
parameters_.Reset(new HParameter*[parameter_count]);
@ -68,7 +69,7 @@ class CodeStubGraphBuilderBase : public HGraphBuilder {
return arguments_length_;
}
CompilationInfo* info() { return info_; }
CodeStub* stub() { return info_->code_stub(); }
CodeStub* stub() { return code_stub_; }
HContext* context() { return context_; }
Isolate* isolate() { return info_->isolate(); }
@ -124,6 +125,7 @@ class CodeStubGraphBuilderBase : public HGraphBuilder {
base::SmartArrayPointer<HParameter*> parameters_;
HValue* arguments_length_;
CompilationInfo* info_;
CodeStub* code_stub_;
CodeStubDescriptor descriptor_;
HContext* context_;
};
@ -214,8 +216,8 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
template <class Stub>
class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
public:
explicit CodeStubGraphBuilder(CompilationInfo* info)
: CodeStubGraphBuilderBase(info) {}
explicit CodeStubGraphBuilder(CompilationInfo* info, CodeStub* stub)
: CodeStubGraphBuilderBase(info, stub) {}
protected:
virtual HValue* BuildCodeStub() {
@ -269,13 +271,8 @@ Handle<Code> HydrogenCodeStub::GenerateLightweightMissCode(
masm.GetCode(&desc);
// Copy the generated code into a heap object.
Code::Flags flags = Code::ComputeFlags(
GetCodeKind(),
GetICState(),
GetExtraICState(),
GetStubType());
Handle<Code> new_object = factory->NewCode(
desc, flags, masm.CodeObject(), NeedsImmovableCode());
desc, GetCodeFlags(), masm.CodeObject(), NeedsImmovableCode());
return new_object;
}
@ -297,8 +294,15 @@ static Handle<Code> DoGenerateCode(Stub* stub) {
timer.Start();
}
Zone zone;
CompilationInfo info(stub, isolate, &zone);
CodeStubGraphBuilder<Stub> builder(&info);
CompilationInfo info(CodeStub::MajorName(stub->MajorKey()), isolate, &zone,
stub->GetCodeFlags());
// Parameter count is number of stack parameters.
int parameter_count = descriptor.GetStackParameterCount();
if (descriptor.function_mode() == NOT_JS_FUNCTION_STUB_MODE) {
parameter_count--;
}
info.set_parameter_count(parameter_count);
CodeStubGraphBuilder<Stub> builder(&info, stub);
LChunk* chunk = OptimizeGraph(builder.CreateGraph());
Handle<Code> code = chunk->Codegen();
if (FLAG_profile_hydrogen_code_stub_compilation) {
@ -2186,8 +2190,8 @@ template <>
class CodeStubGraphBuilder<KeyedLoadGenericStub>
: public CodeStubGraphBuilderBase {
public:
explicit CodeStubGraphBuilder(CompilationInfo* info)
: CodeStubGraphBuilderBase(info) {}
explicit CodeStubGraphBuilder(CompilationInfo* info, CodeStub* stub)
: CodeStubGraphBuilderBase(info, stub) {}
protected:
virtual HValue* BuildCodeStub();

View File

@ -96,6 +96,12 @@ Code::Kind CodeStub::GetCodeKind() const {
}
Code::Flags CodeStub::GetCodeFlags() const {
return Code::ComputeFlags(GetCodeKind(), GetICState(), GetExtraICState(),
GetStubType());
}
Handle<Code> CodeStub::GetCodeCopy(const Code::FindAndReplacePattern& pattern) {
Handle<Code> ic = GetCode();
ic = isolate()->factory()->CopyCode(ic);
@ -474,7 +480,7 @@ Handle<Code> TurboFanCodeStub::GenerateCode() {
Zone zone;
CallInterfaceDescriptor descriptor(GetCallInterfaceDescriptor());
compiler::CodeStubAssembler assembler(isolate(), &zone, descriptor,
GetCodeKind(), name);
GetCodeFlags(), name);
GenerateAssembly(&assembler);
return assembler.GenerateCode();
}

View File

@ -240,6 +240,8 @@ class CodeStub BASE_EMBEDDED {
virtual ExtraICState GetExtraICState() const { return kNoExtraICState; }
virtual Code::StubType GetStubType() const { return Code::NORMAL; }
Code::Flags GetCodeFlags() const;
friend std::ostream& operator<<(std::ostream& os, const CodeStub& s) {
s.PrintName(os);
return os;
@ -323,8 +325,10 @@ class CodeStub BASE_EMBEDDED {
#define DEFINE_CODE_STUB(NAME, SUPER) \
protected: \
public: \
inline Major MajorKey() const override { return NAME; }; \
\
protected: \
DEFINE_CODE_STUB_BASE(NAME##Stub, SUPER)

View File

@ -124,18 +124,9 @@ Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm,
CompilationInfo* info) {
Isolate* isolate = info->isolate();
Code::Flags flags;
if (info->IsStub() && info->code_stub()) {
DCHECK_EQ(info->output_code_kind(), info->code_stub()->GetCodeKind());
flags = Code::ComputeFlags(
info->output_code_kind(), info->code_stub()->GetICState(),
info->code_stub()->GetExtraICState(), info->code_stub()->GetStubType());
} else {
flags = Code::ComputeFlags(info->output_code_kind());
}
// Allocate and install the code.
CodeDesc desc;
Code::Flags flags = info->code_flags();
bool is_crankshafted =
Code::ExtractKindFromFlags(flags) == Code::OPTIMIZED_FUNCTION ||
info->IsStub();

View File

@ -110,8 +110,8 @@ bool CompilationInfo::has_scope() const {
CompilationInfo::CompilationInfo(ParseInfo* parse_info)
: CompilationInfo(parse_info, nullptr, nullptr, BASE, parse_info->isolate(),
parse_info->zone()) {
: CompilationInfo(parse_info, nullptr, Code::ComputeFlags(Code::FUNCTION),
BASE, parse_info->isolate(), parse_info->zone()) {
// Compiling for the snapshot typically results in different code than
// compiling later on. This means that code recompiled with deoptimization
// support won't be "equivalent" (as defined by SharedFunctionInfo::
@ -138,23 +138,17 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info)
}
CompilationInfo::CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone)
: CompilationInfo(nullptr, stub, CodeStub::MajorName(stub->MajorKey()),
STUB, isolate, zone) {}
CompilationInfo::CompilationInfo(const char* debug_name, Isolate* isolate,
Zone* zone)
: CompilationInfo(nullptr, nullptr, debug_name, STUB, isolate, zone) {
set_output_code_kind(Code::STUB);
}
Zone* zone, Code::Flags code_flags)
: CompilationInfo(nullptr, debug_name, code_flags, STUB, isolate, zone) {}
CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
const char* debug_name, Mode mode,
CompilationInfo::CompilationInfo(ParseInfo* parse_info, const char* debug_name,
Code::Flags code_flags, Mode mode,
Isolate* isolate, Zone* zone)
: parse_info_(parse_info),
isolate_(isolate),
flags_(0),
code_stub_(code_stub),
code_flags_(code_flags),
mode_(mode),
osr_ast_id_(BailoutId::None()),
zone_(zone),
@ -168,19 +162,7 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
parameter_count_(0),
optimization_id_(-1),
osr_expr_stack_height_(0),
debug_name_(debug_name) {
// Parameter count is number of stack parameters.
if (code_stub_ != NULL) {
CodeStubDescriptor descriptor(code_stub_);
parameter_count_ = descriptor.GetStackParameterCount();
if (descriptor.function_mode() == NOT_JS_FUNCTION_STUB_MODE) {
parameter_count_--;
}
set_output_code_kind(code_stub->GetCodeKind());
} else {
set_output_code_kind(Code::FUNCTION);
}
}
debug_name_(debug_name) {}
CompilationInfo::~CompilationInfo() {

View File

@ -67,8 +67,8 @@ class CompilationInfo {
};
explicit CompilationInfo(ParseInfo* parse_info);
CompilationInfo(CodeStub* stub, Isolate* isolate, Zone* zone);
CompilationInfo(const char* debug_name, Isolate* isolate, Zone* zone);
CompilationInfo(const char* debug_name, Isolate* isolate, Zone* zone,
Code::Flags code_flags = Code::ComputeFlags(Code::STUB));
virtual ~CompilationInfo();
ParseInfo* parse_info() const { return parse_info_; }
@ -98,7 +98,7 @@ class CompilationInfo {
Zone* zone() { return zone_; }
bool is_osr() const { return !osr_ast_id_.IsNone(); }
Handle<Code> code() const { return code_; }
CodeStub* code_stub() const { return code_stub_; }
Code::Flags code_flags() const { return code_flags_; }
BailoutId osr_ast_id() const { return osr_ast_id_; }
Handle<Code> unoptimized_code() const { return unoptimized_code_; }
int opt_count() const { return opt_count_; }
@ -212,7 +212,7 @@ class CompilationInfo {
// will make code flushing more aggressive. Only apply to Code::FUNCTION,
// since StaticMarkingVisitor::IsFlushable only flushes proper functions.
return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() &&
!is_debug() && output_code_kind_ == Code::FUNCTION;
!is_debug() && output_code_kind() == Code::FUNCTION;
}
void EnsureFeedbackVector();
@ -253,7 +253,8 @@ class CompilationInfo {
osr_ast_id_ = osr_ast_id;
unoptimized_code_ = unoptimized;
optimization_id_ = isolate()->NextOptimizationId();
set_output_code_kind(Code::OPTIMIZED_FUNCTION);
code_flags_ =
Code::KindField::update(code_flags_, Code::OPTIMIZED_FUNCTION);
}
// Deoptimization support.
@ -362,9 +363,9 @@ class CompilationInfo {
base::SmartArrayPointer<char> GetDebugName() const;
Code::Kind output_code_kind() const { return output_code_kind_; }
void set_output_code_kind(Code::Kind kind) { output_code_kind_ = kind; }
Code::Kind output_code_kind() const {
return Code::ExtractKindFromFlags(code_flags_);
}
protected:
ParseInfo* parse_info_;
@ -385,8 +386,8 @@ class CompilationInfo {
STUB
};
CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
const char* debug_name, Mode mode, Isolate* isolate,
CompilationInfo(ParseInfo* parse_info, const char* debug_name,
Code::Flags code_flags, Mode mode, Isolate* isolate,
Zone* zone);
Isolate* isolate_;
@ -405,10 +406,8 @@ class CompilationInfo {
unsigned flags_;
Code::Kind output_code_kind_;
Code::Flags code_flags_;
// For compiled stubs, the stub object
CodeStub* code_stub_;
// The compiled code.
Handle<Code> code_;

View File

@ -27,12 +27,12 @@ namespace compiler {
CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
const CallInterfaceDescriptor& descriptor,
Code::Kind kind, const char* name)
Code::Flags flags, const char* name)
: raw_assembler_(new RawMachineAssembler(
isolate, new (zone) Graph(zone),
Linkage::GetStubCallDescriptor(isolate, zone, descriptor, 0,
CallDescriptor::kNoFlags))),
kind_(kind),
flags_(flags),
name_(name),
code_generated_(false) {}
@ -45,7 +45,7 @@ Handle<Code> CodeStubAssembler::GenerateCode() {
Schedule* schedule = raw_assembler_->Export();
Handle<Code> code = Pipeline::GenerateCodeForCodeStub(
isolate(), raw_assembler_->call_descriptor(), graph(), schedule, kind_,
isolate(), raw_assembler_->call_descriptor(), graph(), schedule, flags_,
name_);
code_generated_ = true;

View File

@ -30,8 +30,8 @@ class Schedule;
class CodeStubAssembler {
public:
CodeStubAssembler(Isolate* isolate, Zone* zone,
const CallInterfaceDescriptor& descriptor, Code::Kind kind,
const char* name);
const CallInterfaceDescriptor& descriptor,
Code::Flags flags, const char* name);
virtual ~CodeStubAssembler();
Handle<Code> GenerateCode();
@ -82,7 +82,7 @@ class CodeStubAssembler {
Zone* zone();
base::SmartPointer<RawMachineAssembler> raw_assembler_;
Code::Kind kind_;
Code::Flags flags_;
const char* name_;
bool code_generated_;

View File

@ -176,9 +176,10 @@ MaybeHandle<Code> FastAccessorAssembler::Build() {
// Export the schedule and call the compiler.
Schedule* schedule = assembler_->Export();
Code::Flags flags = Code::ComputeFlags(Code::STUB);
MaybeHandle<Code> code = Pipeline::GenerateCodeForCodeStub(
assembler_->isolate(), assembler_->call_descriptor(), assembler_->graph(),
schedule, Code::STUB, "FastAccessorAssembler");
schedule, flags, "FastAccessorAssembler");
// Update state & return.
state_ = !code.is_null() ? kBuilt : kError;

View File

@ -53,9 +53,10 @@ Handle<Code> InterpreterAssembler::GenerateCode() {
const char* bytecode_name = interpreter::Bytecodes::ToString(bytecode_);
Schedule* schedule = raw_assembler_->Export();
Code::Flags flags = Code::ComputeFlags(Code::STUB);
Handle<Code> code = Pipeline::GenerateCodeForCodeStub(
isolate(), raw_assembler_->call_descriptor(), graph(), schedule,
Code::STUB, bytecode_name);
isolate(), raw_assembler_->call_descriptor(), graph(), schedule, flags,
bytecode_name);
#ifdef ENABLE_DISASSEMBLER
if (FLAG_trace_ignition_codegen) {

View File

@ -120,14 +120,7 @@ bool CallDescriptor::CanTailCall(const Node* node,
CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) {
if (info->code_stub() != nullptr) {
// Use the code stub interface descriptor.
CodeStub* stub = info->code_stub();
CallInterfaceDescriptor descriptor = stub->GetCallInterfaceDescriptor();
return GetStubCallDescriptor(
info->isolate(), zone, descriptor, stub->GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties);
}
DCHECK(!info->IsStub());
if (info->has_literal()) {
// If we already have the function literal, use the number of parameters
// plus the receiver.

View File

@ -1207,10 +1207,9 @@ Handle<Code> Pipeline::GenerateCode() {
Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate,
CallDescriptor* call_descriptor,
Graph* graph, Schedule* schedule,
Code::Kind kind,
Code::Flags flags,
const char* debug_name) {
CompilationInfo info(debug_name, isolate, graph->zone());
info.set_output_code_kind(kind);
CompilationInfo info(debug_name, isolate, graph->zone(), flags);
// Construct a pipeline for scheduling and code generation.
ZonePool zone_pool;

View File

@ -35,7 +35,7 @@ class Pipeline {
static Handle<Code> GenerateCodeForCodeStub(Isolate* isolate,
CallDescriptor* call_descriptor,
Graph* graph, Schedule* schedule,
Code::Kind kind,
Code::Flags flags,
const char* debug_name);
// Run the pipeline on a machine graph and generate code. If {schedule} is

View File

@ -1853,9 +1853,9 @@ Handle<JSFunction> CompileJSToWasmWrapper(
module->GetFunctionSignature(index)->parameter_count());
CallDescriptor* incoming = Linkage::GetJSCallDescriptor(
&zone, false, params + 1, CallDescriptor::kNoFlags);
CompilationInfo info("js-to-wasm", isolate, &zone);
// TODO(titzer): this is technically a WASM wrapper, not a wasm function.
info.set_output_code_kind(Code::WASM_FUNCTION);
Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION);
CompilationInfo info("js-to-wasm", isolate, &zone, flags);
Handle<Code> code =
Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr);
@ -1928,9 +1928,9 @@ Handle<Code> CompileWasmToJSWrapper(Isolate* isolate, wasm::ModuleEnv* module,
// Schedule and compile to machine code.
CallDescriptor* incoming = module->GetWasmCallDescriptor(&zone, func->sig);
CompilationInfo info("wasm-to-js", isolate, &zone);
// TODO(titzer): this is technically a WASM wrapper, not a wasm function.
info.set_output_code_kind(Code::WASM_FUNCTION);
Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION);
CompilationInfo info("wasm-to-js", isolate, &zone, flags);
code = Pipeline::GenerateCodeForTesting(&info, incoming, &graph, nullptr);
#ifdef ENABLE_DISASSEMBLER
@ -2007,8 +2007,8 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate,
// Run the compiler pipeline to generate machine code.
CallDescriptor* descriptor = const_cast<CallDescriptor*>(
module_env->GetWasmCallDescriptor(&zone, function.sig));
CompilationInfo info("wasm", isolate, &zone);
info.set_output_code_kind(Code::WASM_FUNCTION);
Code::Flags flags = Code::ComputeFlags(Code::WASM_FUNCTION);
CompilationInfo info("wasm", isolate, &zone, flags);
Handle<Code> code =
Pipeline::GenerateCodeForTesting(&info, descriptor, &graph);

View File

@ -2449,8 +2449,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
CallInterfaceDescriptor descriptor =
info()->code_stub()->GetCallInterfaceDescriptor();
CallInterfaceDescriptor descriptor = graph()->descriptor();
int index = static_cast<int>(instr->index());
Register reg = descriptor.GetRegisterParameter(index);
return DefineFixed(result, reg);

View File

@ -1966,8 +1966,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
CallInterfaceDescriptor descriptor =
info()->code_stub()->GetCallInterfaceDescriptor();
CallInterfaceDescriptor descriptor = graph()->descriptor();
int index = static_cast<int>(instr->index());
Register reg = descriptor.GetRegisterParameter(index);
return DefineFixed(result, reg);

View File

@ -1185,7 +1185,7 @@ void HGraphBuilder::LoopBuilder::EndBody() {
HGraph* HGraphBuilder::CreateGraph() {
graph_ = new(zone()) HGraph(info_);
graph_ = new (zone()) HGraph(info_, descriptor_);
if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_);
CompilationPhase phase("H_Block building", info_);
set_current_block(graph()->entry_block());
@ -3547,14 +3547,14 @@ HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) {
HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
: HGraphBuilder(info),
: HGraphBuilder(info, CallInterfaceDescriptor()),
function_state_(NULL),
initial_function_state_(this, info, NORMAL_RETURN, 0),
ast_context_(NULL),
break_scope_(NULL),
inlined_count_(0),
globals_(10, info->zone()),
osr_(new(info->zone()) HOsrBuilder(this)) {
osr_(new (info->zone()) HOsrBuilder(this)) {
// This is not initialized in the initializer list because the
// constructor for the initial state relies on function_state_ == NULL
// to know it's the initial state.
@ -3641,7 +3641,7 @@ std::ostream& operator<<(std::ostream& os, const HBasicBlock& b) {
}
HGraph::HGraph(CompilationInfo* info)
HGraph::HGraph(CompilationInfo* info, CallInterfaceDescriptor descriptor)
: isolate_(info->isolate()),
next_block_id_(0),
entry_block_(NULL),
@ -3651,6 +3651,7 @@ HGraph::HGraph(CompilationInfo* info)
uint32_instructions_(NULL),
osr_(NULL),
info_(info),
descriptor_(descriptor),
zone_(info->zone()),
is_recursive_(false),
use_optimistic_licm_(false),
@ -3660,8 +3661,6 @@ HGraph::HGraph(CompilationInfo* info)
no_side_effects_scope_count_(0),
disallow_adding_new_values_(false) {
if (info->IsStub()) {
CallInterfaceDescriptor descriptor =
info->code_stub()->GetCallInterfaceDescriptor();
start_environment_ =
new (zone_) HEnvironment(zone_, descriptor.GetRegisterParameterCount());
} else {

View File

@ -297,11 +297,12 @@ class BoundsCheckTable;
class InductionVariableBlocksTable;
class HGraph final : public ZoneObject {
public:
explicit HGraph(CompilationInfo* info);
explicit HGraph(CompilationInfo* info, CallInterfaceDescriptor descriptor);
Isolate* isolate() const { return isolate_; }
Zone* zone() const { return zone_; }
CompilationInfo* info() const { return info_; }
CallInterfaceDescriptor descriptor() const { return descriptor_; }
const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
@ -486,6 +487,7 @@ class HGraph final : public ZoneObject {
HOsrBuilder* osr_;
CompilationInfo* info_;
CallInterfaceDescriptor descriptor_;
Zone* zone_;
bool is_recursive_;
@ -1006,8 +1008,10 @@ class HAllocationMode final BASE_EMBEDDED {
class HGraphBuilder {
public:
explicit HGraphBuilder(CompilationInfo* info)
explicit HGraphBuilder(CompilationInfo* info,
CallInterfaceDescriptor descriptor)
: info_(info),
descriptor_(descriptor),
graph_(NULL),
current_block_(NULL),
scope_(info->scope()),
@ -1912,6 +1916,7 @@ class HGraphBuilder {
}
CompilationInfo* info_;
CallInterfaceDescriptor descriptor_;
HGraph* graph_;
HBasicBlock* current_block_;
Scope* scope_;

View File

@ -2500,8 +2500,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
CallInterfaceDescriptor descriptor =
info()->code_stub()->GetCallInterfaceDescriptor();
CallInterfaceDescriptor descriptor = graph()->descriptor();
int index = static_cast<int>(instr->index());
Register reg = descriptor.GetRegisterParameter(index);
return DefineFixed(result, reg);

View File

@ -2396,8 +2396,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
CallInterfaceDescriptor descriptor =
info()->code_stub()->GetCallInterfaceDescriptor();
CallInterfaceDescriptor descriptor = graph()->descriptor();
int index = static_cast<int>(instr->index());
Register reg = descriptor.GetRegisterParameter(index);
return DefineFixed(result, reg);

View File

@ -2401,8 +2401,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
CallInterfaceDescriptor descriptor =
info()->code_stub()->GetCallInterfaceDescriptor();
CallInterfaceDescriptor descriptor = graph()->descriptor();
int index = static_cast<int>(instr->index());
Register reg = descriptor.GetRegisterParameter(index);
return DefineFixed(result, reg);

View File

@ -2402,8 +2402,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
CallInterfaceDescriptor descriptor =
info()->code_stub()->GetCallInterfaceDescriptor();
CallInterfaceDescriptor descriptor = graph()->descriptor();
int index = static_cast<int>(instr->index());
Register reg = descriptor.GetRegisterParameter(index);
return DefineFixed(result, reg);

View File

@ -2493,8 +2493,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
return DefineAsSpilled(result, spill_index);
} else {
DCHECK(info()->IsStub());
CallInterfaceDescriptor descriptor =
info()->code_stub()->GetCallInterfaceDescriptor();
CallInterfaceDescriptor descriptor = graph()->descriptor();
int index = static_cast<int>(instr->index());
Register reg = descriptor.GetRegisterParameter(index);
return DefineFixed(result, reg);

View File

@ -16,7 +16,7 @@ class CodeStubAssemblerTester : public CodeStubAssembler {
CodeStubAssemblerTester(Isolate* isolate,
const CallInterfaceDescriptor& descriptor)
: CodeStubAssembler(isolate, isolate->runtime_zone(), descriptor,
Code::STUB, "test"),
Code::ComputeFlags(Code::STUB), "test"),
scope_(isolate) {}
private:

View File

@ -71,20 +71,6 @@ TEST(TestLinkageJSFunctionIncoming) {
}
TEST(TestLinkageCodeStubIncoming) {
Isolate* isolate = CcTest::InitIsolateOnce();
Zone zone;
ToNumberStub stub(isolate);
CompilationInfo info(&stub, isolate, &zone);
CallDescriptor* descriptor = Linkage::ComputeIncoming(&zone, &info);
CHECK(descriptor);
CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount()));
CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount()));
CHECK_EQ(Operator::kNoProperties, descriptor->properties());
CHECK_EQ(false, descriptor->IsJSFunctionCall());
}
TEST(TestLinkageJSCall) {
HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + c");
@ -109,6 +95,20 @@ TEST(TestLinkageRuntimeCall) {
TEST(TestLinkageStubCall) {
Isolate* isolate = CcTest::InitIsolateOnce();
Zone zone;
ToNumberStub stub(isolate);
CompilationInfo info("test", isolate, &zone, Code::ComputeFlags(Code::STUB));
CallInterfaceDescriptor interface_descriptor =
stub.GetCallInterfaceDescriptor();
CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
isolate, &zone, interface_descriptor, stub.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties);
CHECK(descriptor);
CHECK_EQ(0, static_cast<int>(descriptor->StackParameterCount()));
CHECK_EQ(1, static_cast<int>(descriptor->ReturnCount()));
CHECK_EQ(Operator::kNoProperties, descriptor->properties());
CHECK_EQ(false, descriptor->IsJSFunctionCall());
// TODO(titzer): test linkage creation for outgoing stub calls.
}

View File

@ -27,8 +27,13 @@ TEST(RunStringLengthStub) {
// Create code and an accompanying descriptor.
StringLengthStub stub(isolate);
Handle<Code> code = stub.GenerateCode();
CompilationInfo info(&stub, isolate, zone);
CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info);
CompilationInfo info("test", isolate, zone,
Code::ComputeFlags(Code::HANDLER));
CallInterfaceDescriptor interface_descriptor =
stub.GetCallInterfaceDescriptor();
CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
isolate, zone, interface_descriptor, stub.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties);
// Create a function to call the code using the descriptor.
Graph graph(zone);