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

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

Issue 1427483002: [es6] Better support for built-ins subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
« src/runtime/runtime-object.cc ('K') | « src/runtime/runtime-typedarray.cc ('k') | no next file » | 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 2e3adb73c566612247f73c3a1fa62c6ebac6623f..d6c63ab585bdf5b4235e4dfa536528bc4ae533c2 100644
--- a/src/x64/builtins-x64.cc
+++ b/src/x64/builtins-x64.cc
@@ -1432,6 +1432,7 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- rax : number of arguments
// -- rdi : constructor function
+ // -- rdx : original constructor
// -- rsp[0] : return address
// -- rsp[(argc - n) * 8] : arg[n] (zero-based)
// -- rsp[(argc + 1) * 8] : receiver
@@ -1458,17 +1459,19 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
{
Label convert, done_convert;
__ JumpIfSmi(rbx, &convert, Label::kNear);
- __ CmpObjectType(rbx, FIRST_NONSTRING_TYPE, rdx);
+ __ CmpObjectType(rbx, FIRST_NONSTRING_TYPE, rcx);
__ j(below, &done_convert);
__ bind(&convert);
{
FrameScope scope(masm, StackFrame::INTERNAL);
ToStringStub stub(masm->isolate());
+ __ Push(rdx);
__ Push(rdi);
__ Move(rax, rbx);
__ CallStub(&stub);
__ Move(rbx, rax);
__ Pop(rdi);
+ __ Pop(rdx);
}
__ bind(&done_convert);
}
@@ -1478,9 +1481,14 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- rbx : the first argument
// -- rdi : constructor function
+ // -- rdx : original constructor
// -----------------------------------
+ Label allocate, done_allocate, rt_call;
+
+ // Fall back to runtime if the original constructor and constructor differ.
+ __ cmpp(rdx, rdi);
+ __ j(not_equal, &rt_call);
- Label allocate, done_allocate;
__ Allocate(JSValue::kSize, rax, rcx, no_reg, &allocate, TAG_OBJECT);
__ bind(&done_allocate);
@@ -1506,6 +1514,22 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
__ Pop(rbx);
}
__ jmp(&done_allocate);
+
+ // Fallback to the runtime to create new object.
+ __ bind(&rt_call);
+ {
+ FrameScope scope(masm, StackFrame::INTERNAL);
+ __ Push(rbx);
+ __ Push(rdi);
+ __ Push(rdi); // argument 2/1: constructor function
Toon Verwaest 2015/10/26 15:10:57 I don't understand 2/1, 3/2...
Igor Sheludko 2015/10/27 12:56:12 Done.
+ __ Push(rdx); // argument 3/2: original constructor
+ // TODO(ishell): allocation site?
+ __ CallRuntime(Runtime::kNewObject, 2);
Toon Verwaest 2015/10/26 15:10:57 Please add some tests here that subclassing now wo
Igor Sheludko 2015/10/27 12:56:12 Done.
+ __ Pop(rdi);
+ __ Pop(rbx);
+ }
+ __ movp(FieldOperand(rax, JSValue::kValueOffset), rbx);
+ __ Ret();
}
}
« src/runtime/runtime-object.cc ('K') | « src/runtime/runtime-typedarray.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698