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

Unified Diff: runtime/vm/raw_object.cc

Issue 12544015: Implement 'dart:typeddata' directly in the VM instead of using 'dart:scalarlist' (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/raw_object.cc
===================================================================
--- runtime/vm/raw_object.cc (revision 19594)
+++ runtime/vm/raw_object.cc (working copy)
@@ -203,6 +203,25 @@
instance_size = Float64Array::InstanceSize(byte_array_length);
break;
}
+#define SIZE_FROM_CLASS(clazz) \
+ case kTypedData##clazz##Cid:
+ CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) {
+ const RawTypedData* raw_obj =
+ reinterpret_cast<const RawTypedData*>(this);
+ intptr_t cid = raw_obj->GetClassId();
+ intptr_t array_len = Smi::Value(raw_obj->ptr()->length_);
+ intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid);
+ instance_size = TypedData::InstanceSize(lengthInBytes);
+ break;
+ }
+#undef SIZE_FROM_CLASS
+#define SIZE_FROM_CLASS(clazz) \
+ case kExternalTypedData##clazz##Cid:
Ivan Posva 2013/03/07 08:53:31 This code should never be reached, as the size of
siva 2013/03/07 21:47:43 True, I removed it. On 2013/03/07 08:53:31, Ivan
+ CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) {
+ instance_size = ExternalTypedData::InstanceSize();
+ break;
+ }
+#undef SIZE_FROM_CLASS
case kTypeArgumentsCid: {
const RawTypeArguments* raw_array =
reinterpret_cast<const RawTypeArguments*>(this);
@@ -291,6 +310,24 @@
}
CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS)
#undef RAW_VISITPOINTERS
+#define RAW_VISITPOINTERS(clazz) \
+ case kTypedData##clazz##Cid:
+ CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) {
+ RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(this);
+ size = RawTypedData::VisitTypedDataPointers(raw_obj, visitor);
+ break;
+ }
+#undef RAW_VISITPOINTERS
+#define RAW_VISITPOINTERS(clazz) \
+ case kExternalTypedData##clazz##Cid:
+ CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) {
+ RawExternalTypedData* raw_obj =
+ reinterpret_cast<RawExternalTypedData*>(this);
+ size = RawExternalTypedData::VisitExternalTypedDataPointers(raw_obj,
+ visitor);
+ break;
+ }
+#undef RAW_VISITPOINTERS
case kFreeListElement: {
ASSERT(FreeBit::decode(ptr()->tags_));
uword addr = RawObject::ToAddr(const_cast<RawObject*>(this));
@@ -999,8 +1036,7 @@
}
-intptr_t
- RawExternalFloat32x4Array::VisitExternalFloat32x4ArrayPointers(
+intptr_t RawExternalFloat32x4Array::VisitExternalFloat32x4ArrayPointers(
RawExternalFloat32x4Array* raw_obj, ObjectPointerVisitor* visitor) {
// Make sure that we got here with the tagged pointer as this.
ASSERT(raw_obj->IsHeapObject());
@@ -1027,6 +1063,27 @@
}
+intptr_t RawTypedData::VisitTypedDataPointers(
+ RawTypedData* raw_obj, ObjectPointerVisitor* visitor) {
+ // Make sure that we got here with the tagged pointer as this.
+ ASSERT(raw_obj->IsHeapObject());
+ intptr_t cid = raw_obj->GetClassId();
+ intptr_t array_len = Smi::Value(raw_obj->ptr()->length_);
+ intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid);
+ visitor->VisitPointers(raw_obj->from(), raw_obj->to());
+ return TypedData::InstanceSize(lengthInBytes);
+}
+
+
+intptr_t RawExternalTypedData::VisitExternalTypedDataPointers(
+ RawExternalTypedData* raw_obj, ObjectPointerVisitor* visitor) {
+ // Make sure that we got here with the tagged pointer as this.
+ ASSERT(raw_obj->IsHeapObject());
+ visitor->VisitPointers(raw_obj->from(), raw_obj->to());
+ return ExternalTypedData::InstanceSize();
+}
+
+
intptr_t RawDartFunction::VisitDartFunctionPointers(
RawDartFunction* raw_obj, ObjectPointerVisitor* visitor) {
// Function (defined in core library) is an abstract class.

Powered by Google App Engine
This is Rietveld 408576698