Chromium Code Reviews| Index: src/serialize.cc |
| diff --git a/src/serialize.cc b/src/serialize.cc |
| index b271fa2a0fdb50adbf02daa4d45ebe394905291a..42c6d698c7af3c79fc247a91d4c4b7fff0362720 100644 |
| --- a/src/serialize.cc |
| +++ b/src/serialize.cc |
| @@ -649,10 +649,7 @@ ExternalReferenceDecoder::~ExternalReferenceDecoder() { |
| DeleteArray(encodings_); |
| } |
| - |
| -bool Serializer::serialization_enabled_ = false; |
| -bool Serializer::too_late_to_enable_now_ = false; |
| - |
| +Atomic32 Serializer::serialization_state_ = SERIALIZER_STATE_UNINITIALIZED; |
|
Hannes Payer (out of office)
2014/04/17 09:48:10
AtomicWord
mvstanton
2014/04/17 14:18:29
Done.
|
| class CodeAddressMap: public CodeEventLogger { |
| public: |
| @@ -765,22 +762,33 @@ class CodeAddressMap: public CodeEventLogger { |
| CodeAddressMap* Serializer::code_address_map_ = NULL; |
| -void Serializer::Enable(Isolate* isolate) { |
| - if (!serialization_enabled_) { |
| - ASSERT(!too_late_to_enable_now_); |
| - } |
| - if (serialization_enabled_) return; |
| - serialization_enabled_ = true; |
| +void Serializer::RequestEnable(Isolate* isolate) { |
| isolate->InitializeLoggingAndCounters(); |
| code_address_map_ = new CodeAddressMap(isolate); |
| } |
| -void Serializer::Disable() { |
| - if (!serialization_enabled_) return; |
| - serialization_enabled_ = false; |
| - delete code_address_map_; |
| - code_address_map_ = NULL; |
| +void Serializer::InitializeOncePerProcess() { |
| + ASSERT(NoBarrier_Load(&serialization_state_) == |
| + SERIALIZER_STATE_UNINITIALIZED); |
| + SerializationState state = code_address_map_ |
| + ? SERIALIZER_STATE_ENABLED |
| + : SERIALIZER_STATE_DISABLED; |
| + NoBarrier_Store(&serialization_state_, state); |
|
Hannes Payer (out of office)
2014/04/17 09:48:10
Can we have a comment here why this works and why
mvstanton
2014/04/17 14:18:29
Yes, done, and no.
|
| +} |
| + |
| + |
| +void Serializer::TearDown() { |
| + 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); |
|
Hannes Payer (out of office)
2014/04/17 09:48:10
The assumption is that this method is just invoked
mvstanton
2014/04/17 14:18:29
Good point, done.
|
| } |