Commit 4246ac30 authored by danno@chromium.org's avatar danno@chromium.org

Generalize calling to C++ on stub deopt

Remove code specific to KeyedLoadICs in DoCompiledStubFrame on all platforms, driving stub frame translation by the register parameter information found in a stub's CodeStubInterfaceDescriptor.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13320 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c4bed033
......@@ -1259,7 +1259,7 @@ CODE_AGE_LIST(DEFINE_CODE_AGE_BUILTIN_GENERATOR)
#undef DEFINE_CODE_AGE_BUILTIN_GENERATOR
void Builtins::Generate_NotifyICMiss(MacroAssembler* masm) {
void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) {
{
FrameScope scope(masm, StackFrame::INTERNAL);
......@@ -1268,7 +1268,7 @@ void Builtins::Generate_NotifyICMiss(MacroAssembler* masm) {
// registers.
__ stm(db_w, sp, kJSCallerSaved | kCalleeSaved);
// Pass the function and deoptimization type to the runtime system.
__ CallRuntime(Runtime::kNotifyICMiss, 0);
__ CallRuntime(Runtime::kNotifyStubFailure, 0);
__ ldm(ia_w, sp, kJSCallerSaved | kCalleeSaved);
}
......
......@@ -44,7 +44,7 @@ void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
isolate->builtins()->KeyedLoadIC_Miss();
FUNCTION_ADDR(KeyedLoadIC_Miss);
}
......
......@@ -458,35 +458,39 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
// FROM TO <-fp
// | .... | | .... |
// +-------------------------+ +-------------------------+
// | JSFunction continuation | | JSFunction continuation |
// | JSFunction continuation | | parameter 1 |
// +-------------------------+ +-------------------------+
// | | saved frame (fp) | | .... |
// | +=========================+<-fp +-------------------------+
// | | JSFunction context | | parameter n |
// v +-------------------------+ +-------------------------|
// | COMPILED_STUB marker | | JSFunction continuation |
// +-------------------------+ +-------------------------+<-sp
// | | saved frame (fp) |
// | +=========================+<-fp
// | | JSFunction context |
// v +-------------------------+
// | COMPILED_STUB marker | fp = saved frame
// +-------------------------+ f8 = JSFunction context
// | |
// | ... |
// | |
// +-------------------------+<-sp
// | | r0 = number of parameters
// | ... | r1 = failure handler address
// | | fp = saved frame
// +-------------------------+<-sp cp = JSFunction context
//
//
int output_frame_size = 1 * kPointerSize;
FrameDescription* output_frame =
new(output_frame_size) FrameDescription(output_frame_size, 0);
Code* notify_miss =
isolate_->builtins()->builtin(Builtins::kNotifyICMiss);
output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
output_frame->SetContinuation(
reinterpret_cast<intptr_t>(notify_miss->entry()));
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor =
isolate_->code_stub_interface_descriptor(major_key);
Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
int output_frame_size =
(1 + descriptor->register_param_count_) * kPointerSize;
FrameDescription* output_frame =
new(output_frame_size) FrameDescription(output_frame_size, 0);
Code* notify_failure =
isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
output_frame->SetContinuation(
reinterpret_cast<uint32_t>(notify_failure->entry()));
Code* code;
CEntryStub(1, kSaveFPRegs).FindCodeInCache(&code, isolate_);
output_frame->SetPc(reinterpret_cast<intptr_t>(code->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
output_frame->SetFrameSlot(0, value);
......@@ -496,20 +500,23 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
value = input_->GetFrameSlot(input_frame_size - 3 * kPointerSize);
output_frame->SetRegister(cp.code(), value);
Translation::Opcode opcode =
static_cast<Translation::Opcode>(iterator->Next());
ASSERT(opcode == Translation::REGISTER);
USE(opcode);
int input_reg = iterator->Next();
intptr_t input_value = input_->GetRegister(input_reg);
output_frame->SetRegister(r1.code(), input_value);
int32_t next = iterator->Next();
opcode = static_cast<Translation::Opcode>(next);
ASSERT(opcode == Translation::REGISTER);
input_reg = iterator->Next();
input_value = input_->GetRegister(input_reg);
output_frame->SetRegister(r0.code(), input_value);
int parameter_offset = kPointerSize * descriptor->register_param_count_;
for (int i = 0; i < descriptor->register_param_count_; ++i) {
Translation::Opcode opcode =
static_cast<Translation::Opcode>(iterator->Next());
ASSERT(opcode == Translation::REGISTER);
USE(opcode);
int input_reg = iterator->Next();
intptr_t reg_value = input_->GetRegister(input_reg);
output_frame->SetFrameSlot(parameter_offset, reg_value);
parameter_offset -= kPointerSize;
}
ApiFunction function(descriptor->deoptimization_handler_);
ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_);
intptr_t handler = reinterpret_cast<intptr_t>(xref.address());
output_frame->SetRegister(r0.code(), descriptor->register_param_count_);
output_frame->SetRegister(r1.code(), handler);
ASSERT(frame_index == 0);
output_[frame_index] = output_frame;
......
......@@ -107,7 +107,7 @@ enum BuiltinExtraArguments {
Code::kNoExtraICState) \
V(NotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, \
Code::kNoExtraICState) \
V(NotifyICMiss, BUILTIN, UNINITIALIZED, \
V(NotifyStubFailure, BUILTIN, UNINITIALIZED, \
Code::kNoExtraICState) \
V(NotifyOSR, BUILTIN, UNINITIALIZED, \
Code::kNoExtraICState) \
......@@ -388,7 +388,7 @@ class Builtins {
static void Generate_NotifyDeoptimized(MacroAssembler* masm);
static void Generate_NotifyLazyDeoptimized(MacroAssembler* masm);
static void Generate_NotifyOSR(MacroAssembler* masm);
static void Generate_NotifyICMiss(MacroAssembler* masm);
static void Generate_NotifyStubFailure(MacroAssembler* masm);
static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm);
static void Generate_FunctionCall(MacroAssembler* masm);
......
......@@ -247,7 +247,7 @@ struct CodeStubInterfaceDescriptor {
register_params_(NULL) { }
int register_param_count_;
Register* register_params_;
Handle<Code> deoptimization_handler_;
Address deoptimization_handler_;
};
......
......@@ -575,7 +575,7 @@ CODE_AGE_LIST(DEFINE_CODE_AGE_BUILTIN_GENERATOR)
#undef DEFINE_CODE_AGE_BUILTIN_GENERATOR
void Builtins::Generate_NotifyICMiss(MacroAssembler* masm) {
void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) {
// Enter an internal frame.
{
FrameScope scope(masm, StackFrame::INTERNAL);
......@@ -584,7 +584,7 @@ void Builtins::Generate_NotifyICMiss(MacroAssembler* masm) {
// stubs that tail call the runtime on deopts passing their parameters in
// registers.
__ pushad();
__ CallRuntime(Runtime::kNotifyICMiss, 0);
__ CallRuntime(Runtime::kNotifyStubFailure, 0);
__ popad();
// Tear down internal frame.
}
......
......@@ -48,7 +48,7 @@ void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
isolate->builtins()->KeyedLoadIC_Miss();
FUNCTION_ADDR(KeyedLoadIC_Miss);
}
......
......@@ -565,35 +565,39 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
// FROM TO <-ebp
// | .... | | .... |
// +-------------------------+ +-------------------------+
// | JSFunction continuation | | JSFunction continuation |
// | JSFunction continuation | | parameter 1 |
// +-------------------------+ +-------------------------+
// | | saved frame (ebp) | | .... |
// | +=========================+<-ebp +-------------------------+
// | | JSFunction context | | parameter n |
// v +-------------------------+ +-------------------------|
// | COMPILED_STUB marker | | JSFunction continuation |
// +-------------------------+ +-------------------------+<-esp
// | | saved frame (ebp) |
// | +=========================+<-ebp
// | | JSFunction context |
// v +-------------------------+
// | COMPILED_STUB marker | ebp = saved frame
// +-------------------------+ esi = JSFunction context
// | |
// | ... |
// | |
// +-------------------------+<-esp
// | | eax = number of parameters
// | ... | ebx = failure handler address
// | | ebp = saved frame
// +-------------------------+<-esp esi = JSFunction context
//
//
int output_frame_size = 1 * kPointerSize;
FrameDescription* output_frame =
new(output_frame_size) FrameDescription(output_frame_size, 0);
Code* notify_miss =
isolate_->builtins()->builtin(Builtins::kNotifyICMiss);
output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
output_frame->SetContinuation(
reinterpret_cast<uint32_t>(notify_miss->entry()));
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor =
isolate_->code_stub_interface_descriptor(major_key);
Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
int output_frame_size =
(1 + descriptor->register_param_count_) * kPointerSize;
FrameDescription* output_frame =
new(output_frame_size) FrameDescription(output_frame_size, 0);
Code* notify_failure =
isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
output_frame->SetContinuation(
reinterpret_cast<uint32_t>(notify_failure->entry()));
Code* code;
CEntryStub(1, kSaveFPRegs).FindCodeInCache(&code, isolate_);
output_frame->SetPc(reinterpret_cast<intptr_t>(code->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
output_frame->SetFrameSlot(0, value);
......@@ -603,20 +607,22 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
value = input_->GetFrameSlot(input_frame_size - 3 * kPointerSize);
output_frame->SetRegister(esi.code(), value);
Translation::Opcode opcode =
static_cast<Translation::Opcode>(iterator->Next());
ASSERT(opcode == Translation::REGISTER);
USE(opcode);
int input_reg = iterator->Next();
intptr_t input_value = input_->GetRegister(input_reg);
output_frame->SetRegister(edx.code(), input_value);
int32_t next = iterator->Next();
opcode = static_cast<Translation::Opcode>(next);
ASSERT(opcode == Translation::REGISTER);
input_reg = iterator->Next();
input_value = input_->GetRegister(input_reg);
output_frame->SetRegister(ecx.code(), input_value);
int parameter_offset = kPointerSize * descriptor->register_param_count_;
for (int i = 0; i < descriptor->register_param_count_; ++i) {
Translation::Opcode opcode =
static_cast<Translation::Opcode>(iterator->Next());
ASSERT(opcode == Translation::REGISTER);
USE(opcode);
int input_reg = iterator->Next();
intptr_t reg_value = input_->GetRegister(input_reg);
output_frame->SetFrameSlot(parameter_offset, reg_value);
parameter_offset -= kPointerSize;
}
intptr_t handler =
reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_);
output_frame->SetRegister(eax.code(), descriptor->register_param_count_);
output_frame->SetRegister(ebx.code(), handler);
ASSERT(frame_index == 0);
output_[frame_index] = output_frame;
......
......@@ -854,6 +854,8 @@ class ToBooleanIC: public IC {
enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK };
void PatchInlinedSmiCode(Address address, InlinedSmiCheck check);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss);
} } // namespace v8::internal
#endif // V8_IC_H_
......@@ -7889,7 +7889,7 @@ class ActivationsFinder : public ThreadVisitor {
};
RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyICMiss) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyStubFailure) {
HandleScope scope(isolate);
ASSERT(args.length() == 0);
Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
......
......@@ -89,7 +89,7 @@ namespace internal {
F(ForceParallelRecompile, 1, 1) \
F(InstallRecompiledCode, 1, 1) \
F(NotifyDeoptimized, 1, 1) \
F(NotifyICMiss, 0, 1) \
F(NotifyStubFailure, 0, 1) \
F(NotifyOSR, 0, 1) \
F(DeoptimizeFunction, 1, 1) \
F(ClearFunctionTypeFeedback, 1, 1) \
......
......@@ -646,7 +646,7 @@ CODE_AGE_LIST(DEFINE_CODE_AGE_BUILTIN_GENERATOR)
#undef DEFINE_CODE_AGE_BUILTIN_GENERATOR
void Builtins::Generate_NotifyICMiss(MacroAssembler* masm) {
void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) {
// Enter an internal frame.
{
FrameScope scope(masm, StackFrame::INTERNAL);
......@@ -655,7 +655,7 @@ void Builtins::Generate_NotifyICMiss(MacroAssembler* masm) {
// stubs that tail call the runtime on deopts passing their parameters in
// registers.
__ Pushad();
__ CallRuntime(Runtime::kNotifyICMiss, 0);
__ CallRuntime(Runtime::kNotifyStubFailure, 0);
__ Popad();
// Tear down internal frame.
}
......
......@@ -44,7 +44,7 @@ void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
isolate->builtins()->KeyedLoadIC_Miss();
FUNCTION_ADDR(KeyedLoadIC_Miss);
}
......
......@@ -454,35 +454,39 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
// FROM TO <-rbp
// | .... | | .... |
// +-------------------------+ +-------------------------+
// | JSFunction continuation | | JSFunction continuation |
// | JSFunction continuation | | parameter 1 |
// +-------------------------+ +-------------------------+
// | | saved frame (rbp) | | .... |
// | +=========================+<-rbp +-------------------------+
// | | JSFunction context | | parameter n |
// v +-------------------------+ +-------------------------|
// | COMPILED_STUB marker | | JSFunction continuation |
// +-------------------------+ +-------------------------+<-rsp
// | | saved frame (rbp) |
// | +=========================+<-rbp
// | | JSFunction context |
// v +-------------------------+
// | COMPILED_STUB marker | rbp = saved frame
// +-------------------------+ rsi = JSFunction context
// | |
// | ... |
// | |
// +-------------------------+<-rsp
// | | rax = number of parameters
// | ... | rbx = failure handler address
// | | rbp = saved frame
// +-------------------------+<-rsp rsi = JSFunction context
//
//
int output_frame_size = 1 * kPointerSize;
FrameDescription* output_frame =
new(output_frame_size) FrameDescription(output_frame_size, 0);
Code* notify_miss =
isolate_->builtins()->builtin(Builtins::kNotifyICMiss);
output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
output_frame->SetContinuation(
reinterpret_cast<intptr_t>(notify_miss->entry()));
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor =
isolate_->code_stub_interface_descriptor(major_key);
Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
int output_frame_size =
(1 + descriptor->register_param_count_) * kPointerSize;
FrameDescription* output_frame =
new(output_frame_size) FrameDescription(output_frame_size, 0);
Code* notify_failure =
isolate_->builtins()->builtin(Builtins::kNotifyStubFailure);
output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS));
output_frame->SetContinuation(
reinterpret_cast<intptr_t>(notify_failure->entry()));
Code* code;
CEntryStub(1, kDontSaveFPRegs).FindCodeInCache(&code, isolate_);
output_frame->SetPc(reinterpret_cast<intptr_t>(code->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
output_frame->SetFrameSlot(0, value);
......@@ -492,20 +496,22 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
value = input_->GetFrameSlot(input_frame_size - 3 * kPointerSize);
output_frame->SetRegister(rsi.code(), value);
Translation::Opcode opcode =
static_cast<Translation::Opcode>(iterator->Next());
ASSERT(opcode == Translation::REGISTER);
USE(opcode);
int input_reg = iterator->Next();
intptr_t input_value = input_->GetRegister(input_reg);
output_frame->SetRegister(rdx.code(), input_value);
int32_t next = iterator->Next();
opcode = static_cast<Translation::Opcode>(next);
ASSERT(opcode == Translation::REGISTER);
input_reg = iterator->Next();
input_value = input_->GetRegister(input_reg);
output_frame->SetRegister(rax.code(), input_value);
int parameter_offset = kPointerSize * descriptor->register_param_count_;
for (int i = 0; i < descriptor->register_param_count_; ++i) {
Translation::Opcode opcode =
static_cast<Translation::Opcode>(iterator->Next());
ASSERT(opcode == Translation::REGISTER);
USE(opcode);
int input_reg = iterator->Next();
intptr_t reg_value = input_->GetRegister(input_reg);
output_frame->SetFrameSlot(parameter_offset, reg_value);
parameter_offset -= kPointerSize;
}
intptr_t handler =
reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_);
output_frame->SetRegister(rax.code(), descriptor->register_param_count_);
output_frame->SetRegister(rbx.code(), handler);
ASSERT(frame_index == 0);
output_[frame_index] = output_frame;
......
......@@ -152,7 +152,7 @@ var knownProblems = {
"LazyRecompile": true,
"ParallelRecompile": true,
"NotifyDeoptimized": true,
"NotifyICMiss": true,
"NotifyStubFailure": true,
"NotifyOSR": true,
"CreateObjectLiteralBoilerplate": true,
"CloneLiteralBoilerplate": true,
......
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