| Index: src/x87/builtins-x87.cc
|
| diff --git a/src/x87/builtins-x87.cc b/src/x87/builtins-x87.cc
|
| index be973c8995de16f1b21739892010ff8878781925..1294eed15def87667e563e9156fe8aa6f15f4d7e 100644
|
| --- a/src/x87/builtins-x87.cc
|
| +++ b/src/x87/builtins-x87.cc
|
| @@ -1251,7 +1251,68 @@ void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
|
| }
|
|
|
|
|
| -void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
|
| +// static
|
| +void Builtins::Generate_StringConstructor(MacroAssembler* masm) {
|
| + // ----------- S t a t e -------------
|
| + // -- eax : number of arguments
|
| + // -- edi : constructor function
|
| + // -- esp[0] : return address
|
| + // -- esp[(argc - n) * 4] : arg[n] (zero-based)
|
| + // -- esp[(argc + 1) * 4] : receiver
|
| + // -----------------------------------
|
| +
|
| + // 1. Load the first argument into eax and get rid of the rest (including the
|
| + // receiver).
|
| + Label no_arguments;
|
| + {
|
| + __ test(eax, eax);
|
| + __ j(zero, &no_arguments, Label::kNear);
|
| + __ mov(ebx, Operand(esp, eax, times_pointer_size, 0));
|
| + __ PopReturnAddressTo(ecx);
|
| + __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
|
| + __ PushReturnAddressFrom(ecx);
|
| + __ mov(eax, ebx);
|
| + }
|
| +
|
| + // 2a. At least one argument, return eax if it's a string, otherwise
|
| + // dispatch to appropriate conversion.
|
| + Label to_string, symbol_descriptive_string;
|
| + {
|
| + __ JumpIfSmi(eax, &to_string, Label::kNear);
|
| + STATIC_ASSERT(FIRST_NONSTRING_TYPE == SYMBOL_TYPE);
|
| + __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx);
|
| + __ j(above, &to_string, Label::kNear);
|
| + __ j(equal, &symbol_descriptive_string, Label::kNear);
|
| + __ Ret();
|
| + }
|
| +
|
| + // 2b. No arguments, return the empty string (and pop the receiver).
|
| + __ bind(&no_arguments);
|
| + {
|
| + __ LoadRoot(eax, Heap::kempty_stringRootIndex);
|
| + __ ret(1 * kPointerSize);
|
| + }
|
| +
|
| + // 3a. Convert eax to a string.
|
| + __ bind(&to_string);
|
| + {
|
| + ToStringStub stub(masm->isolate());
|
| + __ TailCallStub(&stub);
|
| + }
|
| +
|
| + // 3b. Convert symbol in eax to a string.
|
| + __ bind(&symbol_descriptive_string);
|
| + {
|
| + __ PopReturnAddressTo(ecx);
|
| + __ Push(eax);
|
| + __ PushReturnAddressFrom(ecx);
|
| + __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1);
|
| + }
|
| +}
|
| +
|
| +
|
| +// static
|
| +void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
|
| // ----------- S t a t e -------------
|
| // -- eax : number of arguments
|
| // -- edi : constructor function
|
|
|