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

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: Rebase 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
Index: src/serialize.h
diff --git a/src/serialize.h b/src/serialize.h
index 1fc125bcd38188e1540dc532a223a2bea6c061d7..93874e6b74daa1ead577bd6190bf7e199856364c 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -456,6 +456,12 @@ class SerializationAddressMapper {
class CodeAddressMap;
+enum SerializationState {
+ SERIALIZER_STATE_DISABLED = 0,
+ SERIALIZER_STATE_ENABLED = 1,
+ SERIALIZER_STATE_PERMANENTLY_DISABLED = 2
+};
+
// There can be only one serializer per V8 process.
class Serializer : public SerializerDeserializer {
public:
@@ -474,9 +480,26 @@ class Serializer : public SerializerDeserializer {
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_; }
+ // going on. Returns true if serialization was disabled, and now it's
+ // permanetely disabled.
+ static bool TrySetPermanentlyDisabled() {
+ LockGuard<Mutex> lock_guard(&serialization_mutex_);
+ // Changes are only made under the lock.
+ if (serialization_state_ == SERIALIZER_STATE_DISABLED) {
+ serialization_state_ = SERIALIZER_STATE_PERMANENTLY_DISABLED;
+ return true;
+ }
+ return false;
+ }
+ static bool IsPermanentlyDisabled() {
+ LockGuard<Mutex> lock_guard(&serialization_mutex_);
+ return serialization_state_ ==
+ SERIALIZER_STATE_PERMANENTLY_DISABLED;
+ }
+ static bool enabled() {
+ LockGuard<Mutex> lock_guard(&serialization_mutex_);
+ return serialization_state_ == SERIALIZER_STATE_ENABLED;
+ }
SerializationAddressMapper* address_mapper() { return &address_mapper_; }
void PutRoot(int index,
HeapObject* object,
@@ -574,9 +597,10 @@ 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_;
+
+ static Mutex serialization_mutex_;
+ static SerializationState serialization_state_;
+
SerializationAddressMapper address_mapper_;
intptr_t root_index_wave_front_;
void Pad();
« src/arm/assembler-arm.cc ('K') | « src/ia32/assembler-ia32.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698