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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if (context_index > 0) { | |
66 // A non-default context uses the global proxy from the snapshot. | |
67 DCHECK(global_proxy.is_null()); | |
68 } | |
69 | |
70 MaybeHandle<Object> maybe_context = | 65 MaybeHandle<Object> maybe_context = |
71 deserializer.DeserializePartial(isolate, global_proxy); | 66 deserializer.DeserializePartial(isolate, global_proxy); |
72 Handle<Object> result; | 67 Handle<Object> result; |
73 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); | 68 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); |
74 CHECK(result->IsContext()); | 69 CHECK(result->IsContext()); |
75 if (FLAG_profile_deserialization) { | 70 if (FLAG_profile_deserialization) { |
76 double ms = timer.Elapsed().InMillisecondsF(); | 71 double ms = timer.Elapsed().InMillisecondsF(); |
77 int bytes = context_data.length(); | 72 int bytes = context_data.length(); |
78 PrintF("[Deserializing context #%zu (%d bytes) took %0.3f ms]\n", | 73 PrintF("[Deserializing context #%zu (%d bytes) took %0.3f ms]\n", |
79 context_index, bytes, ms); | 74 context_index, bytes, ms); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 Vector<const byte> SnapshotData::Payload() const { | 220 Vector<const byte> SnapshotData::Payload() const { |
226 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size; | 221 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size; |
227 const byte* payload = data_ + kHeaderSize + reservations_size; | 222 const byte* payload = data_ + kHeaderSize + reservations_size; |
228 int length = GetHeaderValue(kPayloadLengthOffset); | 223 int length = GetHeaderValue(kPayloadLengthOffset); |
229 DCHECK_EQ(data_ + size_, payload + length); | 224 DCHECK_EQ(data_ + size_, payload + length); |
230 return Vector<const byte>(payload, length); | 225 return Vector<const byte>(payload, length); |
231 } | 226 } |
232 | 227 |
233 } // namespace internal | 228 } // namespace internal |
234 } // namespace v8 | 229 } // namespace v8 |
OLD | NEW |