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

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

Issue 1310463005: - Ensure that HandleScope is initialized with a thread. (Remove (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments Created 5 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
« no previous file with comments | « runtime/vm/service_test.cc ('k') | runtime/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"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 Object* reference_; 291 Object* reference_;
292 DeserializeState state_; 292 DeserializeState state_;
293 bool defer_canonicalization_; 293 bool defer_canonicalization_;
294 ZoneGrowableArray<intptr_t>* patch_records_; 294 ZoneGrowableArray<intptr_t>* patch_records_;
295 }; 295 };
296 296
297 297
298 // Reads a snapshot into objects. 298 // Reads a snapshot into objects.
299 class SnapshotReader : public BaseReader { 299 class SnapshotReader : public BaseReader {
300 public: 300 public:
301 Thread* thread() const { return thread_; }
301 Zone* zone() const { return zone_; } 302 Zone* zone() const { return zone_; }
302 Isolate* isolate() const { return isolate_; } 303 Isolate* isolate() const { return thread_->isolate(); }
303 Heap* heap() const { return heap_; } 304 Heap* heap() const { return heap_; }
304 ObjectStore* object_store() const { return isolate_->object_store(); } 305 ObjectStore* object_store() const { return isolate()->object_store(); }
305 ClassTable* class_table() const { return isolate_->class_table(); } 306 ClassTable* class_table() const { return isolate()->class_table(); }
306 PassiveObject* PassiveObjectHandle() { return &pobj_; } 307 PassiveObject* PassiveObjectHandle() { return &pobj_; }
307 Array* ArrayHandle() { return &array_; } 308 Array* ArrayHandle() { return &array_; }
308 String* StringHandle() { return &str_; } 309 String* StringHandle() { return &str_; }
309 AbstractType* TypeHandle() { return &type_; } 310 AbstractType* TypeHandle() { return &type_; }
310 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; } 311 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; }
311 Array* TokensHandle() { return &tokens_; } 312 Array* TokensHandle() { return &tokens_; }
312 TokenStream* StreamHandle() { return &stream_; } 313 TokenStream* StreamHandle() { return &stream_; }
313 ExternalTypedData* DataHandle() { return &data_; } 314 ExternalTypedData* DataHandle() { return &data_; }
314 TypedData* TypedDataHandle() { return &typed_data_; } 315 TypedData* TypedDataHandle() { return &typed_data_; }
315 Snapshot::Kind kind() const { return kind_; } 316 Snapshot::Kind kind() const { return kind_; }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 RawObject* NewInteger(int64_t value); 384 RawObject* NewInteger(int64_t value);
384 RawStacktrace* NewStacktrace(); 385 RawStacktrace* NewStacktrace();
385 386
386 RawInstructions* GetInstructionsById(int32_t id); 387 RawInstructions* GetInstructionsById(int32_t id);
387 388
388 protected: 389 protected:
389 SnapshotReader(const uint8_t* buffer, 390 SnapshotReader(const uint8_t* buffer,
390 intptr_t size, 391 intptr_t size,
391 Snapshot::Kind kind, 392 Snapshot::Kind kind,
392 ZoneGrowableArray<BackRefNode>* backward_references, 393 ZoneGrowableArray<BackRefNode>* backward_references,
393 Isolate* isolate, 394 Thread* thread);
394 Zone* zone);
395 ~SnapshotReader() { } 395 ~SnapshotReader() { }
396 396
397 ZoneGrowableArray<BackRefNode>* GetBackwardReferenceTable() const { 397 ZoneGrowableArray<BackRefNode>* GetBackwardReferenceTable() const {
398 return backward_references_; 398 return backward_references_;
399 } 399 }
400 void ResetBackwardReferenceTable() { backward_references_ = NULL; } 400 void ResetBackwardReferenceTable() { backward_references_ = NULL; }
401 PageSpace* old_space() const { return old_space_; } 401 PageSpace* old_space() const { return old_space_; }
402 402
403 private: 403 private:
404 // Allocate uninitialized objects, this is used when reading a full snapshot. 404 // Allocate uninitialized objects, this is used when reading a full snapshot.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 intptr_t NextAvailableObjectId() const; 459 intptr_t NextAvailableObjectId() const;
460 460
461 void SetReadException(const char* msg); 461 void SetReadException(const char* msg);
462 462
463 RawObject* VmIsolateSnapshotObject(intptr_t index) const; 463 RawObject* VmIsolateSnapshotObject(intptr_t index) const;
464 464
465 bool is_vm_isolate() const; 465 bool is_vm_isolate() const;
466 466
467 Snapshot::Kind kind_; // Indicates type of snapshot(full, script, message). 467 Snapshot::Kind kind_; // Indicates type of snapshot(full, script, message).
468 bool snapshot_code_; 468 bool snapshot_code_;
469 Isolate* isolate_; // Current isolate. 469 Thread* thread_; // Current thread.
470 Zone* zone_; // Zone for allocations while reading snapshot. 470 Zone* zone_; // Zone for allocations while reading snapshot.
471 Heap* heap_; // Heap of the current isolate. 471 Heap* heap_; // Heap of the current isolate.
472 PageSpace* old_space_; // Old space of the current isolate. 472 PageSpace* old_space_; // Old space of the current isolate.
473 Class& cls_; // Temporary Class handle. 473 Class& cls_; // Temporary Class handle.
474 Object& obj_; // Temporary Object handle. 474 Object& obj_; // Temporary Object handle.
475 PassiveObject& pobj_; // Temporary PassiveObject handle. 475 PassiveObject& pobj_; // Temporary PassiveObject handle.
476 Array& array_; // Temporary Array handle. 476 Array& array_; // Temporary Array handle.
477 Field& field_; // Temporary Field handle. 477 Field& field_; // Temporary Field handle.
478 String& str_; // Temporary String handle. 478 String& str_; // Temporary String handle.
479 Library& library_; // Temporary library handle. 479 Library& library_; // Temporary library handle.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 friend class TypeRef; 526 friend class TypeRef;
527 friend class UnhandledException; 527 friend class UnhandledException;
528 friend class UnresolvedClass; 528 friend class UnresolvedClass;
529 friend class WeakProperty; 529 friend class WeakProperty;
530 DISALLOW_COPY_AND_ASSIGN(SnapshotReader); 530 DISALLOW_COPY_AND_ASSIGN(SnapshotReader);
531 }; 531 };
532 532
533 533
534 class VmIsolateSnapshotReader : public SnapshotReader { 534 class VmIsolateSnapshotReader : public SnapshotReader {
535 public: 535 public:
536 VmIsolateSnapshotReader(const uint8_t* buffer, intptr_t size, Zone* zone); 536 VmIsolateSnapshotReader(const uint8_t* buffer, intptr_t size, Thread* thread);
537 ~VmIsolateSnapshotReader(); 537 ~VmIsolateSnapshotReader();
538 538
539 RawApiError* ReadVmIsolateSnapshot(); 539 RawApiError* ReadVmIsolateSnapshot();
540 540
541 private: 541 private:
542 DISALLOW_COPY_AND_ASSIGN(VmIsolateSnapshotReader); 542 DISALLOW_COPY_AND_ASSIGN(VmIsolateSnapshotReader);
543 }; 543 };
544 544
545 545
546 class IsolateSnapshotReader : public SnapshotReader { 546 class IsolateSnapshotReader : public SnapshotReader {
547 public: 547 public:
548 IsolateSnapshotReader(const uint8_t* buffer, 548 IsolateSnapshotReader(const uint8_t* buffer,
549 intptr_t size, 549 intptr_t size,
550 Isolate* isolate, 550 Thread* thread);
551 Zone* zone);
552 ~IsolateSnapshotReader(); 551 ~IsolateSnapshotReader();
553 552
554 private: 553 private:
555 DISALLOW_COPY_AND_ASSIGN(IsolateSnapshotReader); 554 DISALLOW_COPY_AND_ASSIGN(IsolateSnapshotReader);
556 }; 555 };
557 556
558 557
559 class ScriptSnapshotReader : public SnapshotReader { 558 class ScriptSnapshotReader : public SnapshotReader {
560 public: 559 public:
561 ScriptSnapshotReader(const uint8_t* buffer, 560 ScriptSnapshotReader(const uint8_t* buffer,
562 intptr_t size, 561 intptr_t size,
563 Isolate* isolate, 562 Thread* thread);
564 Zone* zone);
565 ~ScriptSnapshotReader(); 563 ~ScriptSnapshotReader();
566 564
567 private: 565 private:
568 DISALLOW_COPY_AND_ASSIGN(ScriptSnapshotReader); 566 DISALLOW_COPY_AND_ASSIGN(ScriptSnapshotReader);
569 }; 567 };
570 568
571 569
572 class MessageSnapshotReader : public SnapshotReader { 570 class MessageSnapshotReader : public SnapshotReader {
573 public: 571 public:
574 MessageSnapshotReader(const uint8_t* buffer, 572 MessageSnapshotReader(const uint8_t* buffer,
575 intptr_t size, 573 intptr_t size,
576 Isolate* isolate, 574 Thread* thread);
577 Zone* zone);
578 ~MessageSnapshotReader(); 575 ~MessageSnapshotReader();
579 576
580 private: 577 private:
581 DISALLOW_COPY_AND_ASSIGN(MessageSnapshotReader); 578 DISALLOW_COPY_AND_ASSIGN(MessageSnapshotReader);
582 }; 579 };
583 580
584 581
585 class BaseWriter : public StackResource { 582 class BaseWriter : public StackResource {
586 public: 583 public:
587 // Size of the snapshot. 584 // Size of the snapshot.
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 809
813 void InitializeForwardList(ForwardList* forward_list) { 810 void InitializeForwardList(ForwardList* forward_list) {
814 ASSERT(forward_list_ == NULL); 811 ASSERT(forward_list_ == NULL);
815 forward_list_ = forward_list; 812 forward_list_ = forward_list;
816 } 813 }
817 void ResetForwardList() { 814 void ResetForwardList() {
818 ASSERT(forward_list_ != NULL); 815 ASSERT(forward_list_ != NULL);
819 forward_list_ = NULL; 816 forward_list_ = NULL;
820 } 817 }
821 818
822 Isolate* isolate() const { return isolate_; } 819 Thread* thread() const { return thread_; }
820 Isolate* isolate() const { return thread_->isolate(); }
823 ObjectStore* object_store() const { return object_store_; } 821 ObjectStore* object_store() const { return object_store_; }
824 822
825 private: 823 private:
826 Snapshot::Kind kind_; 824 Snapshot::Kind kind_;
827 Isolate* isolate_; 825 Thread* thread_;
828 ObjectStore* object_store_; // Object store for common classes. 826 ObjectStore* object_store_; // Object store for common classes.
829 ClassTable* class_table_; // Class table for the class index to class lookup. 827 ClassTable* class_table_; // Class table for the class index to class lookup.
830 ForwardList* forward_list_; 828 ForwardList* forward_list_;
831 Exceptions::ExceptionType exception_type_; // Exception type. 829 Exceptions::ExceptionType exception_type_; // Exception type.
832 const char* exception_msg_; // Message associated with exception. 830 const char* exception_msg_; // Message associated with exception.
833 bool unmarked_objects_; // True if marked objects have been unmarked. 831 bool unmarked_objects_; // True if marked objects have been unmarked.
834 bool can_send_any_object_; // True if any Dart instance can be sent. 832 bool can_send_any_object_; // True if any Dart instance can be sent.
835 bool snapshot_code_; 833 bool snapshot_code_;
836 834
837 friend class FullSnapshotWriter; 835 friend class FullSnapshotWriter;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 private: 969 private:
972 SnapshotWriter* writer_; 970 SnapshotWriter* writer_;
973 bool as_references_; 971 bool as_references_;
974 972
975 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 973 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
976 }; 974 };
977 975
978 } // namespace dart 976 } // namespace dart
979 977
980 #endif // VM_SNAPSHOT_H_ 978 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « runtime/vm/service_test.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698