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 // Used for building with external snapshots. | 5 // Used for building with external snapshots. |
6 | 6 |
7 #include "src/snapshot.h" | 7 #include "src/snapshot.h" |
8 | 8 |
9 #include "src/serialize.h" | 9 #include "src/serialize.h" |
10 #include "src/snapshot-source-sink.h" | 10 #include "src/snapshot-source-sink.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 bool Snapshot::Initialize(Isolate* isolate) { | 51 bool Snapshot::Initialize(Isolate* isolate) { |
52 if (!HaveASnapshotToStartFrom()) | 52 if (!HaveASnapshotToStartFrom()) |
53 return false; | 53 return false; |
54 | 54 |
55 base::ElapsedTimer timer; | 55 base::ElapsedTimer timer; |
56 if (FLAG_profile_deserialization) { | 56 if (FLAG_profile_deserialization) { |
57 timer.Start(); | 57 timer.Start(); |
58 } | 58 } |
59 SnapshotByteSource source(snapshot_impl_->data, snapshot_impl_->size); | 59 SnapshotByteSource source(snapshot_impl_->data, snapshot_impl_->size); |
60 Deserializer deserializer(&source); | 60 Deserializer deserializer(&source); |
61 deserializer.set_reservation(NEW_SPACE, snapshot_impl_->new_space_used); | 61 deserializer.AddReservation(NEW_SPACE, snapshot_impl_->new_space_used); |
62 deserializer.set_reservation(OLD_POINTER_SPACE, | 62 deserializer.AddReservation(OLD_POINTER_SPACE, |
63 snapshot_impl_->pointer_space_used); | 63 snapshot_impl_->pointer_space_used); |
64 deserializer.set_reservation(OLD_DATA_SPACE, | 64 deserializer.AddReservation(OLD_DATA_SPACE, snapshot_impl_->data_space_used); |
65 snapshot_impl_->data_space_used); | 65 deserializer.AddReservation(CODE_SPACE, snapshot_impl_->code_space_used); |
66 deserializer.set_reservation(CODE_SPACE, snapshot_impl_->code_space_used); | 66 deserializer.AddReservation(MAP_SPACE, snapshot_impl_->map_space_used); |
67 deserializer.set_reservation(MAP_SPACE, snapshot_impl_->map_space_used); | 67 deserializer.AddReservation(CELL_SPACE, snapshot_impl_->cell_space_used); |
68 deserializer.set_reservation(CELL_SPACE, snapshot_impl_->cell_space_used); | 68 deserializer.AddReservation(PROPERTY_CELL_SPACE, |
69 deserializer.set_reservation(PROPERTY_CELL_SPACE, | 69 snapshot_impl_->property_cell_space_used); |
70 snapshot_impl_->property_cell_space_used); | 70 deserializer.AddReservation(LO_SPACE, snapshot_impl_->lo_space_used); |
71 deserializer.set_reservation(LO_SPACE, snapshot_impl_->lo_space_used); | |
72 bool success = isolate->Init(&deserializer); | 71 bool success = isolate->Init(&deserializer); |
73 if (FLAG_profile_deserialization) { | 72 if (FLAG_profile_deserialization) { |
74 double ms = timer.Elapsed().InMillisecondsF(); | 73 double ms = timer.Elapsed().InMillisecondsF(); |
75 PrintF("[Snapshot loading and deserialization took %0.3f ms]\n", ms); | 74 PrintF("[Snapshot loading and deserialization took %0.3f ms]\n", ms); |
76 } | 75 } |
77 return success; | 76 return success; |
78 } | 77 } |
79 | 78 |
80 | 79 |
81 Handle<Context> Snapshot::NewContextFromSnapshot(Isolate* isolate) { | 80 Handle<Context> Snapshot::NewContextFromSnapshot(Isolate* isolate) { |
82 if (!HaveASnapshotToStartFrom()) | 81 if (!HaveASnapshotToStartFrom()) |
83 return Handle<Context>(); | 82 return Handle<Context>(); |
84 | 83 |
85 SnapshotByteSource source(snapshot_impl_->context_data, | 84 SnapshotByteSource source(snapshot_impl_->context_data, |
86 snapshot_impl_->context_size); | 85 snapshot_impl_->context_size); |
87 Deserializer deserializer(&source); | 86 Deserializer deserializer(&source); |
88 deserializer.set_reservation(NEW_SPACE, | 87 deserializer.AddReservation(NEW_SPACE, |
89 snapshot_impl_->context_new_space_used); | 88 snapshot_impl_->context_new_space_used); |
90 deserializer.set_reservation(OLD_POINTER_SPACE, | 89 deserializer.AddReservation(OLD_POINTER_SPACE, |
91 snapshot_impl_->context_pointer_space_used); | 90 snapshot_impl_->context_pointer_space_used); |
92 deserializer.set_reservation(OLD_DATA_SPACE, | 91 deserializer.AddReservation(OLD_DATA_SPACE, |
93 snapshot_impl_->context_data_space_used); | 92 snapshot_impl_->context_data_space_used); |
94 deserializer.set_reservation(CODE_SPACE, | 93 deserializer.AddReservation(CODE_SPACE, |
95 snapshot_impl_->context_code_space_used); | 94 snapshot_impl_->context_code_space_used); |
96 deserializer.set_reservation(MAP_SPACE, | 95 deserializer.AddReservation(MAP_SPACE, |
97 snapshot_impl_->context_map_space_used); | 96 snapshot_impl_->context_map_space_used); |
98 deserializer.set_reservation(CELL_SPACE, | 97 deserializer.AddReservation(CELL_SPACE, |
99 snapshot_impl_->context_cell_space_used); | 98 snapshot_impl_->context_cell_space_used); |
100 deserializer.set_reservation(PROPERTY_CELL_SPACE, | 99 deserializer.AddReservation(PROPERTY_CELL_SPACE, |
101 snapshot_impl_-> | 100 snapshot_impl_->context_property_cell_space_used); |
102 context_property_cell_space_used); | 101 deserializer.AddReservation(LO_SPACE, snapshot_impl_->context_lo_space_used); |
103 deserializer.set_reservation(LO_SPACE, snapshot_impl_->context_lo_space_used); | |
104 Object* root; | 102 Object* root; |
105 deserializer.DeserializePartial(isolate, &root); | 103 deserializer.DeserializePartial(isolate, &root); |
106 CHECK(root->IsContext()); | 104 CHECK(root->IsContext()); |
107 return Handle<Context>(Context::cast(root)); | 105 return Handle<Context>(Context::cast(root)); |
108 } | 106 } |
109 | 107 |
110 | 108 |
111 void SetSnapshotFromFile(StartupData* snapshot_blob) { | 109 void SetSnapshotFromFile(StartupData* snapshot_blob) { |
112 DCHECK(snapshot_blob); | 110 DCHECK(snapshot_blob); |
113 DCHECK(snapshot_blob->data); | 111 DCHECK(snapshot_blob->data); |
(...skipping 22 matching lines...) Expand all Loading... |
136 snapshot_impl_->context_data_space_used = source.GetInt(); | 134 snapshot_impl_->context_data_space_used = source.GetInt(); |
137 snapshot_impl_->context_code_space_used = source.GetInt(); | 135 snapshot_impl_->context_code_space_used = source.GetInt(); |
138 snapshot_impl_->context_map_space_used = source.GetInt(); | 136 snapshot_impl_->context_map_space_used = source.GetInt(); |
139 snapshot_impl_->context_cell_space_used = source.GetInt(); | 137 snapshot_impl_->context_cell_space_used = source.GetInt(); |
140 snapshot_impl_->context_property_cell_space_used = source.GetInt(); | 138 snapshot_impl_->context_property_cell_space_used = source.GetInt(); |
141 | 139 |
142 DCHECK(success); | 140 DCHECK(success); |
143 } | 141 } |
144 | 142 |
145 } } // namespace v8::internal | 143 } } // namespace v8::internal |
OLD | NEW |