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

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

Issue 1413003008: Support fast-path allocation for subclass constructors with correctly initialized initial maps. (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 | « src/runtime/runtime-object.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 94918fa27c6e6804b6b6cda1f7cf3562845c4bd8..4efd3bfb23d4b4479ba2ebf103c3620739db218c 100644
--- a/src/x64/builtins-x64.cc
+++ b/src/x64/builtins-x64.cc
@@ -149,14 +149,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ cmpp(Operand(kScratchRegister, 0), Immediate(0));
__ j(not_equal, &rt_call);
- // Fall back to runtime if the original constructor and function differ.
- __ cmpp(rdx, rdi);
+ // Verify that the original constructor is a JSFunction.
+ __ CmpObjectType(rdx, JS_FUNCTION_TYPE, rbx);
__ j(not_equal, &rt_call);
- // Verified that the constructor is a JSFunction.
// Load the initial map and verify that it is in fact a map.
- // rdi: constructor
- __ movp(rax, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
+ // rdx: original constructor
+ __ movp(rax, FieldOperand(rdx, JSFunction::kPrototypeOrInitialMapOffset));
// Will both indicate a NULL and a Smi
DCHECK(kSmiTag == 0);
__ JumpIfSmi(rax, &rt_call);
@@ -165,6 +164,11 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ CmpObjectType(rax, MAP_TYPE, rbx);
__ j(not_equal, &rt_call);
+ // Fall back to runtime if the expected base constructor and base
+ // constructor differ.
+ __ cmpp(rdi, FieldOperand(rax, Map::kConstructorOrBackPointerOffset));
+ __ j(not_equal, &rt_call);
+
// Check that the constructor is not constructing a JSFunction (see
// comments in Runtime_NewObject in runtime.cc). In which case the
// initial map's instance type would be JS_FUNCTION_TYPE.
@@ -192,7 +196,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ Push(rdx);
__ Push(rdi);
- __ Push(rdi); // constructor
+ __ Push(rax); // initial map
__ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
__ Pop(rdi);
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698