| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 Object** limit = current + (size >> kPointerSizeLog2); | 1920 Object** limit = current + (size >> kPointerSizeLog2); |
| 1921 while (current < limit) { | 1921 while (current < limit) { |
| 1922 DataType data = static_cast<DataType>(source_->Get()); | 1922 DataType data = static_cast<DataType>(source_->Get()); |
| 1923 switch (data) { | 1923 switch (data) { |
| 1924 case SMI_SERIALIZATION: | 1924 case SMI_SERIALIZATION: |
| 1925 *current++ = Smi::FromInt(source_->GetInt() - kSmiBias); | 1925 *current++ = Smi::FromInt(source_->GetInt() - kSmiBias); |
| 1926 break; | 1926 break; |
| 1927 case RAW_DATA_SERIALIZATION: { | 1927 case RAW_DATA_SERIALIZATION: { |
| 1928 int size = source_->GetInt(); | 1928 int size = source_->GetInt(); |
| 1929 byte* raw_data_out = reinterpret_cast<byte*>(current); | 1929 byte* raw_data_out = reinterpret_cast<byte*>(current); |
| 1930 for (int j = 0; j < size; j++) { | 1930 source_->CopyRaw(raw_data_out, size); |
| 1931 *raw_data_out++ = source_->Get(); | 1931 current = reinterpret_cast<Object**>(raw_data_out + size); |
| 1932 } | |
| 1933 current = reinterpret_cast<Object**>(raw_data_out); | |
| 1934 break; | 1932 break; |
| 1935 } | 1933 } |
| 1936 case OBJECT_SERIALIZATION: { | 1934 case OBJECT_SERIALIZATION: { |
| 1937 // Recurse to unpack an object that is forward-referenced from here. | 1935 // Recurse to unpack an object that is forward-referenced from here. |
| 1938 bool in_new_space = ReadObject(current); | 1936 bool in_new_space = ReadObject(current); |
| 1939 if (in_new_space && space != NEW_SPACE) { | 1937 if (in_new_space && space != NEW_SPACE) { |
| 1940 Heap::RecordWrite(address, | 1938 Heap::RecordWrite(address, |
| 1941 reinterpret_cast<Address>(current) - address); | 1939 reinterpret_cast<Address>(current) - address); |
| 1942 } | 1940 } |
| 1943 current++; | 1941 current++; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 location_of_branch_data += Assembler::kCallTargetSize; | 1975 location_of_branch_data += Assembler::kCallTargetSize; |
| 1978 current = reinterpret_cast<Object**>(location_of_branch_data); | 1976 current = reinterpret_cast<Object**>(location_of_branch_data); |
| 1979 break; | 1977 break; |
| 1980 } | 1978 } |
| 1981 case EXTERNAL_REFERENCE_SERIALIZATION: { | 1979 case EXTERNAL_REFERENCE_SERIALIZATION: { |
| 1982 int reference_id = source_->GetInt(); | 1980 int reference_id = source_->GetInt(); |
| 1983 Address address = external_reference_decoder_->Decode(reference_id); | 1981 Address address = external_reference_decoder_->Decode(reference_id); |
| 1984 *current++ = reinterpret_cast<Object*>(address); | 1982 *current++ = reinterpret_cast<Object*>(address); |
| 1985 break; | 1983 break; |
| 1986 } | 1984 } |
| 1985 case EXTERNAL_BRANCH_TARGET_SERIALIZATION: { |
| 1986 int reference_id = source_->GetInt(); |
| 1987 Address address = external_reference_decoder_->Decode(reference_id); |
| 1988 Address location_of_branch_data = reinterpret_cast<Address>(current); |
| 1989 Assembler::set_external_target_at(location_of_branch_data, address); |
| 1990 location_of_branch_data += Assembler::kExternalTargetSize; |
| 1991 current = reinterpret_cast<Object**>(location_of_branch_data); |
| 1992 break; |
| 1993 } |
| 1987 default: | 1994 default: |
| 1988 UNREACHABLE(); | 1995 UNREACHABLE(); |
| 1989 } | 1996 } |
| 1990 } | 1997 } |
| 1991 ASSERT(current == limit); | 1998 ASSERT(current == limit); |
| 1992 return space == NEW_SPACE; | 1999 return space == NEW_SPACE; |
| 1993 } | 2000 } |
| 1994 | 2001 |
| 1995 | 2002 |
| 1996 void SnapshotByteSink::PutInt(uintptr_t integer, const char* description) { | 2003 void SnapshotByteSink::PutInt(uintptr_t integer, const char* description) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 | 2159 |
| 2153 for (Address* current = start; current < end; current++) { | 2160 for (Address* current = start; current < end; current++) { |
| 2154 sink_->Put(EXTERNAL_REFERENCE_SERIALIZATION, "External reference"); | 2161 sink_->Put(EXTERNAL_REFERENCE_SERIALIZATION, "External reference"); |
| 2155 int reference_id = serializer_->EncodeExternalReference(*current); | 2162 int reference_id = serializer_->EncodeExternalReference(*current); |
| 2156 sink_->PutInt(reference_id, "reference id"); | 2163 sink_->PutInt(reference_id, "reference id"); |
| 2157 } | 2164 } |
| 2158 bytes_processed_so_far_ += (end - start) * kPointerSize; | 2165 bytes_processed_so_far_ += (end - start) * kPointerSize; |
| 2159 } | 2166 } |
| 2160 | 2167 |
| 2161 | 2168 |
| 2169 void Serializer2::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { |
| 2170 Address target_start = rinfo->target_address_address(); |
| 2171 OutputRawData(target_start); |
| 2172 Address target = rinfo->target_address(); |
| 2173 uint32_t encoding = serializer_->EncodeExternalReference(target); |
| 2174 CHECK(target == NULL ? encoding == 0 : encoding != 0); |
| 2175 sink_->Put(EXTERNAL_BRANCH_TARGET_SERIALIZATION, "External reference"); |
| 2176 sink_->PutInt(encoding, "reference id"); |
| 2177 bytes_processed_so_far_ += Assembler::kExternalTargetSize; |
| 2178 } |
| 2179 |
| 2180 |
| 2162 void Serializer2::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { | 2181 void Serializer2::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { |
| 2163 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); | 2182 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); |
| 2164 Address target_start = rinfo->target_address_address(); | 2183 Address target_start = rinfo->target_address_address(); |
| 2165 OutputRawData(target_start); | 2184 OutputRawData(target_start); |
| 2166 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 2185 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 2167 serializer_->SerializeObject(target, CODE_TARGET_REPRESENTATION); | 2186 serializer_->SerializeObject(target, CODE_TARGET_REPRESENTATION); |
| 2168 bytes_processed_so_far_ += Assembler::kCallTargetSize; | 2187 bytes_processed_so_far_ += Assembler::kCallTargetSize; |
| 2169 } | 2188 } |
| 2170 | 2189 |
| 2171 | 2190 |
| 2172 void Serializer2::ObjectSerializer::OutputRawData(Address up_to) { | 2191 void Serializer2::ObjectSerializer::OutputRawData(Address up_to) { |
| 2173 Address object_start = object_->address(); | 2192 Address object_start = object_->address(); |
| 2174 int up_to_offset = up_to - object_start; | 2193 int up_to_offset = up_to - object_start; |
| 2175 int skipped = up_to_offset - bytes_processed_so_far_; | 2194 int skipped = up_to_offset - bytes_processed_so_far_; |
| 2176 // This assert will fail if the reloc info gives us the target_address_address | 2195 // This assert will fail if the reloc info gives us the target_address_address |
| 2177 // locations in a non-ascending order. Luckily that doesn't happen. | 2196 // locations in a non-ascending order. Luckily that doesn't happen. |
| 2178 ASSERT(skipped >= 0); | 2197 ASSERT(skipped >= 0); |
| 2179 if (skipped != 0) { | 2198 if (skipped != 0) { |
| 2180 sink_->Put(RAW_DATA_SERIALIZATION, "raw data"); | 2199 sink_->Put(RAW_DATA_SERIALIZATION, "raw data"); |
| 2181 sink_->PutInt(skipped, "length"); | 2200 sink_->PutInt(skipped, "length"); |
| 2182 for (int i = 0; i < skipped; i++) { | 2201 for (int i = 0; i < skipped; i++) { |
| 2183 unsigned int data = object_start[bytes_processed_so_far_ + i]; | 2202 unsigned int data = object_start[bytes_processed_so_far_ + i]; |
| 2184 sink_->Put(data, "byte"); | 2203 sink_->Put(data, "byte"); |
| 2185 } | 2204 } |
| 2205 bytes_processed_so_far_ += skipped; |
| 2186 } | 2206 } |
| 2187 bytes_processed_so_far_ += skipped; | |
| 2188 } | 2207 } |
| 2189 | 2208 |
| 2190 | 2209 |
| 2191 int Serializer2::SpaceOfObject(HeapObject* object) { | 2210 int Serializer2::SpaceOfObject(HeapObject* object) { |
| 2192 for (int i = FIRST_SPACE; i <= LAST_SPACE; i++) { | 2211 for (int i = FIRST_SPACE; i <= LAST_SPACE; i++) { |
| 2193 AllocationSpace s = static_cast<AllocationSpace>(i); | 2212 AllocationSpace s = static_cast<AllocationSpace>(i); |
| 2194 if (Heap::InSpace(object, s)) { | 2213 if (Heap::InSpace(object, s)) { |
| 2195 if (i == LO_SPACE) { | 2214 if (i == LO_SPACE) { |
| 2196 if (object->IsCode()) { | 2215 if (object->IsCode()) { |
| 2197 return kLargeCode; | 2216 return kLargeCode; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); | 2261 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); |
| 2243 } | 2262 } |
| 2244 } | 2263 } |
| 2245 int allocation_address = fullness_[space]; | 2264 int allocation_address = fullness_[space]; |
| 2246 fullness_[space] = allocation_address + size; | 2265 fullness_[space] = allocation_address + size; |
| 2247 return allocation_address; | 2266 return allocation_address; |
| 2248 } | 2267 } |
| 2249 | 2268 |
| 2250 | 2269 |
| 2251 } } // namespace v8::internal | 2270 } } // namespace v8::internal |
| OLD | NEW |