Index: src/mips/code-stubs-mips.cc |
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc |
index 3cf1145a1931b4e3cb4136000a86cfe0c68dd1fd..f62112011bcec5d3377acbed69faab58285e62f9 100644 |
--- a/src/mips/code-stubs-mips.cc |
+++ b/src/mips/code-stubs-mips.cc |
@@ -2503,7 +2503,10 @@ static void GenerateRecordCallTarget(MacroAssembler* masm, bool is_super) { |
static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { |
- __ lw(a3, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
+ // ----------- S t a t e ------------- |
+ // -- a1 : the function to call |
+ // -- a3 : the function's shared function info |
+ // ----------------------------------- |
__ lw(t0, FieldMemOperand(a3, SharedFunctionInfo::kCompilerHintsOffset)); |
// Do not transform the receiver for strict mode functions. |
@@ -2536,6 +2539,29 @@ static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { |
} |
+static void EmitClassConstructorCallCheck(MacroAssembler* masm) { |
+ // ----------- S t a t e ------------- |
+ // -- a1 : the function to call |
+ // -- a3 : the function's shared function info |
+ // ----------------------------------- |
+ // ClassConstructor Check: ES6 section 9.2.1 [[Call]] |
+ Label non_class_constructor; |
+ // Check whether the current function is a classConstructor This only works |
+ // since kClassConstructor is more than 1 bit away from the byte boundary in |
+ // CompilerHints (note that compiler_hints is stored as smi on 32bit |
+ // architectures) |
+ STATIC_ASSERT((FunctionKind::kClassConstructor << kSmiTagSize) < |
+ (1 << kBitsPerByte)); |
+ __ lbu(t0, FieldMemOperand(a3, SharedFunctionInfo::kFunctionKindByteOffset)); |
+ // Left-shift to account for smi storage in 32bits. |
+ __ And(at, t0, Operand(FunctionKind::kClassConstructor << kSmiTagSize)); |
+ __ Branch(&non_class_constructor, eq, at, Operand(zero_reg)); |
+ // Step: 2, If we call a classConstructor Function throw a TypeError. |
+ __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); |
+ __ bind(&non_class_constructor); |
+} |
+ |
+ |
static void CallFunctionNoFeedback(MacroAssembler* masm, |
int argc, bool needs_checks, |
bool call_as_method) { |
@@ -2552,6 +2578,9 @@ static void CallFunctionNoFeedback(MacroAssembler* masm, |
__ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); |
} |
+ __ lw(a3, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
+ EmitClassConstructorCallCheck(masm); |
+ |
// Fast-case: Invoke the function now. |
// a1: pushed function |
ParameterCount actual(argc); |
@@ -2719,6 +2748,10 @@ void CallICStub::Generate(MacroAssembler* masm) { |
__ sw(a3, FieldMemOperand(at, FixedArray::kHeaderSize + kPointerSize)); |
__ bind(&have_js_function); |
+ |
+ __ lw(a3, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
+ EmitClassConstructorCallCheck(masm); |
+ |
if (CallAsMethod()) { |
EmitContinueIfStrictOrNative(masm, &cont); |
// Compute the receiver in sloppy mode. |