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

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

Issue 1191973004: 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
Index: src/x64/builtins-x64.cc
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc
index 4fa405d55f4ec8c9bb066844448ee37d424ede9e..7e4c9f8a6cac2625f1d6989a77350e85d298cbb6 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);
@@ -402,6 +407,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);
@@ -410,6 +419,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.
@@ -425,6 +439,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));
@@ -437,7 +455,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());
}
@@ -481,12 +501,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/code-stubs-x64.cc » ('j') | test/mjsunit/harmony/new-target.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698