Reviewers: Hannes Payer,
Message:
Hi Hannes, here is the field needed for nested literals, PTAL, thanks!
--Michael
Description:
Add field nested_sites to AllocationSite. This field is used to maintain
allocation site information for nested array and object literals.
It's not used productively in this CL, merely maintained in a minimal
way. (that comes next :)).
BUG=
Please review this at https://codereview.chromium.org/23463047/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+35, -1 lines):
M src/code-stubs-hydrogen.cc
M src/hydrogen-instructions.h
M src/objects-inl.h
M src/objects.h
M src/objects.cc
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index
0d06209b613db0f9dc46d32dbab532591edd720d..b43268834f0b9a34e781048dcdc61c67d3a2824c
100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -473,6 +473,11 @@ HValue*
CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
HObjectAccess::ForAllocationSiteTransitionInfo(),
initial_elements_kind);
+ // Unlike literals, constructed arrays don't have nested sites
+ Add<HStoreNamedField>(object,
+ HObjectAccess::ForAllocationSiteNestedSites(),
+ graph()->GetConstant0());
+
// Store an empty fixed array for the code dependency.
HConstant* empty_fixed_array =
Add<HConstant>(isolate()->factory()->empty_fixed_array());
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
505bc80d09d17f4dff8e629e7f8388b25fd31ae9..13aaffcb6b9a9628f5f8b6f572ceece514a853df
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -5697,6 +5697,10 @@ class HObjectAccess V8_FINAL {
return HObjectAccess(kInobject, AllocationSite::kTransitionInfoOffset);
}
+ static HObjectAccess ForAllocationSiteNestedSites() {
+ return HObjectAccess(kInobject, AllocationSite::kNestedSitesOffset);
+ }
+
static HObjectAccess ForAllocationSiteDependentCode() {
return HObjectAccess(kInobject, AllocationSite::kDependentCodeOffset);
}
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
4ee437214b61ba630d6f87ac204fecda7e7ae01a..526f12eb68628004a0854f0d557e9fc671fcd5e4
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1325,6 +1325,7 @@ bool JSObject::ShouldTrackAllocationInfo() {
void AllocationSite::Initialize() {
SetElementsKind(GetInitialFastElementsKind());
+ set_nested_sites(Smi::FromInt(0));
set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()),
SKIP_WRITE_BARRIER);
}
@@ -4487,6 +4488,7 @@ ACCESSORS(SignatureInfo, args, Object, kArgsOffset)
ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset)
ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset)
+ACCESSORS(AllocationSite, nested_sites, Object, kNestedSitesOffset)
ACCESSORS(AllocationSite, dependent_code, DependentCode,
kDependentCodeOffset)
ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset)
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
f45dd4c0f70f3e33b4efbf98a3c37db27efe19d8..592c37fea7f5938035ee143b309c4b8b98dae411
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8953,6 +8953,24 @@ Handle<String> SeqString::Truncate(Handle<SeqString>
string, int new_length) {
}
+AllocationSite* AllocationSite::GetLastNestedSite() {
+ AllocationSite* current_site = this;
+ while (current_site->nested_sites() != Smi::FromInt(0)) {
+ current_site = AllocationSite::cast(current_site->nested_sites());
+ }
+ return current_site == this ? NULL : current_site;
+}
+
+
+void AllocationSite::AppendNestedSite(AllocationSite* nested_site) {
+ AllocationSite* last_nested_site = GetLastNestedSite();
+ AllocationSite* append_to = last_nested_site == NULL
+ ? this
+ : last_nested_site;
+ append_to->set_nested_sites(nested_site);
+}
+
+
AllocationMemento* AllocationMemento::FindForJSObject(JSObject* object) {
// Currently, AllocationMemento objects are only allocated immediately
// after JSArrays in NewSpace, and detecting whether a JSArray has one
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
4c099fdc31d0e3b2f21533b5927d31ef3094348b..043b0bd75a89bed3690658943c9fc03c5c5bdf7a
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7827,11 +7827,15 @@ class AllocationSite: public Struct {
static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024;
DECL_ACCESSORS(transition_info, Object)
+ DECL_ACCESSORS(nested_sites, Object)
DECL_ACCESSORS(dependent_code, DependentCode)
DECL_ACCESSORS(weak_next, Object)
inline void Initialize();
+ AllocationSite* GetLastNestedSite();
+ void AppendNestedSite(AllocationSite* nested_site);
+
ElementsKind GetElementsKind() {
ASSERT(!IsLiteralSite());
return
static_cast<ElementsKind>(Smi::cast(transition_info())->value());
@@ -7858,7 +7862,8 @@ class AllocationSite: public Struct {
static inline bool CanTrack(InstanceType type);
static const int kTransitionInfoOffset = HeapObject::kHeaderSize;
- static const int kDependentCodeOffset = kTransitionInfoOffset +
kPointerSize;
+ static const int kNestedSitesOffset = kTransitionInfoOffset +
kPointerSize;
+ static const int kDependentCodeOffset = kNestedSitesOffset +
kPointerSize;
static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize;
static const int kSize = kWeakNextOffset + kPointerSize;
--
--
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.