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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 642 }
643 643
644 644
645 ExternalReferenceDecoder::~ExternalReferenceDecoder() { 645 ExternalReferenceDecoder::~ExternalReferenceDecoder() {
646 for (int type = kFirstTypeCode; type < kTypeCodeCount; ++type) { 646 for (int type = kFirstTypeCode; type < kTypeCodeCount; ++type) {
647 DeleteArray(encodings_[type]); 647 DeleteArray(encodings_[type]);
648 } 648 }
649 DeleteArray(encodings_); 649 DeleteArray(encodings_);
650 } 650 }
651 651
652 652 SerializationState Serializer::serialization_state_ = SERIALIZER_STATE_DISABLED;
653 bool Serializer::serialization_enabled_ = false; 653 Mutex Serializer::serialization_mutex_;
654 bool Serializer::too_late_to_enable_now_ = false;
655
656 654
657 class CodeAddressMap: public CodeEventLogger { 655 class CodeAddressMap: public CodeEventLogger {
658 public: 656 public:
659 explicit CodeAddressMap(Isolate* isolate) 657 explicit CodeAddressMap(Isolate* isolate)
660 : isolate_(isolate) { 658 : isolate_(isolate) {
661 isolate->logger()->addCodeEventListener(this); 659 isolate->logger()->addCodeEventListener(this);
662 } 660 }
663 661
664 virtual ~CodeAddressMap() { 662 virtual ~CodeAddressMap() {
665 isolate_->logger()->removeCodeEventListener(this); 663 isolate_->logger()->removeCodeEventListener(this);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 757
760 NameMap address_to_name_map_; 758 NameMap address_to_name_map_;
761 Isolate* isolate_; 759 Isolate* isolate_;
762 }; 760 };
763 761
764 762
765 CodeAddressMap* Serializer::code_address_map_ = NULL; 763 CodeAddressMap* Serializer::code_address_map_ = NULL;
766 764
767 765
768 void Serializer::Enable(Isolate* isolate) { 766 void Serializer::Enable(Isolate* isolate) {
769 if (!serialization_enabled_) { 767 LockGuard<Mutex> lock_guard(&serialization_mutex_);
770 ASSERT(!too_late_to_enable_now_); 768 // Check again under the lock.
771 } 769 if (enabled()) return;
772 if (serialization_enabled_) return; 770
773 serialization_enabled_ = true; 771 ASSERT(!IsPermanentlyDisabled());
772
773 serialization_state_ = SERIALIZER_STATE_ENABLED;
774
774 isolate->InitializeLoggingAndCounters(); 775 isolate->InitializeLoggingAndCounters();
775 code_address_map_ = new CodeAddressMap(isolate); 776 code_address_map_ = new CodeAddressMap(isolate);
776 } 777 }
777 778
778 779
779 void Serializer::Disable() { 780 void Serializer::Disable() {
780 if (!serialization_enabled_) return; 781 LockGuard<Mutex> lock_guard(&serialization_mutex_);
781 serialization_enabled_ = false; 782 if (!enabled()) {
783 ASSERT(code_address_map_ == NULL);
784 return;
785 }
786 if (serialization_state_ != SERIALIZER_STATE_PERMANENTLY_DISABLED) {
787 serialization_state_ = SERIALIZER_STATE_DISABLED;
788 }
782 delete code_address_map_; 789 delete code_address_map_;
783 code_address_map_ = NULL; 790 code_address_map_ = NULL;
784 } 791 }
785 792
786 793
787 Deserializer::Deserializer(SnapshotByteSource* source) 794 Deserializer::Deserializer(SnapshotByteSource* source)
788 : isolate_(NULL), 795 : isolate_(NULL),
789 source_(source), 796 source_(source),
790 external_reference_decoder_(NULL) { 797 external_reference_decoder_(NULL) {
791 for (int i = 0; i < LAST_SPACE + 1; i++) { 798 for (int i = 0; i < LAST_SPACE + 1; i++) {
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 1890
1884 bool SnapshotByteSource::AtEOF() { 1891 bool SnapshotByteSource::AtEOF() {
1885 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; 1892 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false;
1886 for (int x = position_; x < length_; x++) { 1893 for (int x = position_; x < length_; x++) {
1887 if (data_[x] != SerializerDeserializer::nop()) return false; 1894 if (data_[x] != SerializerDeserializer::nop()) return false;
1888 } 1895 }
1889 return true; 1896 return true;
1890 } 1897 }
1891 1898
1892 } } // namespace v8::internal 1899 } } // namespace v8::internal
OLDNEW
« 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