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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 } else if (space_number == CELL_SPACE) { \ | 770 } else if (space_number == CELL_SPACE) { \ |
771 dest_space = isolate->heap()->cell_space(); \ | 771 dest_space = isolate->heap()->cell_space(); \ |
772 } else { \ | 772 } else { \ |
773 ASSERT(space_number >= LO_SPACE); \ | 773 ASSERT(space_number >= LO_SPACE); \ |
774 dest_space = isolate->heap()->lo_space(); \ | 774 dest_space = isolate->heap()->lo_space(); \ |
775 } | 775 } |
776 | 776 |
777 | 777 |
778 static const int kUnknownOffsetFromStart = -1; | 778 static const int kUnknownOffsetFromStart = -1; |
779 | 779 |
780 #ifdef V8_TARGET_ARCH_MIPS | |
781 #define PATCH_SITE_ADJUST(addr) \ | |
782 (addr - 3 * kPointerSize) | |
Erik Corry
2012/03/17 02:49:18
This should be kInstructionSize (and I moved the f
| |
783 #else | |
784 #define PATCH_SITE_ADJUST(addr) \ | |
785 (addr) | |
786 #endif | |
787 | |
780 | 788 |
781 void Deserializer::ReadChunk(Object** current, | 789 void Deserializer::ReadChunk(Object** current, |
782 Object** limit, | 790 Object** limit, |
783 int source_space, | 791 int source_space, |
784 Address current_object_address) { | 792 Address current_object_address) { |
785 Isolate* const isolate = isolate_; | 793 Isolate* const isolate = isolate_; |
786 bool write_barrier_needed = (current_object_address != NULL && | 794 bool write_barrier_needed = (current_object_address != NULL && |
787 source_space != NEW_SPACE && | 795 source_space != NEW_SPACE && |
788 source_space != CELL_SPACE && | 796 source_space != CELL_SPACE && |
789 source_space != CODE_SPACE && | 797 source_space != CODE_SPACE && |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
841 new_object = HeapObject::FromAddress(object_address); \ | 849 new_object = HeapObject::FromAddress(object_address); \ |
842 } \ | 850 } \ |
843 } \ | 851 } \ |
844 if (within == kFirstInstruction) { \ | 852 if (within == kFirstInstruction) { \ |
845 Code* new_code_object = reinterpret_cast<Code*>(new_object); \ | 853 Code* new_code_object = reinterpret_cast<Code*>(new_object); \ |
846 new_object = reinterpret_cast<Object*>( \ | 854 new_object = reinterpret_cast<Object*>( \ |
847 new_code_object->instruction_start()); \ | 855 new_code_object->instruction_start()); \ |
848 } \ | 856 } \ |
849 if (how == kFromCode) { \ | 857 if (how == kFromCode) { \ |
850 Address location_of_branch_data = \ | 858 Address location_of_branch_data = \ |
851 reinterpret_cast<Address>(current); \ | 859 reinterpret_cast<Address>(current); \ |
Erik Corry
2012/03/17 02:49:18
It turns out this code can be simplified a little
| |
852 Assembler::set_target_at(location_of_branch_data, \ | 860 Address patch_site = PATCH_SITE_ADJUST(location_of_branch_data); \ |
861 if (patch_site != location_of_branch_data) { \ | |
862 current_was_incremented = true; \ | |
863 } \ | |
864 Assembler::set_target_at(patch_site, \ | |
853 reinterpret_cast<Address>(new_object)); \ | 865 reinterpret_cast<Address>(new_object)); \ |
854 if (within == kFirstInstruction) { \ | 866 if (within == kFirstInstruction) { \ |
855 location_of_branch_data += Assembler::kCallTargetSize; \ | 867 location_of_branch_data += Assembler::kCallTargetSize; \ |
856 current = reinterpret_cast<Object**>(location_of_branch_data); \ | 868 current = reinterpret_cast<Object**>(location_of_branch_data); \ |
857 current_was_incremented = true; \ | 869 current_was_incremented = true; \ |
858 } \ | 870 } \ |
859 } else { \ | 871 } else { \ |
860 *current = new_object; \ | 872 *current = new_object; \ |
861 } \ | 873 } \ |
862 } \ | 874 } \ |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 Object* object = current[-1]; | 988 Object* object = current[-1]; |
977 ASSERT(!isolate->heap()->InNewSpace(object)); | 989 ASSERT(!isolate->heap()->InNewSpace(object)); |
978 for (int i = 0; i < repeats; i++) current[i] = object; | 990 for (int i = 0; i < repeats; i++) current[i] = object; |
979 current += repeats; | 991 current += repeats; |
980 break; | 992 break; |
981 } | 993 } |
982 | 994 |
983 // Deserialize a new object and write a pointer to it to the current | 995 // Deserialize a new object and write a pointer to it to the current |
984 // object. | 996 // object. |
985 ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject) | 997 ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject) |
998 // Deserialize a new object from pointer found in code and write | |
999 // a pointer to it to the current object. Required only for MIPS. | |
1000 #if V8_TARGET_ARCH_MIPS | |
1001 ONE_PER_SPACE(kNewObject, kFromCode, kStartOfObject) | |
1002 #endif | |
986 // Support for direct instruction pointers in functions | 1003 // Support for direct instruction pointers in functions |
987 ONE_PER_CODE_SPACE(kNewObject, kPlain, kFirstInstruction) | 1004 ONE_PER_CODE_SPACE(kNewObject, kPlain, kFirstInstruction) |
988 // Deserialize a new code object and write a pointer to its first | 1005 // Deserialize a new code object and write a pointer to its first |
989 // instruction to the current code object. | 1006 // instruction to the current code object. |
990 ONE_PER_SPACE(kNewObject, kFromCode, kFirstInstruction) | 1007 ONE_PER_SPACE(kNewObject, kFromCode, kFirstInstruction) |
991 // Find a recently deserialized object using its offset from the current | 1008 // Find a recently deserialized object using its offset from the current |
992 // allocation point and write a pointer to it to the current object. | 1009 // allocation point and write a pointer to it to the current object. |
993 ALL_SPACES(kBackref, kPlain, kStartOfObject) | 1010 ALL_SPACES(kBackref, kPlain, kStartOfObject) |
994 // Find a recently deserialized code object using its offset from the | 1011 // Find a recently deserialized code object using its offset from the |
1012 // current allocation point and write a pointer to it to the current | |
1013 // object. Required only for MIPS. | |
1014 ALL_SPACES(kBackref, kFromCode, kStartOfObject) | |
Erik Corry
2012/03/17 02:49:18
The order is not important here so I moved these i
| |
1015 // Find a recently deserialized code object using its offset from the | |
995 // current allocation point and write a pointer to its first instruction | 1016 // current allocation point and write a pointer to its first instruction |
996 // to the current code object or the instruction pointer in a function | 1017 // to the current code object or the instruction pointer in a function |
997 // object. | 1018 // object. |
998 ALL_SPACES(kBackref, kFromCode, kFirstInstruction) | 1019 ALL_SPACES(kBackref, kFromCode, kFirstInstruction) |
999 ALL_SPACES(kBackref, kPlain, kFirstInstruction) | 1020 ALL_SPACES(kBackref, kPlain, kFirstInstruction) |
1000 // Find an already deserialized object using its offset from the start | 1021 // Find an already deserialized object using its offset from the start |
1001 // and write a pointer to it to the current object. | 1022 // and write a pointer to it to the current object. |
1002 ALL_SPACES(kFromStart, kPlain, kStartOfObject) | 1023 ALL_SPACES(kFromStart, kPlain, kStartOfObject) |
1003 ALL_SPACES(kFromStart, kPlain, kFirstInstruction) | 1024 ALL_SPACES(kFromStart, kPlain, kFirstInstruction) |
1004 // Find an already deserialized code object using its offset from the | 1025 // Find an already deserialized code object using its offset from the |
1005 // start and write a pointer to its first instruction to the current code | 1026 // start and write a pointer to its first instruction to the current code |
1006 // object. | 1027 // object. |
1007 ALL_SPACES(kFromStart, kFromCode, kFirstInstruction) | 1028 ALL_SPACES(kFromStart, kFromCode, kFirstInstruction) |
1029 // Find an already deserialized code object using its offset from | |
1030 // the start and write a pointer to it to the current object. | |
1031 // Required only for MIPS. | |
1032 ALL_SPACES(kFromStart, kFromCode, kStartOfObject) | |
1008 // Find an object in the roots array and write a pointer to it to the | 1033 // Find an object in the roots array and write a pointer to it to the |
1009 // current object. | 1034 // current object. |
1010 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) | 1035 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) |
1011 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0, kUnknownOffsetFromStart) | 1036 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0, kUnknownOffsetFromStart) |
1012 // Find an object in the partial snapshots cache and write a pointer to it | 1037 // Find an object in the partial snapshots cache and write a pointer to it |
1013 // to the current object. | 1038 // to the current object. |
1014 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) | 1039 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) |
1015 CASE_BODY(kPartialSnapshotCache, | 1040 CASE_BODY(kPartialSnapshotCache, |
1016 kPlain, | 1041 kPlain, |
1017 kStartOfObject, | 1042 kStartOfObject, |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1674 int Serializer::SpaceAreaSize(int space) { | 1699 int Serializer::SpaceAreaSize(int space) { |
1675 if (space == CODE_SPACE) { | 1700 if (space == CODE_SPACE) { |
1676 return isolate_->memory_allocator()->CodePageAreaSize(); | 1701 return isolate_->memory_allocator()->CodePageAreaSize(); |
1677 } else { | 1702 } else { |
1678 return Page::kPageSize - Page::kObjectStartOffset; | 1703 return Page::kPageSize - Page::kObjectStartOffset; |
1679 } | 1704 } |
1680 } | 1705 } |
1681 | 1706 |
1682 | 1707 |
1683 } } // namespace v8::internal | 1708 } } // namespace v8::internal |
OLD | NEW |