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

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

Issue 1188383002: Work In Progress: support new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/scopes.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/builtins-x64.cc
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc
index 7ec210ae8de4ceead2bdeaa9665ae07ebe8f3994..84b5caa8c14b7e39df3db3bd54761b402c691eb4 100644
--- a/src/x64/builtins-x64.cc
+++ b/src/x64/builtins-x64.cc
@@ -136,6 +136,7 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function,
+ bool use_new_target,
bool create_memento) {
// ----------- S t a t e -------------
// -- rax: number of arguments
@@ -163,6 +164,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Push the function to invoke on the stack.
__ Push(rdi);
+ if (use_new_target) {
+ __ Push(rdx);
+ }
+
Label rt_call, normal_new, allocated, count_incremented;
__ cmpp(rdx, rdi);
__ j(equal, &normal_new);
@@ -410,6 +415,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Retrieve the function from the stack.
__ Pop(rdi);
+ if (use_new_target) {
+ __ Pop(rdx);
+ }
+
// Retrieve smi-tagged arguments count from the stack.
__ movp(rax, Operand(rsp, 0));
__ SmiToInteger32(rax, rax);
@@ -418,6 +427,11 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// because we may have to return the original one and the calling
// conventions dictate that the called function pops the receiver.
__ Push(rbx);
+
+ if (use_new_target) {
+ __ Push(rdx);
+ }
+
__ Push(rbx);
// Set up pointer to last argument.
@@ -433,6 +447,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ decp(rcx);
__ j(greater_equal, &loop);
+ if (use_new_target) {
+ __ incp(rax); // Pushed new.target
+ }
+
// Call the function.
if (is_api_function) {
__ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
@@ -445,7 +463,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
- if (!is_api_function) {
+ // TODO(adamk): Remove the "!use_new_target" before supporting optimization
+ // of functions that reference new.target
+ if (!is_api_function && !use_new_target) {
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
}
@@ -489,12 +509,17 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
- Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
+ Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
}
void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
- Generate_JSConstructStubHelper(masm, true, false);
+ Generate_JSConstructStubHelper(masm, true, false, false);
+}
+
+
+void Builtins::Generate_JSConstructStubNewTarget(MacroAssembler* masm) {
+ Generate_JSConstructStubHelper(masm, false, true, FLAG_pretenuring_call_new);
}
« no previous file with comments | « src/scopes.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698