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

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
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object.cc
===================================================================
--- runtime/vm/raw_object.cc (revision 19652)
+++ runtime/vm/raw_object.cc (working copy)
@@ -203,6 +203,18 @@
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
case kTypeArgumentsCid: {
const RawTypeArguments* raw_array =
reinterpret_cast<const RawTypeArguments*>(this);
@@ -291,6 +303,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 +1029,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 +1056,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.
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698