OLD | NEW |
---|---|
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 Loading... | |
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 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.
| |
653 bool Serializer::serialization_enabled_ = false; | |
654 bool Serializer::too_late_to_enable_now_ = false; | |
655 | |
656 | 653 |
657 class CodeAddressMap: public CodeEventLogger { | 654 class CodeAddressMap: public CodeEventLogger { |
658 public: | 655 public: |
659 explicit CodeAddressMap(Isolate* isolate) | 656 explicit CodeAddressMap(Isolate* isolate) |
660 : isolate_(isolate) { | 657 : isolate_(isolate) { |
661 isolate->logger()->addCodeEventListener(this); | 658 isolate->logger()->addCodeEventListener(this); |
662 } | 659 } |
663 | 660 |
664 virtual ~CodeAddressMap() { | 661 virtual ~CodeAddressMap() { |
665 isolate_->logger()->removeCodeEventListener(this); | 662 isolate_->logger()->removeCodeEventListener(this); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
758 } | 755 } |
759 | 756 |
760 NameMap address_to_name_map_; | 757 NameMap address_to_name_map_; |
761 Isolate* isolate_; | 758 Isolate* isolate_; |
762 }; | 759 }; |
763 | 760 |
764 | 761 |
765 CodeAddressMap* Serializer::code_address_map_ = NULL; | 762 CodeAddressMap* Serializer::code_address_map_ = NULL; |
766 | 763 |
767 | 764 |
768 void Serializer::Enable(Isolate* isolate) { | 765 void Serializer::RequestEnable(Isolate* isolate) { |
769 if (!serialization_enabled_) { | |
770 ASSERT(!too_late_to_enable_now_); | |
771 } | |
772 if (serialization_enabled_) return; | |
773 serialization_enabled_ = true; | |
774 isolate->InitializeLoggingAndCounters(); | 766 isolate->InitializeLoggingAndCounters(); |
775 code_address_map_ = new CodeAddressMap(isolate); | 767 code_address_map_ = new CodeAddressMap(isolate); |
776 } | 768 } |
777 | 769 |
778 | 770 |
779 void Serializer::Disable() { | 771 void Serializer::InitializeOncePerProcess() { |
780 if (!serialization_enabled_) return; | 772 ASSERT(NoBarrier_Load(&serialization_state_) == |
781 serialization_enabled_ = false; | 773 SERIALIZER_STATE_UNINITIALIZED); |
782 delete code_address_map_; | 774 SerializationState state = code_address_map_ |
783 code_address_map_ = NULL; | 775 ? SERIALIZER_STATE_ENABLED |
776 : SERIALIZER_STATE_DISABLED; | |
777 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.
| |
784 } | 778 } |
785 | 779 |
786 | 780 |
781 void Serializer::TearDown() { | |
782 ASSERT(NoBarrier_Load(&serialization_state_) != | |
783 SERIALIZER_STATE_UNINITIALIZED); | |
784 if (code_address_map_) { | |
785 ASSERT(NoBarrier_Load(&serialization_state_) == | |
786 SERIALIZER_STATE_ENABLED); | |
787 delete code_address_map_; | |
788 code_address_map_ = NULL; | |
789 } | |
790 | |
791 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.
| |
792 } | |
793 | |
794 | |
787 Deserializer::Deserializer(SnapshotByteSource* source) | 795 Deserializer::Deserializer(SnapshotByteSource* source) |
788 : isolate_(NULL), | 796 : isolate_(NULL), |
789 source_(source), | 797 source_(source), |
790 external_reference_decoder_(NULL) { | 798 external_reference_decoder_(NULL) { |
791 for (int i = 0; i < LAST_SPACE + 1; i++) { | 799 for (int i = 0; i < LAST_SPACE + 1; i++) { |
792 reservations_[i] = kUninitializedReservation; | 800 reservations_[i] = kUninitializedReservation; |
793 } | 801 } |
794 } | 802 } |
795 | 803 |
796 | 804 |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1883 | 1891 |
1884 bool SnapshotByteSource::AtEOF() { | 1892 bool SnapshotByteSource::AtEOF() { |
1885 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; | 1893 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; |
1886 for (int x = position_; x < length_; x++) { | 1894 for (int x = position_; x < length_; x++) { |
1887 if (data_[x] != SerializerDeserializer::nop()) return false; | 1895 if (data_[x] != SerializerDeserializer::nop()) return false; |
1888 } | 1896 } |
1889 return true; | 1897 return true; |
1890 } | 1898 } |
1891 | 1899 |
1892 } } // namespace v8::internal | 1900 } } // namespace v8::internal |
OLD | NEW |