| 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 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 ASSERT(where == kFromStart); \ | 831 ASSERT(where == kFromStart); \ |
| 832 if (offset_from_start == kUnknownOffsetFromStart) { \ | 832 if (offset_from_start == kUnknownOffsetFromStart) { \ |
| 833 emit_write_barrier = (space_number == NEW_SPACE); \ | 833 emit_write_barrier = (space_number == NEW_SPACE); \ |
| 834 new_object = GetAddressFromStart(data & kSpaceMask); \ | 834 new_object = GetAddressFromStart(data & kSpaceMask); \ |
| 835 } else { \ | 835 } else { \ |
| 836 Address object_address = pages_[space_number][0] + \ | 836 Address object_address = pages_[space_number][0] + \ |
| 837 (offset_from_start << kObjectAlignmentBits); \ | 837 (offset_from_start << kObjectAlignmentBits); \ |
| 838 new_object = HeapObject::FromAddress(object_address); \ | 838 new_object = HeapObject::FromAddress(object_address); \ |
| 839 } \ | 839 } \ |
| 840 } \ | 840 } \ |
| 841 if (within == kFirstInstruction) { \ | 841 if (within == kInnerPointer) { \ |
| 842 Code* new_code_object = reinterpret_cast<Code*>(new_object); \ | 842 if (space_number != CODE_SPACE || new_object->IsCode()) { \ |
| 843 new_object = reinterpret_cast<Object*>( \ | 843 Code* new_code_object = reinterpret_cast<Code*>(new_object); \ |
| 844 new_code_object->instruction_start()); \ | 844 new_object = reinterpret_cast<Object*>( \ |
| 845 new_code_object->instruction_start()); \ |
| 846 } else { \ |
| 847 ASSERT(space_number == CODE_SPACE || space_number == kLargeCode);\ |
| 848 JSGlobalPropertyCell* cell = \ |
| 849 JSGlobalPropertyCell::cast(new_object); \ |
| 850 new_object = reinterpret_cast<Object*>( \ |
| 851 cell->ValueAddress()); \ |
| 852 } \ |
| 845 } \ | 853 } \ |
| 846 if (how == kFromCode) { \ | 854 if (how == kFromCode) { \ |
| 847 Address location_of_branch_data = \ | 855 Address location_of_branch_data = \ |
| 848 reinterpret_cast<Address>(current); \ | 856 reinterpret_cast<Address>(current); \ |
| 849 Assembler::deserialization_set_special_target_at( \ | 857 Assembler::deserialization_set_special_target_at( \ |
| 850 location_of_branch_data, \ | 858 location_of_branch_data, \ |
| 851 reinterpret_cast<Address>(new_object)); \ | 859 reinterpret_cast<Address>(new_object)); \ |
| 852 location_of_branch_data += Assembler::kSpecialTargetSize; \ | 860 location_of_branch_data += Assembler::kSpecialTargetSize; \ |
| 853 current = reinterpret_cast<Object**>(location_of_branch_data); \ | 861 current = reinterpret_cast<Object**>(location_of_branch_data); \ |
| 854 current_was_incremented = true; \ | 862 current_was_incremented = true; \ |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 Object* object = current[-1]; | 980 Object* object = current[-1]; |
| 973 ASSERT(!isolate->heap()->InNewSpace(object)); | 981 ASSERT(!isolate->heap()->InNewSpace(object)); |
| 974 for (int i = 0; i < repeats; i++) current[i] = object; | 982 for (int i = 0; i < repeats; i++) current[i] = object; |
| 975 current += repeats; | 983 current += repeats; |
| 976 break; | 984 break; |
| 977 } | 985 } |
| 978 | 986 |
| 979 // Deserialize a new object and write a pointer to it to the current | 987 // Deserialize a new object and write a pointer to it to the current |
| 980 // object. | 988 // object. |
| 981 ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject) | 989 ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject) |
| 982 // Support for direct instruction pointers in functions | 990 // Support for direct instruction pointers in functions. It's an inner |
| 983 ONE_PER_CODE_SPACE(kNewObject, kPlain, kFirstInstruction) | 991 // pointer because it points at the entry point, not at the start of the |
| 992 // code object. |
| 993 ONE_PER_CODE_SPACE(kNewObject, kPlain, kInnerPointer) |
| 984 // Deserialize a new code object and write a pointer to its first | 994 // Deserialize a new code object and write a pointer to its first |
| 985 // instruction to the current code object. | 995 // instruction to the current code object. |
| 986 ONE_PER_SPACE(kNewObject, kFromCode, kFirstInstruction) | 996 ONE_PER_SPACE(kNewObject, kFromCode, kInnerPointer) |
| 987 // Find a recently deserialized object using its offset from the current | 997 // Find a recently deserialized object using its offset from the current |
| 988 // allocation point and write a pointer to it to the current object. | 998 // allocation point and write a pointer to it to the current object. |
| 989 ALL_SPACES(kBackref, kPlain, kStartOfObject) | 999 ALL_SPACES(kBackref, kPlain, kStartOfObject) |
| 990 #if V8_TARGET_ARCH_MIPS | 1000 #if V8_TARGET_ARCH_MIPS |
| 991 // Deserialize a new object from pointer found in code and write | 1001 // Deserialize a new object from pointer found in code and write |
| 992 // a pointer to it to the current object. Required only for MIPS, and | 1002 // a pointer to it to the current object. Required only for MIPS, and |
| 993 // omitted on the other architectures because it is fully unrolled and | 1003 // omitted on the other architectures because it is fully unrolled and |
| 994 // would cause bloat. | 1004 // would cause bloat. |
| 995 ONE_PER_SPACE(kNewObject, kFromCode, kStartOfObject) | 1005 ONE_PER_SPACE(kNewObject, kFromCode, kStartOfObject) |
| 996 // Find a recently deserialized code object using its offset from the | 1006 // Find a recently deserialized code object using its offset from the |
| 997 // current allocation point and write a pointer to it to the current | 1007 // current allocation point and write a pointer to it to the current |
| 998 // object. Required only for MIPS. | 1008 // object. Required only for MIPS. |
| 999 ALL_SPACES(kBackref, kFromCode, kStartOfObject) | 1009 ALL_SPACES(kBackref, kFromCode, kStartOfObject) |
| 1000 // Find an already deserialized code object using its offset from | 1010 // Find an already deserialized code object using its offset from |
| 1001 // the start and write a pointer to it to the current object. | 1011 // the start and write a pointer to it to the current object. |
| 1002 // Required only for MIPS. | 1012 // Required only for MIPS. |
| 1003 ALL_SPACES(kFromStart, kFromCode, kStartOfObject) | 1013 ALL_SPACES(kFromStart, kFromCode, kStartOfObject) |
| 1004 #endif | 1014 #endif |
| 1005 // Find a recently deserialized code object using its offset from the | 1015 // Find a recently deserialized code object using its offset from the |
| 1006 // current allocation point and write a pointer to its first instruction | 1016 // current allocation point and write a pointer to its first instruction |
| 1007 // 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 |
| 1008 // object. | 1018 // object. |
| 1009 ALL_SPACES(kBackref, kFromCode, kFirstInstruction) | 1019 ALL_SPACES(kBackref, kFromCode, kInnerPointer) |
| 1010 ALL_SPACES(kBackref, kPlain, kFirstInstruction) | 1020 ALL_SPACES(kBackref, kPlain, kInnerPointer) |
| 1011 // Find an already deserialized object using its offset from the start | 1021 // Find an already deserialized object using its offset from the start |
| 1012 // and write a pointer to it to the current object. | 1022 // and write a pointer to it to the current object. |
| 1013 ALL_SPACES(kFromStart, kPlain, kStartOfObject) | 1023 ALL_SPACES(kFromStart, kPlain, kStartOfObject) |
| 1014 ALL_SPACES(kFromStart, kPlain, kFirstInstruction) | 1024 ALL_SPACES(kFromStart, kPlain, kInnerPointer) |
| 1015 // Find an already deserialized code object using its offset from the | 1025 // Find an already deserialized code object using its offset from the |
| 1016 // 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 |
| 1017 // object. | 1027 // object. |
| 1018 ALL_SPACES(kFromStart, kFromCode, kFirstInstruction) | 1028 ALL_SPACES(kFromStart, kFromCode, kInnerPointer) |
| 1019 // Find an object in the roots array and write a pointer to it to the | 1029 // Find an object in the roots array and write a pointer to it to the |
| 1020 // current object. | 1030 // current object. |
| 1021 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) | 1031 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) |
| 1022 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0, kUnknownOffsetFromStart) | 1032 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0, kUnknownOffsetFromStart) |
| 1023 // Find an object in the partial snapshots cache and write a pointer to it | 1033 // Find an object in the partial snapshots cache and write a pointer to it |
| 1024 // to the current object. | 1034 // to the current object. |
| 1025 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) | 1035 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) |
| 1026 CASE_BODY(kPartialSnapshotCache, | 1036 CASE_BODY(kPartialSnapshotCache, |
| 1027 kPlain, | 1037 kPlain, |
| 1028 kStartOfObject, | 1038 kStartOfObject, |
| 1029 0, | 1039 0, |
| 1030 kUnknownOffsetFromStart) | 1040 kUnknownOffsetFromStart) |
| 1031 // Find an code entry in the partial snapshots cache and | 1041 // Find an code entry in the partial snapshots cache and |
| 1032 // write a pointer to it to the current object. | 1042 // write a pointer to it to the current object. |
| 1033 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kFirstInstruction, 0) | 1043 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kInnerPointer, 0) |
| 1034 CASE_BODY(kPartialSnapshotCache, | 1044 CASE_BODY(kPartialSnapshotCache, |
| 1035 kPlain, | 1045 kPlain, |
| 1036 kFirstInstruction, | 1046 kInnerPointer, |
| 1037 0, | 1047 0, |
| 1038 kUnknownOffsetFromStart) | 1048 kUnknownOffsetFromStart) |
| 1039 // Find an external reference and write a pointer to it to the current | 1049 // Find an external reference and write a pointer to it to the current |
| 1040 // object. | 1050 // object. |
| 1041 CASE_STATEMENT(kExternalReference, kPlain, kStartOfObject, 0) | 1051 CASE_STATEMENT(kExternalReference, kPlain, kStartOfObject, 0) |
| 1042 CASE_BODY(kExternalReference, | 1052 CASE_BODY(kExternalReference, |
| 1043 kPlain, | 1053 kPlain, |
| 1044 kStartOfObject, | 1054 kStartOfObject, |
| 1045 0, | 1055 0, |
| 1046 kUnknownOffsetFromStart) | 1056 kUnknownOffsetFromStart) |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 sink_->PutInt(encoding, "reference id"); | 1543 sink_->PutInt(encoding, "reference id"); |
| 1534 bytes_processed_so_far_ += rinfo->target_address_size(); | 1544 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1535 } | 1545 } |
| 1536 | 1546 |
| 1537 | 1547 |
| 1538 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { | 1548 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { |
| 1539 CHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); | 1549 CHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); |
| 1540 Address target_start = rinfo->target_address_address(); | 1550 Address target_start = rinfo->target_address_address(); |
| 1541 OutputRawData(target_start); | 1551 OutputRawData(target_start); |
| 1542 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 1552 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 1543 serializer_->SerializeObject(target, kFromCode, kFirstInstruction); | 1553 serializer_->SerializeObject(target, kFromCode, kInnerPointer); |
| 1544 bytes_processed_so_far_ += rinfo->target_address_size(); | 1554 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1545 } | 1555 } |
| 1546 | 1556 |
| 1547 | 1557 |
| 1548 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { | 1558 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { |
| 1549 Code* target = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); | 1559 Code* target = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); |
| 1550 OutputRawData(entry_address); | 1560 OutputRawData(entry_address); |
| 1551 serializer_->SerializeObject(target, kPlain, kFirstInstruction); | 1561 serializer_->SerializeObject(target, kPlain, kInnerPointer); |
| 1552 bytes_processed_so_far_ += kPointerSize; | 1562 bytes_processed_so_far_ += kPointerSize; |
| 1553 } | 1563 } |
| 1554 | 1564 |
| 1555 | 1565 |
| 1556 void Serializer::ObjectSerializer::VisitGlobalPropertyCell(RelocInfo* rinfo) { | 1566 void Serializer::ObjectSerializer::VisitGlobalPropertyCell(RelocInfo* rinfo) { |
| 1557 // We shouldn't have any global property cell references in code | 1567 ASSERT(rinfo->rmode() == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 1558 // objects in the snapshot. | 1568 JSGlobalPropertyCell* cell = |
| 1559 UNREACHABLE(); | 1569 JSGlobalPropertyCell::cast(rinfo->target_cell()); |
| 1570 OutputRawData(rinfo->pc()); |
| 1571 serializer_->SerializeObject(cell, kPlain, kInnerPointer); |
| 1560 } | 1572 } |
| 1561 | 1573 |
| 1562 | 1574 |
| 1563 void Serializer::ObjectSerializer::VisitExternalAsciiString( | 1575 void Serializer::ObjectSerializer::VisitExternalAsciiString( |
| 1564 v8::String::ExternalAsciiStringResource** resource_pointer) { | 1576 v8::String::ExternalAsciiStringResource** resource_pointer) { |
| 1565 Address references_start = reinterpret_cast<Address>(resource_pointer); | 1577 Address references_start = reinterpret_cast<Address>(resource_pointer); |
| 1566 OutputRawData(references_start); | 1578 OutputRawData(references_start); |
| 1567 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 1579 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
| 1568 Object* source = HEAP->natives_source_cache()->get(i); | 1580 Object* source = HEAP->natives_source_cache()->get(i); |
| 1569 if (!source->IsUndefined()) { | 1581 if (!source->IsUndefined()) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 int Serializer::SpaceAreaSize(int space) { | 1694 int Serializer::SpaceAreaSize(int space) { |
| 1683 if (space == CODE_SPACE) { | 1695 if (space == CODE_SPACE) { |
| 1684 return isolate_->memory_allocator()->CodePageAreaSize(); | 1696 return isolate_->memory_allocator()->CodePageAreaSize(); |
| 1685 } else { | 1697 } else { |
| 1686 return Page::kPageSize - Page::kObjectStartOffset; | 1698 return Page::kPageSize - Page::kObjectStartOffset; |
| 1687 } | 1699 } |
| 1688 } | 1700 } |
| 1689 | 1701 |
| 1690 | 1702 |
| 1691 } } // namespace v8::internal | 1703 } } // namespace v8::internal |
| OLD | NEW |