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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 const v8::StartupData* blob = isolate->snapshot_blob(); | 75 const v8::StartupData* blob = isolate->snapshot_blob(); |
76 Vector<const byte> context_data = ExtractContextData(blob); | 76 Vector<const byte> context_data = ExtractContextData(blob); |
77 SnapshotData snapshot_data(context_data); | 77 SnapshotData snapshot_data(context_data); |
78 Deserializer deserializer(&snapshot_data); | 78 Deserializer deserializer(&snapshot_data); |
79 | 79 |
80 MaybeHandle<Object> maybe_context = deserializer.DeserializePartial( | 80 MaybeHandle<Object> maybe_context = deserializer.DeserializePartial( |
81 isolate, global_proxy, outdated_contexts_out); | 81 isolate, global_proxy, outdated_contexts_out); |
82 Handle<Object> result; | 82 Handle<Object> result; |
83 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); | 83 if (!maybe_context.ToHandle(&result)) return MaybeHandle<Context>(); |
84 CHECK(result->IsContext()); | 84 CHECK(result->IsContext()); |
| 85 // If the snapshot does not contain a custom script, we need to update |
| 86 // the global object for exactly two contexts: the builtins context and the |
| 87 // script context that has the global "this" binding. |
| 88 CHECK(EmbedsScript(isolate) || (*outdated_contexts_out)->length() == 2); |
85 if (FLAG_profile_deserialization) { | 89 if (FLAG_profile_deserialization) { |
86 double ms = timer.Elapsed().InMillisecondsF(); | 90 double ms = timer.Elapsed().InMillisecondsF(); |
87 int bytes = context_data.length(); | 91 int bytes = context_data.length(); |
88 PrintF("[Deserializing context (%d bytes) took %0.3f ms]\n", bytes, ms); | 92 PrintF("[Deserializing context (%d bytes) took %0.3f ms]\n", bytes, ms); |
89 } | 93 } |
90 return Handle<Context>::cast(result); | 94 return Handle<Context>::cast(result); |
91 } | 95 } |
92 | 96 |
93 | 97 |
94 void CalculateFirstPageSizes(bool is_default_snapshot, | 98 void CalculateFirstPageSizes(bool is_default_snapshot, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); | 228 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); |
225 int context_offset = ContextOffset(startup_length); | 229 int context_offset = ContextOffset(startup_length); |
226 const byte* context_data = | 230 const byte* context_data = |
227 reinterpret_cast<const byte*>(data->data + context_offset); | 231 reinterpret_cast<const byte*>(data->data + context_offset); |
228 DCHECK_LT(context_offset, data->raw_size); | 232 DCHECK_LT(context_offset, data->raw_size); |
229 int context_length = data->raw_size - context_offset; | 233 int context_length = data->raw_size - context_offset; |
230 return Vector<const byte>(context_data, context_length); | 234 return Vector<const byte>(context_data, context_length); |
231 } | 235 } |
232 } // namespace internal | 236 } // namespace internal |
233 } // namespace v8 | 237 } // namespace v8 |
OLD | NEW |