Index: src/x64/builtins-x64.cc |
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
index 2e3adb73c566612247f73c3a1fa62c6ebac6623f..885aa12c5e8269e33f44b3c4be80ee03d5f433bc 100644 |
--- a/src/x64/builtins-x64.cc |
+++ b/src/x64/builtins-x64.cc |
@@ -1707,6 +1707,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
// static |
void Builtins::Generate_CallFunction(MacroAssembler* masm) { |
+ // ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) |
// ----------- S t a t e ------------- |
// -- rax : the number of arguments (not including the receiver) |
// -- rdi : the function to call (checked to be a JSFunction) |
@@ -1715,16 +1716,30 @@ void Builtins::Generate_CallFunction(MacroAssembler* masm) { |
Label convert, convert_global_proxy, convert_to_object, done_convert; |
StackArgumentsAccessor args(rsp, rax); |
__ AssertFunction(rdi); |
- // TODO(bmeurer): Throw a TypeError if function's [[FunctionKind]] internal |
- // slot is "classConstructor". |
+ STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == |
Benedikt Meurer
2015/10/22 11:08:05
Move the STATIC_ASSERT to the actual use site.
Camillo Bruni
2015/11/03 16:05:26
done
|
+ SharedFunctionInfo::kStrictModeByteOffset); |
+ |
+ __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
+ { |
+ Label non_classConstructor; |
+ __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
Benedikt Meurer
2015/10/22 11:08:04
No need to load the shared function info twice.
Camillo Bruni
2015/11/03 16:05:26
done
|
+ // Check whether the current function is a classConstructor |
+ __ testb(FieldOperand(rdx, SharedFunctionInfo::kIsArrowByteOffset), |
Benedikt Meurer
2015/10/22 11:08:04
kIsArrowByteOffset is very confusing.
Camillo Bruni
2015/11/03 16:05:26
done
|
+ Immediate(FunctionKind::kClassConstructor)); |
+ __ j(zero, &non_classConstructor); |
Benedikt Meurer
2015/10/22 11:08:04
You can use Label::kNear here.
Camillo Bruni
2015/11/03 16:05:27
done
|
+ // Step: 2, If we call a classConstructor Function throw a TypeError. |
+ { |
+ FrameScope frame(masm, StackFrame::INTERNAL); |
+ __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); |
+ } |
+ __ bind(&non_classConstructor); |
Benedikt Meurer
2015/10/22 11:08:04
Nit: non_class_constructor
Camillo Bruni
2015/11/03 16:05:26
done
|
+ } |
+ |
// 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); |
__ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
- __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
+ |
// We need to convert the receiver for non-native sloppy mode functions. |
__ testb(FieldOperand(rdx, SharedFunctionInfo::kNativeByteOffset), |
Immediate((1 << SharedFunctionInfo::kNativeBitWithinByte) | |