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

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

Issue 10693071: Use VM type cast and save handles. (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
« no previous file with comments | « runtime/vm/native_entry.h ('k') | runtime/vm/object.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 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 /* T::Cast cannot be applied to a null Object, because the object vtable */ \
96 /* is not setup for type T, although some methods are supposed to work */ \
97 /* with null, for example Instance::Equals(). */ \
95 static const object& Cast(const Object& obj) { \ 98 static const object& Cast(const Object& obj) { \
96 ASSERT(obj.Is##object()); \ 99 ASSERT(obj.Is##object()); \
97 return reinterpret_cast<const object&>(obj); \ 100 return reinterpret_cast<const object&>(obj); \
98 } \ 101 } \
99 static Raw##object* null() { \ 102 static Raw##object* null() { \
100 return reinterpret_cast<Raw##object*>(Object::null()); \ 103 return reinterpret_cast<Raw##object*>(Object::null()); \
101 } \ 104 } \
102 virtual const char* ToCString() const; \ 105 virtual const char* ToCString() const; \
103 static const ObjectKind kInstanceKind = k##object; \ 106 static const ObjectKind kInstanceKind = k##object; \
104 protected: /* NOLINT */ \ 107 protected: /* NOLINT */ \
(...skipping 4962 matching lines...) Expand 10 before | Expand all | Expand 10 after
5067 5070
5068 5071
5069 intptr_t TokenStream::Length() const { 5072 intptr_t TokenStream::Length() const {
5070 return Smi::Value(raw_ptr()->length_); 5073 return Smi::Value(raw_ptr()->length_);
5071 } 5074 }
5072 5075
5073 5076
5074 Token::Kind TokenStream::KindAt(intptr_t index) const { 5077 Token::Kind TokenStream::KindAt(intptr_t index) const {
5075 const Object& obj = Object::Handle(TokenAt(index)); 5078 const Object& obj = Object::Handle(TokenAt(index));
5076 if (obj.IsSmi()) { 5079 if (obj.IsSmi()) {
5077 return static_cast<Token::Kind>( 5080 return static_cast<Token::Kind>(Smi::Cast(obj).Value());
5078 Smi::Value(reinterpret_cast<RawSmi*>(obj.raw())));
5079 } else if (obj.IsLiteralToken()) { 5081 } else if (obj.IsLiteralToken()) {
5080 LiteralToken& token = LiteralToken::Handle(); 5082 return LiteralToken::Cast(obj).kind();
5081 token ^= obj.raw();
5082 return token.kind();
5083 } 5083 }
5084 ASSERT(obj.IsString()); // Must be an identifier. 5084 ASSERT(obj.IsString()); // Must be an identifier.
5085 return Token::kIDENT; 5085 return Token::kIDENT;
5086 } 5086 }
5087 5087
5088 5088
5089 void Context::SetAt(intptr_t index, const Instance& value) const { 5089 void Context::SetAt(intptr_t index, const Instance& value) const {
5090 StorePointer(InstanceAddr(index), value.raw()); 5090 StorePointer(InstanceAddr(index), value.raw());
5091 } 5091 }
5092 5092
5093 5093
5094 intptr_t Stackmap::SizeInBits() const { 5094 intptr_t Stackmap::SizeInBits() const {
5095 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); 5095 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
5096 } 5096 }
5097 5097
5098 } // namespace dart 5098 } // namespace dart
5099 5099
5100 #endif // VM_OBJECT_H_ 5100 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/native_entry.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698