Reviewers: Michael Starzinger,
Message:
PTAL
Initial ports. I cannot even turn on the flag temporarily because super()
support is still missing. (Only tests failing locally with the flag turned
on
are involving super calls.)
Description:
Fix memento initialization when constructing from new call
Push a placeholder when we do not create mementos to preserve fixed frame
sizes.
BUG=
Please review this at https://codereview.chromium.org/1239593003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+32, -20 lines):
M src/deoptimizer.cc
M src/frames.h
M src/frames.cc
M src/ia32/builtins-ia32.cc
M src/x64/builtins-x64.cc
M test/cctest/test-mementos.cc
Index: src/deoptimizer.cc
diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc
index
c6e6baa942fcdbaf3750c6e1e0fc8162c088ba86..587fc0946a9157caa542a45696d449503b6c4246
100644
--- a/src/deoptimizer.cc
+++ b/src/deoptimizer.cc
@@ -1221,6 +1221,12 @@ void
Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
output_frame->SetFrameSlot(output_offset, value);
DebugPrintOutputSlot(value, frame_index, output_offset, "code object\n");
+ // The allocation site.
+ output_offset -= kPointerSize;
+ value = reinterpret_cast<intptr_t>(isolate_->heap()->undefined_value());
+ output_frame->SetFrameSlot(output_offset, value);
+ DebugPrintOutputSlot(value, frame_index, output_offset, "allocation
site\n");
+
// Number of incoming arguments.
output_offset -= kPointerSize;
value = reinterpret_cast<intptr_t>(Smi::FromInt(height - 1));
Index: src/frames.cc
diff --git a/src/frames.cc b/src/frames.cc
index
5dea8484c96ea1318fa15e4bee21f98287e15a5f..66bcf3d448445ba6d93c207a7ea73dcd92f59fe6
100644
--- a/src/frames.cc
+++ b/src/frames.cc
@@ -738,8 +738,8 @@ Object* JavaScriptFrame::GetOriginalConstructor() const
{
}
DCHECK(IsConstructFrame(fp));
STATIC_ASSERT(ConstructFrameConstants::kOriginalConstructorOffset ==
- StandardFrameConstants::kExpressionsOffset - 2 *
kPointerSize);
- return GetExpression(fp, 2);
+ StandardFrameConstants::kExpressionsOffset - 3 *
kPointerSize);
+ return GetExpression(fp, 3);
}
Index: src/frames.h
diff --git a/src/frames.h b/src/frames.h
index
0d2a2e3aa832d055d0ac269a58ed5d7641a792fd..9eee5a136e9b8d35cfa61215b7a06afb76e6e092
100644
--- a/src/frames.h
+++ b/src/frames.h
@@ -155,16 +155,18 @@ class ConstructFrameConstants : public AllStatic {
public:
// FP-relative.
static const int kImplicitReceiverOffset =
- StandardFrameConstants::kExpressionsOffset - 3 * kPointerSize;
+ StandardFrameConstants::kExpressionsOffset - 4 * kPointerSize;
static const int kOriginalConstructorOffset =
- StandardFrameConstants::kExpressionsOffset - 2 * kPointerSize;
+ StandardFrameConstants::kExpressionsOffset - 3 * kPointerSize;
static const int kLengthOffset =
+ StandardFrameConstants::kExpressionsOffset - 2 * kPointerSize;
+ static const int kAllocationSiteOffset =
StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize;
static const int kCodeOffset =
StandardFrameConstants::kExpressionsOffset - 0 * kPointerSize;
static const int kFrameSize =
- StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
+ StandardFrameConstants::kFixedFrameSize + 5 * kPointerSize;
};
Index: src/ia32/builtins-ia32.cc
diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc
index
5cbecc22bafd2aa8099bb8ab2a4e08da8a056bdf..6a80ddd23d68b8714f316b110b638981626457de
100644
--- a/src/ia32/builtins-ia32.cc
+++ b/src/ia32/builtins-ia32.cc
@@ -117,10 +117,9 @@ static void
Generate_JSConstructStubHelper(MacroAssembler* masm,
{
FrameScope scope(masm, StackFrame::CONSTRUCT);
- if (create_memento) {
- __ AssertUndefinedOrAllocationSite(ebx);
- __ push(ebx);
- }
+ // Always push a potential allocation site to preserve a fixed frame
size.
+ __ AssertUndefinedOrAllocationSite(ebx);
+ __ push(ebx);
// Preserve the incoming parameters on the stack.
__ SmiTag(eax);
@@ -254,7 +253,8 @@ static void
Generate_JSConstructStubHelper(MacroAssembler* masm,
__ mov(Operand(esi, AllocationMemento::kMapOffset),
factory->allocation_memento_map());
// Get the cell or undefined.
- __ mov(edx, Operand(esp, kPointerSize*2));
+ __ mov(edx, Operand(esp, 3 * kPointerSize));
+ __ AssertUndefinedOrAllocationSite(edx);
__ mov(Operand(esi, AllocationMemento::kAllocationSiteOffset),
edx);
} else {
@@ -422,12 +422,13 @@ void
Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
// -- edx: original constructor
// -----------------------------------
- // TODO(dslomov): support pretenuring
- CHECK(!FLAG_pretenuring_call_new);
-
{
FrameScope frame_scope(masm, StackFrame::CONSTRUCT);
+ // Always push a potential allocation site to preserve a fixed frame
size.
+ __ AssertUndefinedOrAllocationSite(ebx);
+ __ push(ebx);
+
// Preserve actual arguments count.
__ SmiTag(eax);
__ push(eax);
Index: src/x64/builtins-x64.cc
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc
index
c59d3ba78fbd557467904af73bba72810fb9521f..c32f84746fa61916cda6b1e9f681e392bedabb7c
100644
--- a/src/x64/builtins-x64.cc
+++ b/src/x64/builtins-x64.cc
@@ -116,10 +116,9 @@ static void
Generate_JSConstructStubHelper(MacroAssembler* masm,
{
FrameScope scope(masm, StackFrame::CONSTRUCT);
- if (create_memento) {
- __ AssertUndefinedOrAllocationSite(rbx);
- __ Push(rbx);
- }
+ // Always push a potential allocation site to preserve a fixed frame
size.
+ __ AssertUndefinedOrAllocationSite(rbx);
+ __ Push(rbx);
// Preserve the incoming parameters on the stack.
__ Integer32ToSmi(rax, rax);
@@ -254,7 +253,8 @@ static void
Generate_JSConstructStubHelper(MacroAssembler* masm,
__ Move(Operand(rsi, AllocationMemento::kMapOffset),
factory->allocation_memento_map());
// Get the cell or undefined.
- __ movp(rdx, Operand(rsp, kPointerSize*2));
+ __ movp(rdx, Operand(rsp, 3 * kPointerSize));
+ __ AssertUndefinedOrAllocationSite(rdx);
__ movp(Operand(rsi, AllocationMemento::kAllocationSiteOffset),
rdx);
} else {
__ InitializeFieldsWithFiller(rcx, rdi, rdx);
@@ -420,12 +420,14 @@ void
Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
// -- rbx: allocation site or undefined
// -- rdx: original constructor
// -----------------------------------
- // TODO(dslomov): support pretenuring
- CHECK(!FLAG_pretenuring_call_new);
{
FrameScope frame_scope(masm, StackFrame::CONSTRUCT);
+ // Always push a potential allocation site to preserve a fixed frame
size.
+ __ AssertUndefinedOrAllocationSite(rbx);
+ __ Push(rbx);
+
// Store a smi-tagged arguments count on the stack.
__ Integer32ToSmi(rax, rax);
__ Push(rax);
Index: test/cctest/test-mementos.cc
diff --git a/test/cctest/test-mementos.cc b/test/cctest/test-mementos.cc
index
9aa1e6d30e70c7fd8284fffe349242a10da217d2..a97666384bf245d3f7c1b840d93ddc9673cbb0f4
100644
--- a/test/cctest/test-mementos.cc
+++ b/test/cctest/test-mementos.cc
@@ -101,6 +101,7 @@ TEST(PretenuringCallNew) {
CcTest::InitializeVM();
if (!i::FLAG_allocation_site_pretenuring) return;
if (!i::FLAG_pretenuring_call_new) return;
+ if (i::FLAG_always_opt) return;
v8::HandleScope scope(CcTest::isolate());
Isolate* isolate = CcTest::i_isolate();
--
--
v8-dev mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.