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

Unified Diff: runtime/vm/object.h

Issue 11312183: - Do not mix scalar values and object fields in RawInstance to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 14777)
+++ runtime/vm/object.h (working copy)
@@ -3074,14 +3074,9 @@
return ((index >= 0) && (index < clazz()->ptr()->num_native_fields_));
}
- intptr_t GetNativeField(int index) const {
- return *NativeFieldAddr(index);
- }
+ inline intptr_t GetNativeField(Isolate* isolate, int index) const;
+ void SetNativeField(int index, intptr_t value) const;
cshapiro 2012/11/12 18:48:45 Interesting, GetNativeField needs the isolate but
Tom Ball 2012/11/12 21:05:15 SetNativeField calls Object::Handle(RawObject*), w
Ivan Posva 2012/11/12 22:01:03 The reason I pass the isolate in GetNativeField is
- void SetNativeField(int index, intptr_t value) const {
- *NativeFieldAddr(index) = value;
- }
-
// Returns true if the instance is a closure object.
bool IsClosure() const;
@@ -3099,11 +3094,8 @@
RawObject** FieldAddr(const Field& field) const {
return FieldAddrAtOffset(field.Offset());
}
- intptr_t* NativeFieldAddr(int index) const {
- ASSERT(IsValidNativeIndex(index));
- return reinterpret_cast<intptr_t*>((raw_value() - kHeapObjectTag)
- + (index * kWordSize)
- + sizeof(RawObject));
+ RawObject** NativeFieldsAddr() const {
+ return FieldAddrAtOffset(sizeof(RawObject));
}
void SetFieldAtOffset(intptr_t offset, const Object& value) const {
StorePointer(FieldAddrAtOffset(offset), value.raw());
@@ -5849,6 +5841,16 @@
}
+intptr_t Instance::GetNativeField(Isolate* isolate, int index) const {
+ ASSERT(IsValidNativeIndex(index));
+ const Object& native_fields = Object::Handle(isolate, *NativeFieldsAddr());
+ if (native_fields.IsNull()) {
+ return 0;
+ }
+ return IntPtrArray::Cast(native_fields).At(index);
+}
+
+
bool String::Equals(const String& str) const {
if (raw() == str.raw()) {
return true; // Both handles point to the same raw instance.
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/raw_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698