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

Side by Side Diff: vm/snapshot.h

Issue 11293163: Throw illegal argument exception when (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 1 month 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 | « vm/exceptions.cc ('k') | vm/snapshot.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 (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 #ifndef VM_SNAPSHOT_H_ 5 #ifndef VM_SNAPSHOT_H_
6 #define VM_SNAPSHOT_H_ 6 #define VM_SNAPSHOT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/bitfield.h" 10 #include "vm/bitfield.h"
11 #include "vm/datastream.h" 11 #include "vm/datastream.h"
12 #include "vm/exceptions.h"
12 #include "vm/globals.h" 13 #include "vm/globals.h"
13 #include "vm/growable_array.h" 14 #include "vm/growable_array.h"
14 #include "vm/isolate.h" 15 #include "vm/isolate.h"
15 #include "vm/visitor.h" 16 #include "vm/visitor.h"
16 17
17 namespace dart { 18 namespace dart {
18 19
19 // Forward declarations. 20 // Forward declarations.
20 class AbstractType; 21 class AbstractType;
21 class AbstractTypeArguments; 22 class AbstractTypeArguments;
22 class Array; 23 class Array;
23 class Class; 24 class Class;
24 class ClassTable; 25 class ClassTable;
25 class ExternalUint8Array; 26 class ExternalUint8Array;
26 class GrowableObjectArray; 27 class GrowableObjectArray;
27 class Heap; 28 class Heap;
29 class LanguageError;
28 class Library; 30 class Library;
29 class Object; 31 class Object;
30 class ObjectStore; 32 class ObjectStore;
31 class RawAbstractTypeArguments; 33 class RawAbstractTypeArguments;
32 class RawApiError; 34 class RawApiError;
33 class RawArray; 35 class RawArray;
34 class RawBigint; 36 class RawBigint;
35 class RawClass; 37 class RawClass;
36 class RawContext; 38 class RawContext;
37 class RawDouble; 39 class RawDouble;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 421
420 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter); 422 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter);
421 }; 423 };
422 424
423 425
424 class SnapshotWriter : public BaseWriter { 426 class SnapshotWriter : public BaseWriter {
425 protected: 427 protected:
426 SnapshotWriter(Snapshot::Kind kind, 428 SnapshotWriter(Snapshot::Kind kind,
427 uint8_t** buffer, 429 uint8_t** buffer,
428 ReAlloc alloc, 430 ReAlloc alloc,
429 intptr_t increment_size) 431 intptr_t increment_size);
430 : BaseWriter(buffer, alloc, increment_size),
431 kind_(kind),
432 object_store_(Isolate::Current()->object_store()),
433 class_table_(Isolate::Current()->class_table()),
434 forward_list_() {
435 }
436 432
437 public: 433 public:
438 // Snapshot kind. 434 // Snapshot kind.
439 Snapshot::Kind kind() const { return kind_; } 435 Snapshot::Kind kind() const { return kind_; }
440 436
441 // Serialize an object into the buffer. 437 // Serialize an object into the buffer.
442 void WriteObject(RawObject* raw); 438 void WriteObject(RawObject* raw);
443 439
444 uword GetObjectTags(RawObject* raw); 440 uword GetObjectTags(RawObject* raw);
445 441
442 Exceptions::ExceptionType exception_type() const {
443 return exception_type_;
444 }
445 void set_exception_type(Exceptions::ExceptionType type) {
446 exception_type_ = type;
447 }
448 const char* exception_msg() const { return exception_msg_; }
449 void set_exception_msg(const char* msg) {
450 exception_msg_ = msg;
451 }
452 LanguageError* ErrorHandle() { return &error_; }
453 void ThrowException(Exceptions::ExceptionType type, const char* msg);
454
446 protected: 455 protected:
447 class ForwardObjectNode : public ZoneAllocated { 456 class ForwardObjectNode : public ZoneAllocated {
448 public: 457 public:
449 ForwardObjectNode(RawObject* raw, uword tags, SerializeState state) 458 ForwardObjectNode(RawObject* raw, uword tags, SerializeState state)
450 : raw_(raw), tags_(tags), state_(state) {} 459 : raw_(raw), tags_(tags), state_(state) {}
451 RawObject* raw() const { return raw_; } 460 RawObject* raw() const { return raw_; }
452 uword tags() const { return tags_; } 461 uword tags() const { return tags_; }
453 bool is_serialized() const { return state_ == kIsSerialized; } 462 bool is_serialized() const { return state_ == kIsSerialized; }
454 void set_state(SerializeState value) { state_ = value; } 463 void set_state(SerializeState value) { state_ = value; }
455 464
(...skipping 23 matching lines...) Expand all
479 RawAbstractTypeArguments* type_arguments, 488 RawAbstractTypeArguments* type_arguments,
480 RawObject* data[]); 489 RawObject* data[]);
481 490
482 ObjectStore* object_store() const { return object_store_; } 491 ObjectStore* object_store() const { return object_store_; }
483 492
484 private: 493 private:
485 Snapshot::Kind kind_; 494 Snapshot::Kind kind_;
486 ObjectStore* object_store_; // Object store for common classes. 495 ObjectStore* object_store_; // Object store for common classes.
487 ClassTable* class_table_; // Class table for the class index to class lookup. 496 ClassTable* class_table_; // Class table for the class index to class lookup.
488 GrowableArray<ForwardObjectNode*> forward_list_; 497 GrowableArray<ForwardObjectNode*> forward_list_;
498 Exceptions::ExceptionType exception_type_; // Exception type.
499 const char* exception_msg_; // Message associated with exception.
500 LanguageError& error_; // Error handle.
489 501
490 friend class RawArray; 502 friend class RawArray;
491 friend class RawClass; 503 friend class RawClass;
492 friend class RawGrowableObjectArray; 504 friend class RawGrowableObjectArray;
493 friend class RawImmutableArray; 505 friend class RawImmutableArray;
494 friend class RawJSRegExp; 506 friend class RawJSRegExp;
495 friend class RawLibrary; 507 friend class RawLibrary;
496 friend class RawLiteralToken; 508 friend class RawLiteralToken;
497 friend class RawScript; 509 friend class RawScript;
498 friend class RawTokenStream; 510 friend class RawTokenStream;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 private: 586 private:
575 SnapshotWriter* writer_; 587 SnapshotWriter* writer_;
576 bool as_references_; 588 bool as_references_;
577 589
578 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 590 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
579 }; 591 };
580 592
581 } // namespace dart 593 } // namespace dart
582 594
583 #endif // VM_SNAPSHOT_H_ 595 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « vm/exceptions.cc ('k') | vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698