Reviewers: Benedikt Meurer,
Message:
Hi Benedikt, here is a CL that removes a dependency on a type cell in the
other
direction. No hurry, thanks for a look when you can,
--Michael
Description:
Array constructor shouldn't require a Cell, just an AllocationSite.
The Array constructor has a needless dependency on an input argument
that is a Cell. It uses this to walk through to an AllocationSite.
The dependency hampers future work. Instead, pass the AllocationSite
as input to the Array constructor.
Please review this at https://codereview.chromium.org/140963004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+30, -66 lines):
M src/arm/code-stubs-arm.cc
M src/code-stubs-hydrogen.cc
M src/code-stubs.h
M src/ia32/code-stubs-ia32.cc
M src/mips/code-stubs-mips.cc
M src/objects.h
M src/runtime.cc
M src/x64/code-stubs-x64.cc
Index: src/arm/code-stubs-arm.cc
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index
ed340ff1937507931921549a1de8bac9fa1e6001..b9c5f3188f8edac3e65cad30467a0c7dd090ad75
100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -200,7 +200,7 @@ static void InitializeArrayConstructorDescriptor(
// register state
// r0 -- number of arguments
// r1 -- function
- // r2 -- type info cell with elements kind
+ // r2 -- allocation site with elements kind
static Register registers_variable_args[] = { r1, r2, r0 };
static Register registers_no_args[] = { r1, r2 };
@@ -5580,7 +5580,7 @@ static void CreateArrayDispatch(MacroAssembler* masm,
static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
AllocationSiteOverrideMode
mode) {
- // r2 - type info cell (if mode != DISABLE_ALLOCATION_SITES)
+ // r2 - allocation site (if mode != DISABLE_ALLOCATION_SITES)
// r3 - kind (if mode != DISABLE_ALLOCATION_SITES)
// r0 - number of arguments
// r1 - constructor?
@@ -5620,22 +5620,14 @@ static void
CreateArrayDispatchOneArgument(MacroAssembler* masm,
// We are going to create a holey array, but our kind is non-holey.
// Fix kind and retry (only if we have an allocation site in the cell).
__ add(r3, r3, Operand(1));
- __ ldr(r5, FieldMemOperand(r2, Cell::kValueOffset));
-
- if (FLAG_debug_code) {
- __ ldr(r5, FieldMemOperand(r5, 0));
- __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex);
- __ Assert(eq, kExpectedAllocationSiteInCell);
- __ ldr(r5, FieldMemOperand(r2, Cell::kValueOffset));
- }
// Save the resulting elements kind in type info. We can't just store
r3
// in the AllocationSite::transition_info field because elements kind
is
// restricted to a portion of the field...upper bits need to be left
alone.
STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
- __ ldr(r4, FieldMemOperand(r5, AllocationSite::kTransitionInfoOffset));
+ __ ldr(r4, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset));
__ add(r4, r4, Operand(Smi::FromInt(kFastElementsKindPackedToHoley)));
- __ str(r4, FieldMemOperand(r5, AllocationSite::kTransitionInfoOffset));
+ __ str(r4, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset));
__ bind(&normal_sequence);
int last_index = GetSequenceIndexFromFastElementsKind(
@@ -5759,15 +5751,15 @@ void ArrayConstructorStub::Generate(MacroAssembler*
masm) {
// Get the elements kind and case on that.
__ CompareRoot(r2, Heap::kUndefinedValueRootIndex);
__ b(eq, &no_info);
- __ ldr(r3, FieldMemOperand(r2, Cell::kValueOffset));
+ __ ldr(r2, FieldMemOperand(r2, Cell::kValueOffset));
// If the type cell is undefined, or contains anything other than an
// AllocationSite, call an array constructor that doesn't use
AllocationSites.
- __ ldr(r4, FieldMemOperand(r3, 0));
+ __ ldr(r4, FieldMemOperand(r2, 0));
__ CompareRoot(r4, Heap::kAllocationSiteMapRootIndex);
__ b(ne, &no_info);
- __ ldr(r3, FieldMemOperand(r3, AllocationSite::kTransitionInfoOffset));
+ __ ldr(r3, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset));
__ SmiUntag(r3);
STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
__ and_(r3, r3, Operand(AllocationSite::ElementsKindBits::kMask));
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index
785b9ca9ac679facf17147930569c054e5e7cecd..04c66b878145c47580b6d04508166a37f681fc02
100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -652,10 +652,7 @@ HValue*
CodeStubGraphBuilderBase::BuildArrayConstructor(
AllocationSiteOverrideMode override_mode,
ArgumentClass argument_class) {
HValue* constructor =
GetParameter(ArrayConstructorStubBase::kConstructor);
- HValue* property_cell =
GetParameter(ArrayConstructorStubBase::kPropertyCell);
- // Walk through the property cell to the AllocationSite
- HValue* alloc_site = Add<HLoadNamedField>(property_cell,
- HObjectAccess::ForCellValue());
+ HValue* alloc_site =
GetParameter(ArrayConstructorStubBase::kAllocationSite);
JSArrayBuilder array_builder(this, kind, alloc_site, constructor,
override_mode);
HValue* result = NULL;
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index
c567e7544b83e48fb88458b93aa97b1b3d2a6801..79aa2dd09e64c88d787ae98fd0e2532498040ea5
100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -2037,7 +2037,7 @@ class ArrayConstructorStubBase : public
HydrogenCodeStub {
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kConstructor = 0;
- static const int kPropertyCell = 1;
+ static const int kAllocationSite = 1;
protected:
void BasePrintName(const char* name, StringStream* stream);
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index
92be1b51f4a9b89844f5a4f77c7cb668ec522062..9862bccf15317f27742246645eb8201bf54877ce
100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -191,7 +191,7 @@ static void InitializeArrayConstructorDescriptor(
// register state
// eax -- number of arguments
// edi -- function
- // ebx -- type info cell with elements kind
+ // ebx -- allocation site with elements kind
static Register registers_variable_args[] = { edi, ebx, eax };
static Register registers_no_args[] = { edi, ebx };
@@ -5431,7 +5431,7 @@ static void CreateArrayDispatch(MacroAssembler* masm,
static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
AllocationSiteOverrideMode
mode) {
- // ebx - type info cell (if mode != DISABLE_ALLOCATION_SITES)
+ // ebx - allocation site (if mode != DISABLE_ALLOCATION_SITES)
// edx - kind (if mode != DISABLE_ALLOCATION_SITES)
// eax - number of arguments
// edi - constructor?
@@ -5472,19 +5472,12 @@ static void
CreateArrayDispatchOneArgument(MacroAssembler* masm,
// We are going to create a holey array, but our kind is non-holey.
// Fix kind and retry.
__ inc(edx);
- __ mov(ecx, FieldOperand(ebx, Cell::kValueOffset));
- if (FLAG_debug_code) {
- Handle<Map> allocation_site_map =
- masm->isolate()->factory()->allocation_site_map();
- __ cmp(FieldOperand(ecx, 0), Immediate(allocation_site_map));
- __ Assert(equal, kExpectedAllocationSiteInCell);
- }
// Save the resulting elements kind in type info. We can't just store
r3
// in the AllocationSite::transition_info field because elements kind
is
// restricted to a portion of the field...upper bits need to be left
alone.
STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
- __ add(FieldOperand(ecx, AllocationSite::kTransitionInfoOffset),
+ __ add(FieldOperand(ebx, AllocationSite::kTransitionInfoOffset),
Immediate(Smi::FromInt(kFastElementsKindPackedToHoley)));
__ bind(&normal_sequence);
@@ -5616,13 +5609,13 @@ void ArrayConstructorStub::Generate(MacroAssembler*
masm) {
// AllocationSite, call an array constructor that doesn't use
AllocationSites.
__ cmp(ebx, Immediate(undefined_sentinel));
__ j(equal, &no_info);
- __ mov(edx, FieldOperand(ebx, Cell::kValueOffset));
- __ cmp(FieldOperand(edx, 0), Immediate(
+ __ mov(ebx, FieldOperand(ebx, Cell::kValueOffset));
+ __ cmp(FieldOperand(ebx, 0), Immediate(
masm->isolate()->factory()->allocation_site_map()));
__ j(not_equal, &no_info);
// Only look at the lower 16 bits of the transition info.
- __ mov(edx, FieldOperand(edx, AllocationSite::kTransitionInfoOffset));
+ __ mov(edx, FieldOperand(ebx, AllocationSite::kTransitionInfoOffset));
__ SmiUntag(edx);
STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
__ and_(edx, Immediate(AllocationSite::ElementsKindBits::kMask));
Index: src/mips/code-stubs-mips.cc
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc
index
54f9492ff2e4fda3659d5b8e78adbf5c17651090..607f68b72fa62f755fd0fba21cca89aad78b75df
100644
--- a/src/mips/code-stubs-mips.cc
+++ b/src/mips/code-stubs-mips.cc
@@ -201,7 +201,7 @@ static void InitializeArrayConstructorDescriptor(
// register state
// a0 -- number of arguments
// a1 -- function
- // a2 -- type info cell with elements kind
+ // a2 -- allocation site with elements kind
static Register registers_variable_args[] = { a1, a2, a0 };
static Register registers_no_args[] = { a1, a2 };
@@ -5750,7 +5750,7 @@ static void CreateArrayDispatch(MacroAssembler* masm,
static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
AllocationSiteOverrideMode
mode) {
- // a2 - type info cell (if mode != DISABLE_ALLOCATION_SITES)
+ // a2 - allocation site (if mode != DISABLE_ALLOCATION_SITES)
// a3 - kind (if mode != DISABLE_ALLOCATION_SITES)
// a0 - number of arguments
// a1 - constructor?
@@ -5789,22 +5789,14 @@ static void
CreateArrayDispatchOneArgument(MacroAssembler* masm,
// We are going to create a holey array, but our kind is non-holey.
// Fix kind and retry (only if we have an allocation site in the cell).
__ Addu(a3, a3, Operand(1));
- __ lw(t1, FieldMemOperand(a2, Cell::kValueOffset));
-
- if (FLAG_debug_code) {
- __ lw(t1, FieldMemOperand(t1, 0));
- __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex);
- __ Assert(eq, kExpectedAllocationSiteInCell, t1, Operand(at));
- __ lw(t1, FieldMemOperand(a2, Cell::kValueOffset));
- }
// Save the resulting elements kind in type info. We can't just store
a3
// in the AllocationSite::transition_info field because elements kind
is
// restricted to a portion of the field...upper bits need to be left
alone.
STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
- __ lw(t0, FieldMemOperand(t1, AllocationSite::kTransitionInfoOffset));
+ __ lw(t0, FieldMemOperand(a2, AllocationSite::kTransitionInfoOffset));
__ Addu(t0, t0, Operand(Smi::FromInt(kFastElementsKindPackedToHoley)));
- __ sw(t0, FieldMemOperand(t1, AllocationSite::kTransitionInfoOffset));
+ __ sw(t0, FieldMemOperand(a2, AllocationSite::kTransitionInfoOffset));
__ bind(&normal_sequence);
@@ -5929,15 +5921,15 @@ void ArrayConstructorStub::Generate(MacroAssembler*
masm) {
// Get the elements kind and case on that.
__ LoadRoot(at, Heap::kUndefinedValueRootIndex);
__ Branch(&no_info, eq, a2, Operand(at));
- __ lw(a3, FieldMemOperand(a2, Cell::kValueOffset));
+ __ lw(a2, FieldMemOperand(a2, Cell::kValueOffset));
// If the type cell is undefined, or contains anything other than an
// AllocationSite, call an array constructor that doesn't use
AllocationSites.
- __ lw(t0, FieldMemOperand(a3, 0));
+ __ lw(t0, FieldMemOperand(a2, 0));
__ LoadRoot(at, Heap::kAllocationSiteMapRootIndex);
__ Branch(&no_info, ne, t0, Operand(at));
- __ lw(a3, FieldMemOperand(a3, AllocationSite::kTransitionInfoOffset));
+ __ lw(a3, FieldMemOperand(a2, AllocationSite::kTransitionInfoOffset));
__ SmiUntag(a3);
STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
__ And(a3, a3, Operand(AllocationSite::ElementsKindBits::kMask));
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
85cae02da4b0231dba2f9074abc800319c44058a..bfc790946465b18ec7c256c80f62deaeea0d75ab
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1146,8 +1146,6 @@ class MaybeObject BASE_EMBEDDED {
V(kExpected0AsASmiSentinel, "Expected 0 as a Smi
sentinel") \
V(kExpectedAlignmentMarker, "expected alignment
marker") \
V(kExpectedAllocationSite, "expected allocation
site") \
-
V(kExpectedAllocationSiteInCell,
\
- "Expected AllocationSite in property
cell") \
V(kExpectedPropertyCellInRegisterA2,
\
"Expected property cell in register
a2") \
V(kExpectedPropertyCellInRegisterEbx,
\
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
8697a91ce5a4edfbc20e2c4447bba64d773eb0f0..8e01d6dfe2a26dd9259c59edbaca2d8eab9c544c
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -14780,9 +14780,8 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_ArrayConstructor) {
Handle<AllocationSite> site;
if (!type_info.is_null() &&
*type_info != isolate->heap()->undefined_value() &&
- Cell::cast(*type_info)->value()->IsAllocationSite()) {
- site = Handle<AllocationSite>(
- AllocationSite::cast(Cell::cast(*type_info)->value()), isolate);
+ type_info->IsAllocationSite()) {
+ site = Handle<AllocationSite>::cast(type_info);
ASSERT(!site->SitePointsToLiteral());
}
Index: src/x64/code-stubs-x64.cc
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index
acdc69ecef22fc666e12bbb1ce528cd99e358dcc..0aa64b3266fd5060399ed6bf6036d18a2dda8d22
100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -187,7 +187,7 @@ static void InitializeArrayConstructorDescriptor(
// register state
// rax -- number of arguments
// rdi -- function
- // rbx -- type info cell with elements kind
+ // rbx -- allocation site with elements kind
static Register registers_variable_args[] = { rdi, rbx, rax };
static Register registers_no_args[] = { rdi, rbx };
@@ -5232,7 +5232,7 @@ static void CreateArrayDispatch(MacroAssembler* masm,
static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
AllocationSiteOverrideMode
mode) {
- // rbx - type info cell (if mode != DISABLE_ALLOCATION_SITES)
+ // rbx - allocation site (if mode != DISABLE_ALLOCATION_SITES)
// rdx - kind (if mode != DISABLE_ALLOCATION_SITES)
// rax - number of arguments
// rdi - constructor?
@@ -5278,19 +5278,12 @@ static void
CreateArrayDispatchOneArgument(MacroAssembler* masm,
// We are going to create a holey array, but our kind is non-holey.
// Fix kind and retry (only if we have an allocation site in the cell).
__ incl(rdx);
- __ movp(rcx, FieldOperand(rbx, Cell::kValueOffset));
- if (FLAG_debug_code) {
- Handle<Map> allocation_site_map =
- masm->isolate()->factory()->allocation_site_map();
- __ Cmp(FieldOperand(rcx, 0), allocation_site_map);
- __ Assert(equal, kExpectedAllocationSiteInCell);
- }
// Save the resulting elements kind in type info. We can't just store
r3
// in the AllocationSite::transition_info field because elements kind
is
// restricted to a portion of the field...upper bits need to be left
alone.
STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
- __ SmiAddConstant(FieldOperand(rcx,
AllocationSite::kTransitionInfoOffset),
+ __ SmiAddConstant(FieldOperand(rbx,
AllocationSite::kTransitionInfoOffset),
Smi::FromInt(kFastElementsKindPackedToHoley));
__ bind(&normal_sequence);
@@ -5423,13 +5416,13 @@ void ArrayConstructorStub::Generate(MacroAssembler*
masm) {
// AllocationSite, call an array constructor that doesn't use
AllocationSites.
__ Cmp(rbx, undefined_sentinel);
__ j(equal, &no_info);
- __ movp(rdx, FieldOperand(rbx, Cell::kValueOffset));
- __ Cmp(FieldOperand(rdx, 0),
+ __ movp(rbx, FieldOperand(rbx, Cell::kValueOffset));
+ __ Cmp(FieldOperand(rbx, 0),
masm->isolate()->factory()->allocation_site_map());
__ j(not_equal, &no_info);
// Only look at the lower 16 bits of the transition info.
- __ movp(rdx, FieldOperand(rdx, AllocationSite::kTransitionInfoOffset));
+ __ movp(rdx, FieldOperand(rbx, AllocationSite::kTransitionInfoOffset));
__ SmiToInteger32(rdx, rdx);
STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
__ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask));
--
--
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/groups/opt_out.