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

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

Issue 10915015: Make fewer assumptions about the layout of api handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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/dart_api_impl.cc ('k') | runtime/vm/scavenger.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_DART_API_STATE_H_ 5 #ifndef VM_DART_API_STATE_H_
6 #define VM_DART_API_STATE_H_ 6 #define VM_DART_API_STATE_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "platform/thread.h" 10 #include "platform/thread.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 // Implementation of persistent handles which are handed out through the 99 // Implementation of persistent handles which are handed out through the
100 // dart API. 100 // dart API.
101 class PersistentHandle { 101 class PersistentHandle {
102 public: 102 public:
103 // Accessors. 103 // Accessors.
104 RawObject* raw() const { return raw_; } 104 RawObject* raw() const { return raw_; }
105 void set_raw(RawObject* ref) { raw_ = ref; } 105 void set_raw(RawObject* ref) { raw_ = ref; }
106 void set_raw(const LocalHandle& ref) { raw_ = ref.raw(); } 106 void set_raw(const LocalHandle& ref) { raw_ = ref.raw(); }
107 void set_raw(const Object& object) { raw_ = object.raw(); } 107 void set_raw(const Object& object) { raw_ = object.raw(); }
108 RawObject** raw_addr() { return &raw_; }
108 static intptr_t raw_offset() { return OFFSET_OF(PersistentHandle, raw_); } 109 static intptr_t raw_offset() { return OFFSET_OF(PersistentHandle, raw_); }
109 110
110 private: 111 private:
111 friend class PersistentHandles; 112 friend class PersistentHandles;
112 113
113 PersistentHandle() { } 114 PersistentHandle() { }
114 ~PersistentHandle() { } 115 ~PersistentHandle() { }
115 116
116 // Overload the raw_ field as a next pointer when adding freed 117 // Overload the raw_ field as a next pointer when adding freed
117 // handles to the free list. 118 // handles to the free list.
(...skipping 16 matching lines...) Expand all
134 135
135 // Implementation of persistent handles which are handed out through the 136 // Implementation of persistent handles which are handed out through the
136 // dart API. 137 // dart API.
137 class FinalizablePersistentHandle { 138 class FinalizablePersistentHandle {
138 public: 139 public:
139 // Accessors. 140 // Accessors.
140 RawObject* raw() const { return raw_; } 141 RawObject* raw() const { return raw_; }
141 void set_raw(RawObject* raw) { raw_ = raw; } 142 void set_raw(RawObject* raw) { raw_ = raw; }
142 void set_raw(const LocalHandle& ref) { raw_ = ref.raw(); } 143 void set_raw(const LocalHandle& ref) { raw_ = ref.raw(); }
143 void set_raw(const Object& object) { raw_ = object.raw(); } 144 void set_raw(const Object& object) { raw_ = object.raw(); }
145 RawObject** raw_addr() { return &raw_; }
144 static intptr_t raw_offset() { 146 static intptr_t raw_offset() {
145 return OFFSET_OF(FinalizablePersistentHandle, raw_); 147 return OFFSET_OF(FinalizablePersistentHandle, raw_);
146 } 148 }
147 void* peer() const { return peer_; } 149 void* peer() const { return peer_; }
148 void set_peer(void* peer) { peer_ = peer; } 150 void set_peer(void* peer) { peer_ = peer; }
149 Dart_WeakPersistentHandleFinalizer callback() const { return callback_; } 151 Dart_WeakPersistentHandleFinalizer callback() const { return callback_; }
150 void set_callback(Dart_WeakPersistentHandleFinalizer callback) { 152 void set_callback(Dart_WeakPersistentHandleFinalizer callback) {
151 callback_ = callback; 153 callback_ = callback;
152 } 154 }
153 155
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 values_(values), num_values_(values_length) { 386 values_(values), num_values_(values_length) {
385 } 387 }
386 ~WeakReferenceSet() {} 388 ~WeakReferenceSet() {}
387 389
388 WeakReferenceSet* next() const { return next_; } 390 WeakReferenceSet* next() const { return next_; }
389 391
390 intptr_t num_keys() const { return num_keys_; } 392 intptr_t num_keys() const { return num_keys_; }
391 RawObject** get_key(intptr_t i) { 393 RawObject** get_key(intptr_t i) {
392 ASSERT(i >= 0); 394 ASSERT(i >= 0);
393 ASSERT(i < num_keys_); 395 ASSERT(i < num_keys_);
394 return reinterpret_cast<RawObject**>(keys_[i]); 396 return (reinterpret_cast<PersistentHandle*>(keys_[i]))->raw_addr();
395 } 397 }
396 398
397 intptr_t num_values() const { return num_values_; } 399 intptr_t num_values() const { return num_values_; }
398 RawObject** get_value(intptr_t i) { 400 RawObject** get_value(intptr_t i) {
399 ASSERT(i >= 0); 401 ASSERT(i >= 0);
400 ASSERT(i < num_values_); 402 ASSERT(i < num_values_);
401 return reinterpret_cast<RawObject**>(values_[i]); 403 return (reinterpret_cast<PersistentHandle*>(values_[i]))->raw_addr();
402 } 404 }
403 405
404 static WeakReferenceSet* Pop(WeakReferenceSet** queue) { 406 static WeakReferenceSet* Pop(WeakReferenceSet** queue) {
405 ASSERT(queue != NULL); 407 ASSERT(queue != NULL);
406 WeakReferenceSet* head = *queue; 408 WeakReferenceSet* head = *queue;
407 if (head != NULL) { 409 if (head != NULL) {
408 *queue = head->next(); 410 *queue = head->next();
409 head->next_ = NULL; 411 head->next_ = NULL;
410 } 412 }
411 return head; 413 return head;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 ApiNativeScope::Current()->zone()->GetBaseZone()) {} 673 ApiNativeScope::Current()->zone()->GetBaseZone()) {}
672 ApiGrowableArray() 674 ApiGrowableArray()
673 : BaseGrowableArray<T, ValueObject>( 675 : BaseGrowableArray<T, ValueObject>(
674 ApiNativeScope::Current()->zone()->GetBaseZone()) {} 676 ApiNativeScope::Current()->zone()->GetBaseZone()) {}
675 }; 677 };
676 678
677 679
678 } // namespace dart 680 } // namespace dart
679 681
680 #endif // VM_DART_API_STATE_H_ 682 #endif // VM_DART_API_STATE_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698