Turn off allocation site info for crankshafted array constructor calls.

Once we crankshaft a method, we should turn off allocation site info for
constructed arrays. Additionally, the semantics for doing this were
awkward because the constructed array code stubs get an
AllocationSiteMode as a minor key, but it's used as a permission to
determine the final mode locally based on ElementsKind. I refactored
this to a simpler boolean for override or local control.

BUG=
R=hpayer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14934 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mvstanton@chromium.org 2013-06-04 12:48:51 +00:00
parent 277ec5d7b2
commit 8a02fd3be3
10 changed files with 55 additions and 33 deletions

View File

@ -7244,6 +7244,10 @@ static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) {
ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
T stub(kind);
stub.GetCode(isolate)->set_is_pregenerated(true);
if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) {
T stub1(kind, true);
stub1.GetCode(isolate)->set_is_pregenerated(true);
}
}
}

View File

@ -4229,14 +4229,17 @@ void LCodeGen::DoCallNewArray(LCallNewArray* instr) {
__ mov(r0, Operand(instr->arity()));
__ mov(r2, Operand(instr->hydrogen()->property_cell()));
ElementsKind kind = instr->hydrogen()->elements_kind();
bool disable_allocation_sites =
(AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE);
if (instr->arity() == 0) {
ArrayNoArgumentConstructorStub stub(kind);
ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
} else if (instr->arity() == 1) {
ArraySingleArgumentConstructorStub stub(kind);
ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
} else {
ArrayNArgumentsConstructorStub stub(kind);
ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
}
}

View File

@ -537,7 +537,7 @@ HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() {
this,
casted_stub()->elements_kind(),
GetParameter(ArrayConstructorStubBase::kPropertyCell),
casted_stub()->mode());
casted_stub()->disable_allocation_sites());
return array_builder.AllocateEmptyArray();
}
@ -589,7 +589,7 @@ HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>::
this,
casted_stub()->elements_kind(),
GetParameter(ArrayConstructorStubBase::kPropertyCell),
casted_stub()->mode());
casted_stub()->disable_allocation_sites());
return array_builder.AllocateArray(capacity, length, true);
}
@ -612,7 +612,7 @@ HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() {
this,
kind,
GetParameter(ArrayConstructorStubBase::kPropertyCell),
casted_stub()->mode());
casted_stub()->disable_allocation_sites());
// We need to fill with the hole if it's a smi array in the multi-argument
// case because we might have to bail out while copying arguments into

View File

