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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 if (FLAG_profile_deserialization) { | 59 if (FLAG_profile_deserialization) { |
60 double ms = timer.Elapsed().InMillisecondsF(); | 60 double ms = timer.Elapsed().InMillisecondsF(); |
61 int bytes = startup_data.length(); | 61 int bytes = startup_data.length(); |
62 PrintF("[Deserializing isolate (%d bytes) took %0.3f ms]\n", bytes, ms); | 62 PrintF("[Deserializing isolate (%d bytes) took %0.3f ms]\n", bytes, ms); |
63 } | 63 } |
64 return success; | 64 return success; |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 MaybeHandle<Context> Snapshot::NewContextFromSnapshot( | 68 MaybeHandle<Context> Snapshot::NewContextFromSnapshot( |
69 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, | 69 Isolate* isolate, Handle<JSGlobalProxy> global_proxy) { |
70 Handle<FixedArray>* outdated_contexts_out) { | |
71 if (!isolate->snapshot_available()) return Handle<Context>(); | 70 if (!isolate->snapshot_available()) return Handle<Context>(); |
72 base::ElapsedTimer timer; | 71 base::ElapsedTimer timer; |
73 if (FLAG_profile_deserialization) timer.Start(); | 72 if (FLAG_profile_deserialization) timer.Start(); |
74 | 73 |
75 const v8::StartupData* blob = isolate->snapshot_blob(); | 74 const v8::StartupData* blob = isolate->snapshot_blob(); |
76 Vector<const byte> context_data = ExtractContextData(blob); | 75 Vector<const byte> context_data = ExtractContextData(blob); |
77 SnapshotData snapshot_data(context_data); | 76 SnapshotData snapshot_data(context_data); |
78 Deserializer deserializer(&snapshot_data); | 77 Deserializer deserializer(&snapshot_data); |
79 | 78 |
80 MaybeHandle<Object> maybe_context = deserializer.DeserializePartial( | 79 MaybeHandle<Object> maybe_context = |
81 isolate, global_proxy, outdated_contexts_out); | 80 deserializer.DeserializePartial(isolate, global_proxy); |
82 Handle<Object> result; | 81 Handle<Object> result; |
83 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); | 82 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); |
84 CHECK(result->IsContext()); | 83 CHECK(result->IsContext()); |
85 if (FLAG_profile_deserialization) { | 84 if (FLAG_profile_deserialization) { |
86 double ms = timer.Elapsed().InMillisecondsF(); | 85 double ms = timer.Elapsed().InMillisecondsF(); |
87 int bytes = context_data.length(); | 86 int bytes = context_data.length(); |
88 PrintF("[Deserializing context (%d bytes) took %0.3f ms]\n", bytes, ms); | 87 PrintF("[Deserializing context (%d bytes) took %0.3f ms]\n", bytes, ms); |
89 } | 88 } |
90 return Handle<Context>::cast(result); | 89 return Handle<Context>::cast(result); |
91 } | 90 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); | 223 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); |
225 int context_offset = ContextOffset(startup_length); | 224 int context_offset = ContextOffset(startup_length); |
226 const byte* context_data = | 225 const byte* context_data = |
227 reinterpret_cast<const byte*>(data->data + context_offset); | 226 reinterpret_cast<const byte*>(data->data + context_offset); |
228 DCHECK_LT(context_offset, data->raw_size); | 227 DCHECK_LT(context_offset, data->raw_size); |
229 int context_length = data->raw_size - context_offset; | 228 int context_length = data->raw_size - context_offset; |
230 return Vector<const byte>(context_data, context_length); | 229 return Vector<const byte>(context_data, context_length); |
231 } | 230 } |
232 } // namespace internal | 231 } // namespace internal |
233 } // namespace v8 | 232 } // namespace v8 |
OLD | NEW |