Index: src/arm/builtins-arm.cc |
diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc |
index 0c83f918caa58e45075e2a1b8e384e7dc41810cf..60ed8d0d331d19501b9ab5576f626200ba715671 100644 |
--- a/src/arm/builtins-arm.cc |
+++ b/src/arm/builtins-arm.cc |
@@ -417,7 +417,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 ------------- |
// -- r0 : number of arguments |
// -- r1 : constructor function |
@@ -685,6 +686,19 @@ 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(r0, &dont_throw); |
+ { |
+ FrameScope scope(masm, StackFrame::INTERNAL); |
+ __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); |
+ } |
+ __ bind(&dont_throw); |
+ } |
+ |
__ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); |
__ add(sp, sp, Operand(kPointerSize)); |
if (create_implicit_receiver) { |
@@ -695,17 +709,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, true); |
} |