OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 if (obj->IsAllocationSite()) RelinkAllocationSite(AllocationSite::cast(obj)); | 919 if (obj->IsAllocationSite()) RelinkAllocationSite(AllocationSite::cast(obj)); |
920 | 920 |
921 // Fix up strings from serialized user code. | 921 // Fix up strings from serialized user code. |
922 if (deserializing_user_code()) obj = ProcessNewObjectFromSerializedCode(obj); | 922 if (deserializing_user_code()) obj = ProcessNewObjectFromSerializedCode(obj); |
923 | 923 |
924 *write_back = obj; | 924 *write_back = obj; |
925 #ifdef DEBUG | 925 #ifdef DEBUG |
926 bool is_codespace = (space_number == CODE_SPACE); | 926 bool is_codespace = (space_number == CODE_SPACE); |
927 ASSERT(obj->IsCode() == is_codespace); | 927 ASSERT(obj->IsCode() == is_codespace); |
928 #endif | 928 #endif |
| 929 #if V8_TARGET_ARCH_PPC && \ |
| 930 (ABI_USES_FUNCTION_DESCRIPTORS || V8_OOL_CONSTANT_POOL) |
| 931 // If we're on a platform that uses function descriptors |
| 932 // these jump tables make use of RelocInfo::INTERNAL_REFERENCE. |
| 933 // As the V8 serialization code doesn't handle that relocation type |
| 934 // we use this hack to fix up code that has function descriptors. |
| 935 if (space_number == CODE_SPACE) { |
| 936 Code * code = reinterpret_cast<Code*>(HeapObject::FromAddress(address)); |
| 937 for (RelocIterator it(code); !it.done(); it.next()) { |
| 938 RelocInfo::Mode rmode = it.rinfo()->rmode(); |
| 939 if (rmode == RelocInfo::INTERNAL_REFERENCE) { |
| 940 Assembler::RelocateInternalReference(it.rinfo()->pc(), 0, |
| 941 code->instruction_start()); |
| 942 } |
| 943 } |
| 944 } |
| 945 #endif |
929 } | 946 } |
930 | 947 |
931 void Deserializer::ReadChunk(Object** current, | 948 void Deserializer::ReadChunk(Object** current, |
932 Object** limit, | 949 Object** limit, |
933 int source_space, | 950 int source_space, |
934 Address current_object_address) { | 951 Address current_object_address) { |
935 Isolate* const isolate = isolate_; | 952 Isolate* const isolate = isolate_; |
936 // Write barrier support costs around 1% in startup time. In fact there | 953 // Write barrier support costs around 1% in startup time. In fact there |
937 // are no new space objects in current boot snapshots, so it's not needed, | 954 // are no new space objects in current boot snapshots, so it's not needed, |
938 // but that may change. | 955 // but that may change. |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 // code object. | 1198 // code object. |
1182 CASE_STATEMENT(kNewObject, kPlain, kInnerPointer, CODE_SPACE) | 1199 CASE_STATEMENT(kNewObject, kPlain, kInnerPointer, CODE_SPACE) |
1183 CASE_BODY(kNewObject, kPlain, kInnerPointer, CODE_SPACE) | 1200 CASE_BODY(kNewObject, kPlain, kInnerPointer, CODE_SPACE) |
1184 // Deserialize a new code object and write a pointer to its first | 1201 // Deserialize a new code object and write a pointer to its first |
1185 // instruction to the current code object. | 1202 // instruction to the current code object. |
1186 ALL_SPACES(kNewObject, kFromCode, kInnerPointer) | 1203 ALL_SPACES(kNewObject, kFromCode, kInnerPointer) |
1187 // Find a recently deserialized object using its offset from the current | 1204 // Find a recently deserialized object using its offset from the current |
1188 // allocation point and write a pointer to it to the current object. | 1205 // allocation point and write a pointer to it to the current object. |
1189 ALL_SPACES(kBackref, kPlain, kStartOfObject) | 1206 ALL_SPACES(kBackref, kPlain, kStartOfObject) |
1190 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject) | 1207 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject) |
1191 #if defined(V8_TARGET_ARCH_MIPS) || V8_OOL_CONSTANT_POOL || \ | 1208 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ |
1192 defined(V8_TARGET_ARCH_MIPS64) | 1209 defined(V8_TARGET_ARCH_PPC) || V8_OOL_CONSTANT_POOL |
1193 // Deserialize a new object from pointer found in code and write | 1210 // Deserialize a new object from pointer found in code and write |
1194 // a pointer to it to the current object. Required only for MIPS or ARM | 1211 // a pointer to it to the current object. Required only for MIPS, PPC or |
1195 // with ool constant pool, and omitted on the other architectures because | 1212 // ARM with ool constant pool, and omitted on the other architectures |
1196 // it is fully unrolled and would cause bloat. | 1213 // because it is fully unrolled and would cause bloat. |
1197 ALL_SPACES(kNewObject, kFromCode, kStartOfObject) | 1214 ALL_SPACES(kNewObject, kFromCode, kStartOfObject) |
1198 // Find a recently deserialized code object using its offset from the | 1215 // Find a recently deserialized code object using its offset from the |
1199 // current allocation point and write a pointer to it to the current | 1216 // current allocation point and write a pointer to it to the current |
1200 // object. Required only for MIPS or ARM with ool constant pool. | 1217 // object. Required only for MIPS, PPC or ARM with ool constant pool. |
1201 ALL_SPACES(kBackref, kFromCode, kStartOfObject) | 1218 ALL_SPACES(kBackref, kFromCode, kStartOfObject) |
1202 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject) | 1219 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject) |
1203 #endif | 1220 #endif |
1204 // Find a recently deserialized code object using its offset from the | 1221 // Find a recently deserialized code object using its offset from the |
1205 // current allocation point and write a pointer to its first instruction | 1222 // current allocation point and write a pointer to its first instruction |
1206 // to the current code object or the instruction pointer in a function | 1223 // to the current code object or the instruction pointer in a function |
1207 // object. | 1224 // object. |
1208 ALL_SPACES(kBackref, kFromCode, kInnerPointer) | 1225 ALL_SPACES(kBackref, kFromCode, kInnerPointer) |
1209 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer) | 1226 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer) |
1210 ALL_SPACES(kBackref, kPlain, kInnerPointer) | 1227 ALL_SPACES(kBackref, kPlain, kInnerPointer) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 return length; | 1427 return length; |
1411 } | 1428 } |
1412 | 1429 |
1413 | 1430 |
1414 int Serializer::RootIndex(HeapObject* heap_object, HowToCode from) { | 1431 int Serializer::RootIndex(HeapObject* heap_object, HowToCode from) { |
1415 Heap* heap = isolate()->heap(); | 1432 Heap* heap = isolate()->heap(); |
1416 if (heap->InNewSpace(heap_object)) return kInvalidRootIndex; | 1433 if (heap->InNewSpace(heap_object)) return kInvalidRootIndex; |
1417 for (int i = 0; i < root_index_wave_front_; i++) { | 1434 for (int i = 0; i < root_index_wave_front_; i++) { |
1418 Object* root = heap->roots_array_start()[i]; | 1435 Object* root = heap->roots_array_start()[i]; |
1419 if (!root->IsSmi() && root == heap_object) { | 1436 if (!root->IsSmi() && root == heap_object) { |
1420 #if defined(V8_TARGET_ARCH_MIPS) || V8_OOL_CONSTANT_POOL || \ | 1437 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ |
1421 defined(V8_TARGET_ARCH_MIPS64) | 1438 defined(V8_TARGET_ARCH_PPC) || V8_OOL_CONSTANT_POOL |
1422 if (from == kFromCode) { | 1439 if (from == kFromCode) { |
1423 // In order to avoid code bloat in the deserializer we don't have | 1440 // In order to avoid code bloat in the deserializer we don't have |
1424 // support for the encoding that specifies a particular root should | 1441 // support for the encoding that specifies a particular root should |
1425 // be written from within code. | 1442 // be written from within code. |
1426 return kInvalidRootIndex; | 1443 return kInvalidRootIndex; |
1427 } | 1444 } |
1428 #endif | 1445 #endif |
1429 return i; | 1446 return i; |
1430 } | 1447 } |
1431 } | 1448 } |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 | 2087 |
2071 int SerializedCodeData::CheckSum(String* string) { | 2088 int SerializedCodeData::CheckSum(String* string) { |
2072 int checksum = Version::Hash(); | 2089 int checksum = Version::Hash(); |
2073 #ifdef DEBUG | 2090 #ifdef DEBUG |
2074 uint32_t seed = static_cast<uint32_t>(checksum); | 2091 uint32_t seed = static_cast<uint32_t>(checksum); |
2075 checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); | 2092 checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); |
2076 #endif // DEBUG | 2093 #endif // DEBUG |
2077 return checksum; | 2094 return checksum; |
2078 } | 2095 } |
2079 } } // namespace v8::internal | 2096 } } // namespace v8::internal |
OLD | NEW |