Commit 43ef9bc6 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [builtins] One runtime fallback is enough for the String constructor.

  port 34b7b21d (r32000)

  original commit message:
  If inline allocation fails, we can just use the %NewObject fallback,
  which will do the right thing. We don't need a dedicated fallback to
  %AllocateInNewSpace.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32002}
parent 1dcf534c
...@@ -1407,22 +1407,19 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { ...@@ -1407,22 +1407,19 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
__ bind(&done_convert); __ bind(&done_convert);
} }
// 3. Allocate a JSValue wrapper for the string. // 3. Check if original constructor and constructor differ.
Label new_object;
__ cmp(edx, edi);
__ j(not_equal, &new_object);
// 4. Allocate a JSValue wrapper for the string.
{ {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- ebx : the first argument // -- ebx : the first argument
// -- edi : constructor function // -- edi : constructor function
// -- edx : original constructor // -- edx : original constructor
// ----------------------------------- // -----------------------------------
__ Allocate(JSValue::kSize, eax, ecx, no_reg, &new_object, TAG_OBJECT);
Label allocate, done_allocate, rt_call;
// Fall back to runtime if the original constructor and constructor differ.
__ cmp(edx, edi);
__ j(not_equal, &rt_call);
__ Allocate(JSValue::kSize, eax, ecx, no_reg, &allocate, TAG_OBJECT);
__ bind(&done_allocate);
// Initialize the JSValue in eax. // Initialize the JSValue in eax.
__ LoadGlobalFunctionInitialMap(edi, ecx); __ LoadGlobalFunctionInitialMap(edi, ecx);
...@@ -1434,35 +1431,19 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { ...@@ -1434,35 +1431,19 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
__ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx);
STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize);
__ Ret(); __ Ret();
}
// Fallback to the runtime to allocate in new space. // 5. Fallback to the runtime to create new object.
__ bind(&allocate); __ bind(&new_object);
{ {
FrameScope scope(masm, StackFrame::INTERNAL); FrameScope scope(masm, StackFrame::INTERNAL);
__ Push(ebx); __ Push(ebx); // the first argument
__ Push(edi); __ Push(edi); // constructor function
__ Push(Smi::FromInt(JSValue::kSize)); __ Push(edx); // original constructor
__ CallRuntime(Runtime::kAllocateInNewSpace, 1); __ CallRuntime(Runtime::kNewObject, 2);
__ Pop(edi); __ Pop(FieldOperand(eax, JSValue::kValueOffset));
__ Pop(ebx);
}
__ jmp(&done_allocate);
// Fallback to the runtime to create new object.
__ bind(&rt_call);
{
FrameScope scope(masm, StackFrame::INTERNAL);
__ Push(ebx);
__ Push(edi);
__ Push(edi); // constructor function
__ Push(edx); // original constructor
__ CallRuntime(Runtime::kNewObject, 2);
__ Pop(edi);
__ Pop(ebx);
}
__ mov(FieldOperand(eax, JSValue::kValueOffset), ebx);
__ Ret();
} }
__ Ret();
} }
......
...@@ -804,6 +804,7 @@ class MacroAssembler: public Assembler { ...@@ -804,6 +804,7 @@ class MacroAssembler: public Assembler {
void Push(const Operand& src) { push(src); } void Push(const Operand& src) { push(src); }
void Push(Immediate value) { push(value); } void Push(Immediate value) { push(value); }
void Pop(Register dst) { pop(dst); } void Pop(Register dst) { pop(dst); }
void Pop(const Operand& dst) { pop(dst); }
void PushReturnAddressFrom(Register src) { push(src); } void PushReturnAddressFrom(Register src) { push(src); }
void PopReturnAddressTo(Register dst) { pop(dst); } void PopReturnAddressTo(Register dst) { pop(dst); }
......
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