Reviewers: Michael Starzinger,
Description:
Do not visit smis in the root list during GC.
[email protected]
BUG=328804
LOG=N
Please review this at https://codereview.chromium.org/166023003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+53, -22 lines):
M include/v8.h
M src/heap-inl.h
M src/heap.h
M src/heap.cc
M src/objects.h
M src/serialize.h
M src/serialize.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
dc1506f994d6f01889e314599d263a3dea8146fa..dd8f2685bc37115638f5332ddbefd42a79c16cea
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5414,7 +5414,7 @@ class Internals {
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
- static const int kEmptyStringRootIndex = 148;
+ static const int kEmptyStringRootIndex = 141;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index
35bad4af39ec94937720004f4e760332c2a0e36b..a45e3ab9d9ce1630f6b2a2a6da719fd1b42beb45
100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -820,6 +820,13 @@ void VerifyPointersVisitor::VisitPointers(Object**
start, Object** end) {
}
+void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
+ for (Object** current = start; current < end; current++) {
+ CHECK((*current)->IsSmi());
+ }
+}
+
+
double GCTracer::SizeOfHeapObjects() {
return (static_cast<double>(heap_->SizeOfObjects())) / MB;
}
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
c17794f99b394456583b5bf9d9241777f1bc0d63..93d250813451075bd029c8076749117abdf6eb5e
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -5841,6 +5841,9 @@ void Heap::Verify() {
VerifyPointersVisitor visitor;
IterateRoots(&visitor, VISIT_ONLY_STRONG);
+ VerifySmisVisitor smis_visitor;
+ IterateRootSmis(&smis_visitor);
+
new_space_.Verify();
old_pointer_space_->Verify(&visitor);
@@ -6138,6 +6141,12 @@ void Heap::IterateWeakRoots(ObjectVisitor* v,
VisitMode mode) {
}
+void Heap::IterateRootSmis(ObjectVisitor* v) {
+ v->VisitPointers(&roots_[kRootSmisStart], &roots_[kRootListLength]);
+ v->Synchronize(VisitorSynchronization::kRootSmisList);
+}
+
+
void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]);
v->Synchronize(VisitorSynchronization::kStrongRootList);
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
eb3afd9fc4d94c6c119560b36a9fc6ec764225f1..a607f1777709ea6328e526ac5e46bcdf0a303ccc
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -78,7 +78,6 @@ namespace internal {
V(ByteArray, empty_byte_array,
EmptyByteArray) \
V(DescriptorArray, empty_descriptor_array,
EmptyDescriptorArray) \
V(ConstantPoolArray, empty_constant_pool_array,
EmptyConstantPoolArray) \
- V(Smi, stack_limit,
StackLimit) \
V(Oddball, arguments_marker,
ArgumentsMarker) \
/* The roots above this line should be boring from a GC point of
view. */ \
/* This means they are never in new space and never on a page that
is */ \
@@ -186,14 +185,8 @@ namespace internal {
V(Code, js_entry_code,
JsEntryCode) \
V(Code, js_construct_entry_code,
JsConstructEntryCode) \
V(FixedArray, natives_source_cache,
NativesSourceCache) \
- V(Smi, last_script_id,
LastScriptId) \
V(Script, empty_script,
EmptyScript) \
- V(Smi, real_stack_limit,
RealStackLimit) \
V(NameDictionary, intrinsic_function_names,
IntrinsicFunctionNames) \
- V(Smi, arguments_adaptor_deopt_pc_offset,
ArgumentsAdaptorDeoptPCOffset) \
- V(Smi, construct_stub_deopt_pc_offset,
ConstructStubDeoptPCOffset) \
- V(Smi, getter_stub_deopt_pc_offset,
GetterStubDeoptPCOffset) \
- V(Smi, setter_stub_deopt_pc_offset,
SetterStubDeoptPCOffset) \
V(Cell, undefined_cell,
UndefineCell) \
V(JSObject, observation_state,
ObservationState) \
V(Map, external_map,
ExternalMap) \
@@ -206,8 +199,19 @@ namespace internal {
V(FixedArray, allocation_sites_scratchpad,
AllocationSitesScratchpad) \
V(JSObject, microtask_state, MicrotaskState)
+// Entries in this list are limited to Smis and are not visited during GC.
+#define
ROOT_SMI_LIST(V) \
+ V(Smi, last_script_id,
LastScriptId) \
+ V(Smi, real_stack_limit,
RealStackLimit) \
+ V(Smi, stack_limit,
StackLimit) \
+ V(Smi, arguments_adaptor_deopt_pc_offset,
ArgumentsAdaptorDeoptPCOffset) \
+ V(Smi, construct_stub_deopt_pc_offset,
ConstructStubDeoptPCOffset) \
+ V(Smi, getter_stub_deopt_pc_offset,
GetterStubDeoptPCOffset) \
+ V(Smi, setter_stub_deopt_pc_offset, SetterStubDeoptPCOffset)
+
#define ROOT_LIST(V) \
STRONG_ROOT_LIST(V) \
+ ROOT_SMI_LIST(V) \
V(StringTable, string_table, StringTable)
// Heap roots that are known to be immortal immovable, for which we can
safely
@@ -1347,6 +1351,9 @@ class Heap {
void IterateRoots(ObjectVisitor* v, VisitMode mode);
// Iterates over all strong roots in the heap.
void IterateStrongRoots(ObjectVisitor* v, VisitMode mode);
+ // Iterates over entries in the root smis list. Only interesting to the
+ // serializer/deserializer, since GC does not care about smis.
+ void IterateRootSmis(ObjectVisitor* v);
// Iterates over all the other roots in the heap.
void IterateWeakRoots(ObjectVisitor* v, VisitMode mode);
@@ -1582,26 +1589,27 @@ class Heap {
// Implements the corresponding V8 API function.
bool IdleNotification(int hint);
- // Declare all the root indices.
- enum RootListIndex {
+ // Declare all the root indices. This defines the root list order.
#define ROOT_INDEX_DECLARATION(type, name, camel_name)
k##camel_name##RootIndex,
- STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION)
-#undef ROOT_INDEX_DECLARATION
-
#define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex,
- INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION)
-#undef STRING_DECLARATION
+#define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex,
+ enum RootListIndex {
+ STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION)
+ INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION)
// Utility type maps
-#define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex,
STRUCT_LIST(DECLARE_STRUCT_MAP)
-#undef DECLARE_STRUCT_MAP
-
kStringTableRootIndex,
+ ROOT_SMI_LIST(ROOT_INDEX_DECLARATION)
+ kRootListLength,
kStrongRootListLength = kStringTableRootIndex,
- kRootListLength
+ kRootSmisStart = kStringTableRootIndex + 1
};
+#undef DECLARE_STRUCT_MAP
+#undef STRING_DECLARATION
+#undef ROOT_INDEX_DECLARATION
+
STATIC_CHECK(kUndefinedValueRootIndex ==
Internals::kUndefinedValueRootIndex);
STATIC_CHECK(kNullValueRootIndex == Internals::kNullValueRootIndex);
STATIC_CHECK(kTrueValueRootIndex == Internals::kTrueValueRootIndex);
@@ -2589,6 +2597,13 @@ class VerifyPointersVisitor: public ObjectVisitor {
};
+// Verify that all objects are Smis.
+class VerifySmisVisitor: public ObjectVisitor {
+ public:
+ inline void VisitPointers(Object** start, Object** end);
+};
+
+
// Space iterator for iterating over all spaces of the heap. Returns each
space
// in turn, and null when it is done.
class AllSpaces BASE_EMBEDDED {
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
b17db2a71a1db56798cfe734efa7aaa8ce6135db..149f0a291fcfbdd417b5723bb04954b9e760f4b1
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -10642,6 +10642,7 @@ class BreakPointInfo: public Struct {
V(kStringTable, "string_table", "(Internalized strings)") \
V(kExternalStringsTable, "external_strings_table", "(External strings)")
\
V(kStrongRootList, "strong_root_list", "(Strong roots)") \
+ V(kRootSmisList, "root_smis_list", "(Root smis)") \
V(kInternalizedString, "internalized_string", "(Internal string)") \
V(kBootstrapper, "bootstrapper", "(Bootstrapper)") \
V(kTop, "top", "(Isolate)") \
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index
5adc2b899511c1db9e3fb283add43e62656d7c1e..46fd0eb66b21081f47a3f8ad3256ef3edce7a55f
100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -789,6 +789,7 @@ void Deserializer::Deserialize(Isolate* isolate) {
ASSERT(isolate_->handle_scope_implementer()->blocks()->is_empty());
ASSERT_EQ(NULL, external_reference_decoder_);
external_reference_decoder_ = new ExternalReferenceDecoder(isolate);
+ isolate_->heap()->IterateRootSmis(this);
isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG);
isolate_->heap()->RepairFreeListsAfterBoot();
isolate_->heap()->IterateWeakRoots(this, VISIT_ALL);
@@ -1253,7 +1254,6 @@ void SnapshotByteSink::PutInt(uintptr_t integer,
const char* description) {
Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink)
: isolate_(isolate),
sink_(sink),
- current_root_index_(0),
external_reference_encoder_(new ExternalReferenceEncoder(isolate)),
root_index_wave_front_(0) {
// The serializer is meant to be used only to generate initial heap
images
@@ -1279,7 +1279,7 @@ void StartupSerializer::SerializeStrongReferences() {
CHECK_EQ(0, isolate->eternal_handles()->NumberOfHandles());
// We don't support serializing installed extensions.
CHECK(!isolate->has_installed_extensions());
-
+ isolate->heap()->IterateRootSmis(this);
isolate->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG);
}
Index: src/serialize.h
diff --git a/src/serialize.h b/src/serialize.h
index
ee9df39ad861c57b80a27f9d0fbff07ea036c9df..2ad9bb17edbeeb4ab6b856b5341b369fb2d7dc8a
100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -579,7 +579,6 @@ class Serializer : public SerializerDeserializer {
// relative addresses for back references.
int fullness_[LAST_SPACE + 1];
SnapshotByteSink* sink_;
- int current_root_index_;
ExternalReferenceEncoder* external_reference_encoder_;
static bool serialization_enabled_;
// Did we already make use of the fact that serialization was not
enabled?
--
--
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.