Chromium Code Reviews| Index: src/mips/builtins-mips.cc |
| diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc |
| index 600764ac4eba1235c6886055f703d4ab256d2b2e..40f62c0f769240daa0768d3406a047503616829c 100644 |
| --- a/src/mips/builtins-mips.cc |
| +++ b/src/mips/builtins-mips.cc |
| @@ -1659,6 +1659,21 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { |
| // static |
| +void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
| + // ----------- S t a t e ------------- |
| + // -- a0 : the number of arguments (not including the receiver) |
| + // -- a1 : the constructor to call (checked to be a JSFunctionProxy) |
| + // -- a3 : the original constructor (either the same as the constructor or |
| + // the JSFunction on which new was invoked initially) |
| + // ----------------------------------- |
| + |
| + // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| + __ lw(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset)); |
| + __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| +} |
| + |
| + |
| +// static |
| void Builtins::Generate_Construct(MacroAssembler* masm) { |
| // ----------- S t a t e ------------- |
| // -- a0 : the number of arguments (not including the receiver) |
| @@ -1667,36 +1682,36 @@ void Builtins::Generate_Construct(MacroAssembler* masm) { |
| // the JSFunction on which new was invoked initially) |
| // ----------------------------------- |
| - Label non_callable, non_function; |
| - __ JumpIfSmi(a1, &non_callable); |
| - __ GetObjectType(a1, t1, t2); |
| + // Check if target has a [[Construct]] internal method. |
| + Label non_constructor; |
| + __ JumpIfSmi(a1, &non_constructor); |
| + __ lw(t1, FieldMemOperand(t1, HeapObject::kMapOffset)); |
|
paul.l...
2015/09/24 05:28:20
Benedikt - looks like this should load from (a1, H
|
| + __ lbu(t2, FieldMemOperand(t1, Map::kBitFieldOffset)); |
| + __ And(t2, t2, Operand(1 << Map::kIsCallable)); |
| + __ Branch(&non_constructor, eq, t2, Operand(zero_reg)); |
| + |
| + // Dispatch based on instance type. |
| + __ lbu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset)); |
| __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
| RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); |
| - __ Branch(&non_function, ne, t2, Operand(JS_FUNCTION_PROXY_TYPE)); |
| - |
| - // 1. Construct of function proxy. |
| - // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| - __ lw(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset)); |
| - __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| + __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, |
| + eq, t2, Operand(JS_FUNCTION_PROXY_TYPE)); |
| - // 2. Construct of something that else, which might have a [[Construct]] |
| - // internal method (if not we raise an exception). |
| - __ bind(&non_function); |
| - // Check if target has a [[Call]] internal method. |
| - // TODO(bmeurer): This shoud use IsConstructor once available. |
| - __ lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); |
| - __ And(t1, t1, Operand(1 << Map::kIsCallable)); |
| - __ Branch(&non_callable, eq, t1, Operand(zero_reg)); |
| - // Overwrite the original receiver with the (original) target. |
| - __ sll(at, a0, kPointerSizeLog2); |
| - __ addu(at, sp, at); |
| - __ sw(a1, MemOperand(at)); |
| - // Let the "call_as_constructor_delegate" take care of the rest. |
| - __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1); |
| - __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); |
| + // Called Construct on an exotic Object with a [[Construct]] internal method. |
| + { |
| + // Overwrite the original receiver with the (original) target. |
| + __ sll(at, a0, kPointerSizeLog2); |
| + __ addu(at, sp, at); |
| + __ sw(a1, MemOperand(at)); |
| + // Let the "call_as_constructor_delegate" take care of the rest. |
| + __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1); |
| + __ Jump(masm->isolate()->builtins()->CallFunction(), |
| + RelocInfo::CODE_TARGET); |
| + } |
| - // 3. Construct of something that is not callable. |
| - __ bind(&non_callable); |
| + // Called Construct on an Object that doesn't have a [[Construct]] internal |
| + // method. |
| + __ bind(&non_constructor); |
| { |
| FrameScope scope(masm, StackFrame::INTERNAL); |
| __ Push(a1); |