Reviewers: Hannes Payer, Michael Starzinger,
Message:
Hi guys, taking a "baby step" of adding DependentCode to AllocationSite.
Could
you especially scrutinize my approach to making sure a write barrier isn't
used
in code-stubs-hydrogen.cc?
Thanks,
--Michael
Description:
Added a DependentCode field to AllocationSite. It's not currently used,
this initial CL is just to get the object layout correct.
BUG=
Please review this at https://codereview.chromium.org/23567003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/code-stubs-hydrogen.cc
M src/heap-snapshot-generator.cc
M src/hydrogen-instructions.h
M src/objects-inl.h
M src/objects-printer.cc
M src/objects.h
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index
3e18138eb2b459bc9b0f56392aae3334d2b643f6..b94301fb6796ffbaabeaafe5721c269fc3267a3d
100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -463,14 +463,27 @@ HValue*
CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
HObjectAccess::ForAllocationSiteTransitionInfo(),
initial_elements_kind);
+ // Store an empty fixed array for the code dependency.
+ HConstant* empty_fixed_array =
+ Add<HConstant>(isolate()->factory()->empty_fixed_array());
+ ASSERT(!isolate()->heap()->InNewSpace(
+ isolate()->heap()->empty_fixed_array()));
+ HStoreNamedField* store = Add<HStoreNamedField>(
+ object,
+ HObjectAccess::ForAllocationSiteDependentCode(),
+ empty_fixed_array);
+ // TODO(mvstanton): Can I improve on using SkipWriteBarrier()? Should the
+ // empty fixed array be an "immortal immovable?"
+ store->SkipWriteBarrier();
+
// 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,
HObjectAccess::ForAllocationSiteList());
- HStoreNamedField* store =
- Add<HStoreNamedField>(object,
HObjectAccess::ForAllocationSiteWeakNext(),
- site);
+ store = Add<HStoreNamedField>(object,
+ HObjectAccess::ForAllocationSiteWeakNext(),
+ site);
store->SkipWriteBarrier();
Add<HStoreNamedField>(site_list, HObjectAccess::ForAllocationSiteList(),
object);
Index: src/heap-snapshot-generator.cc
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index
1c8a7b3dc4d7a3bb93cee7dce1d5ab68eae4c248..41f8458ba1432249e395be694f7cc11c2ede115b
100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -1288,6 +1288,8 @@ void
V8HeapExplorer::ExtractAllocationSiteReferences(int entry,
AllocationSite* site)
{
SetInternalReference(site, entry, "transition_info",
site->transition_info(),
AllocationSite::kTransitionInfoOffset);
+ SetInternalReference(site, entry, "dependent_code",
site->dependent_code(),
+ AllocationSite::kDependentCodeOffset);
}
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
8668793c8a3e4844783ca40d1ad1a1cc054f6829..38c52b23435a140d4b7432401f9630fa8ca22a69
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -5518,6 +5518,10 @@ class HObjectAccess V8_FINAL {
return HObjectAccess(kInobject, AllocationSite::kTransitionInfoOffset);
}
+ static HObjectAccess ForAllocationSiteDependentCode() {
+ return HObjectAccess(kInobject, AllocationSite::kDependentCodeOffset);
+ }
+
static HObjectAccess ForAllocationSiteWeakNext() {
return HObjectAccess(kInobject, AllocationSite::kWeakNextOffset);
}
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
13ae603520b222ff9f4a6bdfacbf57718742af15..4187704ae11c45716588c78c996966e5e3adcb8f
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1323,6 +1323,12 @@ bool JSObject::ShouldTrackAllocationInfo() {
return false;
}
+void AllocationSite::Initialize() {
+ SetElementsKind(GetInitialFastElementsKind());
+ set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()),
+ SKIP_WRITE_BARRIER);
+}
+
// Heuristic: We only need to create allocation site info if the
boilerplate
// elements kind is the initial elements kind.
@@ -4505,6 +4511,8 @@ ACCESSORS(SignatureInfo, args, Object, kArgsOffset)
ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset)
ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset)
+ACCESSORS(AllocationSite, dependent_code, DependentCode,
+ kDependentCodeOffset)
ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset)
ACCESSORS(AllocationMemento, allocation_site, Object,
kAllocationSiteOffset)
Index: src/objects-printer.cc
diff --git a/src/objects-printer.cc b/src/objects-printer.cc
index
9ea060f5ed81f7abcba5a7617de45490ae59480d..9d440aa0906efb7f31fded64fb5a4a9de2dce8bf
100644
--- a/src/objects-printer.cc
+++ b/src/objects-printer.cc
@@ -1098,9 +1098,10 @@ void AllocationSite::AllocationSitePrint(FILE* out) {
HeapObject::PrintHeader(out, "AllocationSite");
PrintF(out, " - weak_next: ");
weak_next()->ShortPrint(out);
- PrintF(out, "\n");
+ PrintF(out, "\n - dependent code: ");
+ dependent_code()->ShortPrint(out);
- PrintF(out, " - transition_info: ");
+ PrintF(out, "\n - transition_info: ");
if (transition_info()->IsCell()) {
Cell* cell = Cell::cast(transition_info());
Object* cell_contents = cell->value();
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
4685dc7d314cf4c4a99f6fcdd69b0c8455f35704..b4388c373605c108d6c0889c8cc736faa5fb184b
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7816,11 +7816,10 @@ class AllocationSite: public Struct {
static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024;
DECL_ACCESSORS(transition_info, Object)
+ DECL_ACCESSORS(dependent_code, DependentCode)
DECL_ACCESSORS(weak_next, Object)
- void Initialize() {
- SetElementsKind(GetInitialFastElementsKind());
- }
+ inline void Initialize();
ElementsKind GetElementsKind() {
ASSERT(!IsLiteralSite());
@@ -7847,11 +7846,12 @@ class AllocationSite: public Struct {
static inline AllocationSiteMode GetMode(ElementsKind from, ElementsKind
to);
static const int kTransitionInfoOffset = HeapObject::kHeaderSize;
- static const int kWeakNextOffset = kTransitionInfoOffset + kPointerSize;
+ static const int kDependentCodeOffset = kTransitionInfoOffset +
kPointerSize;
+ static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize;
static const int kSize = kWeakNextOffset + kPointerSize;
typedef FixedBodyDescriptor<HeapObject::kHeaderSize,
- kTransitionInfoOffset + kPointerSize,
+ kDependentCodeOffset + kPointerSize,
kSize> BodyDescriptor;
private:
--
--
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.