| 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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 CASE_STATEMENT(kNewObject, kPlain, kInnerPointer, CODE_SPACE) | 970 CASE_STATEMENT(kNewObject, kPlain, kInnerPointer, CODE_SPACE) |
| 971 CASE_BODY(kNewObject, kPlain, kInnerPointer, CODE_SPACE) | 971 CASE_BODY(kNewObject, kPlain, kInnerPointer, CODE_SPACE) |
| 972 // Deserialize a new code object and write a pointer to its first | 972 // Deserialize a new code object and write a pointer to its first |
| 973 // instruction to the current code object. | 973 // instruction to the current code object. |
| 974 ALL_SPACES(kNewObject, kFromCode, kInnerPointer) | 974 ALL_SPACES(kNewObject, kFromCode, kInnerPointer) |
| 975 // Find a recently deserialized object using its offset from the current | 975 // Find a recently deserialized object using its offset from the current |
| 976 // allocation point and write a pointer to it to the current object. | 976 // allocation point and write a pointer to it to the current object. |
| 977 ALL_SPACES(kBackref, kPlain, kStartOfObject) | 977 ALL_SPACES(kBackref, kPlain, kStartOfObject) |
| 978 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject) | 978 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject) |
| 979 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ | 979 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ |
| 980 defined(V8_TARGET_ARCH_PPC) || V8_OOL_CONSTANT_POOL | 980 defined(V8_TARGET_ARCH_PPC) |
| 981 // Deserialize a new object from pointer found in code and write | 981 // Deserialize a new object from pointer found in code and write |
| 982 // a pointer to it to the current object. Required only for MIPS, PPC or | 982 // a pointer to it to the current object. Required only for MIPS, PPC or |
| 983 // ARM with ool constant pool, and omitted on the other architectures | 983 // ARM with ool constant pool, and omitted on the other architectures |
| 984 // because it is fully unrolled and would cause bloat. | 984 // because it is fully unrolled and would cause bloat. |
| 985 ALL_SPACES(kNewObject, kFromCode, kStartOfObject) | 985 ALL_SPACES(kNewObject, kFromCode, kStartOfObject) |
| 986 // Find a recently deserialized code object using its offset from the | 986 // Find a recently deserialized code object using its offset from the |
| 987 // current allocation point and write a pointer to it to the current | 987 // current allocation point and write a pointer to it to the current |
| 988 // object. Required only for MIPS, PPC or ARM with ool constant pool. | 988 // object. Required only for MIPS, PPC or ARM with ool constant pool. |
| 989 ALL_SPACES(kBackref, kFromCode, kStartOfObject) | 989 ALL_SPACES(kBackref, kFromCode, kStartOfObject) |
| 990 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject) | 990 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject) |
| 991 #endif | 991 #endif |
| 992 // Find a recently deserialized code object using its offset from the | 992 // Find a recently deserialized code object using its offset from the |
| 993 // current allocation point and write a pointer to its first instruction | 993 // current allocation point and write a pointer to its first instruction |
| 994 // to the current code object or the instruction pointer in a function | 994 // to the current code object or the instruction pointer in a function |
| 995 // object. | 995 // object. |
| 996 ALL_SPACES(kBackref, kFromCode, kInnerPointer) | 996 ALL_SPACES(kBackref, kFromCode, kInnerPointer) |
| 997 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer) | 997 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer) |
| 998 ALL_SPACES(kBackref, kPlain, kInnerPointer) | 998 ALL_SPACES(kBackref, kPlain, kInnerPointer) |
| 999 ALL_SPACES(kBackrefWithSkip, kPlain, kInnerPointer) | 999 ALL_SPACES(kBackrefWithSkip, kPlain, kInnerPointer) |
| 1000 // Find an object in the roots array and write a pointer to it to the | 1000 // Find an object in the roots array and write a pointer to it to the |
| 1001 // current object. | 1001 // current object. |
| 1002 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) | 1002 CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0) |
| 1003 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0) | 1003 CASE_BODY(kRootArray, kPlain, kStartOfObject, 0) |
| 1004 #if defined(V8_TARGET_ARCH_MIPS) || V8_OOL_CONSTANT_POOL || \ | 1004 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ |
| 1005 defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) | 1005 defined(V8_TARGET_ARCH_PPC) |
| 1006 // Find an object in the roots array and write a pointer to it to in code. | 1006 // Find an object in the roots array and write a pointer to it to in code. |
| 1007 CASE_STATEMENT(kRootArray, kFromCode, kStartOfObject, 0) | 1007 CASE_STATEMENT(kRootArray, kFromCode, kStartOfObject, 0) |
| 1008 CASE_BODY(kRootArray, kFromCode, kStartOfObject, 0) | 1008 CASE_BODY(kRootArray, kFromCode, kStartOfObject, 0) |
| 1009 #endif | 1009 #endif |
| 1010 // Find an object in the partial snapshots cache and write a pointer to it | 1010 // Find an object in the partial snapshots cache and write a pointer to it |
| 1011 // to the current object. | 1011 // to the current object. |
| 1012 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) | 1012 CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0) |
| 1013 CASE_BODY(kPartialSnapshotCache, kPlain, kStartOfObject, 0) | 1013 CASE_BODY(kPartialSnapshotCache, kPlain, kStartOfObject, 0) |
| 1014 // Find an code entry in the partial snapshots cache and | 1014 // Find an code entry in the partial snapshots cache and |
| 1015 // write a pointer to it to the current object. | 1015 // write a pointer to it to the current object. |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 current_contents, kPlain, kStartOfObject, 0); | 1849 current_contents, kPlain, kStartOfObject, 0); |
| 1850 bytes_processed_so_far_ += kPointerSize; | 1850 bytes_processed_so_far_ += kPointerSize; |
| 1851 current++; | 1851 current++; |
| 1852 } | 1852 } |
| 1853 } | 1853 } |
| 1854 } | 1854 } |
| 1855 } | 1855 } |
| 1856 | 1856 |
| 1857 | 1857 |
| 1858 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { | 1858 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { |
| 1859 // Out-of-line constant pool entries will be visited by the ConstantPoolArray. | |
| 1860 if (FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool()) return; | |
| 1861 | |
| 1862 int skip = OutputRawData(rinfo->target_address_address(), | 1859 int skip = OutputRawData(rinfo->target_address_address(), |
| 1863 kCanReturnSkipInsteadOfSkipping); | 1860 kCanReturnSkipInsteadOfSkipping); |
| 1864 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; | 1861 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
| 1865 Object* object = rinfo->target_object(); | 1862 Object* object = rinfo->target_object(); |
| 1866 serializer_->SerializeObject(HeapObject::cast(object), how_to_code, | 1863 serializer_->SerializeObject(HeapObject::cast(object), how_to_code, |
| 1867 kStartOfObject, skip); | 1864 kStartOfObject, skip); |
| 1868 bytes_processed_so_far_ += rinfo->target_address_size(); | 1865 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1869 } | 1866 } |
| 1870 | 1867 |
| 1871 | 1868 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1923 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; | 1920 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
| 1924 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); | 1921 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); |
| 1925 sink_->PutInt(skip, "SkipB4ExternalRef"); | 1922 sink_->PutInt(skip, "SkipB4ExternalRef"); |
| 1926 Address target = rinfo->target_address(); | 1923 Address target = rinfo->target_address(); |
| 1927 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); | 1924 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); |
| 1928 bytes_processed_so_far_ += rinfo->target_address_size(); | 1925 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1929 } | 1926 } |
| 1930 | 1927 |
| 1931 | 1928 |
| 1932 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { | 1929 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { |
| 1933 // Out-of-line constant pool entries will be visited by the ConstantPoolArray. | |
| 1934 if (FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool()) return; | |
| 1935 | |
| 1936 int skip = OutputRawData(rinfo->target_address_address(), | 1930 int skip = OutputRawData(rinfo->target_address_address(), |
| 1937 kCanReturnSkipInsteadOfSkipping); | 1931 kCanReturnSkipInsteadOfSkipping); |
| 1938 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 1932 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 1939 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); | 1933 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); |
| 1940 bytes_processed_so_far_ += rinfo->target_address_size(); | 1934 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1941 } | 1935 } |
| 1942 | 1936 |
| 1943 | 1937 |
| 1944 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { | 1938 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { |
| 1945 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); | 1939 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); |
| 1946 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); | 1940 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); |
| 1947 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); | 1941 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); |
| 1948 bytes_processed_so_far_ += kPointerSize; | 1942 bytes_processed_so_far_ += kPointerSize; |
| 1949 } | 1943 } |
| 1950 | 1944 |
| 1951 | 1945 |
| 1952 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { | 1946 void Serializer::ObjectSerializer::VisitCell(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->pc(), kCanReturnSkipInsteadOfSkipping); | 1947 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); |
| 1957 Cell* object = Cell::cast(rinfo->target_cell()); | 1948 Cell* object = Cell::cast(rinfo->target_cell()); |
| 1958 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); | 1949 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); |
| 1959 bytes_processed_so_far_ += kPointerSize; | 1950 bytes_processed_so_far_ += kPointerSize; |
| 1960 } | 1951 } |
| 1961 | 1952 |
| 1962 | 1953 |
| 1963 void Serializer::ObjectSerializer::VisitExternalOneByteString( | 1954 void Serializer::ObjectSerializer::VisitExternalOneByteString( |
| 1964 v8::String::ExternalOneByteStringResource** resource_pointer) { | 1955 v8::String::ExternalOneByteStringResource** resource_pointer) { |
| 1965 Address references_start = reinterpret_cast<Address>(resource_pointer); | 1956 Address references_start = reinterpret_cast<Address>(resource_pointer); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1993 // Code age headers are not serializable. | 1984 // Code age headers are not serializable. |
| 1994 code->MakeYoung(serializer_->isolate()); | 1985 code->MakeYoung(serializer_->isolate()); |
| 1995 int mode_mask = RelocInfo::kCodeTargetMask | | 1986 int mode_mask = RelocInfo::kCodeTargetMask | |
| 1996 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 1987 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 1997 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 1988 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 1998 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | | 1989 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | |
| 1999 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | | 1990 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | |
| 2000 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); | 1991 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
| 2001 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { | 1992 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { |
| 2002 RelocInfo* rinfo = it.rinfo(); | 1993 RelocInfo* rinfo = it.rinfo(); |
| 2003 if (!(FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool())) { | 1994 rinfo->WipeOut(); |
| 2004 rinfo->WipeOut(); | |
| 2005 } | |
| 2006 } | 1995 } |
| 2007 // We need to wipe out the header fields *after* wiping out the | 1996 // We need to wipe out the header fields *after* wiping out the |
| 2008 // relocations, because some of these fields are needed for the latter. | 1997 // relocations, because some of these fields are needed for the latter. |
| 2009 code->WipeOutHeader(); | 1998 code->WipeOutHeader(); |
| 2010 return code->address(); | 1999 return code->address(); |
| 2011 } | 2000 } |
| 2012 | 2001 |
| 2013 | 2002 |
| 2014 int Serializer::ObjectSerializer::OutputRawData( | 2003 int Serializer::ObjectSerializer::OutputRawData( |
| 2015 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) { | 2004 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) { |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 DisallowHeapAllocation no_gc; | 2581 DisallowHeapAllocation no_gc; |
| 2593 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2582 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2594 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2583 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2595 if (r == CHECK_SUCCESS) return scd; | 2584 if (r == CHECK_SUCCESS) return scd; |
| 2596 cached_data->Reject(); | 2585 cached_data->Reject(); |
| 2597 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2586 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2598 delete scd; | 2587 delete scd; |
| 2599 return NULL; | 2588 return NULL; |
| 2600 } | 2589 } |
| 2601 } } // namespace v8::internal | 2590 } } // namespace v8::internal |
| OLD | NEW |