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

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

Issue 23465004: More cleanup related to malformed and malbounded types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/parser.cc ('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/bigint_operations.h" 5 #include "vm/bigint_operations.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 DECLARE_FLAG(bool, error_on_malformed_type); 14 DECLARE_FLAG(bool, error_on_bad_type);
15 15
16 16
17 #define NEW_OBJECT(type) \ 17 #define NEW_OBJECT(type) \
18 ((kind == Snapshot::kFull) ? reader->New##type() : type::New()) 18 ((kind == Snapshot::kFull) ? reader->New##type() : type::New())
19 19
20 #define NEW_OBJECT_WITH_LEN(type, len) \ 20 #define NEW_OBJECT_WITH_LEN(type, len) \
21 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len)) 21 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len))
22 22
23 #define NEW_OBJECT_WITH_LEN_SPACE(type, len, kind) \ 23 #define NEW_OBJECT_WITH_LEN_SPACE(type, len, kind) \
24 ((kind == Snapshot::kFull) ? \ 24 ((kind == Snapshot::kFull) ? \
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 242
243 void RawType::WriteTo(SnapshotWriter* writer, 243 void RawType::WriteTo(SnapshotWriter* writer,
244 intptr_t object_id, 244 intptr_t object_id,
245 Snapshot::Kind kind) { 245 Snapshot::Kind kind) {
246 ASSERT(writer != NULL); 246 ASSERT(writer != NULL);
247 247
248 // Only resolved and finalized types should be written to a snapshot. 248 // Only resolved and finalized types should be written to a snapshot.
249 // TODO(regis): Replace the test below by an ASSERT() or remove the flag test. 249 // TODO(regis): Replace the test below by an ASSERT() or remove the flag test.
250 if (FLAG_error_on_malformed_type && 250 if (FLAG_error_on_bad_type &&
251 (ptr()->type_state_ != RawType::kFinalizedInstantiated) && 251 (ptr()->type_state_ != RawType::kFinalizedInstantiated) &&
252 (ptr()->type_state_ != RawType::kFinalizedUninstantiated)) { 252 (ptr()->type_state_ != RawType::kFinalizedUninstantiated)) {
253 // Print the name of the class of the unfinalized type, as well as the 253 // Print the name of the class of the unfinalized type, as well as the
254 // token location from where it is referred to, making sure not 254 // token location from where it is referred to, making sure not
255 // to allocate any handles. Unfortunately, we cannot print the script name. 255 // to allocate any handles. Unfortunately, we cannot print the script name.
256 const intptr_t cid = ClassIdTag::decode(*reinterpret_cast<uword*>( 256 const intptr_t cid = ClassIdTag::decode(*reinterpret_cast<uword*>(
257 reinterpret_cast<uword>(ptr()->type_class_) - kHeapObjectTag + 257 reinterpret_cast<uword>(ptr()->type_class_) - kHeapObjectTag +
258 Object::tags_offset())); 258 Object::tags_offset()));
259 if (cid == kUnresolvedClassCid) { 259 if (cid == kUnresolvedClassCid) {
260 OS::Print("Snapshotting unresolved type '%s' at token pos %" Pd "\n", 260 OS::Print("Snapshotting unresolved type '%s' at token pos %" Pd "\n",
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 328 }
329 329
330 330
331 void RawTypeParameter::WriteTo(SnapshotWriter* writer, 331 void RawTypeParameter::WriteTo(SnapshotWriter* writer,
332 intptr_t object_id, 332 intptr_t object_id,
333 Snapshot::Kind kind) { 333 Snapshot::Kind kind) {
334 ASSERT(writer != NULL); 334 ASSERT(writer != NULL);
335 335
336 // Only finalized type parameters should be written to a snapshot. 336 // Only finalized type parameters should be written to a snapshot.
337 // TODO(regis): Replace the test below by an ASSERT() or remove the flag test. 337 // TODO(regis): Replace the test below by an ASSERT() or remove the flag test.
338 if (FLAG_error_on_malformed_type && 338 if (FLAG_error_on_bad_type &&
339 (ptr()->type_state_ != RawTypeParameter::kFinalizedUninstantiated)) { 339 (ptr()->type_state_ != RawTypeParameter::kFinalizedUninstantiated)) {
340 // Print the name of the unfinalized type parameter, the name of the class 340 // Print the name of the unfinalized type parameter, the name of the class
341 // it parameterizes, as well as the token location from where it is referred 341 // it parameterizes, as well as the token location from where it is referred
342 // to, making sure not to allocate any handles. Unfortunately, we cannot 342 // to, making sure not to allocate any handles. Unfortunately, we cannot
343 // print the script name. 343 // print the script name.
344 OS::Print("Snapshotting unfinalized type parameter '%s' of class '%s' at " 344 OS::Print("Snapshotting unfinalized type parameter '%s' of class '%s' at "
345 "token pos %" Pd "\n", 345 "token pos %" Pd "\n",
346 RawOneByteStringToCString( 346 RawOneByteStringToCString(
347 reinterpret_cast<RawOneByteString*>(ptr()->name_)), 347 reinterpret_cast<RawOneByteString*>(ptr()->name_)),
348 RawOneByteStringToCString( 348 RawOneByteStringToCString(
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 } 2644 }
2645 2645
2646 2646
2647 void RawMirrorReference::WriteTo(SnapshotWriter* writer, 2647 void RawMirrorReference::WriteTo(SnapshotWriter* writer,
2648 intptr_t object_id, 2648 intptr_t object_id,
2649 Snapshot::Kind kind) { 2649 Snapshot::Kind kind) {
2650 UNREACHABLE(); 2650 UNREACHABLE();
2651 } 2651 }
2652 2652
2653 } // namespace dart 2653 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698