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 // 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 if (FLAG_profile_deserialization) { | 45 if (FLAG_profile_deserialization) { |
46 double ms = timer.Elapsed().InMillisecondsF(); | 46 double ms = timer.Elapsed().InMillisecondsF(); |
47 int bytes = startup_data.length(); | 47 int bytes = startup_data.length(); |
48 PrintF("[Deserializing isolate (%d bytes) took %0.3f ms]\n", bytes, ms); | 48 PrintF("[Deserializing isolate (%d bytes) took %0.3f ms]\n", bytes, ms); |
49 } | 49 } |
50 return success; | 50 return success; |
51 } | 51 } |
52 | 52 |
53 MaybeHandle<Context> Snapshot::NewContextFromSnapshot( | 53 MaybeHandle<Context> Snapshot::NewContextFromSnapshot( |
54 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, size_t context_index, | 54 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, size_t context_index, |
55 v8::DeserializeInternalFieldsCallback internal_fields_deserializer) { | 55 v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) { |
56 if (!isolate->snapshot_available()) return Handle<Context>(); | 56 if (!isolate->snapshot_available()) return Handle<Context>(); |
57 base::ElapsedTimer timer; | 57 base::ElapsedTimer timer; |
58 if (FLAG_profile_deserialization) timer.Start(); | 58 if (FLAG_profile_deserialization) timer.Start(); |
59 | 59 |
60 const v8::StartupData* blob = isolate->snapshot_blob(); | 60 const v8::StartupData* blob = isolate->snapshot_blob(); |
61 Vector<const byte> context_data = | 61 Vector<const byte> context_data = |
62 ExtractContextData(blob, static_cast<int>(context_index)); | 62 ExtractContextData(blob, static_cast<int>(context_index)); |
63 SnapshotData snapshot_data(context_data); | 63 SnapshotData snapshot_data(context_data); |
64 Deserializer deserializer(&snapshot_data); | 64 Deserializer deserializer(&snapshot_data); |
65 | 65 |
66 MaybeHandle<Object> maybe_context = deserializer.DeserializePartial( | 66 MaybeHandle<Object> maybe_context = deserializer.DeserializePartial( |
67 isolate, global_proxy, internal_fields_deserializer); | 67 isolate, global_proxy, embedder_fields_deserializer); |
68 Handle<Object> result; | 68 Handle<Object> result; |
69 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); | 69 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); |
70 CHECK(result->IsContext()); | 70 CHECK(result->IsContext()); |
71 if (FLAG_profile_deserialization) { | 71 if (FLAG_profile_deserialization) { |
72 double ms = timer.Elapsed().InMillisecondsF(); | 72 double ms = timer.Elapsed().InMillisecondsF(); |
73 int bytes = context_data.length(); | 73 int bytes = context_data.length(); |
74 PrintF("[Deserializing context #%zu (%d bytes) took %0.3f ms]\n", | 74 PrintF("[Deserializing context #%zu (%d bytes) took %0.3f ms]\n", |
75 context_index, bytes, ms); | 75 context_index, bytes, ms); |
76 } | 76 } |
77 return Handle<Context>::cast(result); | 77 return Handle<Context>::cast(result); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 Vector<const byte> SnapshotData::Payload() const { | 221 Vector<const byte> SnapshotData::Payload() const { |
222 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size; | 222 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size; |
223 const byte* payload = data_ + kHeaderSize + reservations_size; | 223 const byte* payload = data_ + kHeaderSize + reservations_size; |
224 int length = GetHeaderValue(kPayloadLengthOffset); | 224 int length = GetHeaderValue(kPayloadLengthOffset); |
225 DCHECK_EQ(data_ + size_, payload + length); | 225 DCHECK_EQ(data_ + size_, payload + length); |
226 return Vector<const byte>(payload, length); | 226 return Vector<const byte>(payload, length); |
227 } | 227 } |
228 | 228 |
229 } // namespace internal | 229 } // namespace internal |
230 } // namespace v8 | 230 } // namespace v8 |
OLD | NEW |