Chromium Code Reviews| Index: src/mips64/builtins-mips64.cc |
| diff --git a/src/mips64/builtins-mips64.cc b/src/mips64/builtins-mips64.cc |
| index a0bc3d3226ca1f79cb56d5d1ea17cc8a5ddcb9b2..0310173c0360a521ec72c0eeb46255d8d7edeb22 100644 |
| --- a/src/mips64/builtins-mips64.cc |
| +++ b/src/mips64/builtins-mips64.cc |
| @@ -422,7 +422,8 @@ void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
| static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| bool is_api_function, |
| - bool create_implicit_receiver) { |
| + bool create_implicit_receiver, |
| + bool check_derived_construct) { |
| // ----------- S t a t e ------------- |
| // -- a0 : number of arguments |
| // -- a1 : constructor function |
| @@ -677,6 +678,20 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| // Leave construct frame. |
| } |
| + // ES6 9.2.2. Step 13+ |
| + // Check that the result is not a Smi, indicating that the constructor result |
| + // from a derived class is neither undefined nor an Object. |
| + if (check_derived_construct) { |
| + Label dont_throw; |
| + __ JumpIfNotSmi(v0, &dont_throw); |
| + { |
| + FrameScope scope(masm, StackFrame::INTERNAL); |
| + __ push(v0); |
|
Camillo Bruni
2016/01/15 13:51:47
same here ;)
balazs.kilvady
2016/01/15 13:59:44
Done.
|
| + __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); |
| + } |
| + __ bind(&dont_throw); |
| + } |
| + |
| __ SmiScale(a4, a1, kPointerSizeLog2); |
| __ Daddu(sp, sp, a4); |
| __ Daddu(sp, sp, kPointerSize); |
| @@ -688,23 +703,23 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
| - Generate_JSConstructStubHelper(masm, false, true); |
| + Generate_JSConstructStubHelper(masm, false, true, false); |
| } |
| void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
| - Generate_JSConstructStubHelper(masm, true, true); |
| + Generate_JSConstructStubHelper(masm, true, true, false); |
| } |
| void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
| - Generate_JSConstructStubHelper(masm, false, false); |
| + Generate_JSConstructStubHelper(masm, false, false, false); |
| } |
| void Builtins::Generate_JSBuiltinsConstructStubForDerived( |
| MacroAssembler* masm) { |
| - Generate_JSConstructStubHelper(masm, false, false); |
| + Generate_JSConstructStubHelper(masm, false, false, true); |
| } |