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

Side by Side Diff: src/serialize.h

Issue 240193002: Serializer enable/disable flags need thread safety. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code comment response. 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
« no previous file with comments | « src/mksnapshot.cc ('k') | src/serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 ~Serializer(); 463 ~Serializer();
464 void VisitPointers(Object** start, Object** end); 464 void VisitPointers(Object** start, Object** end);
465 // You can call this after serialization to find out how much space was used 465 // You can call this after serialization to find out how much space was used
466 // in each space. 466 // in each space.
467 int CurrentAllocationAddress(int space) { 467 int CurrentAllocationAddress(int space) {
468 ASSERT(space < kNumberOfSpaces); 468 ASSERT(space < kNumberOfSpaces);
469 return fullness_[space]; 469 return fullness_[space];
470 } 470 }
471 471
472 Isolate* isolate() const { return isolate_; } 472 Isolate* isolate() const { return isolate_; }
473 static void Enable(Isolate* isolate); 473 static void RequestEnable(Isolate* isolate);
474 static void Disable(); 474 static void InitializeOncePerProcess();
475 static void TearDown();
475 476
476 // Call this when you have made use of the fact that there is no serialization 477 static bool enabled() {
477 // going on. 478 SerializationState state = static_cast<SerializationState>(
478 static void TooLateToEnableNow() { too_late_to_enable_now_ = true; } 479 NoBarrier_Load(&serialization_state_));
479 static bool enabled() { return serialization_enabled_; } 480 ASSERT(state != SERIALIZER_STATE_UNINITIALIZED);
481 return state == SERIALIZER_STATE_ENABLED;
482 }
480 SerializationAddressMapper* address_mapper() { return &address_mapper_; } 483 SerializationAddressMapper* address_mapper() { return &address_mapper_; }
481 void PutRoot(int index, 484 void PutRoot(int index,
482 HeapObject* object, 485 HeapObject* object,
483 HowToCode how, 486 HowToCode how,
484 WhereToPoint where, 487 WhereToPoint where,
485 int skip); 488 int skip);
486 489
487 protected: 490 protected:
488 static const int kInvalidRootIndex = -1; 491 static const int kInvalidRootIndex = -1;
489 492
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 // Some roots should not be serialized, because their actual value depends on 570 // Some roots should not be serialized, because their actual value depends on
568 // absolute addresses and they are reset after deserialization, anyway. 571 // absolute addresses and they are reset after deserialization, anyway.
569 bool ShouldBeSkipped(Object** current); 572 bool ShouldBeSkipped(Object** current);
570 573
571 Isolate* isolate_; 574 Isolate* isolate_;
572 // Keep track of the fullness of each space in order to generate 575 // Keep track of the fullness of each space in order to generate
573 // relative addresses for back references. 576 // relative addresses for back references.
574 int fullness_[LAST_SPACE + 1]; 577 int fullness_[LAST_SPACE + 1];
575 SnapshotByteSink* sink_; 578 SnapshotByteSink* sink_;
576 ExternalReferenceEncoder* external_reference_encoder_; 579 ExternalReferenceEncoder* external_reference_encoder_;
577 static bool serialization_enabled_; 580
578 // Did we already make use of the fact that serialization was not enabled? 581 enum SerializationState {
579 static bool too_late_to_enable_now_; 582 SERIALIZER_STATE_UNINITIALIZED = 0,
583 SERIALIZER_STATE_DISABLED = 1,
584 SERIALIZER_STATE_ENABLED = 2
585 };
586
587 static AtomicWord serialization_state_;
588
580 SerializationAddressMapper address_mapper_; 589 SerializationAddressMapper address_mapper_;
581 intptr_t root_index_wave_front_; 590 intptr_t root_index_wave_front_;
582 void Pad(); 591 void Pad();
583 592
584 friend class ObjectSerializer; 593 friend class ObjectSerializer;
585 friend class Deserializer; 594 friend class Deserializer;
586 595
587 private: 596 private:
588 static CodeAddressMap* code_address_map_; 597 static CodeAddressMap* code_address_map_;
589 DISALLOW_COPY_AND_ASSIGN(Serializer); 598 DISALLOW_COPY_AND_ASSIGN(Serializer);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 private: 666 private:
658 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { 667 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) {
659 return false; 668 return false;
660 } 669 }
661 }; 670 };
662 671
663 672
664 } } // namespace v8::internal 673 } } // namespace v8::internal
665 674
666 #endif // V8_SERIALIZE_H_ 675 #endif // V8_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/mksnapshot.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698