[stubs] Port CreateAllocationSiteStub to Turbofan

BUG=608675

Review-Url: https://codereview.chromium.org/2184073002
Cr-Commit-Position: refs/heads/master@{#38095}
This commit is contained in:
danno 2016-07-27 05:17:29 -07:00 committed by Commit bot
parent e97b8686f2
commit 1130e9c85b
3 changed files with 63 additions and 88 deletions

View File

@ -543,85 +543,6 @@ Handle<Code> FastCloneShallowArrayStub::GenerateCode() {
}
template <>
HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
// This stub is performance sensitive, the generated code must be tuned
// so that it doesn't build an eager frame.
info()->MarkMustNotHaveEagerFrame();
HValue* size = Add<HConstant>(AllocationSite::kSize);
HInstruction* object =
Add<HAllocate>(size, HType::JSObject(), TENURED, JS_OBJECT_TYPE,
graph()->GetConstant0());
// Store the map
Handle<Map> allocation_site_map = isolate()->factory()->allocation_site_map();
AddStoreMapConstant(object, allocation_site_map);
// Store the payload (smi elements kind)
HValue* initial_elements_kind = Add<HConstant>(GetInitialFastElementsKind());
Add<HStoreNamedField>(object,
HObjectAccess::ForAllocationSiteOffset(
AllocationSite::kTransitionInfoOffset),
initial_elements_kind);
// Unlike literals, constructed arrays don't have nested sites
Add<HStoreNamedField>(object,
HObjectAccess::ForAllocationSiteOffset(
AllocationSite::kNestedSiteOffset),
graph()->GetConstant0());
// Pretenuring calculation field.
Add<HStoreNamedField>(object,
HObjectAccess::ForAllocationSiteOffset(
AllocationSite::kPretenureDataOffset),
graph()->GetConstant0());
// Pretenuring memento creation count field.
Add<HStoreNamedField>(object,
HObjectAccess::ForAllocationSiteOffset(
AllocationSite::kPretenureCreateCountOffset),
graph()->GetConstant0());
// Store an empty fixed array for the code dependency.
HConstant* empty_fixed_array =
Add<HConstant>(isolate()->factory()->empty_fixed_array());
Add<HStoreNamedField>(
object,
HObjectAccess::ForAllocationSiteOffset(
AllocationSite::kDependentCodeOffset),
empty_fixed_array);
// Link the object to the allocation site list
HValue* site_list = Add<HConstant>(
ExternalReference::allocation_sites_list_address(isolate()));
HValue* site = Add<HLoadNamedField>(site_list, nullptr,
HObjectAccess::ForAllocationSiteList());
// TODO(mvstanton): This is a store to a weak pointer, which we may want to
// mark as such in order to skip the write barrier, once we have a unified
// system for weakness. For now we decided to keep it like this because having
// an initial write barrier backed store makes this pointer strong until the
// next GC, and allocation sites are designed to survive several GCs anyway.
Add<HStoreNamedField>(
object,
HObjectAccess::ForAllocationSiteOffset(AllocationSite::kWeakNextOffset),
site);
Add<HStoreNamedField>(site_list, HObjectAccess::ForAllocationSiteList(),
object);
HInstruction* feedback_vector = GetParameter(Descriptor::kVector);
HInstruction* slot = GetParameter(Descriptor::kSlot);
Add<HStoreKeyed>(feedback_vector, slot, object, nullptr, FAST_ELEMENTS,
INITIALIZING_STORE);
return feedback_vector;
}
Handle<Code> CreateAllocationSiteStub::GenerateCode() {
return DoGenerateCode(this);
}
template <>
HValue* CodeStubGraphBuilder<CreateWeakCellStub>::BuildCodeStub() {
// This stub is performance sensitive, the generated code must be tuned

View File

@ -4120,9 +4120,6 @@ void FastCloneShallowArrayStub::InitializeDescriptor(
}
void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {}
void CreateWeakCellStub::InitializeDescriptor(CodeStubDescriptor* d) {}
@ -4706,6 +4703,65 @@ void ProfileEntryHookStub::EntryHookTrampoline(intptr_t function,
entry_hook(function, stack_pointer);
}
void CreateAllocationSiteStub::GenerateAssembly(
CodeStubAssembler* assembler) const {
typedef compiler::Node Node;
Node* size = assembler->IntPtrConstant(AllocationSite::kSize);
Node* site = assembler->Allocate(size, compiler::CodeAssembler::kPretenured);
// Store the map
Node* map =
assembler->HeapConstant(isolate()->factory()->allocation_site_map());
assembler->StoreMapNoWriteBarrier(site, map);
Node* kind =
assembler->SmiConstant(Smi::FromInt(GetInitialFastElementsKind()));
assembler->StoreObjectFieldNoWriteBarrier(
site, AllocationSite::kTransitionInfoOffset, kind);
// Unlike literals, constructed arrays don't have nested sites
Node* zero = assembler->IntPtrConstant(0);
assembler->StoreObjectFieldNoWriteBarrier(
site, AllocationSite::kNestedSiteOffset, zero);
// Pretenuring calculation field.
assembler->StoreObjectFieldNoWriteBarrier(
site, AllocationSite::kPretenureDataOffset, zero);
// Pretenuring memento creation count field.
assembler->StoreObjectFieldNoWriteBarrier(
site, AllocationSite::kPretenureCreateCountOffset, zero);
// Store an empty fixed array for the code dependency.
Node* empty_fixed_array =
assembler->HeapConstant(isolate()->factory()->empty_fixed_array());
assembler->StoreObjectFieldNoWriteBarrier(
site, AllocationSite::kDependentCodeOffset, empty_fixed_array);
// Link the object to the allocation site list
Node* site_list = assembler->ExternalConstant(
ExternalReference::allocation_sites_list_address(isolate()));
Node* next_site = assembler->LoadBufferObject(site_list, 0);
// TODO(mvstanton): This is a store to a weak pointer, which we may want to
// mark as such in order to skip the write barrier, once we have a unified
// system for weakness. For now we decided to keep it like this because having
// an initial write barrier backed store makes this pointer strong until the
// next GC, and allocation sites are designed to survive several GCs anyway.
assembler->StoreObjectField(site, AllocationSite::kWeakNextOffset, next_site);
assembler->StoreNoWriteBarrier(MachineRepresentation::kTagged, site_list,
site);
Node* feedback_vector = assembler->Parameter(Descriptor::kVector);
Node* slot = assembler->Parameter(Descriptor::kSlot);
assembler->StoreFixedArrayElement(feedback_vector, slot, site,
UPDATE_WRITE_BARRIER,
CodeStubAssembler::SMI_PARAMETERS);
assembler->Return(site);
}
void ArrayNoArgumentConstructorStub::GenerateAssembly(
CodeStubAssembler* assembler) const {
typedef compiler::Node Node;

View File

@ -56,7 +56,6 @@ namespace internal {
/* HydrogenCodeStubs */ \
V(BinaryOpIC) \
V(BinaryOpWithAllocationSite) \
V(CreateAllocationSite) \
V(CreateWeakCell) \
V(ElementsTransitionAndStore) \
V(FastArrayPush) \
@ -99,6 +98,7 @@ namespace internal {
V(ArrayNoArgumentConstructor) \
V(ArraySingleArgumentConstructor) \
V(ArrayNArgumentsConstructor) \
V(CreateAllocationSite) \
V(StringLength) \
V(Add) \
V(Subtract) \
@ -1204,16 +1204,14 @@ class FastCloneShallowObjectStub : public TurboFanCodeStub {
DEFINE_TURBOFAN_CODE_STUB(FastCloneShallowObject, TurboFanCodeStub);
};
class CreateAllocationSiteStub : public HydrogenCodeStub {
class CreateAllocationSiteStub : public TurboFanCodeStub {
public:
explicit CreateAllocationSiteStub(Isolate* isolate)
: HydrogenCodeStub(isolate) { }
: TurboFanCodeStub(isolate) {}
static void GenerateAheadOfTime(Isolate* isolate);
DEFINE_CALL_INTERFACE_DESCRIPTOR(CreateAllocationSite);
DEFINE_HYDROGEN_CODE_STUB(CreateAllocationSite, HydrogenCodeStub);
DEFINE_TURBOFAN_CODE_STUB(CreateAllocationSite, TurboFanCodeStub);
};