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" |
11 #include "src/full-codegen/full-codegen.h" | 11 #include "src/full-codegen/full-codegen.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 #ifdef DEBUG | 16 #ifdef DEBUG |
17 bool Snapshot::SnapshotIsValid(v8::StartupData* snapshot_blob) { | 17 bool Snapshot::SnapshotIsValid(v8::StartupData* snapshot_blob) { |
18 return !Snapshot::ExtractStartupData(snapshot_blob).is_empty() && | 18 return !Snapshot::ExtractStartupData(snapshot_blob).is_empty() && |
19 !Snapshot::ExtractContextData(snapshot_blob).is_empty(); | 19 !Snapshot::ExtractContextData(snapshot_blob).is_empty(); |
20 } | 20 } |
21 #endif // DEBUG | 21 #endif // DEBUG |
22 | 22 |
23 | 23 |
| 24 bool Snapshot::HaveASnapshotToStartFrom(Isolate* isolate) { |
| 25 // Do not use snapshots if the isolate is used to create snapshots. |
| 26 return isolate->snapshot_blob() != NULL && |
| 27 isolate->snapshot_blob()->data != NULL; |
| 28 } |
| 29 |
| 30 |
24 bool Snapshot::EmbedsScript(Isolate* isolate) { | 31 bool Snapshot::EmbedsScript(Isolate* isolate) { |
25 if (!isolate->snapshot_available()) return false; | 32 if (!isolate->snapshot_available()) return false; |
26 return ExtractMetadata(isolate->snapshot_blob()).embeds_script(); | 33 return ExtractMetadata(isolate->snapshot_blob()).embeds_script(); |
27 } | 34 } |
28 | 35 |
29 | 36 |
30 uint32_t Snapshot::SizeOfFirstPage(Isolate* isolate, AllocationSpace space) { | 37 uint32_t Snapshot::SizeOfFirstPage(Isolate* isolate, AllocationSpace space) { |
31 DCHECK(space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE); | 38 DCHECK(space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE); |
32 if (!isolate->snapshot_available()) { | 39 if (!isolate->snapshot_available()) { |
33 return static_cast<uint32_t>(MemoryAllocator::PageAreaSize(space)); | 40 return static_cast<uint32_t>(MemoryAllocator::PageAreaSize(space)); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); | 228 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); |
222 int context_offset = ContextOffset(startup_length); | 229 int context_offset = ContextOffset(startup_length); |
223 const byte* context_data = | 230 const byte* context_data = |
224 reinterpret_cast<const byte*>(data->data + context_offset); | 231 reinterpret_cast<const byte*>(data->data + context_offset); |
225 DCHECK_LT(context_offset, data->raw_size); | 232 DCHECK_LT(context_offset, data->raw_size); |
226 int context_length = data->raw_size - context_offset; | 233 int context_length = data->raw_size - context_offset; |
227 return Vector<const byte>(context_data, context_length); | 234 return Vector<const byte>(context_data, context_length); |
228 } | 235 } |
229 } // namespace internal | 236 } // namespace internal |
230 } // namespace v8 | 237 } // namespace v8 |
OLD | NEW |