| 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/snapshot/serialize.h" | 5 #include "src/snapshot/serialize.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { | 47 ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { |
| 48 // Miscellaneous | 48 // Miscellaneous |
| 49 Add(ExternalReference::roots_array_start(isolate).address(), | 49 Add(ExternalReference::roots_array_start(isolate).address(), |
| 50 "Heap::roots_array_start()"); | 50 "Heap::roots_array_start()"); |
| 51 Add(ExternalReference::address_of_stack_limit(isolate).address(), | 51 Add(ExternalReference::address_of_stack_limit(isolate).address(), |
| 52 "StackGuard::address_of_jslimit()"); | 52 "StackGuard::address_of_jslimit()"); |
| 53 Add(ExternalReference::address_of_real_stack_limit(isolate).address(), | 53 Add(ExternalReference::address_of_real_stack_limit(isolate).address(), |
| 54 "StackGuard::address_of_real_jslimit()"); | 54 "StackGuard::address_of_real_jslimit()"); |
| 55 Add(ExternalReference::new_space_start(isolate).address(), | 55 Add(ExternalReference::new_space_start(isolate).address(), |
| 56 "Heap::NewSpaceStart()"); | 56 "Heap::NewSpaceStart()"); |
| 57 Add(ExternalReference::new_space_mask(isolate).address(), | |
| 58 "Heap::NewSpaceMask()"); | |
| 59 Add(ExternalReference::new_space_allocation_limit_address(isolate).address(), | 57 Add(ExternalReference::new_space_allocation_limit_address(isolate).address(), |
| 60 "Heap::NewSpaceAllocationLimitAddress()"); | 58 "Heap::NewSpaceAllocationLimitAddress()"); |
| 61 Add(ExternalReference::new_space_allocation_top_address(isolate).address(), | 59 Add(ExternalReference::new_space_allocation_top_address(isolate).address(), |
| 62 "Heap::NewSpaceAllocationTopAddress()"); | 60 "Heap::NewSpaceAllocationTopAddress()"); |
| 63 Add(ExternalReference::mod_two_doubles_operation(isolate).address(), | 61 Add(ExternalReference::mod_two_doubles_operation(isolate).address(), |
| 64 "mod_two_doubles"); | 62 "mod_two_doubles"); |
| 65 // Keyed lookup cache. | 63 // Keyed lookup cache. |
| 66 Add(ExternalReference::keyed_lookup_cache_keys(isolate).address(), | 64 Add(ExternalReference::keyed_lookup_cache_keys(isolate).address(), |
| 67 "KeyedLookupCache::keys()"); | 65 "KeyedLookupCache::keys()"); |
| 68 Add(ExternalReference::keyed_lookup_cache_field_offsets(isolate).address(), | 66 Add(ExternalReference::keyed_lookup_cache_field_offsets(isolate).address(), |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 STATIC_ASSERT((within & ~kWhereToPointMask) == 0); \ | 932 STATIC_ASSERT((within & ~kWhereToPointMask) == 0); \ |
| 935 STATIC_ASSERT((space_number & ~kSpaceMask) == 0); | 933 STATIC_ASSERT((space_number & ~kSpaceMask) == 0); |
| 936 | 934 |
| 937 #define CASE_BODY(where, how, within, space_number_if_any) \ | 935 #define CASE_BODY(where, how, within, space_number_if_any) \ |
| 938 { \ | 936 { \ |
| 939 bool emit_write_barrier = false; \ | 937 bool emit_write_barrier = false; \ |
| 940 bool current_was_incremented = false; \ | 938 bool current_was_incremented = false; \ |
| 941 int space_number = space_number_if_any == kAnyOldSpace \ | 939 int space_number = space_number_if_any == kAnyOldSpace \ |
| 942 ? (data & kSpaceMask) \ | 940 ? (data & kSpaceMask) \ |
| 943 : space_number_if_any; \ | 941 : space_number_if_any; \ |
| 942 Object* new_object = NULL; /* May not be a real Object pointer. */ \ |
| 944 if (where == kNewObject && how == kPlain && within == kStartOfObject) { \ | 943 if (where == kNewObject && how == kPlain && within == kStartOfObject) { \ |
| 945 ReadObject(space_number, current); \ | 944 ReadObject(space_number, current); \ |
| 946 emit_write_barrier = (space_number == NEW_SPACE); \ | 945 emit_write_barrier = (space_number == NEW_SPACE); \ |
| 947 } else { \ | 946 } else { \ |
| 948 Object* new_object = NULL; /* May not be a real Object pointer. */ \ | |
| 949 if (where == kNewObject) { \ | 947 if (where == kNewObject) { \ |
| 950 ReadObject(space_number, &new_object); \ | 948 ReadObject(space_number, &new_object); \ |
| 951 } else if (where == kBackref) { \ | 949 } else if (where == kBackref) { \ |
| 952 emit_write_barrier = (space_number == NEW_SPACE); \ | 950 emit_write_barrier = (space_number == NEW_SPACE); \ |
| 953 new_object = GetBackReferencedObject(data & kSpaceMask); \ | 951 new_object = GetBackReferencedObject(data & kSpaceMask); \ |
| 954 } else if (where == kBackrefWithSkip) { \ | 952 } else if (where == kBackrefWithSkip) { \ |
| 955 int skip = source_.GetInt(); \ | 953 int skip = source_.GetInt(); \ |
| 956 current = reinterpret_cast<Object**>( \ | 954 current = reinterpret_cast<Object**>( \ |
| 957 reinterpret_cast<Address>(current) + skip); \ | 955 reinterpret_cast<Address>(current) + skip); \ |
| 958 emit_write_barrier = (space_number == NEW_SPACE); \ | 956 emit_write_barrier = (space_number == NEW_SPACE); \ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 reinterpret_cast<Address>(new_object)); \ | 1005 reinterpret_cast<Address>(new_object)); \ |
| 1008 location_of_branch_data += Assembler::kSpecialTargetSize; \ | 1006 location_of_branch_data += Assembler::kSpecialTargetSize; \ |
| 1009 current = reinterpret_cast<Object**>(location_of_branch_data); \ | 1007 current = reinterpret_cast<Object**>(location_of_branch_data); \ |
| 1010 current_was_incremented = true; \ | 1008 current_was_incremented = true; \ |
| 1011 } else { \ | 1009 } else { \ |
| 1012 UnalignedCopy(current, &new_object); \ | 1010 UnalignedCopy(current, &new_object); \ |
| 1013 } \ | 1011 } \ |
| 1014 } \ | 1012 } \ |
| 1015 if (emit_write_barrier && write_barrier_needed) { \ | 1013 if (emit_write_barrier && write_barrier_needed) { \ |
| 1016 Address current_address = reinterpret_cast<Address>(current); \ | 1014 Address current_address = reinterpret_cast<Address>(current); \ |
| 1015 /* Builtins have been filtered above, so we are on-heap. */ \ |
| 1017 isolate->heap()->RecordWrite( \ | 1016 isolate->heap()->RecordWrite( \ |
| 1018 current_object_address, \ | 1017 reinterpret_cast<Object*>(current_object_address + 1), \ |
| 1019 static_cast<int>(current_address - current_object_address)); \ | 1018 static_cast<int>(current_address - current_object_address), \ |
| 1019 new_object); \ |
| 1020 } \ | 1020 } \ |
| 1021 if (!current_was_incremented) { \ | 1021 if (!current_was_incremented) { \ |
| 1022 current++; \ | 1022 current++; \ |
| 1023 } \ | 1023 } \ |
| 1024 break; \ | 1024 break; \ |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 // This generates a case and a body for the new space (which has to do extra | 1027 // This generates a case and a body for the new space (which has to do extra |
| 1028 // write barrier handling) and handles the other spaces with fall-through cases | 1028 // write barrier handling) and handles the other spaces with fall-through cases |
| 1029 // and one body. | 1029 // and one body. |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 current = reinterpret_cast<Object**>( | 1241 current = reinterpret_cast<Object**>( |
| 1242 reinterpret_cast<Address>(current) + skip); | 1242 reinterpret_cast<Address>(current) + skip); |
| 1243 // Fall through. | 1243 // Fall through. |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 FOUR_CASES(kHotObject) | 1246 FOUR_CASES(kHotObject) |
| 1247 FOUR_CASES(kHotObject + 4) { | 1247 FOUR_CASES(kHotObject + 4) { |
| 1248 int index = data & kHotObjectMask; | 1248 int index = data & kHotObjectMask; |
| 1249 Object* hot_object = hot_objects_.Get(index); | 1249 Object* hot_object = hot_objects_.Get(index); |
| 1250 UnalignedCopy(current, &hot_object); | 1250 UnalignedCopy(current, &hot_object); |
| 1251 if (write_barrier_needed && isolate->heap()->InNewSpace(hot_object)) { | 1251 if (write_barrier_needed) { |
| 1252 Address current_address = reinterpret_cast<Address>(current); | 1252 Address current_address = reinterpret_cast<Address>(current); |
| 1253 isolate->heap()->RecordWrite( | 1253 isolate->heap()->RecordWrite( |
| 1254 current_object_address, | 1254 reinterpret_cast<Object*>(current_object_address + 1), |
| 1255 static_cast<int>(current_address - current_object_address)); | 1255 static_cast<int>(current_address - current_object_address), |
| 1256 hot_object); |
| 1256 } | 1257 } |
| 1257 current++; | 1258 current++; |
| 1258 break; | 1259 break; |
| 1259 } | 1260 } |
| 1260 | 1261 |
| 1261 // Deserialize raw data of fixed length from 1 to 32 words. | 1262 // Deserialize raw data of fixed length from 1 to 32 words. |
| 1262 STATIC_ASSERT(kNumberOfFixedRawData == 32); | 1263 STATIC_ASSERT(kNumberOfFixedRawData == 32); |
| 1263 SIXTEEN_CASES(kFixedRawData) | 1264 SIXTEEN_CASES(kFixedRawData) |
| 1264 SIXTEEN_CASES(kFixedRawData + 16) { | 1265 SIXTEEN_CASES(kFixedRawData + 16) { |
| 1265 byte* raw_data_out = reinterpret_cast<byte*>(current); | 1266 byte* raw_data_out = reinterpret_cast<byte*>(current); |
| (...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2847 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2848 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2848 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2849 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2849 if (r == CHECK_SUCCESS) return scd; | 2850 if (r == CHECK_SUCCESS) return scd; |
| 2850 cached_data->Reject(); | 2851 cached_data->Reject(); |
| 2851 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2852 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2852 delete scd; | 2853 delete scd; |
| 2853 return NULL; | 2854 return NULL; |
| 2854 } | 2855 } |
| 2855 } // namespace internal | 2856 } // namespace internal |
| 2856 } // namespace v8 | 2857 } // namespace v8 |
| OLD | NEW |