Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: src/serialize.cc

Issue 296853007: Make serializer non-static. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/serialize.h ('k') | src/v8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index 2b43c0ee69a9f09ed972f815727a549d63a8ddd1..526e0292335128b9eb67ecce69bb32b591558991 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -613,7 +613,6 @@ ExternalReferenceDecoder::~ExternalReferenceDecoder() {
DeleteArray(encodings_);
}
-AtomicWord Serializer::serialization_state_ = SERIALIZER_STATE_UNINITIALIZED;
class CodeAddressMap: public CodeEventLogger {
public:
@@ -723,48 +722,6 @@ class CodeAddressMap: public CodeEventLogger {
};
-CodeAddressMap* Serializer::code_address_map_ = NULL;
-
-
-void Serializer::RequestEnable(Isolate* isolate) {
- isolate->InitializeLoggingAndCounters();
- code_address_map_ = new CodeAddressMap(isolate);
-}
-
-
-void Serializer::InitializeOncePerProcess() {
- // InitializeOncePerProcess is called by V8::InitializeOncePerProcess, a
- // method guaranteed to be called only once in a process lifetime.
- // serialization_state_ is read by many threads, hence the use of
- // Atomic primitives. Here, we don't need a barrier or mutex to
- // write it because V8 initialization is done by one thread, and gates
- // all reads of serialization_state_.
- ASSERT(NoBarrier_Load(&serialization_state_) ==
- SERIALIZER_STATE_UNINITIALIZED);
- SerializationState state = code_address_map_
- ? SERIALIZER_STATE_ENABLED
- : SERIALIZER_STATE_DISABLED;
- NoBarrier_Store(&serialization_state_, state);
-}
-
-
-void Serializer::TearDown() {
- // TearDown is called by V8::TearDown() for the default isolate. It's safe
- // to shut down the serializer by that point. Just to be safe, we restore
- // serialization_state_ to uninitialized.
- ASSERT(NoBarrier_Load(&serialization_state_) !=
- SERIALIZER_STATE_UNINITIALIZED);
- if (code_address_map_) {
- ASSERT(NoBarrier_Load(&serialization_state_) ==
- SERIALIZER_STATE_ENABLED);
- delete code_address_map_;
- code_address_map_ = NULL;
- }
-
- NoBarrier_Store(&serialization_state_, SERIALIZER_STATE_UNINITIALIZED);
-}
-
-
Deserializer::Deserializer(SnapshotByteSource* source)
: isolate_(NULL),
source_(source),
@@ -1262,7 +1219,8 @@ Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink)
: isolate_(isolate),
sink_(sink),
external_reference_encoder_(new ExternalReferenceEncoder(isolate)),
- root_index_wave_front_(0) {
+ root_index_wave_front_(0),
+ code_address_map_(NULL) {
// The serializer is meant to be used only to generate initial heap images
// from a context in which there is only one isolate.
for (int i = 0; i <= LAST_SPACE; i++) {
@@ -1273,6 +1231,7 @@ Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink)
Serializer::~Serializer() {
delete external_reference_encoder_;
+ if (code_address_map_ != NULL) delete code_address_map_;
}
@@ -1338,7 +1297,7 @@ void Serializer::VisitPointers(Object** start, Object** end) {
// deserialized objects.
void SerializerDeserializer::Iterate(Isolate* isolate,
ObjectVisitor* visitor) {
- if (Serializer::enabled(isolate)) return;
+ if (isolate->serializer_enabled()) return;
for (int i = 0; ; i++) {
if (isolate->serialize_partial_snapshot_cache_length() <= i) {
// Extend the array ready to get a value from the visitor when
@@ -1578,12 +1537,14 @@ void Serializer::ObjectSerializer::Serialize() {
"ObjectSerialization");
sink_->PutInt(size >> kObjectAlignmentBits, "Size in words");
- ASSERT(code_address_map_);
- const char* code_name = code_address_map_->Lookup(object_->address());
- LOG(serializer_->isolate_,
- CodeNameEvent(object_->address(), sink_->Position(), code_name));
- LOG(serializer_->isolate_,
- SnapshotPositionEvent(object_->address(), sink_->Position()));
+ if (serializer_->code_address_map_) {
+ const char* code_name =
+ serializer_->code_address_map_->Lookup(object_->address());
+ LOG(serializer_->isolate_,
+ CodeNameEvent(object_->address(), sink_->Position(), code_name));
+ LOG(serializer_->isolate_,
+ SnapshotPositionEvent(object_->address(), sink_->Position()));
+ }
// Mark this object as already serialized.
int offset = serializer_->Allocate(space, size);
@@ -1863,6 +1824,12 @@ void Serializer::Pad() {
}
+void Serializer::InitializeCodeAddressMap() {
+ isolate_->InitializeLoggingAndCounters();
+ code_address_map_ = new CodeAddressMap(isolate_);
+}
+
+
bool SnapshotByteSource::AtEOF() {
if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false;
for (int x = position_; x < length_; x++) {
« no previous file with comments | « src/serialize.h ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698