@ -1726,19 +1726,22 @@ class TransitionElementsKindStub : public HydrogenCodeStub {
class ArrayConstructorStubBase : public HydrogenCodeStub {
public:
ArrayConstructorStubBase(ElementsKind kind, AllocationSiteMode mode) {
ArrayConstructorStubBase(ElementsKind kind, bool disable_allocation_sites) {
// It only makes sense to override local allocation site behavior
// if there is a difference between the global allocation site policy
// for an ElementsKind and the desired usage of the stub.
ASSERT(!disable_allocation_sites ||
AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE);
bit_field_ = ElementsKindBits::encode(kind) |
AllocationSiteModeBits::encode(mode == TRACK_ALLOCATION_SITE);
DisableAllocationSitesBits::encode(disable_allocation_sites);
}
ElementsKind elements_kind() const {
return ElementsKindBits::decode(bit_field_);
}
AllocationSiteMode mode() const {
return AllocationSiteModeBits::decode(bit_field_)
? TRACK_ALLOCATION_SITE
: DONT_TRACK_ALLOCATION_SITE;
bool disable_allocation_sites() const {
return DisableAllocationSitesBits::decode(bit_field_);
}
virtual bool IsPregenerated() { return true; }
@ -1753,7 +1756,7 @@ class ArrayConstructorStubBase : public HydrogenCodeStub {
int NotMissMinorKey() { return bit_field_; }
class ElementsKindBits: public BitField<ElementsKind, 0, 8> {};
class AllocationSiteModeBits: public BitField<bool, 8, 1> {};
class DisableAllocationSitesBits: public BitField<bool, 8, 1> {};
uint32_t bit_field_;
DISALLOW_COPY_AND_ASSIGN(ArrayConstructorStubBase);
@ -1764,8 +1767,8 @@ class ArrayNoArgumentConstructorStub : public ArrayConstructorStubBase {
public:
ArrayNoArgumentConstructorStub(
ElementsKind kind,
AllocationSiteMode mode = TRACK_ALLOCATION_SITE)
: ArrayConstructorStubBase(kind, mode) {
bool disable_allocation_sites = false)
: ArrayConstructorStubBase(kind, disable_allocation_sites) {
}
virtual Handle<Code> GenerateCode();
@ -1785,8 +1788,8 @@ class ArraySingleArgumentConstructorStub : public ArrayConstructorStubBase {
public:
ArraySingleArgumentConstructorStub(
ElementsKind kind,
AllocationSiteMode mode = TRACK_ALLOCATION_SITE)
: ArrayConstructorStubBase(kind, mode) {
bool disable_allocation_sites = false)
: ArrayConstructorStubBase(kind, disable_allocation_sites) {
}
virtual Handle<Code> GenerateCode();
@ -1806,8 +1809,8 @@ class ArrayNArgumentsConstructorStub : public ArrayConstructorStubBase {
public:
ArrayNArgumentsConstructorStub(
ElementsKind kind,
AllocationSiteMode mode = TRACK_ALLOCATION_SITE) :
ArrayConstructorStubBase(kind, mode) {
bool disable_allocation_sites = false)
: ArrayConstructorStubBase(kind, disable_allocation_sites) {
}
virtual Handle<Code> GenerateCode();

View File

@ -1766,15 +1766,13 @@ HInstruction* HGraphBuilder::BuildGetArrayFunction(HValue* context) {
HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder,
ElementsKind kind,
HValue* allocation_site_payload,
AllocationSiteMode mode) :
bool disable_allocation_sites) :
builder_(builder),
kind_(kind),
allocation_site_payload_(allocation_site_payload) {
if (mode == DONT_TRACK_ALLOCATION_SITE) {
mode_ = mode;
} else {
mode_ = AllocationSiteInfo::GetMode(kind);
}
mode_ = disable_allocation_sites
? DONT_TRACK_ALLOCATION_SITE
: AllocationSiteInfo::GetMode(kind);
}

View File

@ -1232,7 +1232,7 @@ class HGraphBuilder {
JSArrayBuilder(HGraphBuilder* builder,
ElementsKind kind,
HValue* allocation_site_payload,
AllocationSiteMode mode);
bool disable_allocation_sites);
HValue* AllocateEmptyArray();
HValue* AllocateArray(HValue* capacity, HValue* length_field,

View File

@ -7823,8 +7823,12 @@ static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) {
TERMINAL_FAST_ELEMENTS_KIND);
for (int i = 0; i <= to_index; ++i) {
ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
T stub(kind);
T stub(kind, false);
stub.GetCode(isolate)->set_is_pregenerated(true);
if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) {
T stub1(kind, true);
stub1.GetCode(isolate)->set_is_pregenerated(true);
}
}
}

View File

@ -4238,14 +4238,17 @@ void LCodeGen::DoCallNewArray(LCallNewArray* instr) {
__ Set(eax, Immediate(instr->arity()));
__ mov(ebx, instr->hydrogen()->property_cell());
ElementsKind kind = instr->hydrogen()->elements_kind();
bool disable_allocation_sites =
(AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE);
if (instr->arity() == 0) {
ArrayNoArgumentConstructorStub stub(kind);
ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
} else if (instr->arity() == 1) {
ArraySingleArgumentConstructorStub stub(kind);
ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
} else {
ArrayNArgumentsConstructorStub stub(kind);
ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
}
}

View File

@ -6830,6 +6830,10 @@ static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) {
ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
T stub(kind);
stub.GetCode(isolate)->set_is_pregenerated(true);
if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) {
T stub1(kind, true);
stub1.GetCode(isolate)->set_is_pregenerated(true);
}
}
}

View File

@ -3935,14 +3935,17 @@ void LCodeGen::DoCallNewArray(LCallNewArray* instr) {
__ Set(rax, instr->arity());
__ Move(rbx, instr->hydrogen()->property_cell());
ElementsKind kind = instr->hydrogen()->elements_kind();
bool disable_allocation_sites =
(AllocationSiteInfo::GetMode(kind) == TRACK_ALLOCATION_SITE);
if (instr->arity() == 0) {
ArrayNoArgumentConstructorStub stub(kind);
ArrayNoArgumentConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
} else if (instr->arity() == 1) {
ArraySingleArgumentConstructorStub stub(kind);
ArraySingleArgumentConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
} else {
ArrayNArgumentsConstructorStub stub(kind);
ArrayNArgumentsConstructorStub stub(kind, disable_allocation_sites);
CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
}
}