Commit f55b66ca authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [stubs] Introduce ToNameStub to implement %_ToName.

  port a0878333(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}
parent 22445627
......@@ -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) {
ZoneList<Expression*>* args = expr->arguments();
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, &not_name, Label::kNear);
__ Ret();
__ bind(&not_name);
Label not_heap_number;
__ CompareMap(eax, masm->isolate()->factory()->heap_number_map());
__ j(not_equal, &not_heap_number, Label::kNear);
__ bind(&is_number);
NumberToStringStub stub(isolate());
__ TailCallStub(&stub);
__ bind(&not_heap_number);
Label not_oddball;
__ CmpInstanceType(edi, ODDBALL_TYPE);
__ j(not_equal, &not_oddball, Label::kNear);
__ mov(eax, FieldOperand(eax, Oddball::kToStringOffset));
__ Ret();
__ bind(&not_oddball);
__ pop(ecx); // Pop return address.
__ push(eax); // Push argument.
__ push(ecx); // Push return address.
__ TailCallRuntime(Runtime::kToName);
}
void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
Register left,
Register right,
......
......@@ -118,6 +118,10 @@ const Register ToLengthDescriptor::ReceiverRegister() { return eax; }
const Register ToStringDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return eax; }
......
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