Unify some PlatformCodeStubs.
R=mvstanton@chromium.org Review URL: https://codereview.chromium.org/527933002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23631 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
c54ba398e2
commit
d0c3652d96
@ -811,20 +811,10 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) {
|
||||
__ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r2,
|
||||
r3);
|
||||
if (cc == eq) {
|
||||
StringCompareStub::GenerateFlatAsciiStringEquals(masm,
|
||||
lhs,
|
||||
rhs,
|
||||
r2,
|
||||
r3,
|
||||
r4);
|
||||
StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, r2, r3, r4);
|
||||
} else {
|
||||
StringCompareStub::GenerateCompareFlatAsciiStrings(masm,
|
||||
lhs,
|
||||
rhs,
|
||||
r2,
|
||||
r3,
|
||||
r4,
|
||||
r5);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, r2, r3, r4,
|
||||
r5);
|
||||
}
|
||||
// Never falls through to here.
|
||||
|
||||
@ -865,7 +855,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
|
||||
|
||||
const Register scratch = r1;
|
||||
|
||||
if (save_doubles_ == kSaveFPRegs) {
|
||||
if (save_doubles()) {
|
||||
__ SaveFPRegs(sp, scratch);
|
||||
}
|
||||
const int argument_count = 1;
|
||||
@ -877,7 +867,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
|
||||
__ CallCFunction(
|
||||
ExternalReference::store_buffer_overflow_function(isolate()),
|
||||
argument_count);
|
||||
if (save_doubles_ == kSaveFPRegs) {
|
||||
if (save_doubles()) {
|
||||
__ RestoreFPRegs(sp, scratch);
|
||||
}
|
||||
__ ldm(ia_w, sp, kCallerSaved | pc.bit()); // Also pop pc to get Ret(0).
|
||||
@ -3296,12 +3286,11 @@ void SubStringStub::Generate(MacroAssembler* masm) {
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3) {
|
||||
void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left, Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3) {
|
||||
Register length = scratch1;
|
||||
|
||||
// Compare lengths.
|
||||
@ -3335,13 +3324,9 @@ void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3,
|
||||
Register scratch4) {
|
||||
void StringHelper::GenerateCompareFlatAsciiStrings(
|
||||
MacroAssembler* masm, Register left, Register right, Register scratch1,
|
||||
Register scratch2, Register scratch3, Register scratch4) {
|
||||
Label result_not_equal, compare_lengths;
|
||||
// Find minimum length and length difference.
|
||||
__ ldr(scratch1, FieldMemOperand(left, String::kLengthOffset));
|
||||
@ -3373,14 +3358,9 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateAsciiCharsCompareLoop(
|
||||
MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register length,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Label* chars_not_equal) {
|
||||
void StringHelper::GenerateAsciiCharsCompareLoop(
|
||||
MacroAssembler* masm, Register left, Register right, Register length,
|
||||
Register scratch1, Register scratch2, Label* chars_not_equal) {
|
||||
// Change index to run from -length to -1 by adding length to string
|
||||
// start. This means that loop ends when index reaches zero, which
|
||||
// doesn't need an additional compare.
|
||||
@ -3432,7 +3412,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
|
||||
// Compare flat ASCII strings natively. Remove arguments from stack first.
|
||||
__ IncrementCounter(counters->string_compare_native(), 1, r2, r3);
|
||||
__ add(sp, sp, Operand(2 * kPointerSize));
|
||||
GenerateCompareFlatAsciiStrings(masm, r1, r0, r2, r3, r4, r5);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, r1, r0, r2, r3, r4, r5);
|
||||
|
||||
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
|
||||
// tagged as a small integer.
|
||||
@ -3705,11 +3685,11 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
|
||||
|
||||
// Compare flat ASCII strings. Returns when done.
|
||||
if (equality) {
|
||||
StringCompareStub::GenerateFlatAsciiStringEquals(
|
||||
masm, left, right, tmp1, tmp2, tmp3);
|
||||
StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2,
|
||||
tmp3);
|
||||
} else {
|
||||
StringCompareStub::GenerateCompareFlatAsciiStrings(
|
||||
masm, left, right, tmp1, tmp2, tmp3, tmp4);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
|
||||
tmp3, tmp4);
|
||||
}
|
||||
|
||||
// Handle more complex cases in runtime.
|
||||
|
@ -14,24 +14,6 @@ namespace internal {
|
||||
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 {
|
||||
public:
|
||||
// Generate code for copying a large number of characters. This function
|
||||
@ -58,28 +40,6 @@ class StringHelper : public AllStatic {
|
||||
static void GenerateHashGetHash(MacroAssembler* masm,
|
||||
Register hash);
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
|
||||
};
|
||||
|
||||
|
||||
class SubStringStub: public PlatformCodeStub {
|
||||
public:
|
||||
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
|
||||
|
||||
private:
|
||||
Major MajorKey() const { return SubString; }
|
||||
uint32_t MinorKey() const { return 0; }
|
||||
|
||||
void Generate(MacroAssembler* masm);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class StringCompareStub: public PlatformCodeStub {
|
||||
public:
|
||||
explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
|
||||
|
||||
// Compares two flat ASCII strings and returns result in r0.
|
||||
static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
Register left,
|
||||
@ -89,8 +49,7 @@ class StringCompareStub: public PlatformCodeStub {
|
||||
Register scratch3,
|
||||
Register scratch4);
|
||||
|
||||
// Compares two flat ASCII strings for equality and returns result
|
||||
// in r0.
|
||||
// Compares two flat ASCII strings for equality and returns result in r0.
|
||||
static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
@ -99,10 +58,6 @@ class StringCompareStub: public PlatformCodeStub {
|
||||
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,
|
||||
@ -110,6 +65,8 @@ class StringCompareStub: public PlatformCodeStub {
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Label* chars_not_equal);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
|
||||
};
|
||||
|
||||
|
||||
|
@ -630,11 +630,10 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) {
|
||||
__ IncrementCounter(isolate()->counters()->string_compare_native(), 1, x10,
|
||||
x11);
|
||||
if (cond == eq) {
|
||||
StringCompareStub::GenerateFlatAsciiStringEquals(masm, lhs, rhs,
|
||||
x10, x11, x12);
|
||||
StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, x10, x11, x12);
|
||||
} else {
|
||||
StringCompareStub::GenerateCompareFlatAsciiStrings(masm, lhs, rhs,
|
||||
x10, x11, x12, x13);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, x10, x11, x12,
|
||||
x13);
|
||||
}
|
||||
|
||||
// Never fall through to here.
|
||||
@ -684,7 +683,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
|
||||
saved_fp_regs.Remove(*(masm->FPTmpList()));
|
||||
|
||||
__ PushCPURegList(saved_regs);
|
||||
if (save_doubles_ == kSaveFPRegs) {
|
||||
if (save_doubles()) {
|
||||
__ PushCPURegList(saved_fp_regs);
|
||||
}
|
||||
|
||||
@ -693,7 +692,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
|
||||
__ CallCFunction(
|
||||
ExternalReference::store_buffer_overflow_function(isolate()), 1, 0);
|
||||
|
||||
if (save_doubles_ == kSaveFPRegs) {
|
||||
if (save_doubles()) {
|
||||
__ PopCPURegList(saved_fp_regs);
|
||||
}
|
||||
__ PopCPURegList(saved_regs);
|
||||
@ -3430,11 +3429,10 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
|
||||
|
||||
// Compare flat ASCII strings. Returns when done.
|
||||
if (equality) {
|
||||
StringCompareStub::GenerateFlatAsciiStringEquals(
|
||||
masm, lhs, rhs, x10, x11, x12);
|
||||
StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, x10, x11, x12);
|
||||
} else {
|
||||
StringCompareStub::GenerateCompareFlatAsciiStrings(
|
||||
masm, lhs, rhs, x10, x11, x12, x13);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, x10, x11, x12,
|
||||
x13);
|
||||
}
|
||||
|
||||
// Handle more complex cases in runtime.
|
||||
@ -3851,12 +3849,11 @@ void SubStringStub::Generate(MacroAssembler* masm) {
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3) {
|
||||
void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left, Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3) {
|
||||
DCHECK(!AreAliased(left, right, scratch1, scratch2, scratch3));
|
||||
Register result = x0;
|
||||
Register left_length = scratch1;
|
||||
@ -3893,13 +3890,9 @@ void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3,
|
||||
Register scratch4) {
|
||||
void StringHelper::GenerateCompareFlatAsciiStrings(
|
||||
MacroAssembler* masm, Register left, Register right, Register scratch1,
|
||||
Register scratch2, Register scratch3, Register scratch4) {
|
||||
DCHECK(!AreAliased(left, right, scratch1, scratch2, scratch3, scratch4));
|
||||
Label result_not_equal, compare_lengths;
|
||||
|
||||
@ -3938,14 +3931,9 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateAsciiCharsCompareLoop(
|
||||
MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register length,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Label* chars_not_equal) {
|
||||
void StringHelper::GenerateAsciiCharsCompareLoop(
|
||||
MacroAssembler* masm, Register left, Register right, Register length,
|
||||
Register scratch1, Register scratch2, Label* chars_not_equal) {
|
||||
DCHECK(!AreAliased(left, right, length, scratch1, scratch2));
|
||||
|
||||
// Change index to run from -length to -1 by adding length to string
|
||||
@ -3999,7 +3987,8 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
|
||||
// Compare flat ASCII strings natively. Remove arguments from stack first,
|
||||
// as this function will generate a return.
|
||||
__ IncrementCounter(counters->string_compare_native(), 1, x3, x4);
|
||||
GenerateCompareFlatAsciiStrings(masm, left, right, x12, x13, x14, x15);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, x12, x13,
|
||||
x14, x15);
|
||||
|
||||
__ Bind(&runtime);
|
||||
|
||||
|
@ -14,24 +14,6 @@ namespace internal {
|
||||
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 {
|
||||
public:
|
||||
// TODO(all): These don't seem to be used any more. Delete them.
|
||||
@ -49,7 +31,24 @@ class StringHelper : public AllStatic {
|
||||
Register hash,
|
||||
Register scratch);
|
||||
|
||||
// Compares two flat ASCII strings and returns result in x0.
|
||||
static void GenerateCompareFlatAsciiStrings(
|
||||
MacroAssembler* masm, Register left, Register right, Register scratch1,
|
||||
Register scratch2, Register scratch3, Register scratch4);
|
||||
|
||||
// Compare two flat ASCII strings for equality and returns result in x0.
|
||||
static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, Register left,
|
||||
Register right, Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3);
|
||||
|
||||
private:
|
||||
static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm, Register left,
|
||||
Register right, Register length,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Label* chars_not_equal);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
|
||||
};
|
||||
|
||||
@ -405,55 +404,6 @@ class NameDictionaryLookupStub: public PlatformCodeStub {
|
||||
LookupMode mode_;
|
||||
};
|
||||
|
||||
|
||||
class SubStringStub: public PlatformCodeStub {
|
||||
public:
|
||||
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
|
||||
|
||||
private:
|
||||
Major MajorKey() const { return SubString; }
|
||||
uint32_t MinorKey() const { return 0; }
|
||||
|
||||
void Generate(MacroAssembler* masm);
|
||||
};
|
||||
|
||||
|
||||
class StringCompareStub: public PlatformCodeStub {
|
||||
public:
|
||||
explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
|
||||
|
||||
// Compares two flat ASCII strings and returns result in x0.
|
||||
static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3,
|
||||
Register scratch4);
|
||||
|
||||
// Compare two flat ASCII strings for equality and returns result
|
||||
// in x0.
|
||||
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,
|
||||
Label* chars_not_equal);
|
||||
};
|
||||
|
||||
} } // namespace v8::internal
|
||||
|
||||
#endif // V8_ARM64_CODE_STUBS_ARM64_H_
|
||||
|
@ -2626,6 +2626,53 @@ class ProfileEntryHookStub : public PlatformCodeStub {
|
||||
};
|
||||
|
||||
|
||||
class StoreBufferOverflowStub : public PlatformCodeStub {
|
||||
public:
|
||||
StoreBufferOverflowStub(Isolate* isolate, SaveFPRegsMode save_fp)
|
||||
: PlatformCodeStub(isolate) {
|
||||
minor_key_ = SaveDoublesBits::encode(save_fp == kSaveFPRegs);
|
||||
}
|
||||
|
||||
void Generate(MacroAssembler* masm);
|
||||
|
||||
static void GenerateFixedRegStubsAheadOfTime(Isolate* isolate);
|
||||
virtual bool SometimesSetsUpAFrame() { return false; }
|
||||
|
||||
private:
|
||||
Major MajorKey() const OVERRIDE { return StoreBufferOverflow; }
|
||||
|
||||
bool save_doubles() const { return SaveDoublesBits::decode(minor_key_); }
|
||||
|
||||
class SaveDoublesBits : public BitField<bool, 0, 1> {};
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(StoreBufferOverflowStub);
|
||||
};
|
||||
|
||||
|
||||
class SubStringStub : public PlatformCodeStub {
|
||||
public:
|
||||
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
|
||||
|
||||
private:
|
||||
Major MajorKey() const OVERRIDE { return SubString; }
|
||||
|
||||
void Generate(MacroAssembler* masm);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SubStringStub);
|
||||
};
|
||||
|
||||
|
||||
class StringCompareStub : public PlatformCodeStub {
|
||||
public:
|
||||
explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
|
||||
|
||||
private:
|
||||
virtual Major MajorKey() const { return StringCompare; }
|
||||
|
||||
virtual void Generate(MacroAssembler* masm);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(StringCompareStub);
|
||||
};
|
||||
} } // namespace v8::internal
|
||||
|
||||
#endif // V8_CODE_STUBS_H_
|
||||
|
@ -144,7 +144,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
|
||||
// store the registers in any particular way, but we do have to store and
|
||||
// restore them.
|
||||
__ pushad();
|
||||
if (save_doubles_ == kSaveFPRegs) {
|
||||
if (save_doubles()) {
|
||||
__ sub(esp, Immediate(kDoubleSize * XMMRegister::kMaxNumRegisters));
|
||||
for (int i = 0; i < XMMRegister::kMaxNumRegisters; i++) {
|
||||
XMMRegister reg = XMMRegister::from_code(i);
|
||||
@ -160,7 +160,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
|
||||
__ CallCFunction(
|
||||
ExternalReference::store_buffer_overflow_function(isolate()),
|
||||
argument_count);
|
||||
if (save_doubles_ == kSaveFPRegs) {
|
||||
if (save_doubles()) {
|
||||
for (int i = 0; i < XMMRegister::kMaxNumRegisters; i++) {
|
||||
XMMRegister reg = XMMRegister::from_code(i);
|
||||
__ movsd(reg, Operand(esp, i * kDoubleSize));
|
||||
@ -1754,18 +1754,10 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) {
|
||||
|
||||
// Inline comparison of ASCII strings.
|
||||
if (cc == equal) {
|
||||
StringCompareStub::GenerateFlatAsciiStringEquals(masm,
|
||||
edx,
|
||||
eax,
|
||||
ecx,
|
||||
ebx);
|
||||
StringHelper::GenerateFlatAsciiStringEquals(masm, edx, eax, ecx, ebx);
|
||||
} else {
|
||||
StringCompareStub::GenerateCompareFlatAsciiStrings(masm,
|
||||
edx,
|
||||
eax,
|
||||
ecx,
|
||||
ebx,
|
||||
edi);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx,
|
||||
edi);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
__ Abort(kUnexpectedFallThroughFromStringComparison);
|
||||
@ -3196,11 +3188,10 @@ void SubStringStub::Generate(MacroAssembler* masm) {
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2) {
|
||||
void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left, Register right,
|
||||
Register scratch1,
|
||||
Register scratch2) {
|
||||
Register length = scratch1;
|
||||
|
||||
// Compare lengths.
|
||||
@ -3232,12 +3223,9 @@ void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3) {
|
||||
void StringHelper::GenerateCompareFlatAsciiStrings(
|
||||
MacroAssembler* masm, Register left, Register right, Register scratch1,
|
||||
Register scratch2, Register scratch3) {
|
||||
Counters* counters = masm->isolate()->counters();
|
||||
__ IncrementCounter(counters->string_compare_native(), 1);
|
||||
|
||||
@ -3298,13 +3286,9 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateAsciiCharsCompareLoop(
|
||||
MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register length,
|
||||
Register scratch,
|
||||
Label* chars_not_equal,
|
||||
void StringHelper::GenerateAsciiCharsCompareLoop(
|
||||
MacroAssembler* masm, Register left, Register right, Register length,
|
||||
Register scratch, Label* chars_not_equal,
|
||||
Label::Distance chars_not_equal_near) {
|
||||
// Change index to run from -length to -1 by adding length to string
|
||||
// start. This means that loop ends when index reaches zero, which
|
||||
@ -3358,7 +3342,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
|
||||
__ pop(ecx);
|
||||
__ add(esp, Immediate(2 * kPointerSize));
|
||||
__ push(ecx);
|
||||
GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi);
|
||||
|
||||
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
|
||||
// tagged as a small integer.
|
||||
@ -3659,11 +3643,10 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
|
||||
|
||||
// Compare flat ASCII strings. Returns when done.
|
||||
if (equality) {
|
||||
StringCompareStub::GenerateFlatAsciiStringEquals(
|
||||
masm, left, right, tmp1, tmp2);
|
||||
StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2);
|
||||
} else {
|
||||
StringCompareStub::GenerateCompareFlatAsciiStrings(
|
||||
masm, left, right, tmp1, tmp2, tmp3);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
|
||||
tmp3);
|
||||
}
|
||||
|
||||
// Handle more complex cases in runtime.
|
||||
|
@ -16,24 +16,6 @@ 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 {
|
||||
public:
|
||||
// Generate code for copying characters using the rep movs instruction.
|
||||
@ -51,45 +33,24 @@ class StringHelper : public AllStatic {
|
||||
Register hash,
|
||||
Register character,
|
||||
Register scratch);
|
||||
|
||||
static void GenerateHashAddCharacter(MacroAssembler* masm,
|
||||
Register hash,
|
||||
Register character,
|
||||
Register scratch);
|
||||
|
||||
static void GenerateHashGetHash(MacroAssembler* masm,
|
||||
Register hash,
|
||||
Register scratch);
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
|
||||
};
|
||||
|
||||
|
||||
class SubStringStub: public PlatformCodeStub {
|
||||
public:
|
||||
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
|
||||
|
||||
private:
|
||||
Major MajorKey() const { return SubString; }
|
||||
uint32_t MinorKey() const { return 0; }
|
||||
|
||||
void Generate(MacroAssembler* masm);
|
||||
};
|
||||
|
||||
|
||||
class StringCompareStub: public PlatformCodeStub {
|
||||
public:
|
||||
explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
|
||||
|
||||
// Compares two flat ASCII strings and returns result in eax.
|
||||
static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register left, Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3);
|
||||
|
||||
// Compares two flat ASCII strings for equality and returns result
|
||||
// in eax.
|
||||
// Compares two flat ASCII strings for equality and returns result in eax.
|
||||
static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
@ -97,10 +58,6 @@ class StringCompareStub: public PlatformCodeStub {
|
||||
Register scratch2);
|
||||
|
||||
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,
|
||||
@ -109,6 +66,8 @@ class StringCompareStub: public PlatformCodeStub {
|
||||
Register scratch,
|
||||
Label* chars_not_equal,
|
||||
Label::Distance chars_not_equal_near = Label::kFar);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
|
||||
};
|
||||
|
||||
|
||||
|
@ -136,7 +136,7 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) {
|
||||
|
||||
|
||||
void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
|
||||
__ PushCallerSaved(save_doubles_);
|
||||
__ PushCallerSaved(save_doubles() ? kSaveFPRegs : kDontSaveFPRegs);
|
||||
const int argument_count = 1;
|
||||
__ PrepareCallCFunction(argument_count);
|
||||
__ LoadAddress(arg_reg_1,
|
||||
@ -146,7 +146,7 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) {
|
||||
__ CallCFunction(
|
||||
ExternalReference::store_buffer_overflow_function(isolate()),
|
||||
argument_count);
|
||||
__ PopCallerSaved(save_doubles_);
|
||||
__ PopCallerSaved(save_doubles() ? kSaveFPRegs : kDontSaveFPRegs);
|
||||
__ ret(0);
|
||||
}
|
||||
|
||||
@ -1624,19 +1624,10 @@ void ICCompareStub::GenerateGeneric(MacroAssembler* masm) {
|
||||
|
||||
// Inline comparison of ASCII strings.
|
||||
if (cc == equal) {
|
||||
StringCompareStub::GenerateFlatAsciiStringEquals(masm,
|
||||
rdx,
|
||||
rax,
|
||||
rcx,
|
||||
rbx);
|
||||
StringHelper::GenerateFlatAsciiStringEquals(masm, rdx, rax, rcx, rbx);
|
||||
} else {
|
||||
StringCompareStub::GenerateCompareFlatAsciiStrings(masm,
|
||||
rdx,
|
||||
rax,
|
||||
rcx,
|
||||
rbx,
|
||||
rdi,
|
||||
r8);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi,
|
||||
r8);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -3143,11 +3134,10 @@ void SubStringStub::Generate(MacroAssembler* masm) {
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2) {
|
||||
void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left, Register right,
|
||||
Register scratch1,
|
||||
Register scratch2) {
|
||||
Register length = scratch1;
|
||||
|
||||
// Compare lengths.
|
||||
@ -3184,13 +3174,9 @@ void StringCompareStub::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3,
|
||||
Register scratch4) {
|
||||
void StringHelper::GenerateCompareFlatAsciiStrings(
|
||||
MacroAssembler* masm, Register left, Register right, Register scratch1,
|
||||
Register scratch2, Register scratch3, Register scratch4) {
|
||||
// Ensure that you can always subtract a string length from a non-negative
|
||||
// number (e.g. another length).
|
||||
STATIC_ASSERT(String::kMaxLength < 0x7fffffff);
|
||||
@ -3258,14 +3244,9 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
|
||||
void StringCompareStub::GenerateAsciiCharsCompareLoop(
|
||||
MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register length,
|
||||
Register scratch,
|
||||
Label* chars_not_equal,
|
||||
Label::Distance near_jump) {
|
||||
void StringHelper::GenerateAsciiCharsCompareLoop(
|
||||
MacroAssembler* masm, Register left, Register right, Register length,
|
||||
Register scratch, Label* chars_not_equal, Label::Distance near_jump) {
|
||||
// Change index to run from -length to -1 by adding length to string
|
||||
// start. This means that loop ends when index reaches zero, which
|
||||
// doesn't need an additional compare.
|
||||
@ -3320,7 +3301,8 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
|
||||
__ PopReturnAddressTo(rcx);
|
||||
__ addp(rsp, Immediate(2 * kPointerSize));
|
||||
__ PushReturnAddressFrom(rcx);
|
||||
GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi,
|
||||
r8);
|
||||
|
||||
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
|
||||
// tagged as a small integer.
|
||||
@ -3607,11 +3589,10 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
|
||||
|
||||
// Compare flat ASCII strings. Returns when done.
|
||||
if (equality) {
|
||||
StringCompareStub::GenerateFlatAsciiStringEquals(
|
||||
masm, left, right, tmp1, tmp2);
|
||||
StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2);
|
||||
} else {
|
||||
StringCompareStub::GenerateCompareFlatAsciiStrings(
|
||||
masm, left, right, tmp1, tmp2, tmp3, kScratchRegister);
|
||||
StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
|
||||
tmp3, kScratchRegister);
|
||||
}
|
||||
|
||||
// Handle more complex cases in runtime.
|
||||
|
@ -13,23 +13,6 @@ namespace internal {
|
||||
|
||||
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 {
|
||||
public:
|
||||
@ -48,46 +31,22 @@ class StringHelper : public AllStatic {
|
||||
Register hash,
|
||||
Register character,
|
||||
Register scratch);
|
||||
|
||||
static void GenerateHashAddCharacter(MacroAssembler* masm,
|
||||
Register hash,
|
||||
Register character,
|
||||
Register scratch);
|
||||
|
||||
static void GenerateHashGetHash(MacroAssembler* masm,
|
||||
Register hash,
|
||||
Register scratch);
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
|
||||
};
|
||||
|
||||
|
||||
class SubStringStub: public PlatformCodeStub {
|
||||
public:
|
||||
explicit SubStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
|
||||
|
||||
private:
|
||||
Major MajorKey() const { return SubString; }
|
||||
uint32_t MinorKey() const { return 0; }
|
||||
|
||||
void Generate(MacroAssembler* masm);
|
||||
};
|
||||
|
||||
|
||||
class StringCompareStub: public PlatformCodeStub {
|
||||
public:
|
||||
explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
|
||||
|
||||
// Compares two flat ASCII strings and returns result in rax.
|
||||
static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
Register scratch1,
|
||||
Register scratch2,
|
||||
Register scratch3,
|
||||
Register scratch4);
|
||||
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 rax.
|
||||
// Compares two flat ASCII strings for equality and returns result in rax.
|
||||
static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
|
||||
Register left,
|
||||
Register right,
|
||||
@ -95,10 +54,6 @@ class StringCompareStub: public PlatformCodeStub {
|
||||
Register scratch2);
|
||||
|
||||
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,
|
||||
@ -107,6 +62,8 @@ class StringCompareStub: public PlatformCodeStub {
|
||||
Register scratch,
|
||||
Label* chars_not_equal,
|
||||
Label::Distance near_jump = Label::kFar);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user