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

Unified Diff: src/serialize.h

Issue 240193002: Serializer enable/disable flags need thread safety. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code comment response. Created 6 years, 8 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/mksnapshot.cc ('k') | src/serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.h
diff --git a/src/serialize.h b/src/serialize.h
index 1fc125bcd38188e1540dc532a223a2bea6c061d7..9e1d3d506866af581ec6aeca0ea3290cab0efd4d 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -470,13 +470,16 @@ class Serializer : public SerializerDeserializer {
}
Isolate* isolate() const { return isolate_; }
- static void Enable(Isolate* isolate);
- static void Disable();
-
- // Call this when you have made use of the fact that there is no serialization
- // going on.
- static void TooLateToEnableNow() { too_late_to_enable_now_ = true; }
- static bool enabled() { return serialization_enabled_; }
+ static void RequestEnable(Isolate* isolate);
+ static void InitializeOncePerProcess();
+ static void TearDown();
+
+ static bool enabled() {
+ SerializationState state = static_cast<SerializationState>(
+ NoBarrier_Load(&serialization_state_));
+ ASSERT(state != SERIALIZER_STATE_UNINITIALIZED);
+ return state == SERIALIZER_STATE_ENABLED;
+ }
SerializationAddressMapper* address_mapper() { return &address_mapper_; }
void PutRoot(int index,
HeapObject* object,
@@ -574,9 +577,15 @@ class Serializer : public SerializerDeserializer {
int fullness_[LAST_SPACE + 1];
SnapshotByteSink* sink_;
ExternalReferenceEncoder* external_reference_encoder_;
- static bool serialization_enabled_;
- // Did we already make use of the fact that serialization was not enabled?
- static bool too_late_to_enable_now_;
+
+ enum SerializationState {
+ SERIALIZER_STATE_UNINITIALIZED = 0,
+ SERIALIZER_STATE_DISABLED = 1,
+ SERIALIZER_STATE_ENABLED = 2
+ };
+
+ static AtomicWord serialization_state_;
+
SerializationAddressMapper address_mapper_;
intptr_t root_index_wave_front_;
void Pad();
« no previous file with comments | « src/mksnapshot.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698