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

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

Issue 11979003: Add a new operator |= which does a simple assignment of the raw pointer into (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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/object.cc » ('j') | runtime/vm/object.cc » ('J')
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 15 matching lines...) Expand all
26 CLASS_LIST(DEFINE_FORWARD_DECLARATION) 26 CLASS_LIST(DEFINE_FORWARD_DECLARATION)
27 #undef DEFINE_FORWARD_DECLARATION 27 #undef DEFINE_FORWARD_DECLARATION
28 class Api; 28 class Api;
29 class Assembler; 29 class Assembler;
30 class Closure; 30 class Closure;
31 class Code; 31 class Code;
32 class DeoptInstr; 32 class DeoptInstr;
33 class LocalScope; 33 class LocalScope;
34 class Symbols; 34 class Symbols;
35 35
36 #if defined(DEBUG)
37 #define CHECK_HANDLE() CheckHandle();
38 #else
39 #define CHECK_HANDLE()
40 #endif
41
36 #define OBJECT_IMPLEMENTATION(object, super) \ 42 #define OBJECT_IMPLEMENTATION(object, super) \
37 public: /* NOLINT */ \ 43 public: /* NOLINT */ \
38 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \ 44 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \
39 void operator=(Raw##object* value) { \ 45 void operator=(Raw##object* value) { \
40 initializeHandle(this, value); \ 46 initializeHandle(this, value); \
41 } \ 47 } \
42 bool Is##object() const { return true; } \ 48 bool Is##object() const { return true; } \
43 void operator^=(RawObject* value) { \ 49 void operator^=(RawObject* value) { \
44 initializeHandle(this, value); \ 50 initializeHandle(this, value); \
45 ASSERT(IsNull() || Is##object()); \ 51 ASSERT(IsNull() || Is##object()); \
46 } \ 52 } \
53 void operator|=(RawObject* value) { \
54 raw_ = value; \
55 CHECK_HANDLE(); \
56 } \
47 static object& Handle(Isolate* isolate, Raw##object* raw_ptr) { \ 57 static object& Handle(Isolate* isolate, Raw##object* raw_ptr) { \
48 object* obj = \ 58 object* obj = \
49 reinterpret_cast<object*>(VMHandles::AllocateHandle(isolate)); \ 59 reinterpret_cast<object*>(VMHandles::AllocateHandle(isolate)); \
50 initializeHandle(obj, raw_ptr); \ 60 initializeHandle(obj, raw_ptr); \
51 return *obj; \ 61 return *obj; \
52 } \ 62 } \
53 static object& Handle() { \ 63 static object& Handle() { \
54 return Handle(Isolate::Current(), object::null()); \ 64 return Handle(Isolate::Current(), object::null()); \
55 } \ 65 } \
56 static object& Handle(Isolate* isolate) { \ 66 static object& Handle(Isolate* isolate) { \
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 369
360 protected: 370 protected:
361 // Used for extracting the C++ vtable during bringup. 371 // Used for extracting the C++ vtable during bringup.
362 Object() : raw_(null_) {} 372 Object() : raw_(null_) {}
363 373
364 uword raw_value() const { 374 uword raw_value() const {
365 return reinterpret_cast<uword>(raw()); 375 return reinterpret_cast<uword>(raw());
366 } 376 }
367 377
368 inline void SetRaw(RawObject* value); 378 inline void SetRaw(RawObject* value);
379 void CheckHandle() const;
369 380
370 cpp_vtable vtable() const { return bit_copy<cpp_vtable>(*this); } 381 cpp_vtable vtable() const { return bit_copy<cpp_vtable>(*this); }
371 void set_vtable(cpp_vtable value) { *vtable_address() = value; } 382 void set_vtable(cpp_vtable value) { *vtable_address() = value; }
372 383
373 static RawObject* Allocate(intptr_t cls_id, 384 static RawObject* Allocate(intptr_t cls_id,
374 intptr_t size, 385 intptr_t size,
375 Heap::Space space); 386 Heap::Space space);
376 387
377 static intptr_t RoundedAllocationSize(intptr_t size) { 388 static intptr_t RoundedAllocationSize(intptr_t size) {
378 return Utils::RoundUp(size, kObjectAlignment); 389 return Utils::RoundUp(size, kObjectAlignment);
(...skipping 5873 matching lines...) Expand 10 before | Expand all | Expand 10 after
6252 6263
6253 6264
6254 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6265 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6255 intptr_t index) { 6266 intptr_t index) {
6256 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6267 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6257 } 6268 }
6258 6269
6259 } // namespace dart 6270 } // namespace dart
6260 6271
6261 #endif // VM_OBJECT_H_ 6272 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698