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

Side by Side Diff: src/snapshot/snapshot-common.cc

Issue 2619203002: [serializer] pass internal fields deserializer callback as argument. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « src/snapshot/snapshot.h ('k') | test/cctest/test-serialize.cc » ('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 // 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 // The common functionality when building with or without snapshots. 5 // The common functionality when building with or without snapshots.
6 6
7 #include "src/snapshot/snapshot.h" 7 #include "src/snapshot/snapshot.h"
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 bool success = isolate->Init(&deserializer); 43 bool success = isolate->Init(&deserializer);
44 if (FLAG_profile_deserialization) { 44 if (FLAG_profile_deserialization) {
45 double ms = timer.Elapsed().InMillisecondsF(); 45 double ms = timer.Elapsed().InMillisecondsF();
46 int bytes = startup_data.length(); 46 int bytes = startup_data.length();
47 PrintF("[Deserializing isolate (%d bytes) took %0.3f ms]\n", bytes, ms); 47 PrintF("[Deserializing isolate (%d bytes) took %0.3f ms]\n", bytes, ms);
48 } 48 }
49 return success; 49 return success;
50 } 50 }
51 51
52 MaybeHandle<Context> Snapshot::NewContextFromSnapshot( 52 MaybeHandle<Context> Snapshot::NewContextFromSnapshot(
53 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, 53 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, size_t context_index,
54 size_t context_index) { 54 v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
55 if (!isolate->snapshot_available()) return Handle<Context>(); 55 if (!isolate->snapshot_available()) return Handle<Context>();
56 base::ElapsedTimer timer; 56 base::ElapsedTimer timer;
57 if (FLAG_profile_deserialization) timer.Start(); 57 if (FLAG_profile_deserialization) timer.Start();
58 58
59 const v8::StartupData* blob = isolate->snapshot_blob(); 59 const v8::StartupData* blob = isolate->snapshot_blob();
60 Vector<const byte> context_data = 60 Vector<const byte> context_data =
61 ExtractContextData(blob, static_cast<int>(context_index)); 61 ExtractContextData(blob, static_cast<int>(context_index));
62 SnapshotData snapshot_data(context_data); 62 SnapshotData snapshot_data(context_data);
63 Deserializer deserializer(&snapshot_data); 63 Deserializer deserializer(&snapshot_data);
64 64
65 MaybeHandle<Object> maybe_context = 65 MaybeHandle<Object> maybe_context = deserializer.DeserializePartial(
66 deserializer.DeserializePartial(isolate, global_proxy); 66 isolate, global_proxy, internal_fields_deserializer);
67 Handle<Object> result; 67 Handle<Object> result;
68 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); 68 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>();
69 CHECK(result->IsContext()); 69 CHECK(result->IsContext());
70 if (FLAG_profile_deserialization) { 70 if (FLAG_profile_deserialization) {
71 double ms = timer.Elapsed().InMillisecondsF(); 71 double ms = timer.Elapsed().InMillisecondsF();
72 int bytes = context_data.length(); 72 int bytes = context_data.length();
73 PrintF("[Deserializing context #%zu (%d bytes) took %0.3f ms]\n", 73 PrintF("[Deserializing context #%zu (%d bytes) took %0.3f ms]\n",
74 context_index, bytes, ms); 74 context_index, bytes, ms);
75 } 75 }
76 return Handle<Context>::cast(result); 76 return Handle<Context>::cast(result);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 Vector<const byte> SnapshotData::Payload() const { 220 Vector<const byte> SnapshotData::Payload() const {
221 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size; 221 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size;
222 const byte* payload = data_ + kHeaderSize + reservations_size; 222 const byte* payload = data_ + kHeaderSize + reservations_size;
223 int length = GetHeaderValue(kPayloadLengthOffset); 223 int length = GetHeaderValue(kPayloadLengthOffset);
224 DCHECK_EQ(data_ + size_, payload + length); 224 DCHECK_EQ(data_ + size_, payload + length);
225 return Vector<const byte>(payload, length); 225 return Vector<const byte>(payload, length);
226 } 226 }
227 227
228 } // namespace internal 228 } // namespace internal
229 } // namespace v8 229 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/snapshot.h ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698