__ stm(db_w, sp, saves);
}
} else if (descriptor->IsJSFunctionCall()) {
- CompilationInfo* info = linkage()->info();
+ CompilationInfo* info = this->info();
__ Prologue(info->IsCodePreAgingActive());
frame()->SetRegisterSaveAreaSize(
StandardFrameConstants::kFixedFrameSizeFromFp);
void CodeGenerator::EnsureSpaceForLazyDeopt() {
int space_needed = Deoptimizer::patch_size();
- if (!linkage()->info()->IsStub()) {
+ if (!info()->IsStub()) {
// Ensure that we have enough space after the previous lazy-bailout
// instruction for patching the code here.
int current_pc = masm()->pc_offset();
__ PushCalleeSavedRegisters();
frame()->SetRegisterSaveAreaSize(20 * kPointerSize);
} else if (descriptor->IsJSFunctionCall()) {
- CompilationInfo* info = linkage()->info();
+ CompilationInfo* info = this->info();
__ SetStackPointer(jssp);
__ Prologue(info->IsCodePreAgingActive());
frame()->SetRegisterSaveAreaSize(
void CodeGenerator::EnsureSpaceForLazyDeopt() {
int space_needed = Deoptimizer::patch_size();
- if (!linkage()->info()->IsStub()) {
+ if (!info()->IsStub()) {
// Ensure that we have enough space after the previous lazy-bailout
// instruction for patching the code here.
intptr_t current_pc = masm()->pc_offset();
: StructuredGraphBuilder(local_zone, jsgraph->graph(), jsgraph->common()),
info_(info),
jsgraph_(jsgraph),
- globals_(0, info->zone()),
+ globals_(0, local_zone),
breakable_(NULL),
execution_context_(NULL) {
- InitializeAstVisitor(info->zone());
+ InitializeAstVisitor(local_zone);
}
namespace compiler {
CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
- InstructionSequence* code)
+ InstructionSequence* code, CompilationInfo* info)
: frame_(frame),
linkage_(linkage),
code_(code),
+ info_(info),
current_block_(BasicBlock::RpoNumber::Invalid()),
current_source_position_(SourcePosition::Invalid()),
masm_(code->zone()->isolate(), NULL, 0),
Handle<Code> CodeGenerator::GenerateCode() {
- CompilationInfo* info = linkage()->info();
+ CompilationInfo* info = this->info();
// Emit a code line info recording start event.
PositionsRecorder* recorder = masm()->positions_recorder();
masm()->positions_recorder()->WriteRecordedPositions();
if (FLAG_code_comments) {
Vector<char> buffer = Vector<char>::New(256);
- CompilationInfo* info = linkage()->info();
+ CompilationInfo* info = this->info();
int ln = Script::GetLineNumber(info->script(), code_pos);
int cn = Script::GetColumnNumber(info->script(), code_pos);
if (info->script()->name()->IsString()) {
void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) {
- CompilationInfo* info = linkage()->info();
+ CompilationInfo* info = this->info();
int deopt_count = static_cast<int>(deoptimization_states_.size());
if (deopt_count == 0) return;
Handle<DeoptimizationInputData> data =
class CodeGenerator FINAL : public GapResolver::Assembler {
public:
explicit CodeGenerator(Frame* frame, Linkage* linkage,
- InstructionSequence* code);
+ InstructionSequence* code, CompilationInfo* info);
// Generate native code.
Handle<Code> GenerateCode();
GapResolver* resolver() { return &resolver_; }
SafepointTableBuilder* safepoints() { return &safepoints_; }
Zone* zone() const { return code()->zone(); }
+ CompilationInfo* info() const { return info_; }
// Checks if {block} will appear directly after {current_block_} when
// assembling code, in which case, a fall-through can be used.
Frame* const frame_;
Linkage* const linkage_;
InstructionSequence* const code_;
+ CompilationInfo* const info_;
BasicBlock::RpoNumber current_block_;
SourcePosition current_source_position_;
MacroAssembler masm_;
frame->SetRegisterSaveAreaSize(register_save_area_size);
}
} else if (descriptor->IsJSFunctionCall()) {
- CompilationInfo* info = linkage()->info();
+ CompilationInfo* info = this->info();
__ Prologue(info->IsCodePreAgingActive());
frame->SetRegisterSaveAreaSize(
StandardFrameConstants::kFixedFrameSizeFromFp);
void CodeGenerator::EnsureSpaceForLazyDeopt() {
int space_needed = Deoptimizer::patch_size();
- if (!linkage()->info()->IsStub()) {
+ if (!info()->IsStub()) {
// Ensure that we have enough space after the previous lazy-bailout
// instruction for patching the code here.
int current_pc = masm()->pc_offset();
JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph)
: info_(info),
jsgraph_(jsgraph),
- linkage_(new (jsgraph->zone()) Linkage(info)) {}
+ linkage_(new (jsgraph->zone()) Linkage(jsgraph->zone(), info)) {}
void JSGenericLowering::PatchOperator(Node* node, const Operator* op) {
}
-Linkage::Linkage(CompilationInfo* info) : info_(info) {
+CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) {
if (info->function() != NULL) {
// If we already have the function literal, use the number of parameters
// plus the receiver.
- incoming_ = GetJSCallDescriptor(1 + info->function()->parameter_count());
- } else if (!info->closure().is_null()) {
+ return GetJSCallDescriptor(1 + info->function()->parameter_count(), zone);
+ }
+ if (!info->closure().is_null()) {
// If we are compiling a JS function, use a JS call descriptor,
// plus the receiver.
SharedFunctionInfo* shared = info->closure()->shared();
- incoming_ = GetJSCallDescriptor(1 + shared->formal_parameter_count());
- } else if (info->code_stub() != NULL) {
+ return GetJSCallDescriptor(1 + shared->formal_parameter_count(), zone);
+ }
+ if (info->code_stub() != NULL) {
// Use the code stub interface descriptor.
CallInterfaceDescriptor descriptor =
info->code_stub()->GetCallInterfaceDescriptor();
- incoming_ = GetStubCallDescriptor(descriptor);
- } else {
- incoming_ = NULL; // TODO(titzer): ?
+ return GetStubCallDescriptor(descriptor, 0, CallDescriptor::kNoFlags, zone);
}
+ return NULL; // TODO(titzer): ?
}
-FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame, int extra) {
+FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame,
+ int extra) const {
if (frame->GetSpillSlotCount() > 0 || incoming_->IsJSFunctionCall() ||
incoming_->kind() == CallDescriptor::kCallAddress) {
int offset;
}
-CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count) {
- return GetJSCallDescriptor(parameter_count, this->info_->zone());
+CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count) const {
+ return GetJSCallDescriptor(parameter_count, zone_);
}
CallDescriptor* Linkage::GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
- Operator::Properties properties) {
- return GetRuntimeCallDescriptor(function, parameter_count, properties,
- this->info_->zone());
+ Operator::Properties properties) const {
+ return GetRuntimeCallDescriptor(function, parameter_count, properties, zone_);
}
CallDescriptor* Linkage::GetStubCallDescriptor(
CallInterfaceDescriptor descriptor, int stack_parameter_count,
- CallDescriptor::Flags flags) {
- return GetStubCallDescriptor(descriptor, stack_parameter_count, flags,
- this->info_->zone());
+ CallDescriptor::Flags flags) const {
+ return GetStubCallDescriptor(descriptor, stack_parameter_count, flags, zone_);
}
private:
friend class Linkage;
- Kind kind_;
- MachineType target_type_;
- LinkageLocation target_loc_;
- MachineSignature* machine_sig_;
- LocationSignature* location_sig_;
- size_t js_param_count_;
- Operator::Properties properties_;
- RegList callee_saved_registers_;
- Flags flags_;
- const char* debug_name_;
+ const Kind kind_;
+ const MachineType target_type_;
+ const LinkageLocation target_loc_;
+ const MachineSignature* const machine_sig_;
+ const LocationSignature* const location_sig_;
+ const size_t js_param_count_;
+ const Operator::Properties properties_;
+ const RegList callee_saved_registers_;
+ const Flags flags_;
+ const char* const debug_name_;
+
+ DISALLOW_COPY_AND_ASSIGN(CallDescriptor);
};
DEFINE_OPERATORS_FOR_FLAGS(CallDescriptor::Flags)
// Call[Runtime] CEntryStub, arg 1, arg 2, arg 3, [...], fun, #arg, context
class Linkage : public ZoneObject {
public:
- explicit Linkage(CompilationInfo* info);
- explicit Linkage(CompilationInfo* info, CallDescriptor* incoming)
- : info_(info), incoming_(incoming) {}
+ Linkage(Zone* zone, CompilationInfo* info)
+ : zone_(zone), incoming_(ComputeIncoming(zone, info)) {}
+ Linkage(Zone* zone, CallDescriptor* incoming)
+ : zone_(zone), incoming_(incoming) {}
+
+ static CallDescriptor* ComputeIncoming(Zone* zone, CompilationInfo* info);
// The call descriptor for this compilation unit describes the locations
// of incoming parameters and the outgoing return value(s).
- CallDescriptor* GetIncomingDescriptor() { return incoming_; }
- CallDescriptor* GetJSCallDescriptor(int parameter_count);
+ CallDescriptor* GetIncomingDescriptor() const { return incoming_; }
+ CallDescriptor* GetJSCallDescriptor(int parameter_count) const;
static CallDescriptor* GetJSCallDescriptor(int parameter_count, Zone* zone);
- CallDescriptor* GetRuntimeCallDescriptor(Runtime::FunctionId function,
- int parameter_count,
- Operator::Properties properties);
+ CallDescriptor* GetRuntimeCallDescriptor(
+ Runtime::FunctionId function, int parameter_count,
+ Operator::Properties properties) const;
static CallDescriptor* GetRuntimeCallDescriptor(
Runtime::FunctionId function, int parameter_count,
Operator::Properties properties, Zone* zone);
CallDescriptor* GetStubCallDescriptor(
CallInterfaceDescriptor descriptor, int stack_parameter_count = 0,
- CallDescriptor::Flags flags = CallDescriptor::kNoFlags);
+ CallDescriptor::Flags flags = CallDescriptor::kNoFlags) const;
static CallDescriptor* GetStubCallDescriptor(
CallInterfaceDescriptor descriptor, int stack_parameter_count,
CallDescriptor::Flags flags, Zone* zone);
MachineSignature* sig);
// Get the location of an (incoming) parameter to this function.
- LinkageLocation GetParameterLocation(int index) {
+ LinkageLocation GetParameterLocation(int index) const {
return incoming_->GetInputLocation(index + 1); // + 1 to skip target.
}
// Get the machine type of an (incoming) parameter to this function.
- MachineType GetParameterType(int index) {
+ MachineType GetParameterType(int index) const {
return incoming_->GetInputType(index + 1); // + 1 to skip target.
}
// Get the location where this function should place its return value.
- LinkageLocation GetReturnLocation() {
+ LinkageLocation GetReturnLocation() const {
return incoming_->GetReturnLocation(0);
}
// Get the machine type of this function's return value.
- MachineType GetReturnType() { return incoming_->GetReturnType(0); }
+ MachineType GetReturnType() const { return incoming_->GetReturnType(0); }
// Get the frame offset for a given spill slot. The location depends on the
// calling convention and the specific frame layout, and may thus be
// architecture-specific. Negative spill slots indicate arguments on the
// caller's frame. The {extra} parameter indicates an additional offset from
// the frame offset, e.g. to index into part of a double slot.
- FrameOffset GetFrameOffset(int spill_slot, Frame* frame, int extra = 0);
-
- CompilationInfo* info() const { return info_; }
+ FrameOffset GetFrameOffset(int spill_slot, Frame* frame, int extra = 0) const;
static bool NeedsFrameState(Runtime::FunctionId function);
private:
- CompilationInfo* info_;
- CallDescriptor* incoming_;
+ Zone* const zone_;
+ CallDescriptor* const incoming_;
+
+ DISALLOW_COPY_AND_ASSIGN(Linkage);
};
} // namespace compiler
__ MultiPush(saves);
}
} else if (descriptor->IsJSFunctionCall()) {
- CompilationInfo* info = linkage()->info();
+ CompilationInfo* info = this->info();
__ Prologue(info->IsCodePreAgingActive());
frame()->SetRegisterSaveAreaSize(
StandardFrameConstants::kFixedFrameSizeFromFp);
void CodeGenerator::EnsureSpaceForLazyDeopt() {
int space_needed = Deoptimizer::patch_size();
- if (!linkage()->info()->IsStub()) {
+ if (!info()->IsStub()) {
// Ensure that we have enough space after the previous lazy-bailout
// instruction for patching the code here.
int current_pc = masm()->pc_offset();
PhaseScope phase_scope(pipeline_statistics.get(), "change lowering");
SourcePositionTable::Scope pos(data.source_positions(),
SourcePosition::Unknown());
- Linkage linkage(info());
+ Linkage linkage(data.graph_zone(), info());
ValueNumberingReducer vn_reducer(data.graph_zone());
SimplifiedOperatorReducer simple_reducer(data.jsgraph());
ChangeLowering lowering(data.jsgraph(), &linkage);
Handle<Code> code = Handle<Code>::null();
{
// Generate optimized code.
- Linkage linkage(info());
+ Linkage linkage(data.instruction_zone(), info());
code = GenerateCode(&linkage, &data);
info()->SetCode(code);
}
{
int node_count = sequence.VirtualRegisterCount();
if (node_count > UnallocatedOperand::kMaxVirtualRegisters) {
- linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues);
+ info()->AbortOptimization(kNotEnoughVirtualRegistersForValues);
return Handle<Code>::null();
}
ZonePool::Scope zone_scope(data->zone_pool());
- RegisterAllocator allocator(zone_scope.zone(), &frame, linkage->info(),
- &sequence);
+ RegisterAllocator allocator(zone_scope.zone(), &frame, info(), &sequence);
if (!allocator.Allocate(data->pipeline_statistics())) {
- linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
+ info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
return Handle<Code>::null();
}
if (FLAG_trace_turbo) {
Handle<Code> code;
{
PhaseScope phase_scope(data->pipeline_statistics(), "generate code");
- CodeGenerator generator(&frame, linkage, &sequence);
+ CodeGenerator generator(&frame, linkage, &sequence, info());
code = generator.GenerateCode();
}
if (profiler_data != NULL) {
frame()->SetRegisterSaveAreaSize(register_save_area_size);
}
} else if (descriptor->IsJSFunctionCall()) {
- CompilationInfo* info = linkage()->info();
+ CompilationInfo* info = this->info();
__ Prologue(info->IsCodePreAgingActive());
frame()->SetRegisterSaveAreaSize(
StandardFrameConstants::kFixedFrameSizeFromFp);
void CodeGenerator::EnsureSpaceForLazyDeopt() {
int space_needed = Deoptimizer::patch_size();
- if (!linkage()->info()->IsStub()) {
+ if (!info()->IsStub()) {
// Ensure that we have enough space after the previous lazy-bailout
// instruction for patching the code here.
int current_pc = masm()->pc_offset();
CallDescriptor* call_descriptor = this->call_descriptor();
Graph* graph = this->graph();
CompilationInfo info(graph->zone()->isolate(), graph->zone());
- Linkage linkage(&info, call_descriptor);
+ Linkage linkage(graph->zone(), call_descriptor);
Pipeline pipeline(&info);
code_ = pipeline.GenerateCodeForMachineGraph(&linkage, graph, schedule);
}
CHECK(Compiler::EnsureDeoptimizationSupport(&info));
Pipeline pipeline(&info);
- Linkage linkage(&info);
+ Linkage linkage(info.zone(), &info);
Handle<Code> code = pipeline.GenerateCodeForMachineGraph(&linkage, graph);
CHECK(!code.is_null());
function->ReplaceCode(*code);
if (code_.is_null()) {
Zone* zone = graph_->zone();
CompilationInfo info(zone->isolate(), zone);
- Linkage linkage(&info,
+ Linkage linkage(zone,
Linkage::GetSimplifiedCDescriptor(zone, machine_sig_));
Pipeline pipeline(&info);
code_ = pipeline.GenerateCodeForMachineGraph(&linkage, graph_);
void LowerChange(Node* change) {
// Run the graph reducer with changes lowering on a single node.
CompilationInfo info(this->isolate(), this->zone());
- Linkage linkage(&info);
+ Linkage linkage(this->zone(), &info);
ChangeLowering lowering(&jsgraph, &linkage);
GraphReducer reducer(this->graph());
reducer.AddReducer(&lowering);
}
// Initialize the codegen and generate code.
- Linkage* linkage = new (scope_->main_zone()) Linkage(&info);
+ Linkage* linkage = new (scope_->main_zone()) Linkage(info.zone(), &info);
code = new v8::internal::compiler::InstructionSequence(scope_->main_zone(),
graph, schedule);
SourcePositionTable source_positions(graph);
<< *code;
}
- compiler::CodeGenerator generator(&frame, linkage, code);
+ compiler::CodeGenerator generator(&frame, linkage, code, &info);
result_code = generator.GenerateCode();
#ifdef OBJECT_PRINT
graph(zone()),
schedule(zone()),
info(static_cast<HydrogenCodeStub*>(NULL), main_isolate()),
- linkage(&info),
+ linkage(zone(), &info),
common(zone()),
code(NULL) {}
InitializedHandleScope handles;
Handle<JSFunction> function = Compile("a + b");
CompilationInfoWithZone info(function);
- Linkage linkage(&info);
+ Linkage linkage(info.zone(), &info);
}
Handle<JSFunction> function = v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(CompileRun(sources[i])));
CompilationInfoWithZone info(function);
- Linkage linkage(&info);
+ Linkage linkage(info.zone(), &info);
CallDescriptor* descriptor = linkage.GetIncomingDescriptor();
CHECK_NE(NULL, descriptor);
TEST(TestLinkageCodeStubIncoming) {
Isolate* isolate = CcTest::InitIsolateOnce();
CompilationInfoWithZone info(static_cast<HydrogenCodeStub*>(NULL), isolate);
- Linkage linkage(&info);
+ Linkage linkage(info.zone(), &info);
// TODO(titzer): test linkage creation with a bonafide code stub.
// this just checks current behavior.
CHECK_EQ(NULL, linkage.GetIncomingDescriptor());
HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + c");
CompilationInfoWithZone info(function);
- Linkage linkage(&info);
+ Linkage linkage(info.zone(), &info);
for (int i = 0; i < 32; i++) {
CallDescriptor* descriptor = linkage.GetJSCallDescriptor(i);
Zone* zone = this->zone();
CompilationInfo info(zone->isolate(), zone);
Linkage linkage(
- &info, Linkage::GetSimplifiedCDescriptor(zone, this->machine_sig_));
+ zone, Linkage::GetSimplifiedCDescriptor(zone, this->machine_sig_));
ChangeLowering lowering(&jsgraph, &linkage);
GraphReducer reducer(this->graph());
reducer.AddReducer(&lowering);
JSOperatorBuilder javascript(zone());
JSGraph jsgraph(graph(), common(), &javascript, &machine);
CompilationInfo info(isolate(), zone());
- Linkage linkage(&info);
+ Linkage linkage(zone(), &info);
ChangeLowering reducer(&jsgraph, &linkage);
return reducer.Reduce(node);
}
}
EXPECT_NE(0, graph()->NodeCount());
int initial_node_count = graph()->NodeCount();
- CompilationInfo info(test_->isolate(), test_->zone());
- Linkage linkage(&info, call_descriptor());
+ Linkage linkage(test_->zone(), call_descriptor());
InstructionSequence sequence(test_->zone(), graph(), schedule);
SourcePositionTable source_position_table(graph());
InstructionSelector selector(test_->zone(), &linkage, &sequence, schedule,