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

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: 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.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index b271fa2a0fdb50adbf02daa4d45ebe394905291a..96d017d522b0a21f672becdafb188880fbf455d4 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -649,10 +649,8 @@ ExternalReferenceDecoder::~ExternalReferenceDecoder() {
DeleteArray(encodings_);
}
-
-bool Serializer::serialization_enabled_ = false;
-bool Serializer::too_late_to_enable_now_ = false;
-
+SerializationState Serializer::serialization_state_ = SERIALIZER_STATE_DISABLED;
+Mutex Serializer::serialization_mutex_;
class CodeAddressMap: public CodeEventLogger {
public:
@@ -766,19 +764,28 @@ 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;
+ LockGuard<Mutex> lock_guard(&serialization_mutex_);
+ // Check again under the lock.
+ if (enabled()) return;
+
+ ASSERT(!IsPermanentlyDisabled());
+
+ serialization_state_ = SERIALIZER_STATE_ENABLED;
+
isolate->InitializeLoggingAndCounters();
code_address_map_ = new CodeAddressMap(isolate);
}
void Serializer::Disable() {
- if (!serialization_enabled_) return;
- serialization_enabled_ = false;
+ LockGuard<Mutex> lock_guard(&serialization_mutex_);
+ if (!enabled()) {
+ ASSERT(code_address_map_ == NULL);
+ return;
+ }
+ if (serialization_state_ != SERIALIZER_STATE_PERMANENTLY_DISABLED) {
+ serialization_state_ = SERIALIZER_STATE_DISABLED;
+ }
delete code_address_map_;
code_address_map_ = NULL;
}
« src/arm/assembler-arm.cc ('K') | « src/serialize.h ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698