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

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

Issue 1083193005: WIP: new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix return from new func Created 5 years, 8 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 7c670d448b9b4712d63193252d55246cb8db1496..b0b86b25cfbb63ad347d4643aa05a64630fe770a 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
@@ -161,6 +162,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ Push(rax);
// Push the function to invoke on the stack.
+
+ if (use_new_target) {
+ __ Push(rdx);
+ }
__ Push(rdi);
Label rt_call, normal_new, allocated, count_incremented;
@@ -409,6 +414,9 @@ 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));
@@ -418,6 +426,9 @@ 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 +444,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 +460,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
- if (!is_api_function) {
+ if (!is_api_function && !use_new_target) {
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
}
@@ -468,11 +483,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Throw away the result of the constructor invocation and use the
// on-stack receiver as the result.
__ bind(&use_receiver);
- __ movp(rax, Operand(rsp, 0));
+ __ movp(rax, Operand(rsp, (use_new_target ? 1 : 0) * kPointerSize));
// Restore the arguments count and leave the construct frame.
__ bind(&exit);
- __ movp(rbx, Operand(rsp, kPointerSize)); // Get arguments count.
+ // Get arguments count.
+ int offset = (use_new_target ? 2 : 1) * kPointerSize;
+ __ movp(rbx, Operand(rsp, offset));
// Leave construct frame.
}
@@ -489,12 +506,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);
}
@@ -535,7 +557,7 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
__ decp(rcx);
__ j(greater_equal, &loop);
- __ incp(rax); // Pushed new.target.
+ // __ incp(rax); // Pushed new.target.
// Handle step in.
Label skip_step_in;
@@ -561,8 +583,11 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
// Restore context from the frame.
__ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
- __ movp(rbx, Operand(rsp, 0)); // Get arguments count.
- } // Leave construct frame.
+ // Get arguments count.
+ __ movp(rbx, Operand(rsp, 0 * kPointerSize));
+
+ // Leave construct frame.
+ }
// Remove caller arguments from the stack and return.
__ PopReturnAddressTo(rcx);
@@ -1332,6 +1357,7 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
CallConstructStub stub(masm->isolate(), SUPER_CONSTRUCTOR_CALL);
__ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
+ // TODO(arv): Double check this drop.
__ Drop(1);
// Leave internal frame.
« 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