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

Unified Diff: src/serialize.cc

Issue 240193002: Serializer enable/disable flags need thread safety. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Setup and TearDown are controlled by V8::Initialize(). 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
« src/serialize.h ('K') | « 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 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.
}
« src/serialize.h ('K') | « src/serialize.h ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698