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

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

Issue 510613002: Add passive handle types PassiveObject and PassiveInstance to allow (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | « no previous file | runtime/vm/raw_object_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_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 #define REUSABLE_FRIEND_DECLARATION(name) \ 685 #define REUSABLE_FRIEND_DECLARATION(name) \
686 friend class Reusable##name##HandleScope; 686 friend class Reusable##name##HandleScope;
687 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) 687 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION)
688 #undef REUSABLE_FRIEND_DECLARATION 688 #undef REUSABLE_FRIEND_DECLARATION
689 689
690 DISALLOW_ALLOCATION(); 690 DISALLOW_ALLOCATION();
691 DISALLOW_COPY_AND_ASSIGN(Object); 691 DISALLOW_COPY_AND_ASSIGN(Object);
692 }; 692 };
693 693
694 694
695 class PassiveObject : public Object {
696 public:
697 void operator=(RawObject* value) {
698 raw_ = value;
699 }
700 void operator^=(RawObject* value) {
701 raw_ = value;
702 }
703 static PassiveObject& Handle(Isolate* I, RawObject* raw_ptr) {
704 PassiveObject* obj =
705 reinterpret_cast<PassiveObject*>(VMHandles::AllocateHandle(I));
706 obj->raw_ = raw_ptr;
707 obj->set_vtable(NULL);
708 return *obj;
709 }
710 static PassiveObject& Handle(RawObject* raw_ptr) {
711 return Handle(Isolate::Current(), raw_ptr);
712 }
713 static PassiveObject& Handle() {
714 return Handle(Isolate::Current(), Object::null());
715 }
716 static PassiveObject& Handle(Isolate* I) {
717 return Handle(I, Object::null());
718 }
719 static PassiveObject& ZoneHandle(Isolate* I, RawObject* raw_ptr) {
720 PassiveObject* obj = reinterpret_cast<PassiveObject*>(
721 VMHandles::AllocateZoneHandle(I));
722 obj->raw_ = raw_ptr;
723 obj->set_vtable(NULL);
724 return *obj;
725 }
726 static PassiveObject& ZoneHandle(RawObject* raw_ptr) {
727 return ZoneHandle(Isolate::Current(), raw_ptr);
728 }
729 static PassiveObject& ZoneHandle() {
730 return ZoneHandle(Isolate::Current(), Object::null());
731 }
732 static PassiveObject& ZoneHandle(Isolate* I) {
733 return ZoneHandle(I, Object::null());
734 }
735
736 private:
737 PassiveObject() : Object() {}
738 DISALLOW_ALLOCATION();
739 DISALLOW_COPY_AND_ASSIGN(PassiveObject);
740 };
741
742
695 class Class : public Object { 743 class Class : public Object {
696 public: 744 public:
697 intptr_t instance_size() const { 745 intptr_t instance_size() const {
698 ASSERT(is_finalized() || is_prefinalized()); 746 ASSERT(is_finalized() || is_prefinalized());
699 return (raw_ptr()->instance_size_in_words_ * kWordSize); 747 return (raw_ptr()->instance_size_in_words_ * kWordSize);
700 } 748 }
701 void set_instance_size(intptr_t value_in_bytes) const { 749 void set_instance_size(intptr_t value_in_bytes) const {
702 ASSERT(kWordSize != 0); 750 ASSERT(kWordSize != 0);
703 set_instance_size_in_words(value_in_bytes / kWordSize); 751 set_instance_size_in_words(value_in_bytes / kWordSize);
704 } 752 }
(...skipping 6656 matching lines...) Expand 10 before | Expand all | Expand 10 after
7361 7409
7362 7410
7363 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7411 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7364 intptr_t index) { 7412 intptr_t index) {
7365 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7413 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7366 } 7414 }
7367 7415
7368 } // namespace dart 7416 } // namespace dart
7369 7417
7370 #endif // VM_OBJECT_H_ 7418 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698