Eliminate code duplication in lithium calls to vector-based LoadICs

R=verwaest@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23359 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent fb2ac081
...@@ -2990,6 +2990,19 @@ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { ...@@ -2990,6 +2990,19 @@ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
} }
template <class T>
void LCodeGen::EmitVectorLoadICRegisters(T* instr) {
DCHECK(FLAG_vector_ics);
Register vector = ToRegister(instr->temp_vector());
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Move(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(r0));
__ mov(LoadIC::SlotRegister(),
Operand(Smi::FromInt(instr->hydrogen()->slot())));
}
void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->context()).is(cp));
DCHECK(ToRegister(instr->global_object()).is(LoadIC::ReceiverRegister())); DCHECK(ToRegister(instr->global_object()).is(LoadIC::ReceiverRegister()));
...@@ -2997,13 +3010,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { ...@@ -2997,13 +3010,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
__ mov(LoadIC::NameRegister(), Operand(instr->name())); __ mov(LoadIC::NameRegister(), Operand(instr->name()));
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Move(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(r0));
__ mov(LoadIC::SlotRegister(),
Operand(Smi::FromInt(instr->hydrogen()->slot())));
} }
ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL;
Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode); Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode);
...@@ -3126,13 +3133,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { ...@@ -3126,13 +3133,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
// Name is always in r2. // Name is always in r2.
__ mov(LoadIC::NameRegister(), Operand(instr->name())); __ mov(LoadIC::NameRegister(), Operand(instr->name()));
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Move(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(r0));
__ mov(LoadIC::SlotRegister(),
Operand(Smi::FromInt(instr->hydrogen()->slot())));
} }
Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL); Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL);
CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
...@@ -3422,13 +3423,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { ...@@ -3422,13 +3423,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->key()).is(LoadIC::NameRegister())); DCHECK(ToRegister(instr->key()).is(LoadIC::NameRegister()));
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Move(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(r0));
__ mov(LoadIC::SlotRegister(),
Operand(Smi::FromInt(instr->hydrogen()->slot())));
} }
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
......
...@@ -332,6 +332,9 @@ class LCodeGen: public LCodeGenBase { ...@@ -332,6 +332,9 @@ class LCodeGen: public LCodeGenBase {
void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
void DoStoreKeyedFixedArray(LStoreKeyed* instr); void DoStoreKeyedFixedArray(LStoreKeyed* instr);
template <class T>
void EmitVectorLoadICRegisters(T* instr);
ZoneList<LEnvironment*> deoptimizations_; ZoneList<LEnvironment*> deoptimizations_;
ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_; ZoneList<Deoptimizer::JumpTableEntry> deopt_jump_table_;
ZoneList<Handle<Object> > deoptimization_literals_; ZoneList<Handle<Object> > deoptimization_literals_;
......
...@@ -3344,19 +3344,25 @@ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { ...@@ -3344,19 +3344,25 @@ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
} }
template <class T>
void LCodeGen::EmitVectorLoadICRegisters(T* instr) {
DCHECK(FLAG_vector_ics);
Register vector = ToRegister(instr->temp_vector());
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Mov(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(x0));
__ Mov(LoadIC::SlotRegister(), Smi::FromInt(instr->hydrogen()->slot()));
}
void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
DCHECK(ToRegister(instr->context()).is(cp)); DCHECK(ToRegister(instr->context()).is(cp));
DCHECK(ToRegister(instr->global_object()).is(LoadIC::ReceiverRegister())); DCHECK(ToRegister(instr->global_object()).is(LoadIC::ReceiverRegister()));
DCHECK(ToRegister(instr->result()).Is(x0)); DCHECK(ToRegister(instr->result()).Is(x0));
__ Mov(LoadIC::NameRegister(), Operand(instr->name())); __ Mov(LoadIC::NameRegister(), Operand(instr->name()));
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Mov(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(x0));
__ Mov(LoadIC::SlotRegister(),
Smi::FromInt(instr->hydrogen()->slot()));
} }
ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL;
Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode); Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode);
...@@ -3611,13 +3617,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { ...@@ -3611,13 +3617,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->object()).is(LoadIC::ReceiverRegister())); DCHECK(ToRegister(instr->object()).is(LoadIC::ReceiverRegister()));
DCHECK(ToRegister(instr->key()).is(LoadIC::NameRegister())); DCHECK(ToRegister(instr->key()).is(LoadIC::NameRegister()));
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Mov(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(x0));
__ Mov(LoadIC::SlotRegister(),
Smi::FromInt(instr->hydrogen()->slot()));
} }
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
...@@ -3673,13 +3673,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { ...@@ -3673,13 +3673,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
DCHECK(ToRegister(instr->object()).is(LoadIC::ReceiverRegister())); DCHECK(ToRegister(instr->object()).is(LoadIC::ReceiverRegister()));
__ Mov(LoadIC::NameRegister(), Operand(instr->name())); __ Mov(LoadIC::NameRegister(), Operand(instr->name()));
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Mov(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(x0));
__ Mov(LoadIC::SlotRegister(),
Smi::FromInt(instr->hydrogen()->slot()));
} }
Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL); Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL);
......
...@@ -196,6 +196,9 @@ class LCodeGen: public LCodeGenBase { ...@@ -196,6 +196,9 @@ class LCodeGen: public LCodeGenBase {
int* offset, int* offset,
AllocationSiteMode mode); AllocationSiteMode mode);
template <class T>
void EmitVectorLoadICRegisters(T* instr);
// Emits optimized code for %_IsString(x). Preserves input register. // Emits optimized code for %_IsString(x). Preserves input register.
// Returns the condition on which a final split to // Returns the condition on which a final split to
// true and false label should be made, to optimize fallthrough. // true and false label should be made, to optimize fallthrough.
......
...@@ -2828,6 +2828,19 @@ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { ...@@ -2828,6 +2828,19 @@ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
} }
template <class T>
void LCodeGen::EmitVectorLoadICRegisters(T* instr) {
DCHECK(FLAG_vector_ics);
Register vector = ToRegister(instr->temp_vector());
DCHECK(vector.is(LoadIC::VectorRegister()));
__ mov(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(eax));
__ mov(LoadIC::SlotRegister(),
Immediate(Smi::FromInt(instr->hydrogen()->slot())));
}
void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
DCHECK(ToRegister(instr->context()).is(esi)); DCHECK(ToRegister(instr->context()).is(esi));
DCHECK(ToRegister(instr->global_object()).is(LoadIC::ReceiverRegister())); DCHECK(ToRegister(instr->global_object()).is(LoadIC::ReceiverRegister()));
...@@ -2835,13 +2848,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { ...@@ -2835,13 +2848,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
__ mov(LoadIC::NameRegister(), instr->name()); __ mov(LoadIC::NameRegister(), instr->name());
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ mov(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(eax));
__ mov(LoadIC::SlotRegister(),
Immediate(Smi::FromInt(instr->hydrogen()->slot())));
} }
ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL;
Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode); Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode);
...@@ -2978,13 +2985,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { ...@@ -2978,13 +2985,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
__ mov(LoadIC::NameRegister(), instr->name()); __ mov(LoadIC::NameRegister(), instr->name());
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ mov(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(eax));
__ mov(LoadIC::SlotRegister(),
Immediate(Smi::FromInt(instr->hydrogen()->slot())));
} }
Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL); Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL);
CallCode(ic, RelocInfo::CODE_TARGET, instr); CallCode(ic, RelocInfo::CODE_TARGET, instr);
...@@ -3211,13 +3212,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { ...@@ -3211,13 +3212,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->key()).is(LoadIC::NameRegister())); DCHECK(ToRegister(instr->key()).is(LoadIC::NameRegister()));
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ mov(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(eax));
__ mov(LoadIC::SlotRegister(),
Immediate(Smi::FromInt(instr->hydrogen()->slot())));
} }
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
......
...@@ -319,6 +319,9 @@ class LCodeGen: public LCodeGenBase { ...@@ -319,6 +319,9 @@ class LCodeGen: public LCodeGenBase {
void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
void DoStoreKeyedFixedArray(LStoreKeyed* instr); void DoStoreKeyedFixedArray(LStoreKeyed* instr);
template <class T>
void EmitVectorLoadICRegisters(T* instr);
void EmitReturn(LReturn* instr, bool dynamic_frame_alignment); void EmitReturn(LReturn* instr, bool dynamic_frame_alignment);
// Emits code for pushing either a tagged constant, a (non-double) // Emits code for pushing either a tagged constant, a (non-double)
......
...@@ -2846,6 +2846,18 @@ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { ...@@ -2846,6 +2846,18 @@ void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
} }
template <class T>
void LCodeGen::EmitVectorLoadICRegisters(T* instr) {
DCHECK(FLAG_vector_ics);
Register vector = ToRegister(instr->temp_vector());
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Move(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(rax));
__ Move(LoadIC::SlotRegister(), Smi::FromInt(instr->hydrogen()->slot()));
}
void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
DCHECK(ToRegister(instr->context()).is(rsi)); DCHECK(ToRegister(instr->context()).is(rsi));
DCHECK(ToRegister(instr->global_object()).is(LoadIC::ReceiverRegister())); DCHECK(ToRegister(instr->global_object()).is(LoadIC::ReceiverRegister()));
...@@ -2853,12 +2865,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { ...@@ -2853,12 +2865,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
__ Move(LoadIC::NameRegister(), instr->name()); __ Move(LoadIC::NameRegister(), instr->name());
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadGlobalGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Move(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(rax));
__ Move(LoadIC::SlotRegister(), Smi::FromInt(instr->hydrogen()->slot()));
} }
ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL; ContextualMode mode = instr->for_typeof() ? NOT_CONTEXTUAL : CONTEXTUAL;
Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode); Handle<Code> ic = LoadIC::initialize_stub(isolate(), mode);
...@@ -3001,12 +3008,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { ...@@ -3001,12 +3008,7 @@ void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
__ Move(LoadIC::NameRegister(), instr->name()); __ Move(LoadIC::NameRegister(), instr->name());
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadNamedGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Move(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(rax));
__ Move(LoadIC::SlotRegister(), Smi::FromInt(instr->hydrogen()->slot()));
} }
Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL); Handle<Code> ic = LoadIC::initialize_stub(isolate(), NOT_CONTEXTUAL);
CallCode(ic, RelocInfo::CODE_TARGET, instr); CallCode(ic, RelocInfo::CODE_TARGET, instr);
...@@ -3289,12 +3291,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { ...@@ -3289,12 +3291,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->key()).is(LoadIC::NameRegister())); DCHECK(ToRegister(instr->key()).is(LoadIC::NameRegister()));
if (FLAG_vector_ics) { if (FLAG_vector_ics) {
Register vector = ToRegister(instr->temp_vector()); EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
DCHECK(vector.is(LoadIC::VectorRegister()));
__ Move(vector, instr->hydrogen()->feedback_vector());
// No need to allocate this register.
DCHECK(LoadIC::SlotRegister().is(rax));
__ Move(LoadIC::SlotRegister(), Smi::FromInt(instr->hydrogen()->slot()));
} }
Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
......
...@@ -314,6 +314,10 @@ class LCodeGen: public LCodeGenBase { ...@@ -314,6 +314,10 @@ class LCodeGen: public LCodeGenBase {
void DoStoreKeyedExternalArray(LStoreKeyed* instr); void DoStoreKeyedExternalArray(LStoreKeyed* instr);
void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
void DoStoreKeyedFixedArray(LStoreKeyed* instr); void DoStoreKeyedFixedArray(LStoreKeyed* instr);
template <class T>
void EmitVectorLoadICRegisters(T* instr);
#ifdef _MSC_VER #ifdef _MSC_VER
// On windows, you may not access the stack more than one page below // On windows, you may not access the stack more than one page below
// the most recently mapped page. To make the allocated area randomly // the most recently mapped page. To make the allocated area randomly
......
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