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

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

Issue 10713008: Introduce a VM type cast to avoid repeating a type test and spare a handle. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 VMHandles::AllocateZoneHandle(isolate)); \ 85 VMHandles::AllocateZoneHandle(isolate)); \
86 initializeHandle(obj, raw_ptr); \ 86 initializeHandle(obj, raw_ptr); \
87 if (!obj->Is##object()) { \ 87 if (!obj->Is##object()) { \
88 FATAL("Handle check failed."); \ 88 FATAL("Handle check failed."); \
89 } \ 89 } \
90 return *obj; \ 90 return *obj; \
91 } \ 91 } \
92 static object& CheckedZoneHandle(RawObject* raw_ptr) { \ 92 static object& CheckedZoneHandle(RawObject* raw_ptr) { \
93 return CheckedZoneHandle(Isolate::Current(), raw_ptr); \ 93 return CheckedZoneHandle(Isolate::Current(), raw_ptr); \
94 } \ 94 } \
95 static const object* Cast(const Object& obj) { \
96 ASSERT(obj.Is##object()); \
97 return reinterpret_cast<const object*>(&obj); \
98 } \
siva 2012/06/28 17:02:51 Do you think static const object& Cast(const Obje
Ivan Posva 2012/06/28 17:35:58 I really like this suggestion because it keeps the
regis 2012/06/28 18:44:51 I like it. Done.
regis 2012/06/28 18:44:51 Done.
95 static Raw##object* null() { \ 99 static Raw##object* null() { \
96 return reinterpret_cast<Raw##object*>(Object::null()); \ 100 return reinterpret_cast<Raw##object*>(Object::null()); \
97 } \ 101 } \
98 virtual const char* ToCString() const; \ 102 virtual const char* ToCString() const; \
99 static const ObjectKind kInstanceKind = k##object; \ 103 static const ObjectKind kInstanceKind = k##object; \
100 protected: /* NOLINT */ \ 104 protected: /* NOLINT */ \
101 object() : super() {} \ 105 object() : super() {} \
102 private: /* NOLINT */ \ 106 private: /* NOLINT */ \
103 /* Initialize the handle based on the raw_ptr in the presence of null. */ \ 107 /* Initialize the handle based on the raw_ptr in the presence of null. */ \
104 static void initializeHandle(object* obj, RawObject* raw_ptr) { \ 108 static void initializeHandle(object* obj, RawObject* raw_ptr) { \
(...skipping 4982 matching lines...) Expand 10 before | Expand all | Expand 10 after
5087 } 5091 }
5088 5092
5089 5093
5090 intptr_t Stackmap::SizeInBits() const { 5094 intptr_t Stackmap::SizeInBits() const {
5091 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); 5095 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
5092 } 5096 }
5093 5097
5094 } // namespace dart 5098 } // namespace dart
5095 5099
5096 #endif // VM_OBJECT_H_ 5100 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698