Reviewers: Weiliang,
Message:
PTAL>
Description:
X87: Cleanup Generate_JSConstructStubHelper a bit.
port 6ddcd32786dfafc968558ea59c0ca7588c45ebed (r29617)
original commit message:
Cleanup Generate_JSConstructStubHelper a bit.
BUG=
Please review this at https://codereview.chromium.org/1237013002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+36, -50 lines):
M src/x87/builtins-x87.cc
Index: src/x87/builtins-x87.cc
diff --git a/src/x87/builtins-x87.cc b/src/x87/builtins-x87.cc
index
7193e6f054f0ddc8ae598c88a372ec328d9e089f..2e2bcd3603a9f76ef32025e7a8fc2464b9bf1680
100644
--- a/src/x87/builtins-x87.cc
+++ b/src/x87/builtins-x87.cc
@@ -100,42 +100,6 @@ void
Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) {
}
-static void Generate_Runtime_NewObject(MacroAssembler* masm,
- bool create_memento,
- Register original_constructor,
- Label* count_incremented,
- Label* allocated) {
- int offset = kPointerSize;
- if (create_memento) {
- // Get the cell or allocation site.
- __ mov(edi, Operand(esp, kPointerSize * 3));
- __ push(edi);
- offset += kPointerSize;
- }
-
- // Must restore esi (context) and edi (constructor) before calling
- // runtime.
- __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
- __ mov(edi, Operand(esp, offset));
- __ push(edi);
- __ push(original_constructor);
- if (create_memento) {
- __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3);
- } else {
- __ CallRuntime(Runtime::kNewObject, 2);
- }
- __ mov(ebx, eax); // store result in ebx
-
- // Runtime_NewObjectWithAllocationSite increments allocation count.
- // Skip the increment.
- if (create_memento) {
- __ jmp(count_incremented);
- } else {
- __ jmp(allocated);
- }
-}
-
-
static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function,
bool create_memento) {
@@ -164,26 +128,19 @@ static void
Generate_JSConstructStubHelper(MacroAssembler* masm,
__ push(edi);
__ push(edx);
- __ cmp(edx, edi);
- Label normal_new;
- Label count_incremented;
- Label allocated;
- __ j(equal, &normal_new);
-
- // Original constructor and function are different.
- Generate_Runtime_NewObject(masm, create_memento, edx,
&count_incremented,
- &allocated);
- __ bind(&normal_new);
-
// Try to allocate the object without transitioning into C code. If
any of
// the preconditions is not met, the code bails out to the runtime
call.
- Label rt_call;
+ Label rt_call, allocated;
if (FLAG_inline_new) {
ExternalReference debug_step_in_fp =
ExternalReference::debug_step_in_fp_address(masm->isolate());
__ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0));
__ j(not_equal, &rt_call);
+ // Fall back to runtime if the original constructor and function
differ.
+ __ cmp(edx, edi);
+ __ 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.
// edi: constructor
@@ -220,12 +177,14 @@ static void
Generate_JSConstructStubHelper(MacroAssembler* masm,
__ j(not_equal, &allocate);
__ push(eax);
+ __ push(edx);
__ push(edi);
__ push(edi); // constructor
__ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
__ pop(edi);
+ __ pop(edx);
__ pop(eax);
__ mov(esi, Map::kSlackTrackingCounterEnd - 1);
@@ -313,9 +272,36 @@ static void
Generate_JSConstructStubHelper(MacroAssembler* masm,
}
// Allocate the new receiver object using the runtime call.
+ // edx: original constructor
__ bind(&rt_call);
- Generate_Runtime_NewObject(masm, create_memento, edi,
&count_incremented,
- &allocated);
+ int offset = kPointerSize;
+ if (create_memento) {
+ // Get the cell or allocation site.
+ __ mov(edi, Operand(esp, kPointerSize * 3));
+ __ push(edi); // argument 1: allocation site
+ offset += kPointerSize;
+ }
+
+ // Must restore esi (context) and edi (constructor) before calling
+ // runtime.
+ __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
+ __ mov(edi, Operand(esp, offset));
+ __ push(edi); // argument 2/1: constructor function
+ __ push(edx); // argument 3/2: original constructor
+ if (create_memento) {
+ __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3);
+ } else {
+ __ CallRuntime(Runtime::kNewObject, 2);
+ }
+ __ mov(ebx, eax); // store result in ebx
+
+ // Runtime_NewObjectWithAllocationSite increments allocation count.
+ // Skip the increment.
+ Label count_incremented;
+ if (create_memento) {
+ __ jmp(&count_incremented);
+ }
+
// New object allocated.
// ebx: newly allocated object
__ bind(&allocated);
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.