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

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

Issue 10230001: Explicitly initialize Bigint members after uninitialized allocations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: finish a rename Created 8 years, 8 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/raw_object.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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 obj->ptr()->value_ = value; 242 obj->ptr()->value_ = value;
243 return obj; 243 return obj;
244 } 244 }
245 245
246 246
247 RawBigint* SnapshotReader::NewBigint(const char* hex_string) { 247 RawBigint* SnapshotReader::NewBigint(const char* hex_string) {
248 ASSERT(kind_ == Snapshot::kFull); 248 ASSERT(kind_ == Snapshot::kFull);
249 ASSERT(isolate()->no_gc_scope_depth() != 0); 249 ASSERT(isolate()->no_gc_scope_depth() != 0);
250 cls_ = object_store()->bigint_class(); 250 cls_ = object_store()->bigint_class();
251 intptr_t bigint_length = BigintOperations::ComputeChunkLength(hex_string); 251 intptr_t bigint_length = BigintOperations::ComputeChunkLength(hex_string);
252 const Bigint& result = Bigint::Handle(reinterpret_cast<RawBigint*>( 252 RawBigint* obj = reinterpret_cast<RawBigint*>(
253 AllocateUninitialized(cls_, Bigint::InstanceSize(bigint_length)))); 253 AllocateUninitialized(cls_, Bigint::InstanceSize(bigint_length)));
254 BigintOperations::FromHexCString(hex_string, result); 254 obj->ptr()->allocated_length_ = bigint_length;
255 return result.raw(); 255 obj->ptr()->signed_length_ = bigint_length;
siva 2012/04/26 04:45:04 why not add a set_allocated_length() and set_signe
cshapiro 2012/04/26 06:34:53 Hmm... I tried to make the code look like the rest
siva 2012/04/26 17:17:44 Agree, I didn't realize we already had a NoGCScope
256 BigintOperations::FromHexCString(hex_string, Bigint::Handle(obj));
257 return obj;
256 } 258 }
257 259
258 260
259 RawDouble* SnapshotReader::NewDouble(double value) { 261 RawDouble* SnapshotReader::NewDouble(double value) {
260 ASSERT(kind_ == Snapshot::kFull); 262 ASSERT(kind_ == Snapshot::kFull);
261 ASSERT(isolate()->no_gc_scope_depth() != 0); 263 ASSERT(isolate()->no_gc_scope_depth() != 0);
262 cls_ = object_store()->double_class(); 264 cls_ = object_store()->double_class();
263 RawDouble* obj = reinterpret_cast<RawDouble*>( 265 RawDouble* obj = reinterpret_cast<RawDouble*>(
264 AllocateUninitialized(cls_, Double::InstanceSize())); 266 AllocateUninitialized(cls_, Double::InstanceSize()));
265 obj->ptr()->value_ = value; 267 obj->ptr()->value_ = value;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 673
672 674
673 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { 675 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) {
674 for (RawObject** current = first; current <= last; current++) { 676 for (RawObject** current = first; current <= last; current++) {
675 RawObject* raw_obj = *current; 677 RawObject* raw_obj = *current;
676 writer_->WriteObject(raw_obj); 678 writer_->WriteObject(raw_obj);
677 } 679 }
678 } 680 }
679 681
680 } // namespace dart 682 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698