Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Side by Side Diff: src/snapshot/snapshot-common.cc

Issue 2100073002: [snapshot] revisit snapshot API. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/snapshot/snapshot.h ('k') | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/snapshot/deserializer.h" 12 #include "src/snapshot/deserializer.h"
13 #include "src/snapshot/snapshot-source-sink.h" 13 #include "src/snapshot/snapshot-source-sink.h"
14 #include "src/version.h" 14 #include "src/version.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 18
19 #ifdef DEBUG 19 #ifdef DEBUG
20 bool Snapshot::SnapshotIsValid(v8::StartupData* snapshot_blob) { 20 bool Snapshot::SnapshotIsValid(v8::StartupData* snapshot_blob) {
21 return Snapshot::ExtractNumContexts(snapshot_blob) > 0; 21 return Snapshot::ExtractNumContexts(snapshot_blob) > 0;
22 } 22 }
23 #endif // DEBUG 23 #endif // DEBUG
24 24
25 25 bool Snapshot::HasContextSnapshot(Isolate* isolate, size_t index) {
26 bool Snapshot::HaveASnapshotToStartFrom(Isolate* isolate) {
27 // Do not use snapshots if the isolate is used to create snapshots. 26 // Do not use snapshots if the isolate is used to create snapshots.
28 return isolate->snapshot_blob() != NULL && 27 const v8::StartupData* blob = isolate->snapshot_blob();
29 isolate->snapshot_blob()->data != NULL; 28 if (blob == nullptr) return false;
29 if (blob->data == nullptr) return false;
30 size_t num_contexts = static_cast<size_t>(ExtractNumContexts(blob));
31 return index < num_contexts;
30 } 32 }
31 33
32 34
33 uint32_t Snapshot::SizeOfFirstPage(Isolate* isolate, AllocationSpace space) { 35 uint32_t Snapshot::SizeOfFirstPage(Isolate* isolate, AllocationSpace space) {
34 DCHECK(space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE); 36 DCHECK(space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE);
35 if (!isolate->snapshot_available()) { 37 if (!isolate->snapshot_available()) {
36 return static_cast<uint32_t>(MemoryAllocator::PageAreaSize(space)); 38 return static_cast<uint32_t>(MemoryAllocator::PageAreaSize(space));
37 } 39 }
38 uint32_t size; 40 uint32_t size;
39 int offset = kFirstPageSizesOffset + (space - FIRST_PAGED_SPACE) * kInt32Size; 41 int offset = kFirstPageSizesOffset + (space - FIRST_PAGED_SPACE) * kInt32Size;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 Vector<const byte> SnapshotData::Payload() const { 284 Vector<const byte> SnapshotData::Payload() const {
283 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size; 285 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size;
284 const byte* payload = data_ + kHeaderSize + reservations_size; 286 const byte* payload = data_ + kHeaderSize + reservations_size;
285 int length = GetHeaderValue(kPayloadLengthOffset); 287 int length = GetHeaderValue(kPayloadLengthOffset);
286 DCHECK_EQ(data_ + size_, payload + length); 288 DCHECK_EQ(data_ + size_, payload + length);
287 return Vector<const byte>(payload, length); 289 return Vector<const byte>(payload, length);
288 } 290 }
289 291
290 } // namespace internal 292 } // namespace internal
291 } // namespace v8 293 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/snapshot.h ('k') | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698