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 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 CASE_STATEMENT(kNewObject, kPlain, kInnerPointer, CODE_SPACE) | 999 CASE_STATEMENT(kNewObject, kPlain, kInnerPointer, CODE_SPACE) |
1000 CASE_BODY(kNewObject, kPlain, kInnerPointer, CODE_SPACE) | 1000 CASE_BODY(kNewObject, kPlain, kInnerPointer, CODE_SPACE) |
1001 // Deserialize a new code object and write a pointer to its first | 1001 // Deserialize a new code object and write a pointer to its first |
1002 // instruction to the current code object. | 1002 // instruction to the current code object. |
1003 ALL_SPACES(kNewObject, kFromCode, kInnerPointer) | 1003 ALL_SPACES(kNewObject, kFromCode, kInnerPointer) |
1004 // Find a recently deserialized object using its offset from the current | 1004 // Find a recently deserialized object using its offset from the current |
1005 // allocation point and write a pointer to it to the current object. | 1005 // allocation point and write a pointer to it to the current object. |
1006 ALL_SPACES(kBackref, kPlain, kStartOfObject) | 1006 ALL_SPACES(kBackref, kPlain, kStartOfObject) |
1007 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject) | 1007 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject) |
1008 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ | 1008 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ |
1009 defined(V8_TARGET_ARCH_PPC) | 1009 defined(V8_TARGET_ARCH_PPC) || V8_OOL_CONSTANT_POOL |
1010 // Deserialize a new object from pointer found in code and write | 1010 // Deserialize a new object from pointer found in code and write |
1011 // a pointer to it to the current object. Required only for MIPS, PPC or | 1011 // a pointer to it to the current object. Required only for MIPS, PPC or |
1012 // ARM with ool constant pool, and omitted on the other architectures | 1012 // ARM with ool constant pool, and omitted on the other architectures |
1013 // because it is fully unrolled and would cause bloat. | 1013 // because it is fully unrolled and would cause bloat. |
1014 ALL_SPACES(kNewObject, kFromCode, kStartOfObject) | 1014 ALL_SPACES(kNewObject, kFromCode, kStartOfObject) |
1015 // Find a recently deserialized code object using its offset from the | 1015 // Find a recently deserialized code object using its offset from the |
1016 // current allocation point and write a pointer to it to the current | 1016 // current allocation point and write a pointer to it to the current |
1017 // object. Required only for MIPS, PPC or ARM with ool constant pool. | 1017 // object. Required only for MIPS, PPC or ARM with ool constant pool. |
1018 ALL_SPACES(kBackref, kFromCode, kStartOfObject) | 1018 ALL_SPACES(kBackref, kFromCode, kStartOfObject) |
1019 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject) | 1019 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject) |
1020 #endif | 1020 #endif |
1021 // Find a recently deserialized code object using its offset from the | 1021 // Find a recently deserialized code object using its offset from the |
1022 // current allocation point and write a pointer to its first instruction | 1022 // current allocation point and write a pointer to its first instruction |
1023 // to the current code object or the instruction pointer in a function | 1023 // to the current code object or the instruction pointer in a function |
1024 // object. | 1024 // object. |
1025 ALL_SPACES(kBackref, kFromCode, kInnerPointer) | 1025 ALL_SPACES(kBackref, kFromCode, kInnerPointer) |
1026 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer) | 1026 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer) |
1027 ALL_SPACES(kBackref, kPlain, kInnerPointer) | 1027 ALL_SPACES(kBackref, kPlain, kInnerPointer) |
1028 ALL_SPACES(kBackrefWithSkip, kPlain, kInnerPointer) | 1028 ALL_SPACES(kBackrefWithSkip, kPlain, kInnerPointer) |
1029 // 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 |
1030 // current object. | 1030 // current object. |
1031 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) | 1031 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) |
1032 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0) | 1032 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0) |
1033 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ | 1033 #if defined(V8_TARGET_ARCH_MIPS) || V8_OOL_CONSTANT_POOL || \ |
1034 defined(V8_TARGET_ARCH_PPC) | 1034 defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) |
1035 // Find an object in the roots array and write a pointer to it to in code. | 1035 // Find an object in the roots array and write a pointer to it to in code. |
1036 CASE_STATEMENT(kRootArray, kFromCode, kStartOfObject, 0) | 1036 CASE_STATEMENT(kRootArray, kFromCode, kStartOfObject, 0) |
1037 CASE_BODY(kRootArray, kFromCode, kStartOfObject, 0) | 1037 CASE_BODY(kRootArray, kFromCode, kStartOfObject, 0) |
1038 #endif | 1038 #endif |
1039 // Find an object in the partial snapshots cache and write a pointer to it | 1039 // Find an object in the partial snapshots cache and write a pointer to it |
1040 // to the current object. | 1040 // to the current object. |
1041 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) | 1041 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) |
1042 CASE_BODY(kPartialSnapshotCache, kPlain, kStartOfObject, 0) | 1042 CASE_BODY(kPartialSnapshotCache, kPlain, kStartOfObject, 0) |
1043 // Find an code entry in the partial snapshots cache and | 1043 // Find an code entry in the partial snapshots cache and |
1044 // write a pointer to it to the current object. | 1044 // write a pointer to it to the current object. |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 current_contents, kPlain, kStartOfObject, 0); | 1943 current_contents, kPlain, kStartOfObject, 0); |
1944 bytes_processed_so_far_ += kPointerSize; | 1944 bytes_processed_so_far_ += kPointerSize; |
1945 current++; | 1945 current++; |
1946 } | 1946 } |
1947 } | 1947 } |
1948 } | 1948 } |
1949 } | 1949 } |
1950 | 1950 |
1951 | 1951 |
1952 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { | 1952 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { |
| 1953 // Out-of-line constant pool entries will be visited by the ConstantPoolArray. |
| 1954 if (FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool()) return; |
| 1955 |
1953 int skip = OutputRawData(rinfo->target_address_address(), | 1956 int skip = OutputRawData(rinfo->target_address_address(), |
1954 kCanReturnSkipInsteadOfSkipping); | 1957 kCanReturnSkipInsteadOfSkipping); |
1955 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; | 1958 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
1956 Object* object = rinfo->target_object(); | 1959 Object* object = rinfo->target_object(); |
1957 serializer_->SerializeObject(HeapObject::cast(object), how_to_code, | 1960 serializer_->SerializeObject(HeapObject::cast(object), how_to_code, |
1958 kStartOfObject, skip); | 1961 kStartOfObject, skip); |
1959 bytes_processed_so_far_ += rinfo->target_address_size(); | 1962 bytes_processed_so_far_ += rinfo->target_address_size(); |
1960 } | 1963 } |
1961 | 1964 |
1962 | 1965 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; | 2017 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
2015 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); | 2018 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); |
2016 sink_->PutInt(skip, "SkipB4ExternalRef"); | 2019 sink_->PutInt(skip, "SkipB4ExternalRef"); |
2017 Address target = rinfo->target_address(); | 2020 Address target = rinfo->target_address(); |
2018 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); | 2021 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); |
2019 bytes_processed_so_far_ += rinfo->target_address_size(); | 2022 bytes_processed_so_far_ += rinfo->target_address_size(); |
2020 } | 2023 } |
2021 | 2024 |
2022 | 2025 |
2023 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { | 2026 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { |
| 2027 // Out-of-line constant pool entries will be visited by the ConstantPoolArray. |
| 2028 if (FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool()) return; |
| 2029 |
2024 int skip = OutputRawData(rinfo->target_address_address(), | 2030 int skip = OutputRawData(rinfo->target_address_address(), |
2025 kCanReturnSkipInsteadOfSkipping); | 2031 kCanReturnSkipInsteadOfSkipping); |
2026 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 2032 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
2027 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); | 2033 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); |
2028 bytes_processed_so_far_ += rinfo->target_address_size(); | 2034 bytes_processed_so_far_ += rinfo->target_address_size(); |
2029 } | 2035 } |
2030 | 2036 |
2031 | 2037 |
2032 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { | 2038 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { |
2033 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); | 2039 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); |
2034 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); | 2040 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); |
2035 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); | 2041 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); |
2036 bytes_processed_so_far_ += kPointerSize; | 2042 bytes_processed_so_far_ += kPointerSize; |
2037 } | 2043 } |
2038 | 2044 |
2039 | 2045 |
2040 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { | 2046 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { |
| 2047 // Out-of-line constant pool entries will be visited by the ConstantPoolArray. |
| 2048 if (FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool()) return; |
| 2049 |
2041 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); | 2050 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); |
2042 Cell* object = Cell::cast(rinfo->target_cell()); | 2051 Cell* object = Cell::cast(rinfo->target_cell()); |
2043 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); | 2052 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); |
2044 bytes_processed_so_far_ += kPointerSize; | 2053 bytes_processed_so_far_ += kPointerSize; |
2045 } | 2054 } |
2046 | 2055 |
2047 | 2056 |
2048 void Serializer::ObjectSerializer::VisitExternalOneByteString( | 2057 void Serializer::ObjectSerializer::VisitExternalOneByteString( |
2049 v8::String::ExternalOneByteStringResource** resource_pointer) { | 2058 v8::String::ExternalOneByteStringResource** resource_pointer) { |
2050 Address references_start = reinterpret_cast<Address>(resource_pointer); | 2059 Address references_start = reinterpret_cast<Address>(resource_pointer); |
(...skipping 27 matching lines...) Expand all Loading... |
2078 // Code age headers are not serializable. | 2087 // Code age headers are not serializable. |
2079 code->MakeYoung(serializer_->isolate()); | 2088 code->MakeYoung(serializer_->isolate()); |
2080 int mode_mask = RelocInfo::kCodeTargetMask | | 2089 int mode_mask = RelocInfo::kCodeTargetMask | |
2081 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 2090 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
2082 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 2091 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
2083 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | | 2092 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | |
2084 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | | 2093 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | |
2085 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); | 2094 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
2086 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { | 2095 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { |
2087 RelocInfo* rinfo = it.rinfo(); | 2096 RelocInfo* rinfo = it.rinfo(); |
2088 rinfo->WipeOut(); | 2097 if (!(FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool())) { |
| 2098 rinfo->WipeOut(); |
| 2099 } |
2089 } | 2100 } |
2090 // We need to wipe out the header fields *after* wiping out the | 2101 // We need to wipe out the header fields *after* wiping out the |
2091 // relocations, because some of these fields are needed for the latter. | 2102 // relocations, because some of these fields are needed for the latter. |
2092 code->WipeOutHeader(); | 2103 code->WipeOutHeader(); |
2093 return code->address(); | 2104 return code->address(); |
2094 } | 2105 } |
2095 | 2106 |
2096 | 2107 |
2097 int Serializer::ObjectSerializer::OutputRawData( | 2108 int Serializer::ObjectSerializer::OutputRawData( |
2098 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) { | 2109 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) { |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2677 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2688 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2678 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2689 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2679 if (r == CHECK_SUCCESS) return scd; | 2690 if (r == CHECK_SUCCESS) return scd; |
2680 cached_data->Reject(); | 2691 cached_data->Reject(); |
2681 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2692 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2682 delete scd; | 2693 delete scd; |
2683 return NULL; | 2694 return NULL; |
2684 } | 2695 } |
2685 } // namespace internal | 2696 } // namespace internal |
2686 } // namespace v8 | 2697 } // namespace v8 |
OLD | NEW |