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...) 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 if (data == kInternalReference) { |
1064 Assembler::deserialization_set_target_internal_reference_at(pc, | |
1065 target); | |
1066 } else { | |
1067 Assembler::deserialization_set_target_internal_reference_encoded_at( | |
1068 pc, target); | |
1069 } | |
1063 break; | 1070 break; |
1064 } | 1071 } |
1065 | 1072 |
1066 case kNop: | 1073 case kNop: |
1067 break; | 1074 break; |
1068 | 1075 |
1069 case kNextChunk: { | 1076 case kNextChunk: { |
1070 int space = source_.Get(); | 1077 int space = source_.Get(); |
1071 DCHECK(space < kNumberOfPreallocatedSpaces); | 1078 DCHECK(space < kNumberOfPreallocatedSpaces); |
1072 int chunk_index = current_chunk_[space]; | 1079 int chunk_index = current_chunk_[space]; |
(...skipping 747 matching lines...) Loading... | |
1820 // end of the code in the constant pool, whereas internal references are | 1827 // 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 | 1828 // inline. That would cause the skip to be negative. Instead, we store the |
1822 // offset from code entry. | 1829 // offset from code entry. |
1823 Address entry = Code::cast(object_)->entry(); | 1830 Address entry = Code::cast(object_)->entry(); |
1824 intptr_t pc_offset = rinfo->target_internal_reference_address() - entry; | 1831 intptr_t pc_offset = rinfo->target_internal_reference_address() - entry; |
1825 intptr_t target_offset = rinfo->target_internal_reference() - entry; | 1832 intptr_t target_offset = rinfo->target_internal_reference() - entry; |
1826 DCHECK(0 <= pc_offset && | 1833 DCHECK(0 <= pc_offset && |
1827 pc_offset <= Code::cast(object_)->instruction_size()); | 1834 pc_offset <= Code::cast(object_)->instruction_size()); |
1828 DCHECK(0 <= target_offset && | 1835 DCHECK(0 <= target_offset && |
1829 target_offset <= Code::cast(object_)->instruction_size()); | 1836 target_offset <= Code::cast(object_)->instruction_size()); |
1830 sink_->Put(kInternalReference, "InternalRef"); | 1837 rinfo->rmode() == RelocInfo::INTERNAL_REFERENCE |
yangguo
2015/03/19 19:16:33
Please do not use a tertiary operator like this. I
balazs.kilvady
2015/03/20 11:14:42
Done.
| |
1838 ? sink_->Put(kInternalReference, "InternalRef") | |
1839 : sink_->Put(kInternalReferenceEncoded, "InternalRefEnc"); | |
1831 sink_->PutInt(static_cast<uintptr_t>(pc_offset), "internal ref address"); | 1840 sink_->PutInt(static_cast<uintptr_t>(pc_offset), "internal ref address"); |
1832 sink_->PutInt(static_cast<uintptr_t>(target_offset), "internal ref value"); | 1841 sink_->PutInt(static_cast<uintptr_t>(target_offset), "internal ref value"); |
1833 } | 1842 } |
1834 | 1843 |
1835 | 1844 |
1836 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { | 1845 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { |
1837 int skip = OutputRawData(rinfo->target_address_address(), | 1846 int skip = OutputRawData(rinfo->target_address_address(), |
1838 kCanReturnSkipInsteadOfSkipping); | 1847 kCanReturnSkipInsteadOfSkipping); |
1839 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; | 1848 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
1840 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); | 1849 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); |
(...skipping 667 matching lines...) Loading... | |
2508 DisallowHeapAllocation no_gc; | 2517 DisallowHeapAllocation no_gc; |
2509 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2518 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2510 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2519 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2511 if (r == CHECK_SUCCESS) return scd; | 2520 if (r == CHECK_SUCCESS) return scd; |
2512 cached_data->Reject(); | 2521 cached_data->Reject(); |
2513 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2522 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2514 delete scd; | 2523 delete scd; |
2515 return NULL; | 2524 return NULL; |
2516 } | 2525 } |
2517 } } // namespace v8::internal | 2526 } } // namespace v8::internal |
OLD | NEW |