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.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/140963004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18716 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mvstanton@chromium.org 2014-01-21 16:04:39 +00:00
parent 058c5c9f40
commit c472ee85f8
8 changed files with 40 additions and 51 deletions

View File

@ -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 };
@ -5784,7 +5784,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?
@ -5824,22 +5824,20 @@ 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));
__ ldr(r5, FieldMemOperand(r2, 0));
__ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex);
__ Assert(eq, kExpectedAllocationSiteInCell);
__ ldr(r5, FieldMemOperand(r2, Cell::kValueOffset));
__ Assert(eq, kExpectedAllocationSite);
}
// 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(
@ -5963,15 +5961,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));

View File

@ -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;

View File

@ -2062,7 +2062,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);

View File

@ -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 };
@ -5623,7 +5623,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?
@ -5664,19 +5664,19 @@ 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);
__ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map));
__ Assert(equal, kExpectedAllocationSite);
}
// 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);
@ -5808,13 +5808,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));

View File

@ -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 };
@ -5950,7 +5950,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?
@ -5989,22 +5989,20 @@ 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));
__ lw(t1, FieldMemOperand(a2, 0));
__ LoadRoot(at, Heap::kAllocationSiteMapRootIndex);
__ Assert(eq, kExpectedAllocationSiteInCell, t1, Operand(at));
__ lw(t1, FieldMemOperand(a2, Cell::kValueOffset));
__ Assert(eq, kExpectedAllocationSite, t1, Operand(at));
}
// 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);
@ -6129,15 +6127,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));

View File

@ -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, \

View File

@ -14779,10 +14779,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 != isolate->heap()->undefined_value()) {
site = Handle<AllocationSite>::cast(type_info);
ASSERT(!site->SitePointsToLiteral());
}

View File

@ -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 };
@ -5428,7 +5428,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?
@ -5474,19 +5474,19 @@ 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);
__ Cmp(FieldOperand(rbx, 0), allocation_site_map);
__ Assert(equal, kExpectedAllocationSite);
}
// 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);
@ -5619,13 +5619,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));