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