Chromium Code Reviews| Index: src/mips/builtins-mips.cc |
| diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc |
| index d06fc8c88a76a8a1358e717dc4b67c6082097688..dc8d180d95a51138085bf9054f53d07c27904bd1 100644 |
| --- a/src/mips/builtins-mips.cc |
| +++ b/src/mips/builtins-mips.cc |
| @@ -425,7 +425,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 |
| @@ -684,6 +685,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
Sorry, I figured out that I don't have to pass an
balazs.kilvady
2016/01/15 13:59:44
Done.
|
| + __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); |
| + } |
| + __ bind(&dont_throw); |
| + } |
| + |
| __ sll(t0, a1, kPointerSizeLog2 - 1); |
| __ Addu(sp, sp, t0); |
| __ Addu(sp, sp, kPointerSize); |
| @@ -695,23 +710,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); |
| } |