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

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

Issue 1203813002: [es6] Make new.target work in functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add test again. It got lost in last patchset 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/ia32/builtins-ia32.cc ('k') | src/mips64/builtins-mips64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips/builtins-mips.cc
diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc
index 2c80c75c7909eab488380ad3ff64c089eee99629..985f9c714f753f01412308bf2dd9170264efacb0 100644
--- a/src/mips/builtins-mips.cc
+++ b/src/mips/builtins-mips.cc
@@ -348,6 +348,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 -------------
// -- a0 : number of arguments
@@ -379,9 +380,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ push(a2);
}
- // Preserve the two incoming parameters on the stack.
- __ sll(a0, a0, kSmiTagSize); // Tag arguments count.
- __ MultiPushReversed(a0.bit() | a1.bit());
+ // Preserve the incoming parameters on the stack.
+ __ SmiTag(a0);
+ if (use_new_target) {
+ __ Push(a0, a1, a3);
+ } else {
+ __ Push(a0, a1);
+ }
Label rt_call, allocated, normal_new, count_incremented;
__ Branch(&normal_new, eq, a1, Operand(a3));
@@ -628,7 +633,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&allocated);
if (create_memento) {
- __ lw(a2, MemOperand(sp, kPointerSize * 2));
+ int offset = (use_new_target ? 3 : 2) * kPointerSize;
+ __ lw(a2, MemOperand(sp, offset));
__ LoadRoot(t5, Heap::kUndefinedValueRootIndex);
__ Branch(&count_incremented, eq, a2, Operand(t5));
// a2 is an AllocationSite. We are creating a memento from it, so we
@@ -641,22 +647,25 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&count_incremented);
}
+ // Restore the parameters.
+ if (use_new_target) {
+ __ Pop(a3); // new.target
+ }
__ Pop(a1);
- __ Push(t4, t4);
+ // Retrieve smi-tagged arguments count from the stack.
+ __ lw(a0, MemOperand(sp));
+ __ SmiUntag(a0);
- // Reload the number of arguments from the stack.
- // sp[0]: receiver
- // sp[1]: receiver
- // sp[2]: number of arguments (smi-tagged)
- __ lw(a3, MemOperand(sp, 2 * kPointerSize));
+ if (use_new_target) {
+ __ Push(a3, t4, t4);
+ } else {
+ __ Push(t4, t4);
+ }
// Set up pointer to last argument.
__ Addu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
- // Set up number of arguments for function call below.
- __ srl(a0, a3, kSmiTagSize);
-
// Copy arguments and receiver to the expression stack.
// a0: number of arguments
// a1: constructor function
@@ -664,8 +673,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// a3: number of arguments (smi-tagged)
// sp[0]: receiver
// sp[1]: receiver
- // sp[2]: number of arguments (smi-tagged)
+ // sp[2]: new.target (if used)
+ // sp[2/3]: number of arguments (smi-tagged)
Label loop, entry;
+ __ SmiTag(a3, a0);
__ jmp(&entry);
__ bind(&loop);
__ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
@@ -690,7 +701,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Store offset of return address for deoptimizer.
- if (!is_api_function) {
+ // TODO(arv): 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());
}
@@ -705,7 +718,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// If the result is a smi, it is *not* an object in the ECMA sense.
// v0: result
// sp[0]: receiver (newly allocated object)
- // sp[1]: number of arguments (smi-tagged)
+ // sp[1]: new.target (if used)
+ // sp[1/2]: number of arguments (smi-tagged)
__ JumpIfSmi(v0, &use_receiver);
// If the type of the result (stored in its map) is less than
@@ -723,8 +737,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ bind(&exit);
// v0: result
// sp[0]: receiver (newly allocated object)
- // sp[1]: number of arguments (smi-tagged)
- __ lw(a1, MemOperand(sp, kPointerSize));
+ // sp[1]: new.target (if used)
+ // sp[1/2]: number of arguments (smi-tagged)
+ int offset = (use_new_target ? 2 : 1) * kPointerSize;
+ __ lw(a1, MemOperand(sp, offset));
// Leave construct frame.
}
@@ -738,12 +754,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/ia32/builtins-ia32.cc ('k') | src/mips64/builtins-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698