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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 int page_of_pointee = offset >> kPageSizeBits; | 672 int page_of_pointee = offset >> kPageSizeBits; |
673 Address object_address = pages_[space][page_of_pointee] + | 673 Address object_address = pages_[space][page_of_pointee] + |
674 (offset & Page::kPageAlignmentMask); | 674 (offset & Page::kPageAlignmentMask); |
675 return HeapObject::FromAddress(object_address); | 675 return HeapObject::FromAddress(object_address); |
676 } | 676 } |
677 | 677 |
678 | 678 |
679 void Deserializer::Deserialize() { | 679 void Deserializer::Deserialize() { |
680 isolate_ = Isolate::Current(); | 680 isolate_ = Isolate::Current(); |
681 ASSERT(isolate_ != NULL); | 681 ASSERT(isolate_ != NULL); |
682 { | 682 // Don't GC while deserializing - just expand the heap. |
683 // Don't GC while deserializing - just expand the heap. | 683 AlwaysAllocateScope always_allocate; |
684 AlwaysAllocateScope always_allocate; | 684 // Don't use the free lists while deserializing. |
685 // Don't use the free lists while deserializing. | 685 LinearAllocationScope allocate_linearly; |
686 LinearAllocationScope allocate_linearly; | 686 // No active threads. |
687 // No active threads. | 687 ASSERT_EQ(NULL, isolate_->thread_manager()->FirstThreadStateInUse()); |
688 ASSERT_EQ(NULL, isolate_->thread_manager()->FirstThreadStateInUse()); | 688 // No active handles. |
689 // No active handles. | 689 ASSERT(isolate_->handle_scope_implementer()->blocks()->is_empty()); |
690 ASSERT(isolate_->handle_scope_implementer()->blocks()->is_empty()); | 690 ASSERT_EQ(NULL, external_reference_decoder_); |
691 ASSERT_EQ(NULL, external_reference_decoder_); | 691 external_reference_decoder_ = new ExternalReferenceDecoder(); |
692 external_reference_decoder_ = new ExternalReferenceDecoder(); | 692 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); |
693 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); | 693 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); |
694 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); | |
695 | 694 |
696 isolate_->heap()->set_native_contexts_list( | 695 isolate_->heap()->set_native_contexts_list( |
697 isolate_->heap()->undefined_value()); | 696 isolate_->heap()->undefined_value()); |
698 | 697 |
699 // Update data pointers to the external strings containing natives sources. | 698 // Update data pointers to the external strings containing natives sources. |
700 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 699 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
701 Object* source = isolate_->heap()->natives_source_cache()->get(i); | 700 Object* source = isolate_->heap()->natives_source_cache()->get(i); |
702 if (!source->IsUndefined()) { | 701 if (!source->IsUndefined()) { |
703 ExternalAsciiString::cast(source)->update_data_cache(); | 702 ExternalAsciiString::cast(source)->update_data_cache(); |
704 } | |
705 } | 703 } |
706 } | 704 } |
707 | |
708 // Issue code events for newly deserialized code objects. | |
709 LOG_CODE_EVENT(isolate_, LogCodeObjects()); | |
710 LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); | |
711 } | 705 } |
712 | 706 |
713 | 707 |
714 void Deserializer::DeserializePartial(Object** root) { | 708 void Deserializer::DeserializePartial(Object** root) { |
715 isolate_ = Isolate::Current(); | 709 isolate_ = Isolate::Current(); |
716 // Don't GC while deserializing - just expand the heap. | 710 // Don't GC while deserializing - just expand the heap. |
717 AlwaysAllocateScope always_allocate; | 711 AlwaysAllocateScope always_allocate; |
718 // Don't use the free lists while deserializing. | 712 // Don't use the free lists while deserializing. |
719 LinearAllocationScope allocate_linearly; | 713 LinearAllocationScope allocate_linearly; |
720 if (external_reference_decoder_ == NULL) { | 714 if (external_reference_decoder_ == NULL) { |
721 external_reference_decoder_ = new ExternalReferenceDecoder(); | 715 external_reference_decoder_ = new ExternalReferenceDecoder(); |
722 } | 716 } |
723 | |
724 // Keep track of the code space start and end pointers in case new | |
725 // code objects were unserialized | |
726 OldSpace* code_space = isolate_->heap()->code_space(); | |
727 Address start_address = code_space->top(); | |
728 VisitPointer(root); | 717 VisitPointer(root); |
729 | |
730 // There's no code deserialized here. If this assert fires | |
731 // then that's changed and logging should be added to notify | |
732 // the profiler et al of the new code. | |
733 CHECK_EQ(start_address, code_space->top()); | |
734 } | 718 } |
735 | 719 |
736 | 720 |
737 Deserializer::~Deserializer() { | 721 Deserializer::~Deserializer() { |
738 ASSERT(source_->AtEOF()); | 722 ASSERT(source_->AtEOF()); |
739 if (external_reference_decoder_) { | 723 if (external_reference_decoder_) { |
740 delete external_reference_decoder_; | 724 delete external_reference_decoder_; |
741 external_reference_decoder_ = NULL; | 725 external_reference_decoder_ = NULL; |
742 } | 726 } |
743 } | 727 } |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 int Serializer::SpaceAreaSize(int space) { | 1706 int Serializer::SpaceAreaSize(int space) { |
1723 if (space == CODE_SPACE) { | 1707 if (space == CODE_SPACE) { |
1724 return isolate_->memory_allocator()->CodePageAreaSize(); | 1708 return isolate_->memory_allocator()->CodePageAreaSize(); |
1725 } else { | 1709 } else { |
1726 return Page::kPageSize - Page::kObjectStartOffset; | 1710 return Page::kPageSize - Page::kObjectStartOffset; |
1727 } | 1711 } |
1728 } | 1712 } |
1729 | 1713 |
1730 | 1714 |
1731 } } // namespace v8::internal | 1715 } } // namespace v8::internal |
OLD | NEW |