Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: src/snapshot/serialize.cc

Issue 1162993006: Add support for Embedded Constant Pools for PPC and Arm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) || V8_OOL_CONSTANT_POOL 1009 defined(V8_TARGET_ARCH_PPC)
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) || V8_OOL_CONSTANT_POOL || \ 1033 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \
1034 defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) 1034 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
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
1956 int skip = OutputRawData(rinfo->target_address_address(), 1953 int skip = OutputRawData(rinfo->target_address_address(),
1957 kCanReturnSkipInsteadOfSkipping); 1954 kCanReturnSkipInsteadOfSkipping);
1958 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; 1955 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
1959 Object* object = rinfo->target_object(); 1956 Object* object = rinfo->target_object();
1960 serializer_->SerializeObject(HeapObject::cast(object), how_to_code, 1957 serializer_->SerializeObject(HeapObject::cast(object), how_to_code,
1961 kStartOfObject, skip); 1958 kStartOfObject, skip);
1962 bytes_processed_so_far_ += rinfo->target_address_size(); 1959 bytes_processed_so_far_ += rinfo->target_address_size();
1963 } 1960 }
1964 1961
1965 1962
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; 2014 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
2018 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); 2015 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef");
2019 sink_->PutInt(skip, "SkipB4ExternalRef"); 2016 sink_->PutInt(skip, "SkipB4ExternalRef");
2020 Address target = rinfo->target_address(); 2017 Address target = rinfo->target_address();
2021 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); 2018 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id");
2022 bytes_processed_so_far_ += rinfo->target_address_size(); 2019 bytes_processed_so_far_ += rinfo->target_address_size();
2023 } 2020 }
2024 2021
2025 2022
2026 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { 2023 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
2030 int skip = OutputRawData(rinfo->target_address_address(), 2024 int skip = OutputRawData(rinfo->target_address_address(),
2031 kCanReturnSkipInsteadOfSkipping); 2025 kCanReturnSkipInsteadOfSkipping);
2032 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address()); 2026 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address());
2033 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); 2027 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip);
2034 bytes_processed_so_far_ += rinfo->target_address_size(); 2028 bytes_processed_so_far_ += rinfo->target_address_size();
2035 } 2029 }
2036 2030
2037 2031
2038 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { 2032 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) {
2039 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); 2033 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping);
2040 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); 2034 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address));
2041 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); 2035 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip);
2042 bytes_processed_so_far_ += kPointerSize; 2036 bytes_processed_so_far_ += kPointerSize;
2043 } 2037 }
2044 2038
2045 2039
2046 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { 2040 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
2050 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); 2041 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping);
2051 Cell* object = Cell::cast(rinfo->target_cell()); 2042 Cell* object = Cell::cast(rinfo->target_cell());
2052 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); 2043 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip);
2053 bytes_processed_so_far_ += kPointerSize; 2044 bytes_processed_so_far_ += kPointerSize;
2054 } 2045 }
2055 2046
2056 2047
2057 void Serializer::ObjectSerializer::VisitExternalOneByteString( 2048 void Serializer::ObjectSerializer::VisitExternalOneByteString(
2058 v8::String::ExternalOneByteStringResource** resource_pointer) { 2049 v8::String::ExternalOneByteStringResource** resource_pointer) {
2059 Address references_start = reinterpret_cast<Address>(resource_pointer); 2050 Address references_start = reinterpret_cast<Address>(resource_pointer);
(...skipping 27 matching lines...) Expand all
2087 // Code age headers are not serializable. 2078 // Code age headers are not serializable.
2088 code->MakeYoung(serializer_->isolate()); 2079 code->MakeYoung(serializer_->isolate());
2089 int mode_mask = RelocInfo::kCodeTargetMask | 2080 int mode_mask = RelocInfo::kCodeTargetMask |
2090 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | 2081 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
2091 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | 2082 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
2092 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | 2083 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) |
2093 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | 2084 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) |
2094 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); 2085 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED);
2095 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { 2086 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) {
2096 RelocInfo* rinfo = it.rinfo(); 2087 RelocInfo* rinfo = it.rinfo();
2097 if (!(FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool())) { 2088 rinfo->WipeOut();
2098 rinfo->WipeOut();
2099 }
2100 } 2089 }
2101 // We need to wipe out the header fields *after* wiping out the 2090 // We need to wipe out the header fields *after* wiping out the
2102 // relocations, because some of these fields are needed for the latter. 2091 // relocations, because some of these fields are needed for the latter.
2103 code->WipeOutHeader(); 2092 code->WipeOutHeader();
2104 return code->address(); 2093 return code->address();
2105 } 2094 }
2106 2095
2107 2096
2108 int Serializer::ObjectSerializer::OutputRawData( 2097 int Serializer::ObjectSerializer::OutputRawData(
2109 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) { 2098 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) {
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 SerializedCodeData* scd = new SerializedCodeData(cached_data); 2677 SerializedCodeData* scd = new SerializedCodeData(cached_data);
2689 SanityCheckResult r = scd->SanityCheck(isolate, source); 2678 SanityCheckResult r = scd->SanityCheck(isolate, source);
2690 if (r == CHECK_SUCCESS) return scd; 2679 if (r == CHECK_SUCCESS) return scd;
2691 cached_data->Reject(); 2680 cached_data->Reject();
2692 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 2681 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
2693 delete scd; 2682 delete scd;
2694 return NULL; 2683 return NULL;
2695 } 2684 }
2696 } // namespace internal 2685 } // namespace internal
2697 } // namespace v8 2686 } // namespace v8
OLDNEW
« src/objects.h ('K') | « src/runtime/runtime-generator.cc ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698