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

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

Issue 1425353002: PPC: [es6] Better support for built-ins subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ppc/builtins-ppc.cc
diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc
index 881cffb57513e85aa4e6ca00f1125508a8953363..c630016dd26fb1f9efc6f69b9be1722a04dd09fd 100644
--- a/src/ppc/builtins-ppc.cc
+++ b/src/ppc/builtins-ppc.cc
@@ -222,41 +222,44 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r3 : number of arguments
// -- r4 : constructor function
+ // -- r6 : original constructor
// -- lr : return address
// -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
// -- sp[argc * 4] : receiver
// -----------------------------------
- // 1. Load the first argument into r3 and get rid of the rest (including the
+ // 1. Load the first argument into r5 and get rid of the rest (including the
// receiver).
{
Label no_arguments, done;
__ cmpi(r3, Operand::Zero());
__ beq(&no_arguments);
__ subi(r3, r3, Operand(1));
- __ ShiftLeftImm(r3, r3, Operand(kPointerSizeLog2));
- __ LoadPUX(r3, MemOperand(sp, r3));
+ __ ShiftLeftImm(r5, r3, Operand(kPointerSizeLog2));
+ __ LoadPUX(r5, MemOperand(sp, r5));
__ Drop(2);
__ b(&done);
__ bind(&no_arguments);
- __ LoadRoot(r3, Heap::kempty_stringRootIndex);
+ __ LoadRoot(r5, Heap::kempty_stringRootIndex);
__ Drop(1);
__ bind(&done);
}
- // 2. Make sure r3 is a string.
+ // 2. Make sure r5 is a string.
{
Label convert, done_convert;
- __ JumpIfSmi(r3, &convert);
- __ CompareObjectType(r3, r5, r5, FIRST_NONSTRING_TYPE);
+ __ JumpIfSmi(r5, &convert);
+ __ CompareObjectType(r5, r7, r7, FIRST_NONSTRING_TYPE);
__ blt(&done_convert);
__ bind(&convert);
{
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
ToStringStub stub(masm->isolate());
- __ push(r4);
+ __ Push(r4, r6);
+ __ mr(r3, r5);
__ CallStub(&stub);
- __ pop(r4);
+ __ mr(r5, r3);
+ __ Pop(r4, r6);
}
__ bind(&done_convert);
}
@@ -264,13 +267,18 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
// 3. Allocate a JSValue wrapper for the string.
{
// ----------- S t a t e -------------
- // -- r3 : the first argument
+ // -- r5 : the first argument
// -- r4 : constructor function
+ // -- r6 : original constructor
// -- lr : return address
// -----------------------------------
- Label allocate, done_allocate;
- __ mr(r5, r3);
+ Label allocate, done_allocate, rt_call;
+
+ // Fall back to runtime if the original constructor and function differ.
+ __ cmp(r4, r6);
+ __ bne(&rt_call);
+
__ Allocate(JSValue::kSize, r3, r6, r7, &allocate, TAG_OBJECT);
__ bind(&done_allocate);
@@ -294,6 +302,17 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
__ Pop(r4, r5);
}
__ b(&done_allocate);
+
+ // Fallback to the runtime to create new object.
+ __ bind(&rt_call);
+ {
+ FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
+ __ Push(r4, r5, r4, r6); // constructor function, original constructor
+ __ CallRuntime(Runtime::kNewObject, 2);
+ __ Pop(r4, r5);
+ }
+ __ StoreP(r5, FieldMemOperand(r3, JSValue::kValueOffset), r0);
+ __ Ret();
}
}
@@ -509,7 +528,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// r4: constructor function
// r6: original constructor
__ bind(&rt_call);
- __ Push(r4, r6);
+ __ Push(r4, r6); // constructor function, original constructor
__ CallRuntime(Runtime::kNewObject, 2);
__ mr(r7, r3);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698