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

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

Issue 1401643002: Remove isolate parameter when allocating handles (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Sync Created 5 years, 2 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/mirrors_api_impl.cc ('k') | runtime/vm/service.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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #define BASE_OBJECT_IMPLEMENTATION(object, super) \ 58 #define BASE_OBJECT_IMPLEMENTATION(object, super) \
59 public: /* NOLINT */ \ 59 public: /* NOLINT */ \
60 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \ 60 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \
61 bool Is##object() const { return true; } \ 61 bool Is##object() const { return true; } \
62 static object& Handle(Zone* zone, Raw##object* raw_ptr) { \ 62 static object& Handle(Zone* zone, Raw##object* raw_ptr) { \
63 object* obj = \ 63 object* obj = \
64 reinterpret_cast<object*>(VMHandles::AllocateHandle(zone)); \ 64 reinterpret_cast<object*>(VMHandles::AllocateHandle(zone)); \
65 initializeHandle(obj, raw_ptr); \ 65 initializeHandle(obj, raw_ptr); \
66 return *obj; \ 66 return *obj; \
67 } \ 67 } \
68 /* DEPRECATED: Use Zone version. */ \
69 static object& Handle(Isolate* isolate, Raw##object* raw_ptr) { \
70 return Handle(isolate->current_zone(), raw_ptr); \
71 } \
72 static object& Handle() { \ 68 static object& Handle() { \
73 return Handle(Thread::Current()->zone(), object::null()); \ 69 return Handle(Thread::Current()->zone(), object::null()); \
74 } \ 70 } \
75 static object& Handle(Zone* zone) { \ 71 static object& Handle(Zone* zone) { \
76 return Handle(zone, object::null()); \ 72 return Handle(zone, object::null()); \
77 } \ 73 } \
78 /* DEPRECATED: Use Zone version. */ \
79 static object& Handle(Isolate* isolate) { \
80 return Handle(isolate->current_zone(), object::null()); \
81 } \
82 static object& Handle(Raw##object* raw_ptr) { \ 74 static object& Handle(Raw##object* raw_ptr) { \
83 return Handle(Thread::Current()->zone(), raw_ptr); \ 75 return Handle(Thread::Current()->zone(), raw_ptr); \
84 } \ 76 } \
85 static object& CheckedHandle(Zone* zone, RawObject* raw_ptr) { \ 77 static object& CheckedHandle(Zone* zone, RawObject* raw_ptr) { \
86 object* obj = \ 78 object* obj = \
87 reinterpret_cast<object*>(VMHandles::AllocateHandle(zone)); \ 79 reinterpret_cast<object*>(VMHandles::AllocateHandle(zone)); \
88 initializeHandle(obj, raw_ptr); \ 80 initializeHandle(obj, raw_ptr); \
89 if (!obj->Is##object()) { \ 81 if (!obj->Is##object()) { \
90 FATAL2("Handle check failed: saw %s expected %s", \ 82 FATAL2("Handle check failed: saw %s expected %s", \
91 obj->ToCString(), #object); \ 83 obj->ToCString(), #object); \
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 313
322 bool IsReadOnlyHandle() const; 314 bool IsReadOnlyHandle() const;
323 315
324 bool IsNotTemporaryScopedHandle() const; 316 bool IsNotTemporaryScopedHandle() const;
325 317
326 static Object& Handle(Zone* zone, RawObject* raw_ptr) { 318 static Object& Handle(Zone* zone, RawObject* raw_ptr) {
327 Object* obj = reinterpret_cast<Object*>(VMHandles::AllocateHandle(zone)); 319 Object* obj = reinterpret_cast<Object*>(VMHandles::AllocateHandle(zone));
328 initializeHandle(obj, raw_ptr); 320 initializeHandle(obj, raw_ptr);
329 return *obj; 321 return *obj;
330 } 322 }
331 // DEPRECATED: Use Zone version.
332 static Object& Handle(Isolate* isolate, RawObject* raw_ptr) {
333 return Handle(isolate->current_zone(), raw_ptr);
334 }
335 static Object* ReadOnlyHandle() { 323 static Object* ReadOnlyHandle() {
336 Object* obj = reinterpret_cast<Object*>( 324 Object* obj = reinterpret_cast<Object*>(
337 Dart::AllocateReadOnlyHandle()); 325 Dart::AllocateReadOnlyHandle());
338 initializeHandle(obj, Object::null()); 326 initializeHandle(obj, Object::null());
339 return obj; 327 return obj;
340 } 328 }
341 329
342 static Object& Handle() { 330 static Object& Handle() {
343 return Handle(Thread::Current()->zone(), null_); 331 return Handle(Thread::Current()->zone(), null_);
344 } 332 }
345 333
346 static Object& Handle(Zone* zone) { 334 static Object& Handle(Zone* zone) {
347 return Handle(zone, null_); 335 return Handle(zone, null_);
348 } 336 }
349 // DEPRECATED: Use Zone version.
350 static Object& Handle(Isolate* isolate) {
351 return Handle(isolate->current_zone(), null_);
352 }
353 337
354 static Object& Handle(RawObject* raw_ptr) { 338 static Object& Handle(RawObject* raw_ptr) {
355 return Handle(Thread::Current()->zone(), raw_ptr); 339 return Handle(Thread::Current()->zone(), raw_ptr);
356 } 340 }
357 341
358 static Object& ZoneHandle(Zone* zone, RawObject* raw_ptr) { 342 static Object& ZoneHandle(Zone* zone, RawObject* raw_ptr) {
359 Object* obj = reinterpret_cast<Object*>( 343 Object* obj = reinterpret_cast<Object*>(
360 VMHandles::AllocateZoneHandle(zone)); 344 VMHandles::AllocateZoneHandle(zone));
361 initializeHandle(obj, raw_ptr); 345 initializeHandle(obj, raw_ptr);
362 return *obj; 346 return *obj;
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 raw_ = value; 828 raw_ = value;
845 } 829 }
846 830
847 static PassiveObject& Handle(Zone* zone, RawObject* raw_ptr) { 831 static PassiveObject& Handle(Zone* zone, RawObject* raw_ptr) {
848 PassiveObject* obj = reinterpret_cast<PassiveObject*>( 832 PassiveObject* obj = reinterpret_cast<PassiveObject*>(
849 VMHandles::AllocateHandle(zone)); 833 VMHandles::AllocateHandle(zone));
850 obj->raw_ = raw_ptr; 834 obj->raw_ = raw_ptr;
851 obj->set_vtable(0); 835 obj->set_vtable(0);
852 return *obj; 836 return *obj;
853 } 837 }
854 // DEPRECATED - use Zone version.
855 static PassiveObject& Handle(Isolate* I, RawObject* raw_ptr) {
856 return Handle(I->current_zone(), raw_ptr);
857 }
858 static PassiveObject& Handle(RawObject* raw_ptr) { 838 static PassiveObject& Handle(RawObject* raw_ptr) {
859 return Handle(Thread::Current()->zone(), raw_ptr); 839 return Handle(Thread::Current()->zone(), raw_ptr);
860 } 840 }
861 static PassiveObject& Handle() { 841 static PassiveObject& Handle() {
862 return Handle(Thread::Current()->zone(), Object::null()); 842 return Handle(Thread::Current()->zone(), Object::null());
863 } 843 }
864 static PassiveObject& Handle(Zone* zone) { 844 static PassiveObject& Handle(Zone* zone) {
865 return Handle(zone, Object::null()); 845 return Handle(zone, Object::null());
866 } 846 }
867 // DEPRECATED - use Zone version.
868 static PassiveObject& Handle(Isolate* I) {
869 return Handle(I, Object::null());
870 }
871 static PassiveObject& ZoneHandle(Zone* zone, RawObject* raw_ptr) { 847 static PassiveObject& ZoneHandle(Zone* zone, RawObject* raw_ptr) {
872 PassiveObject* obj = reinterpret_cast<PassiveObject*>( 848 PassiveObject* obj = reinterpret_cast<PassiveObject*>(
873 VMHandles::AllocateZoneHandle(zone)); 849 VMHandles::AllocateZoneHandle(zone));
874 obj->raw_ = raw_ptr; 850 obj->raw_ = raw_ptr;
875 obj->set_vtable(0); 851 obj->set_vtable(0);
876 return *obj; 852 return *obj;
877 } 853 }
878 static PassiveObject& ZoneHandle(RawObject* raw_ptr) { 854 static PassiveObject& ZoneHandle(RawObject* raw_ptr) {
879 return ZoneHandle(Thread::Current()->zone(), raw_ptr); 855 return ZoneHandle(Thread::Current()->zone(), raw_ptr);
880 } 856 }
(...skipping 7285 matching lines...) Expand 10 before | Expand all | Expand 10 after
8166 8142
8167 8143
8168 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 8144 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
8169 intptr_t index) { 8145 intptr_t index) {
8170 return array.At((index * kEntryLength) + kTargetFunctionIndex); 8146 return array.At((index * kEntryLength) + kTargetFunctionIndex);
8171 } 8147 }
8172 8148
8173 } // namespace dart 8149 } // namespace dart
8174 8150
8175 #endif // VM_OBJECT_H_ 8151 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/mirrors_api_impl.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698