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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 #undef CASE_BODY | 1041 #undef CASE_BODY |
1042 #undef ALL_SPACES | 1042 #undef ALL_SPACES |
1043 | 1043 |
1044 case kSkip: { | 1044 case kSkip: { |
1045 int size = source_.GetInt(); | 1045 int size = source_.GetInt(); |
1046 current = reinterpret_cast<Object**>( | 1046 current = reinterpret_cast<Object**>( |
1047 reinterpret_cast<intptr_t>(current) + size); | 1047 reinterpret_cast<intptr_t>(current) + size); |
1048 break; | 1048 break; |
1049 } | 1049 } |
1050 | 1050 |
| 1051 case kInternalReferenceEncoded: |
1051 case kInternalReference: { | 1052 case kInternalReference: { |
1052 // Internal reference address is not encoded via skip, but by offset | 1053 // Internal reference address is not encoded via skip, but by offset |
1053 // from code entry. | 1054 // from code entry. |
1054 int pc_offset = source_.GetInt(); | 1055 int pc_offset = source_.GetInt(); |
1055 int target_offset = source_.GetInt(); | 1056 int target_offset = source_.GetInt(); |
1056 Code* code = | 1057 Code* code = |
1057 Code::cast(HeapObject::FromAddress(current_object_address)); | 1058 Code::cast(HeapObject::FromAddress(current_object_address)); |
1058 DCHECK(0 <= pc_offset && pc_offset <= code->instruction_size()); | 1059 DCHECK(0 <= pc_offset && pc_offset <= code->instruction_size()); |
1059 DCHECK(0 <= target_offset && target_offset <= code->instruction_size()); | 1060 DCHECK(0 <= target_offset && target_offset <= code->instruction_size()); |
1060 Address pc = code->entry() + pc_offset; | 1061 Address pc = code->entry() + pc_offset; |
1061 Address target = code->entry() + target_offset; | 1062 Address target = code->entry() + target_offset; |
1062 Assembler::deserialization_set_target_internal_reference_at(pc, target); | 1063 Assembler::deserialization_set_target_internal_reference_at( |
| 1064 pc, target, data == kInternalReference |
| 1065 ? RelocInfo::INTERNAL_REFERENCE |
| 1066 : RelocInfo::INTERNAL_REFERENCE_ENCODED); |
1063 break; | 1067 break; |
1064 } | 1068 } |
1065 | 1069 |
1066 case kNop: | 1070 case kNop: |
1067 break; | 1071 break; |
1068 | 1072 |
1069 case kNextChunk: { | 1073 case kNextChunk: { |
1070 int space = source_.Get(); | 1074 int space = source_.Get(); |
1071 DCHECK(space < kNumberOfPreallocatedSpaces); | 1075 DCHECK(space < kNumberOfPreallocatedSpaces); |
1072 int chunk_index = current_chunk_[space]; | 1076 int chunk_index = current_chunk_[space]; |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 // end of the code in the constant pool, whereas internal references are | 1824 // end of the code in the constant pool, whereas internal references are |
1821 // inline. That would cause the skip to be negative. Instead, we store the | 1825 // inline. That would cause the skip to be negative. Instead, we store the |
1822 // offset from code entry. | 1826 // offset from code entry. |
1823 Address entry = Code::cast(object_)->entry(); | 1827 Address entry = Code::cast(object_)->entry(); |
1824 intptr_t pc_offset = rinfo->target_internal_reference_address() - entry; | 1828 intptr_t pc_offset = rinfo->target_internal_reference_address() - entry; |
1825 intptr_t target_offset = rinfo->target_internal_reference() - entry; | 1829 intptr_t target_offset = rinfo->target_internal_reference() - entry; |
1826 DCHECK(0 <= pc_offset && | 1830 DCHECK(0 <= pc_offset && |
1827 pc_offset <= Code::cast(object_)->instruction_size()); | 1831 pc_offset <= Code::cast(object_)->instruction_size()); |
1828 DCHECK(0 <= target_offset && | 1832 DCHECK(0 <= target_offset && |
1829 target_offset <= Code::cast(object_)->instruction_size()); | 1833 target_offset <= Code::cast(object_)->instruction_size()); |
1830 sink_->Put(kInternalReference, "InternalRef"); | 1834 sink_->Put(rinfo->rmode() == RelocInfo::INTERNAL_REFERENCE |
| 1835 ? kInternalReference |
| 1836 : kInternalReferenceEncoded, |
| 1837 "InternalRef"); |
1831 sink_->PutInt(static_cast<uintptr_t>(pc_offset), "internal ref address"); | 1838 sink_->PutInt(static_cast<uintptr_t>(pc_offset), "internal ref address"); |
1832 sink_->PutInt(static_cast<uintptr_t>(target_offset), "internal ref value"); | 1839 sink_->PutInt(static_cast<uintptr_t>(target_offset), "internal ref value"); |
1833 } | 1840 } |
1834 | 1841 |
1835 | 1842 |
1836 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { | 1843 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { |
1837 int skip = OutputRawData(rinfo->target_address_address(), | 1844 int skip = OutputRawData(rinfo->target_address_address(), |
1838 kCanReturnSkipInsteadOfSkipping); | 1845 kCanReturnSkipInsteadOfSkipping); |
1839 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; | 1846 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
1840 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); | 1847 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2508 DisallowHeapAllocation no_gc; | 2515 DisallowHeapAllocation no_gc; |
2509 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2516 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2510 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2517 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2511 if (r == CHECK_SUCCESS) return scd; | 2518 if (r == CHECK_SUCCESS) return scd; |
2512 cached_data->Reject(); | 2519 cached_data->Reject(); |
2513 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2520 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2514 delete scd; | 2521 delete scd; |
2515 return NULL; | 2522 return NULL; |
2516 } | 2523 } |
2517 } } // namespace v8::internal | 2524 } } // namespace v8::internal |
OLD | NEW |