Index: src/x87/code-stubs-x87.cc |
diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc |
index 0890e9fafc185461420064b934d0c1e495c1a623..1db96051f87df59d03978f1d1d1201c6c093e074 100644 |
--- a/src/x87/code-stubs-x87.cc |
+++ b/src/x87/code-stubs-x87.cc |
@@ -1737,14 +1737,17 @@ static void GenerateRecordCallTarget(MacroAssembler* masm, bool is_super) { |
static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { |
+ // ----------- S t a t e ------------- |
+ // -- edi : the function to call |
+ // -- edx : the function's shared function info |
+ // ----------------------------------- |
// Do not transform the receiver for strict mode functions. |
- __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
- __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), |
+ __ test_b(FieldOperand(edx, SharedFunctionInfo::kStrictModeByteOffset), |
1 << SharedFunctionInfo::kStrictModeBitWithinByte); |
__ j(not_equal, cont); |
// Do not transform the receiver for natives (shared already in ecx). |
- __ test_b(FieldOperand(ecx, SharedFunctionInfo::kNativeByteOffset), |
+ __ test_b(FieldOperand(edx, SharedFunctionInfo::kNativeByteOffset), |
1 << SharedFunctionInfo::kNativeBitWithinByte); |
__ j(not_equal, cont); |
} |
@@ -1769,6 +1772,24 @@ static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { |
} |
+static void EmitClassConstructorCallCheck(MacroAssembler* masm) { |
+ // ----------- S t a t e ------------- |
+ // -- edi : the function to call |
+ // -- edx : 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. |
+ __ test_b(FieldOperand(edx, SharedFunctionInfo::kFunctionKindByteOffset), |
+ SharedFunctionInfo::kClassConstructorBitsWithinByte); |
+ __ j(zero, &non_class_constructor, Label::kNear); |
+ // If we call a classConstructor Function throw a TypeError |
+ // indirectly via the CallFunction builtin. |
+ __ 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) { |
@@ -1784,6 +1805,9 @@ static void CallFunctionNoFeedback(MacroAssembler* masm, |
__ j(not_equal, &slow); |
} |
+ __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
+ EmitClassConstructorCallCheck(masm); |
+ |
// Fast-case: Just invoke the function. |
ParameterCount actual(argc); |
@@ -1956,6 +1980,10 @@ void CallICStub::Generate(MacroAssembler* masm) { |
Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); |
__ bind(&have_js_function); |
+ |
+ __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
+ EmitClassConstructorCallCheck(masm); |
+ |
if (CallAsMethod()) { |
EmitContinueIfStrictOrNative(masm, &cont); |