Index: src/arm/builtins-arm.cc |
diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc |
index 6420e7b7fc6b4f503e6a399cab869b0d63ad45d2..681177163687980a6ea8cd984b11fbb1de4c3fe7 100644 |
--- a/src/arm/builtins-arm.cc |
+++ b/src/arm/builtins-arm.cc |
@@ -1547,19 +1547,38 @@ void Builtins::Generate_CallFunction(MacroAssembler* masm) { |
// -- r0 : the number of arguments (not including the receiver) |
// -- r1 : the function to call (checked to be a JSFunction) |
// ----------------------------------- |
+ // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) |
Label convert, convert_global_proxy, convert_to_object, done_convert; |
__ AssertFunction(r1); |
- // TODO(bmeurer): Throw a TypeError if function's [[FunctionKind]] internal |
- // slot is "classConstructor". |
+ __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
+ { |
+ 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) < |
Benedikt Meurer
2015/11/04 02:56:43
Please use the kFooBitWithinByte trick that we use
Camillo Bruni
2015/11/04 10:47:32
done
|
+ (1 << kBitsPerByte)); |
+ __ ldrb(r3, |
+ FieldMemOperand(r2, SharedFunctionInfo::kFunctionKindByteOffset)); |
+ // Left-shift to account for smi storage in 32bits. |
+ __ tst(r3, Operand(FunctionKind::kClassConstructor << kSmiTagSize)); |
+ __ b(eq, &non_class_constructor); |
+ // Step: 2, If we call a classConstructor Function throw a TypeError. |
+ { |
+ FrameScope frame(masm, StackFrame::INTERNAL); |
+ __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); |
+ } |
+ __ bind(&non_class_constructor); |
+ } |
+ |
// Enter the context of the function; ToObject has to run in the function |
// context, and we also need to take the global proxy from the function |
// context in case of conversion. |
- // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) |
STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == |
SharedFunctionInfo::kStrictModeByteOffset); |
__ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
- __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
// We need to convert the receiver for non-native sloppy mode functions. |
__ ldrb(r3, FieldMemOperand(r2, SharedFunctionInfo::kNativeByteOffset)); |
__ tst(r3, Operand((1 << SharedFunctionInfo::kNativeBitWithinByte) | |