X87: [stubs] Introduce ToNameStub to implement %_ToName.
port a0878333de4dd090f9d8987e1698a9eef9cc7219(r33460) original commit message: We already had hand-written optimized code for %_ToName in fullcodegen, but the optimizing compilers always went to the runtime for %_ToName, which is pretty bad for many of our builtins. So this CL moves the existing native code to a ToNameStub (similar to the existing ToStringStub), and uses the ToNameStub consistently in all compilers to actually implement %_ToName. BUG= Review URL: https://codereview.chromium.org/1622793006 Cr-Commit-Position: refs/heads/master@{#33483}
This commit is contained in:
parent
22445627e8
commit
f55b66ca38
@ -3409,27 +3409,6 @@ void FullCodeGenerator::EmitToInteger(CallRuntime* expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FullCodeGenerator::EmitToName(CallRuntime* expr) {
|
|
||||||
ZoneList<Expression*>* args = expr->arguments();
|
|
||||||
DCHECK_EQ(1, args->length());
|
|
||||||
|
|
||||||
// Load the argument into eax and convert it.
|
|
||||||
VisitForAccumulatorValue(args->at(0));
|
|
||||||
|
|
||||||
// Convert the object to a name.
|
|
||||||
Label convert, done_convert;
|
|
||||||
__ JumpIfSmi(eax, &convert, Label::kNear);
|
|
||||||
STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE);
|
|
||||||
__ CmpObjectType(eax, LAST_NAME_TYPE, ecx);
|
|
||||||
__ j(below_equal, &done_convert, Label::kNear);
|
|
||||||
__ bind(&convert);
|
|
||||||
__ Push(eax);
|
|
||||||
__ CallRuntime(Runtime::kToName);
|
|
||||||
__ bind(&done_convert);
|
|
||||||
context()->Plug(eax);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) {
|
void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) {
|
||||||
ZoneList<Expression*>* args = expr->arguments();
|
ZoneList<Expression*>* args = expr->arguments();
|
||||||
DCHECK(args->length() == 1);
|
DCHECK(args->length() == 1);
|
||||||
|
@ -2868,6 +2868,42 @@ void ToStringStub::Generate(MacroAssembler* masm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToNameStub::Generate(MacroAssembler* masm) {
|
||||||
|
// The ToName stub takes one argument in eax.
|
||||||
|
Label is_number;
|
||||||
|
__ JumpIfSmi(eax, &is_number, Label::kNear);
|
||||||
|
|
||||||
|
Label not_name;
|
||||||
|
STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE);
|
||||||
|
__ CmpObjectType(eax, LAST_NAME_TYPE, edi);
|
||||||
|
// eax: receiver
|
||||||
|
// edi: receiver map
|
||||||
|
__ j(above, ¬_name, Label::kNear);
|
||||||
|
__ Ret();
|
||||||
|
__ bind(¬_name);
|
||||||
|
|
||||||
|
Label not_heap_number;
|
||||||
|
__ CompareMap(eax, masm->isolate()->factory()->heap_number_map());
|
||||||
|
__ j(not_equal, ¬_heap_number, Label::kNear);
|
||||||
|
__ bind(&is_number);
|
||||||
|
NumberToStringStub stub(isolate());
|
||||||
|
__ TailCallStub(&stub);
|
||||||
|
__ bind(¬_heap_number);
|
||||||
|
|
||||||
|
Label not_oddball;
|
||||||
|
__ CmpInstanceType(edi, ODDBALL_TYPE);
|
||||||
|
__ j(not_equal, ¬_oddball, Label::kNear);
|
||||||
|
__ mov(eax, FieldOperand(eax, Oddball::kToStringOffset));
|
||||||
|
__ Ret();
|
||||||
|
__ bind(¬_oddball);
|
||||||
|
|
||||||
|
__ pop(ecx); // Pop return address.
|
||||||
|
__ push(eax); // Push argument.
|
||||||
|
__ push(ecx); // Push return address.
|
||||||
|
__ TailCallRuntime(Runtime::kToName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
|
void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
|
||||||
Register left,
|
Register left,
|
||||||
Register right,
|
Register right,
|
||||||
|
@ -118,6 +118,10 @@ const Register ToLengthDescriptor::ReceiverRegister() { return eax; }
|
|||||||
const Register ToStringDescriptor::ReceiverRegister() { return eax; }
|
const Register ToStringDescriptor::ReceiverRegister() { return eax; }
|
||||||
|
|
||||||
|
|
||||||
|
// static
|
||||||
|
const Register ToNameDescriptor::ReceiverRegister() { return eax; }
|
||||||
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
const Register ToObjectDescriptor::ReceiverRegister() { return eax; }
|
const Register ToObjectDescriptor::ReceiverRegister() { return eax; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user