MIPS: Unify some PlatformCodeStubs.

Port r23631 (87d82e2)

BUG=
R=dusan.milosavljevic@imgtec.com

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23654 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 01b9f4e2
...@@ -875,20 +875,10 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) { ...@@ -875,20 +875,10 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) {
__ IncrementCounter(isolate()->counters()->string_compare_native(), 1, a2, __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, a2,
a3); a3);
if (cc == eq) { if (cc == eq) {
StringCompareStub::GenerateFlatAsciiStringEquals(masm, StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, a2, a3, t0);
lhs,
rhs,
a2,
a3,
t0);
} else { } else {
StringCompareStub::GenerateCompareFlatAsciiStrings(masm, StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, a2, a3, t0,
lhs, t1);
rhs,
a2,
a3,
t0,
t1);
} }
// Never falls through to here. // Never falls through to here.
...@@ -943,7 +933,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { ...@@ -943,7 +933,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
// store the registers in any particular way, but we do have to store and // store the registers in any particular way, but we do have to store and
// restore them. // restore them.
__ MultiPush(kJSCallerSaved | ra.bit()); __ MultiPush(kJSCallerSaved | ra.bit());
if (save_doubles_ == kSaveFPRegs) { if (save_doubles()) {
__ MultiPushFPU(kCallerSavedFPU); __ MultiPushFPU(kCallerSavedFPU);
} }
const int argument_count = 1; const int argument_count = 1;
...@@ -956,7 +946,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { ...@@ -956,7 +946,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
__ CallCFunction( __ CallCFunction(
ExternalReference::store_buffer_overflow_function(isolate()), ExternalReference::store_buffer_overflow_function(isolate()),
argument_count); argument_count);
if (save_doubles_ == kSaveFPRegs) { if (save_doubles()) {
__ MultiPopFPU(kCallerSavedFPU); __ MultiPopFPU(kCallerSavedFPU);
} }
...@@ -3467,12 +3457,11 @@ void SubStringStub::Generate(MacroAssembler* masm) { ...@@ -3467,12 +3457,11 @@ void SubStringStub::Generate(MacroAssembler* masm) {
} }
void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm, void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
Register left, Register left, Register right,
Register right, Register scratch1,
Register scratch1, Register scratch2,
Register scratch2, Register scratch3) {
Register scratch3) {
Register length = scratch1; Register length = scratch1;
// Compare lengths. // Compare lengths.
...@@ -3507,13 +3496,9 @@ void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm, ...@@ -3507,13 +3496,9 @@ void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
} }
void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, void StringHelper::GenerateCompareFlatAsciiStrings(
Register left, MacroAssembler* masm, Register left, Register right, Register scratch1,
Register right, Register scratch2, Register scratch3, Register scratch4) {
Register scratch1,
Register scratch2,
Register scratch3,
Register scratch4) {
Label result_not_equal, compare_lengths; Label result_not_equal, compare_lengths;
// Find minimum length and length difference. // Find minimum length and length difference.
__ lw(scratch1, FieldMemOperand(left, String::kLengthOffset)); __ lw(scratch1, FieldMemOperand(left, String::kLengthOffset));
...@@ -3552,14 +3537,9 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, ...@@ -3552,14 +3537,9 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
} }
void StringCompareStub::GenerateAsciiCharsCompareLoop( void StringHelper::GenerateAsciiCharsCompareLoop(
MacroAssembler* masm, MacroAssembler* masm, Register left, Register right, Register length,
Register left, Register scratch1, Register scratch2, Register scratch3,
Register right,
Register length,
Register scratch1,
Register scratch2,
Register scratch3,
Label* chars_not_equal) { Label* chars_not_equal) {
// Change index to run from -length to -1 by adding length to string // Change index to run from -length to -1 by adding length to string
// start. This means that loop ends when index reaches zero, which // start. This means that loop ends when index reaches zero, which
...@@ -3613,7 +3593,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) { ...@@ -3613,7 +3593,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
// Compare flat ASCII strings natively. Remove arguments from stack first. // Compare flat ASCII strings natively. Remove arguments from stack first.
__ IncrementCounter(counters->string_compare_native(), 1, a2, a3); __ IncrementCounter(counters->string_compare_native(), 1, a2, a3);
__ Addu(sp, sp, Operand(2 * kPointerSize)); __ Addu(sp, sp, Operand(2 * kPointerSize));
GenerateCompareFlatAsciiStrings(masm, a1, a0, a2, a3, t0, t1); StringHelper::GenerateCompareFlatAsciiStrings(masm, a1, a0, a2, a3, t0, t1);
__ bind(&runtime); __ bind(&runtime);
__ TailCallRuntime(Runtime::kStringCompare, 2, 1); __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
...@@ -3913,11 +3893,11 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) { ...@@ -3913,11 +3893,11 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
// Compare flat ASCII strings. Returns when done. // Compare flat ASCII strings. Returns when done.
if (equality) { if (equality) {
StringCompareStub::GenerateFlatAsciiStringEquals( StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2,
masm, left, right, tmp1, tmp2, tmp3); tmp3);
} else { } else {
StringCompareStub::GenerateCompareFlatAsciiStrings( StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
masm, left, right, tmp1, tmp2, tmp3, tmp4); tmp3, tmp4);
} }
// Handle more complex cases in runtime. // Handle more complex cases in runtime.
......
...@@ -15,24 +15,6 @@ namespace internal { ...@@ -15,24 +15,6 @@ namespace internal {
void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code); void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code);
class StoreBufferOverflowStub: public PlatformCodeStub {
public:
StoreBufferOverflowStub(Isolate* isolate, SaveFPRegsMode save_fp)
: PlatformCodeStub(isolate), save_doubles_(save_fp) {}
void Generate(MacroAssembler* masm);
static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate);
virtual bool SometimesSetsUpAFrame() { return false; }
private:
SaveFPRegsMode save_doubles_;
Major MajorKey() const { return StoreBufferOverflow; }
uint32_t MinorKey() const { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
};
class StringHelper : public AllStatic { class StringHelper : public AllStatic {
public: public:
// Generate code for copying a large number of characters. This function // Generate code for copying a large number of characters. This function
...@@ -59,20 +41,34 @@ class StringHelper : public AllStatic { ...@@ -59,20 +41,34 @@ class StringHelper : public AllStatic {
static void GenerateHashGetHash(MacroAssembler* masm, static void GenerateHashGetHash(MacroAssembler* masm,
Register hash); Register hash);
private: // Compare two flat ASCII strings and returns result in v0.
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
}; Register left,
Register right,
Register scratch1,
Register scratch2,
Register scratch3,
Register scratch4);
class SubStringStub: public PlatformCodeStub { // Compares two flat ASCII strings for equality and returns result in v0.
public: static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {} Register left,
Register right,
Register scratch1,
Register scratch2,
Register scratch3);
private: private:
Major MajorKey() const { return SubString; } static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm,
uint32_t MinorKey() const { return 0; } Register left,
Register right,
Register length,
Register scratch1,
Register scratch2,
Register scratch3,
Label* chars_not_equal);
void Generate(MacroAssembler* masm); DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
}; };
...@@ -102,43 +98,6 @@ class RestoreRegistersStateStub: public PlatformCodeStub { ...@@ -102,43 +98,6 @@ class RestoreRegistersStateStub: public PlatformCodeStub {
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
}; };
class StringCompareStub: public PlatformCodeStub {
public:
explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
// Compare two flat ASCII strings and returns result in v0.
static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
Register left,
Register right,
Register scratch1,
Register scratch2,
Register scratch3,
Register scratch4);
// Compares two flat ASCII strings for equality and returns result
// in v0.
static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
Register left,
Register right,
Register scratch1,
Register scratch2,
Register scratch3);
private:
virtual Major MajorKey() const { return StringCompare; }
virtual uint32_t MinorKey() const { return 0; }
virtual void Generate(MacroAssembler* masm);
static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm,
Register left,
Register right,
Register length,
Register scratch1,
Register scratch2,
Register scratch3,
Label* chars_not_equal);
};
// This stub can convert a signed int32 to a heap number (double). It does // This stub can convert a signed int32 to a heap number (double). It does
// not work for int32s that are in Smi range! No GC occurs during this stub // not work for int32s that are in Smi range! No GC occurs during this stub
......
...@@ -868,20 +868,10 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) { ...@@ -868,20 +868,10 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) {
__ IncrementCounter(isolate()->counters()->string_compare_native(), 1, a2, __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, a2,
a3); a3);
if (cc == eq) { if (cc == eq) {
StringCompareStub::GenerateFlatAsciiStringEquals(masm, StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, a2, a3, a4);
lhs,
rhs,
a2,
a3,
a4);
} else { } else {
StringCompareStub::GenerateCompareFlatAsciiStrings(masm, StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, a2, a3, a4,
lhs, a5);
rhs,
a2,
a3,
a4,
a5);
} }
// Never falls through to here. // Never falls through to here.
...@@ -936,7 +926,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { ...@@ -936,7 +926,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
// store the registers in any particular way, but we do have to store and // store the registers in any particular way, but we do have to store and
// restore them. // restore them.
__ MultiPush(kJSCallerSaved | ra.bit()); __ MultiPush(kJSCallerSaved | ra.bit());
if (save_doubles_ == kSaveFPRegs) { if (save_doubles()) {
__ MultiPushFPU(kCallerSavedFPU); __ MultiPushFPU(kCallerSavedFPU);
} }
const int argument_count = 1; const int argument_count = 1;
...@@ -949,7 +939,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { ...@@ -949,7 +939,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
__ CallCFunction( __ CallCFunction(
ExternalReference::store_buffer_overflow_function(isolate()), ExternalReference::store_buffer_overflow_function(isolate()),
argument_count); argument_count);
if (save_doubles_ == kSaveFPRegs) { if (save_doubles()) {
__ MultiPopFPU(kCallerSavedFPU); __ MultiPopFPU(kCallerSavedFPU);
} }
...@@ -3502,12 +3492,11 @@ void SubStringStub::Generate(MacroAssembler* masm) { ...@@ -3502,12 +3492,11 @@ void SubStringStub::Generate(MacroAssembler* masm) {
} }
void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm, void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
Register left, Register left, Register right,
Register right, Register scratch1,
Register scratch1, Register scratch2,
Register scratch2, Register scratch3) {
Register scratch3) {
Register length = scratch1; Register length = scratch1;
// Compare lengths. // Compare lengths.
...@@ -3542,13 +3531,9 @@ void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm, ...@@ -3542,13 +3531,9 @@ void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
} }
void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, void StringHelper::GenerateCompareFlatAsciiStrings(
Register left, MacroAssembler* masm, Register left, Register right, Register scratch1,
Register right, Register scratch2, Register scratch3, Register scratch4) {
Register scratch1,
Register scratch2,
Register scratch3,
Register scratch4) {
Label result_not_equal, compare_lengths; Label result_not_equal, compare_lengths;
// Find minimum length and length difference. // Find minimum length and length difference.
__ ld(scratch1, FieldMemOperand(left, String::kLengthOffset)); __ ld(scratch1, FieldMemOperand(left, String::kLengthOffset));
...@@ -3587,14 +3572,9 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, ...@@ -3587,14 +3572,9 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
} }
void StringCompareStub::GenerateAsciiCharsCompareLoop( void StringHelper::GenerateAsciiCharsCompareLoop(
MacroAssembler* masm, MacroAssembler* masm, Register left, Register right, Register length,
Register left, Register scratch1, Register scratch2, Register scratch3,
Register right,
Register length,
Register scratch1,
Register scratch2,
Register scratch3,
Label* chars_not_equal) { Label* chars_not_equal) {
// Change index to run from -length to -1 by adding length to string // Change index to run from -length to -1 by adding length to string
// start. This means that loop ends when index reaches zero, which // start. This means that loop ends when index reaches zero, which
...@@ -3648,7 +3628,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) { ...@@ -3648,7 +3628,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
// Compare flat ASCII strings natively. Remove arguments from stack first. // Compare flat ASCII strings natively. Remove arguments from stack first.
__ IncrementCounter(counters->string_compare_native(), 1, a2, a3); __ IncrementCounter(counters->string_compare_native(), 1, a2, a3);
__ Daddu(sp, sp, Operand(2 * kPointerSize)); __ Daddu(sp, sp, Operand(2 * kPointerSize));
GenerateCompareFlatAsciiStrings(masm, a1, a0, a2, a3, a4, a5); StringHelper::GenerateCompareFlatAsciiStrings(masm, a1, a0, a2, a3, a4, a5);
__ bind(&runtime); __ bind(&runtime);
__ TailCallRuntime(Runtime::kStringCompare, 2, 1); __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
...@@ -3948,11 +3928,11 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) { ...@@ -3948,11 +3928,11 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
// Compare flat ASCII strings. Returns when done. // Compare flat ASCII strings. Returns when done.
if (equality) { if (equality) {
StringCompareStub::GenerateFlatAsciiStringEquals( StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2,
masm, left, right, tmp1, tmp2, tmp3); tmp3);
} else { } else {
StringCompareStub::GenerateCompareFlatAsciiStrings( StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
masm, left, right, tmp1, tmp2, tmp3, tmp4); tmp3, tmp4);
} }
// Handle more complex cases in runtime. // Handle more complex cases in runtime.
......
...@@ -15,24 +15,6 @@ namespace internal { ...@@ -15,24 +15,6 @@ namespace internal {
void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code); void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code);
class StoreBufferOverflowStub: public PlatformCodeStub {
public:
StoreBufferOverflowStub(Isolate* isolate, SaveFPRegsMode save_fp)
: PlatformCodeStub(isolate), save_doubles_(save_fp) {}
void Generate(MacroAssembler* masm);
static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate);
virtual bool SometimesSetsUpAFrame() { return false; }
private:
SaveFPRegsMode save_doubles_;
Major MajorKey() const { return StoreBufferOverflow; }
uint32_t MinorKey() const { return (save_doubles_ == kSaveFPRegs) ? 1 : 0; }
};
class StringHelper : public AllStatic { class StringHelper : public AllStatic {
public: public:
// Generate code for copying a large number of characters. This function // Generate code for copying a large number of characters. This function
...@@ -58,20 +40,35 @@ class StringHelper : public AllStatic { ...@@ -58,20 +40,35 @@ class StringHelper : public AllStatic {
static void GenerateHashGetHash(MacroAssembler* masm, static void GenerateHashGetHash(MacroAssembler* masm,
Register hash); Register hash);
private: // Compare two flat ASCII strings and returns result in v0.
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
}; Register left,
Register right,
Register scratch1,
Register scratch2,
Register scratch3,
Register scratch4);
class SubStringStub: public PlatformCodeStub { // Compares two flat ASCII strings for equality and returns result in v0.
public: static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {} Register left,
Register right,
Register scratch1,
Register scratch2,
Register scratch3);
private: private:
Major MajorKey() const { return SubString; } static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm,
uint32_t MinorKey() const { return 0; } Register left,
Register right,
Register length,
Register scratch1,
Register scratch2,
Register scratch3,
Label* chars_not_equal);
void Generate(MacroAssembler* masm); private:
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
}; };
...@@ -101,44 +98,6 @@ class RestoreRegistersStateStub: public PlatformCodeStub { ...@@ -101,44 +98,6 @@ class RestoreRegistersStateStub: public PlatformCodeStub {
void Generate(MacroAssembler* masm); void Generate(MacroAssembler* masm);
}; };
class StringCompareStub: public PlatformCodeStub {
public:
explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
// Compare two flat ASCII strings and returns result in v0.
static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
Register left,
Register right,
Register scratch1,
Register scratch2,
Register scratch3,
Register scratch4);
// Compares two flat ASCII strings for equality and returns result
// in v0.
static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
Register left,
Register right,
Register scratch1,
Register scratch2,
Register scratch3);
private:
virtual Major MajorKey() const { return StringCompare; }
virtual uint32_t MinorKey() const { return 0; }
virtual void Generate(MacroAssembler* masm);
static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm,
Register left,
Register right,
Register length,
Register scratch1,
Register scratch2,
Register scratch3,
Label* chars_not_equal);
};
// This stub can convert a signed int32 to a heap number (double). It does // This stub can convert a signed int32 to a heap number (double). It does
// not work for int32s that are in Smi range! No GC occurs during this stub // not work for int32s that are in Smi range! No GC occurs during this stub
// so you don't have to set up the frame. // so you don't have to set up the frame.
......
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