Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Unified Diff: src/x64/builtins-x64.cc

Issue 1418623007: [runtime] Fix ES6 9.2.1 [[Call]] when encountering a classConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) |

Powered by Google App Engine
This is Rietveld 408576698