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

Side by Side Diff: runtime/vm/snapshot.cc

Issue 10867046: Use Heap::kOld when allocating objects for script snapshots. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 cls = library_.LookupClass(str_); 191 cls = library_.LookupClass(str_);
192 } 192 }
193 ASSERT(!cls.IsNull()); 193 ASSERT(!cls.IsNull());
194 return cls.raw(); 194 return cls.raw();
195 } 195 }
196 196
197 197
198 RawObject* SnapshotReader::ReadObjectImpl() { 198 RawObject* SnapshotReader::ReadObjectImpl() {
199 int64_t value = Read<int64_t>(); 199 int64_t value = Read<int64_t>();
200 if ((value & kSmiTagMask) == 0) { 200 if ((value & kSmiTagMask) == 0) {
201 return Integer::New((value >> kSmiTagShift)); 201 return Integer::New((value >> kSmiTagShift), HEAP_SPACE(kind_));
202 } 202 }
203 return ReadObjectImpl(value); 203 return ReadObjectImpl(value);
204 } 204 }
205 205
206 206
207 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header_value) { 207 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header_value) {
208 ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin)); 208 ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin));
209 if (IsVMIsolateObject(header_value)) { 209 if (IsVMIsolateObject(header_value)) {
210 return ReadVMIsolateObject(header_value); 210 return ReadVMIsolateObject(header_value);
211 } else { 211 } else {
212 if (SerializedHeaderTag::decode(header_value) == kObjectId) { 212 if (SerializedHeaderTag::decode(header_value) == kObjectId) {
213 return ReadIndexedObject(SerializedHeaderData::decode(header_value)); 213 return ReadIndexedObject(SerializedHeaderData::decode(header_value));
214 } 214 }
215 ASSERT(SerializedHeaderTag::decode(header_value) == kInlined); 215 ASSERT(SerializedHeaderTag::decode(header_value) == kInlined);
216 return ReadInlinedObject(SerializedHeaderData::decode(header_value)); 216 return ReadInlinedObject(SerializedHeaderData::decode(header_value));
217 } 217 }
218 } 218 }
219 219
220 220
221 RawObject* SnapshotReader::ReadObjectRef() { 221 RawObject* SnapshotReader::ReadObjectRef() {
222 int64_t header_value = Read<int64_t>(); 222 int64_t header_value = Read<int64_t>();
223 if ((header_value & kSmiTagMask) == 0) { 223 if ((header_value & kSmiTagMask) == 0) {
224 return Integer::New((header_value >> kSmiTagShift)); 224 return Integer::New((header_value >> kSmiTagShift), HEAP_SPACE(kind_));
225 } 225 }
226 ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin)); 226 ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin));
227 if (IsVMIsolateObject(header_value)) { 227 if (IsVMIsolateObject(header_value)) {
228 return ReadVMIsolateObject(header_value); 228 return ReadVMIsolateObject(header_value);
229 } else if (SerializedHeaderTag::decode(header_value) == kObjectId) { 229 } else if (SerializedHeaderTag::decode(header_value) == kObjectId) {
230 return ReadIndexedObject(SerializedHeaderData::decode(header_value)); 230 return ReadIndexedObject(SerializedHeaderData::decode(header_value));
231 } 231 }
232 ASSERT(SerializedHeaderTag::decode(header_value) == kInlined); 232 ASSERT(SerializedHeaderTag::decode(header_value) == kInlined);
233 intptr_t object_id = SerializedHeaderData::decode(header_value); 233 intptr_t object_id = SerializedHeaderData::decode(header_value);
234 ASSERT(GetBackRef(object_id) == NULL); 234 ASSERT(GetBackRef(object_id) == NULL);
235 235
236 // Read the class header information and lookup the class. 236 // Read the class header information and lookup the class.
237 intptr_t class_header = ReadIntptrValue(); 237 intptr_t class_header = ReadIntptrValue();
238 238
239 // Since we are only reading an object reference, If it is an instance kind 239 // Since we are only reading an object reference, If it is an instance kind
240 // then we only need to figure out the class of the object and allocate an 240 // then we only need to figure out the class of the object and allocate an
241 // instance of it. The individual fields will be read later. 241 // instance of it. The individual fields will be read later.
242 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { 242 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) {
243 Instance& result = Instance::ZoneHandle(isolate(), Instance::null()); 243 Instance& result = Instance::ZoneHandle(isolate(), Instance::null());
244 AddBackRef(object_id, &result, kIsNotDeserialized); 244 AddBackRef(object_id, &result, kIsNotDeserialized);
245 245
246 cls_ ^= ReadObjectImpl(); // Read class information. 246 cls_ ^= ReadObjectImpl(); // Read class information.
247 ASSERT(!cls_.IsNull()); 247 ASSERT(!cls_.IsNull());
248 intptr_t instance_size = cls_.instance_size(); 248 intptr_t instance_size = cls_.instance_size();
249 ASSERT(instance_size > 0); 249 ASSERT(instance_size > 0);
250 if (kind_ == Snapshot::kFull) { 250 if (kind_ == Snapshot::kFull) {
251 result ^= AllocateUninitialized(cls_, instance_size); 251 result ^= AllocateUninitialized(cls_, instance_size);
252 } else { 252 } else {
253 result ^= Object::Allocate(cls_.id(), instance_size, Heap::kNew); 253 result ^= Object::Allocate(cls_.id(), instance_size, HEAP_SPACE(kind_));
254 } 254 }
255 return result.raw(); 255 return result.raw();
256 } 256 }
257 ASSERT((class_header & kSmiTagMask) != 0); 257 ASSERT((class_header & kSmiTagMask) != 0);
258 cls_ = LookupInternalClass(class_header); 258 cls_ = LookupInternalClass(class_header);
259 ASSERT(!cls_.IsNull()); 259 ASSERT(!cls_.IsNull());
260 260
261 // Similarly Array and ImmutableArray objects are also similarly only 261 // Similarly Array and ImmutableArray objects are also similarly only
262 // allocated here, the individual array elements are read later. 262 // allocated here, the individual array elements are read later.
263 intptr_t class_id = cls_.id(); 263 intptr_t class_id = cls_.id();
264 if (class_id == kArrayCid) { 264 if (class_id == kArrayCid) {
265 // Read the length and allocate an object based on the len. 265 // Read the length and allocate an object based on the len.
266 intptr_t len = ReadSmiValue(); 266 intptr_t len = ReadSmiValue();
267 Array& array = Array::ZoneHandle( 267 Array& array = Array::ZoneHandle(
268 isolate(), 268 isolate(),
269 (kind_ == Snapshot::kFull) ? NewArray(len) : Array::New(len)); 269 ((kind_ == Snapshot::kFull) ?
270 NewArray(len) : Array::New(len, HEAP_SPACE(kind_))));
270 AddBackRef(object_id, &array, kIsNotDeserialized); 271 AddBackRef(object_id, &array, kIsNotDeserialized);
271 272
272 return array.raw(); 273 return array.raw();
273 } 274 }
274 if (class_id == kImmutableArrayCid) { 275 if (class_id == kImmutableArrayCid) {
275 // Read the length and allocate an object based on the len. 276 // Read the length and allocate an object based on the len.
276 intptr_t len = ReadSmiValue(); 277 intptr_t len = ReadSmiValue();
277 ImmutableArray& array = ImmutableArray::ZoneHandle( 278 ImmutableArray& array = ImmutableArray::ZoneHandle(
278 isolate(), 279 isolate(),
279 (kind_ == Snapshot::kFull) ? 280 (kind_ == Snapshot::kFull) ?
280 NewImmutableArray(len) : ImmutableArray::New(len)); 281 NewImmutableArray(len) : ImmutableArray::New(len, HEAP_SPACE(kind_)));
281 AddBackRef(object_id, &array, kIsNotDeserialized); 282 AddBackRef(object_id, &array, kIsNotDeserialized);
282 283
283 return array.raw(); 284 return array.raw();
284 } 285 }
285 286
286 // For all other internal VM classes we read the object inline. 287 // For all other internal VM classes we read the object inline.
287 intptr_t tags = ReadIntptrValue(); 288 intptr_t tags = ReadIntptrValue();
288 switch (class_id) { 289 switch (class_id) {
289 #define SNAPSHOT_READ(clazz) \ 290 #define SNAPSHOT_READ(clazz) \
290 case clazz::kClassId: { \ 291 case clazz::kClassId: { \
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 result = &(Instance::ZoneHandle(isolate(), Instance::null())); 655 result = &(Instance::ZoneHandle(isolate(), Instance::null()));
655 AddBackRef(object_id, result, kIsDeserialized); 656 AddBackRef(object_id, result, kIsDeserialized);
656 cls_ ^= ReadObjectImpl(); 657 cls_ ^= ReadObjectImpl();
657 ASSERT(!cls_.IsNull()); 658 ASSERT(!cls_.IsNull());
658 instance_size = cls_.instance_size(); 659 instance_size = cls_.instance_size();
659 ASSERT(instance_size > 0); 660 ASSERT(instance_size > 0);
660 // Allocate the instance and read in all the fields for the object. 661 // Allocate the instance and read in all the fields for the object.
661 if (kind_ == Snapshot::kFull) { 662 if (kind_ == Snapshot::kFull) {
662 *result ^= AllocateUninitialized(cls_, instance_size); 663 *result ^= AllocateUninitialized(cls_, instance_size);
663 } else { 664 } else {
664 *result ^= Object::Allocate(cls_.id(), instance_size, Heap::kNew); 665 *result ^= Object::Allocate(cls_.id(),
666 instance_size,
667 HEAP_SPACE(kind_));
665 } 668 }
666 } else { 669 } else {
667 cls_ ^= ReadObjectImpl(); 670 cls_ ^= ReadObjectImpl();
668 ASSERT(!cls_.IsNull()); 671 ASSERT(!cls_.IsNull());
669 instance_size = cls_.instance_size(); 672 instance_size = cls_.instance_size();
670 } 673 }
671 intptr_t offset = Object::InstanceSize(); 674 intptr_t offset = Object::InstanceSize();
672 while (offset < instance_size) { 675 while (offset < instance_size) {
673 obj_ = ReadObjectRef(); 676 obj_ = ReadObjectRef();
674 result->SetFieldAtOffset(offset, obj_); 677 result->SetFieldAtOffset(offset, obj_);
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 RawObject* raw_obj = *current; 1143 RawObject* raw_obj = *current;
1141 if (as_references_) { 1144 if (as_references_) {
1142 writer_->WriteObjectRef(raw_obj); 1145 writer_->WriteObjectRef(raw_obj);
1143 } else { 1146 } else {
1144 writer_->WriteObjectImpl(raw_obj); 1147 writer_->WriteObjectImpl(raw_obj);
1145 } 1148 }
1146 } 1149 }
1147 } 1150 }
1148 1151
1149 } // namespace dart 1152 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698