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

Side by Side Diff: src/serialize.cc

Issue 360050: Keep natives source code in external strings instead of putting... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/serialize.h ('k') | tools/js2c.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 #include "execution.h" 32 #include "execution.h"
33 #include "global-handles.h" 33 #include "global-handles.h"
34 #include "ic-inl.h" 34 #include "ic-inl.h"
35 #include "natives.h" 35 #include "natives.h"
36 #include "platform.h" 36 #include "platform.h"
37 #include "runtime.h" 37 #include "runtime.h"
38 #include "serialize.h" 38 #include "serialize.h"
39 #include "stub-cache.h" 39 #include "stub-cache.h"
40 #include "v8threads.h" 40 #include "v8threads.h"
41 #include "top.h" 41 #include "top.h"
42 #include "bootstrapper.h"
42 43
43 namespace v8 { 44 namespace v8 {
44 namespace internal { 45 namespace internal {
45 46
46 // 32-bit encoding: a RelativeAddress must be able to fit in a 47 // 32-bit encoding: a RelativeAddress must be able to fit in a
47 // pointer: it is encoded as an Address with (from LS to MS bits): 48 // pointer: it is encoded as an Address with (from LS to MS bits):
48 // - 2 bits identifying this as a HeapObject. 49 // - 2 bits identifying this as a HeapObject.
49 // - 4 bits to encode the AllocationSpace (including special values for 50 // - 4 bits to encode the AllocationSpace (including special values for
50 // code and fixed arrays in LO space) 51 // code and fixed arrays in LO space)
51 // - 27 bits identifying a word in the space, in one of three formats: 52 // - 27 bits identifying a word in the space, in one of three formats:
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 Assembler::set_external_target_at(location_of_branch_data, address); 2052 Assembler::set_external_target_at(location_of_branch_data, address);
2052 location_of_branch_data += Assembler::kExternalTargetSize; 2053 location_of_branch_data += Assembler::kExternalTargetSize;
2053 current = reinterpret_cast<Object**>(location_of_branch_data); 2054 current = reinterpret_cast<Object**>(location_of_branch_data);
2054 break; 2055 break;
2055 } 2056 }
2056 case START_NEW_PAGE_SERIALIZATION: { 2057 case START_NEW_PAGE_SERIALIZATION: {
2057 int space = source_->Get(); 2058 int space = source_->Get();
2058 pages_[space].Add(last_object_address_); 2059 pages_[space].Add(last_object_address_);
2059 break; 2060 break;
2060 } 2061 }
2062 case NATIVES_STRING_RESOURCE: {
2063 int index = source_->Get();
2064 Vector<const char> source_vector = Natives::GetScriptSource(index);
2065 NativesExternalStringResource* resource =
2066 new NativesExternalStringResource(source_vector.start());
2067 *current++ = reinterpret_cast<Object*>(resource);
2068 break;
2069 }
2061 default: 2070 default:
2062 UNREACHABLE(); 2071 UNREACHABLE();
2063 } 2072 }
2064 } 2073 }
2065 ASSERT(current == limit); 2074 ASSERT(current == limit);
2066 } 2075 }
2067 2076
2068 2077
2069 void SnapshotByteSink::PutInt(uintptr_t integer, const char* description) { 2078 void SnapshotByteSink::PutInt(uintptr_t integer, const char* description) {
2070 const int max_shift = ((kPointerSize * kBitsPerByte) / 7) * 7; 2079 const int max_shift = ((kPointerSize * kBitsPerByte) / 7) * 7;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 object_->IterateBody(map->instance_type(), size, this); 2251 object_->IterateBody(map->instance_type(), size, this);
2243 OutputRawData(object_->address() + size); 2252 OutputRawData(object_->address() + size);
2244 } 2253 }
2245 2254
2246 2255
2247 void Serializer2::ObjectSerializer::VisitPointers(Object** start, 2256 void Serializer2::ObjectSerializer::VisitPointers(Object** start,
2248 Object** end) { 2257 Object** end) {
2249 Object** current = start; 2258 Object** current = start;
2250 while (current < end) { 2259 while (current < end) {
2251 while (current < end && (*current)->IsSmi()) current++; 2260 while (current < end && (*current)->IsSmi()) current++;
2252 OutputRawData(reinterpret_cast<Address>(current)); 2261 if (current < end) OutputRawData(reinterpret_cast<Address>(current));
2253 2262
2254 while (current < end && !(*current)->IsSmi()) { 2263 while (current < end && !(*current)->IsSmi()) {
2255 serializer_->SerializeObject(*current, TAGGED_REPRESENTATION); 2264 serializer_->SerializeObject(*current, TAGGED_REPRESENTATION);
2256 bytes_processed_so_far_ += kPointerSize; 2265 bytes_processed_so_far_ += kPointerSize;
2257 current++; 2266 current++;
2258 } 2267 }
2259 } 2268 }
2260 } 2269 }
2261 2270
2262 2271
(...skipping 26 matching lines...) Expand all
2289 void Serializer2::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { 2298 void Serializer2::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) {
2290 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); 2299 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
2291 Address target_start = rinfo->target_address_address(); 2300 Address target_start = rinfo->target_address_address();
2292 OutputRawData(target_start); 2301 OutputRawData(target_start);
2293 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); 2302 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
2294 serializer_->SerializeObject(target, CODE_TARGET_REPRESENTATION); 2303 serializer_->SerializeObject(target, CODE_TARGET_REPRESENTATION);
2295 bytes_processed_so_far_ += Assembler::kCallTargetSize; 2304 bytes_processed_so_far_ += Assembler::kCallTargetSize;
2296 } 2305 }
2297 2306
2298 2307
2308 void Serializer2::ObjectSerializer::VisitExternalAsciiString(
2309 v8::String::ExternalAsciiStringResource** resource_pointer) {
2310 Address references_start = reinterpret_cast<Address>(resource_pointer);
2311 OutputRawData(references_start);
2312 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
2313 // Use raw_unchecked when maps are munged.
2314 Object* source = Heap::raw_unchecked_natives_source_cache()->get(i);
2315 if (!source->IsUndefined()) {
2316 // Don't use cast when maps are munged.
2317 ExternalAsciiString* string =
2318 reinterpret_cast<ExternalAsciiString*>(source);
2319 typedef v8::String::ExternalAsciiStringResource Resource;
2320 Resource* resource = string->resource();
2321 if (resource == *resource_pointer) {
2322 sink_->Put(NATIVES_STRING_RESOURCE, "NativesStringResource");
2323 sink_->PutSection(i, "NativesStringResourceEnd");
2324 bytes_processed_so_far_ += sizeof(resource);
2325 return;
2326 }
2327 }
2328 }
2329 // One of the strings in the natives cache should match the resource. We
2330 // can't serialize any other kinds of external strings.
2331 UNREACHABLE();
2332 }
2333
2334
2299 void Serializer2::ObjectSerializer::OutputRawData(Address up_to) { 2335 void Serializer2::ObjectSerializer::OutputRawData(Address up_to) {
2300 Address object_start = object_->address(); 2336 Address object_start = object_->address();
2301 int up_to_offset = up_to - object_start; 2337 int up_to_offset = up_to - object_start;
2302 int skipped = up_to_offset - bytes_processed_so_far_; 2338 int skipped = up_to_offset - bytes_processed_so_far_;
2303 // This assert will fail if the reloc info gives us the target_address_address 2339 // This assert will fail if the reloc info gives us the target_address_address
2304 // locations in a non-ascending order. Luckily that doesn't happen. 2340 // locations in a non-ascending order. Luckily that doesn't happen.
2305 ASSERT(skipped >= 0); 2341 ASSERT(skipped >= 0);
2306 if (skipped != 0) { 2342 if (skipped != 0) {
2307 Address base = object_start + bytes_processed_so_far_; 2343 Address base = object_start + bytes_processed_so_far_;
2308 #define RAW_CASE(index, length) \ 2344 #define RAW_CASE(index, length) \
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); 2420 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize);
2385 } 2421 }
2386 } 2422 }
2387 int allocation_address = fullness_[space]; 2423 int allocation_address = fullness_[space];
2388 fullness_[space] = allocation_address + size; 2424 fullness_[space] = allocation_address + size;
2389 return allocation_address; 2425 return allocation_address;
2390 } 2426 }
2391 2427
2392 2428
2393 } } // namespace v8::internal 2429 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/serialize.h ('k') | tools/js2c.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698