Index: src/code-stubs-hydrogen.cc |
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc |
index 06c9039614ce2c1c8e658d602b0ac5fb9305010f..84c688d30014fd60383e5d81bf09c3830c1ebd59 100644 |
--- a/src/code-stubs-hydrogen.cc |
+++ b/src/code-stubs-hydrogen.cc |
@@ -315,16 +315,17 @@ HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); |
int length = casted_stub()->length(); |
- HInstruction* boilerplate = |
+ HInstruction* allocation_site = |
AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
GetParameter(1), |
NULL, |
FAST_ELEMENTS)); |
- |
IfBuilder checker(this); |
- checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); |
+ checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, undefined); |
checker.Then(); |
+ HObjectAccess access = HObjectAccess::ForAllocationSiteInfoSite(); |
+ HInstruction* boilerplate = AddLoad(allocation_site, access); |
if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { |
HValue* elements = AddLoadElements(boilerplate); |
@@ -333,6 +334,7 @@ HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
if_fixed_cow.Then(); |
environment()->Push(BuildCloneShallowArray(context(), |
boilerplate, |
+ allocation_site, |
alloc_site_mode, |
FAST_ELEMENTS, |
0/*copy-on-write*/)); |
@@ -343,12 +345,14 @@ HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
if_fixed.Then(); |
environment()->Push(BuildCloneShallowArray(context(), |
boilerplate, |
+ allocation_site, |
alloc_site_mode, |
FAST_ELEMENTS, |
length)); |
if_fixed.Else(); |
environment()->Push(BuildCloneShallowArray(context(), |
boilerplate, |
+ allocation_site, |
alloc_site_mode, |
FAST_DOUBLE_ELEMENTS, |
length)); |
@@ -356,6 +360,7 @@ HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); |
environment()->Push(BuildCloneShallowArray(context(), |
boilerplate, |
+ allocation_site, |
alloc_site_mode, |
elements_kind, |
length)); |
@@ -421,6 +426,47 @@ Handle<Code> FastCloneShallowObjectStub::GenerateCode() { |
template <> |
+HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() { |
+ Zone* zone = this->zone(); |
+ |
+ HValue* size = AddInstruction(new(zone) HConstant(AllocationSite::kSize)); |
+ // TODO(mvstanton): perhaps flags should be old space allocation |
+ HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; |
Hannes Payer (out of office)
2013/07/03 15:26:45
We could do that right away.
mvstanton
2013/07/05 07:56:14
Done.
|
+ HInstruction* object = AddInstruction(new(zone) |
+ HAllocate(context(), size, HType::JSObject(), flags)); |
+ // Store the map |
+ Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(), |
+ isolate()); |
+ AddStoreMapConstant(object, allocation_site_map); |
+ HValue* initial_elements_kind = AddInstruction(new(zone) HConstant( |
+ GetInitialFastElementsKind())); |
+ AddInstruction(new(zone) HStoreNamedField(object, |
+ HObjectAccess::ForAllocationSitePayload(), initial_elements_kind)); |
+ |
+ // We use a hammer (SkipWriteBarrier()) to indicate that we know the input |
+ // cell is really a Cell, and so no write barrier is needed. Protect with a |
+ // debug code check. |
+ HInstruction* cell = GetParameter(0); |
+ // TODO(mvstanton): make debug code - new instruction, HAssert? |
+ /* |
Hannes Payer (out of office)
2013/07/03 15:26:45
This seems to be not finished.
mvstanton
2013/07/05 07:56:14
I kept the TODO, and altered it to say come back i
|
+ if (FLAG_debug_code) { |
+ |
+ } |
+ */ |
+ |
+ HObjectAccess access = HObjectAccess::ForCellValue(); |
+ HStoreNamedField* store = AddStore(cell, access, object); |
+ store->SkipWriteBarrier(); |
+ return cell; |
+} |
+ |
+ |
+Handle<Code> CreateAllocationSiteStub::GenerateCode() { |
+ return DoGenerateCode(this); |
+} |
+ |
+ |
+template <> |
HValue* CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { |
HInstruction* load = BuildUncheckedMonomorphicElementAccess( |
GetParameter(0), GetParameter(1), NULL, NULL, |
@@ -546,7 +592,10 @@ HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( |
} |
HValue* property_cell = GetParameter(ArrayConstructorStubBase::kPropertyCell); |
- JSArrayBuilder array_builder(this, kind, property_cell, constructor, |
+ // Walk through the property cell to the AllocationSite |
+ HValue* alloc_site = AddInstruction(new(zone()) HLoadNamedField(property_cell, |
+ HObjectAccess::ForCellValue())); |
+ JSArrayBuilder array_builder(this, kind, alloc_site, constructor, |
override_mode); |
HValue* result = NULL; |
switch (argument_class) { |