Index: runtime/vm/dart_api_message.cc |
diff --git a/runtime/vm/dart_api_message.cc b/runtime/vm/dart_api_message.cc |
index 60985b1dcaaa4a16ad3ef0f2ec40a4fe2314920b..37f1a32bb6187063ec1901793dcc89d5ed2f91ff 100644 |
--- a/runtime/vm/dart_api_message.cc |
+++ b/runtime/vm/dart_api_message.cc |
@@ -19,7 +19,6 @@ ApiMessageReader::ApiMessageReader(const uint8_t* buffer, intptr_t length) |
vm_isolate_references_(kNumInitialReferences), |
vm_symbol_references_(NULL) {} |
- |
ApiMessageReader::ApiMessageReader(Message* msg) |
: BaseReader(msg->IsRaw() ? reinterpret_cast<uint8_t*>(msg->raw_obj()) |
: msg->data(), |
@@ -29,7 +28,6 @@ ApiMessageReader::ApiMessageReader(Message* msg) |
vm_isolate_references_(kNumInitialReferences), |
vm_symbol_references_(NULL) {} |
- |
void ApiMessageReader::Init() { |
// We need to have an enclosing ApiNativeScope. |
ASSERT(ApiNativeScope::Current() != NULL); |
@@ -47,7 +45,6 @@ void ApiMessageReader::Init() { |
static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kDynamicType); |
} |
- |
Dart_CObject* ApiMessageReader::ReadMessage() { |
Init(); |
if (PendingBytes() > 0) { |
@@ -64,7 +61,6 @@ Dart_CObject* ApiMessageReader::ReadMessage() { |
} |
} |
- |
intptr_t ApiMessageReader::LookupInternalClass(intptr_t class_header) { |
if (IsVMIsolateObject(class_header)) { |
return GetVMIsolateObjectId(class_header); |
@@ -73,7 +69,6 @@ intptr_t ApiMessageReader::LookupInternalClass(intptr_t class_header) { |
return SerializedHeaderData::decode(class_header); |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObject(Dart_CObject_Type type) { |
Dart_CObject* value = |
reinterpret_cast<Dart_CObject*>(allocator(sizeof(Dart_CObject))); |
@@ -82,38 +77,32 @@ Dart_CObject* ApiMessageReader::AllocateDartCObject(Dart_CObject_Type type) { |
return value; |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectUnsupported() { |
return AllocateDartCObject(Dart_CObject_kUnsupported); |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectNull() { |
return AllocateDartCObject(Dart_CObject_kNull); |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectBool(bool val) { |
Dart_CObject* value = AllocateDartCObject(Dart_CObject_kBool); |
value->value.as_bool = val; |
return value; |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectInt32(int32_t val) { |
Dart_CObject* value = AllocateDartCObject(Dart_CObject_kInt32); |
value->value.as_int32 = val; |
return value; |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectInt64(int64_t val) { |
Dart_CObject* value = AllocateDartCObject(Dart_CObject_kInt64); |
value->value.as_int64 = val; |
return value; |
} |
- |
_Dart_CObject* ApiMessageReader::singleton_uint32_typed_data_ = NULL; |
Dart_CObject* ApiMessageReader::AllocateDartCObjectBigint() { |
@@ -129,14 +118,12 @@ Dart_CObject* ApiMessageReader::AllocateDartCObjectBigint() { |
return value; |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectDouble(double val) { |
Dart_CObject* value = AllocateDartCObject(Dart_CObject_kDouble); |
value->value.as_double = val; |
return value; |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectString(intptr_t length) { |
// Allocate a Dart_CObject structure followed by an array of chars |
// for the string content. The pointer to the string content is set |
@@ -149,7 +136,6 @@ Dart_CObject* ApiMessageReader::AllocateDartCObjectString(intptr_t length) { |
return value; |
} |
- |
static int GetTypedDataSizeInBytes(Dart_TypedData_Type type) { |
switch (type) { |
case Dart_TypedData_kInt8: |
@@ -174,7 +160,6 @@ static int GetTypedDataSizeInBytes(Dart_TypedData_Type type) { |
return -1; |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectTypedData( |
Dart_TypedData_Type type, |
intptr_t length) { |
@@ -197,7 +182,6 @@ Dart_CObject* ApiMessageReader::AllocateDartCObjectTypedData( |
return value; |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectArray(intptr_t length) { |
// Allocate a Dart_CObject structure followed by an array of |
// pointers to Dart_CObject structures. The pointer to the array |
@@ -215,7 +199,6 @@ Dart_CObject* ApiMessageReader::AllocateDartCObjectArray(intptr_t length) { |
return value; |
} |
- |
Dart_CObject* ApiMessageReader::AllocateDartCObjectVmIsolateObj(intptr_t id) { |
RawObject* raw = VmIsolateSnapshotObject(id); |
intptr_t cid = raw->GetClassId(); |
@@ -254,7 +237,6 @@ Dart_CObject* ApiMessageReader::AllocateDartCObjectVmIsolateObj(intptr_t id) { |
} |
} |
- |
Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectInternal( |
Dart_CObject_Internal::Type type) { |
Dart_CObject_Internal* value = reinterpret_cast<Dart_CObject_Internal*>( |
@@ -264,12 +246,10 @@ Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectInternal( |
return value; |
} |
- |
Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectClass() { |
return AllocateDartCObjectInternal(Dart_CObject_Internal::kClass); |
} |
- |
ApiMessageReader::BackRefNode* ApiMessageReader::AllocateBackRefNode( |
Dart_CObject* reference, |
DeserializeState state) { |
@@ -280,7 +260,6 @@ ApiMessageReader::BackRefNode* ApiMessageReader::AllocateBackRefNode( |
return value; |
} |
- |
static Dart_TypedData_Type GetTypedDataTypeFromView( |
Dart_CObject_Internal* object, |
char* class_name) { |
@@ -314,7 +293,6 @@ static Dart_TypedData_Type GetTypedDataTypeFromView( |
return Dart_TypedData_kInvalid; |
} |
- |
Dart_CObject* ApiMessageReader::ReadInlinedObject(intptr_t object_id) { |
// Read the class header information and lookup the class. |
intptr_t class_header = Read<int32_t>(); |
@@ -407,7 +385,6 @@ Dart_CObject* ApiMessageReader::ReadInlinedObject(intptr_t object_id) { |
return ReadInternalVMObject(class_id, object_id); |
} |
- |
Dart_CObject* ApiMessageReader::ReadPredefinedSymbol(intptr_t object_id) { |
ASSERT(Symbols::IsPredefinedSymbolId(object_id)); |
intptr_t symbol_id = object_id - kMaxPredefinedObjectIds; |
@@ -430,12 +407,10 @@ Dart_CObject* ApiMessageReader::ReadPredefinedSymbol(intptr_t object_id) { |
return object; |
} |
- |
intptr_t ApiMessageReader::NextAvailableObjectId() const { |
return backward_references_.length() + kMaxPredefinedObjectIds; |
} |
- |
Dart_CObject* ApiMessageReader::CreateDartCObjectString(RawObject* raw) { |
ASSERT(RawObject::IsOneByteStringClassId(raw->GetClassId())); |
RawOneByteString* raw_str = reinterpret_cast<RawOneByteString*>(raw); |
@@ -447,7 +422,6 @@ Dart_CObject* ApiMessageReader::CreateDartCObjectString(RawObject* raw) { |
return object; |
} |
- |
Dart_CObject* ApiMessageReader::GetCanonicalMintObject(Dart_CObject_Type type, |
int64_t value64) { |
Dart_CObject* object = NULL; |
@@ -468,7 +442,6 @@ Dart_CObject* ApiMessageReader::GetCanonicalMintObject(Dart_CObject_Type type, |
return object; |
} |
- |
Dart_CObject* ApiMessageReader::ReadObjectRef() { |
int64_t value64 = Read<int64_t>(); |
if ((value64 & kSmiTagMask) == 0) { |
@@ -523,7 +496,6 @@ Dart_CObject* ApiMessageReader::ReadObjectRef() { |
return ReadInternalVMObject(class_id, object_id); |
} |
- |
Dart_CObject* ApiMessageReader::ReadVMIsolateObject(intptr_t value) { |
intptr_t object_id = GetVMIsolateObjectId(value); |
if (object_id == kNullObject) { |
@@ -545,7 +517,6 @@ Dart_CObject* ApiMessageReader::ReadVMIsolateObject(intptr_t value) { |
return AllocateDartCObjectNull(); |
} |
- |
Dart_CObject* ApiMessageReader::ReadInternalVMObject(intptr_t class_id, |
intptr_t object_id) { |
switch (class_id) { |
@@ -705,7 +676,6 @@ Dart_CObject* ApiMessageReader::ReadInternalVMObject(intptr_t class_id, |
AllocateDartCObjectTypedData(Dart_TypedData_k##type, len); \ |
AddBackRef(object_id, object, kIsDeserialized); |
- |
#define READ_TYPED_DATA(type, ctype) \ |
{ \ |
READ_TYPED_DATA_HEADER(type); \ |
@@ -817,7 +787,6 @@ Dart_CObject* ApiMessageReader::ReadInternalVMObject(intptr_t class_id, |
} |
} |
- |
Dart_CObject* ApiMessageReader::ReadIndexedObject(intptr_t object_id) { |
if (object_id == kDynamicType || object_id == kDoubleType || |
object_id == kIntType || object_id == kBoolType || |
@@ -831,7 +800,6 @@ Dart_CObject* ApiMessageReader::ReadIndexedObject(intptr_t object_id) { |
return backward_references_[index]->reference(); |
} |
- |
Dart_CObject* ApiMessageReader::ReadObject() { |
Dart_CObject* value = ReadObjectImpl(); |
for (intptr_t i = 0; i < backward_references_.length(); i++) { |
@@ -843,7 +811,6 @@ Dart_CObject* ApiMessageReader::ReadObject() { |
return value; |
} |
- |
Dart_CObject* ApiMessageReader::ReadObjectImpl() { |
int64_t value64 = Read<int64_t>(); |
if ((value64 & kSmiTagMask) == 0) { |
@@ -871,7 +838,6 @@ Dart_CObject* ApiMessageReader::ReadObjectImpl() { |
return ReadInlinedObject(object_id); |
} |
- |
void ApiMessageReader::AddBackRef(intptr_t id, |
Dart_CObject* obj, |
DeserializeState state) { |
@@ -882,7 +848,6 @@ void ApiMessageReader::AddBackRef(intptr_t id, |
backward_references_.Add(node); |
} |
- |
Dart_CObject* ApiMessageReader::GetBackRef(intptr_t id) { |
ASSERT(id >= kMaxPredefinedObjectIds); |
intptr_t index = (id - kMaxPredefinedObjectIds); |
@@ -892,7 +857,6 @@ Dart_CObject* ApiMessageReader::GetBackRef(intptr_t id) { |
return NULL; |
} |
- |
void ApiMessageWriter::WriteMessage(intptr_t field_count, intptr_t* data) { |
// Write out the serialization header value for this object. |
WriteInlinedObjectHeader(kMaxPredefinedObjectIds); |
@@ -913,7 +877,6 @@ void ApiMessageWriter::WriteMessage(intptr_t field_count, intptr_t* data) { |
} |
} |
- |
void ApiMessageWriter::MarkCObject(Dart_CObject* object, intptr_t object_id) { |
// Mark the object as serialized by adding the object id to the |
// upper bits of the type field in the Dart_CObject structure. Add |
@@ -924,19 +887,16 @@ void ApiMessageWriter::MarkCObject(Dart_CObject* object, intptr_t object_id) { |
((mark_value) << kDartCObjectTypeBits) | object->type); |
} |
- |
void ApiMessageWriter::UnmarkCObject(Dart_CObject* object) { |
ASSERT(IsCObjectMarked(object)); |
object->type = |
static_cast<Dart_CObject_Type>(object->type & kDartCObjectTypeMask); |
} |
- |
bool ApiMessageWriter::IsCObjectMarked(Dart_CObject* object) { |
return (object->type & kDartCObjectMarkMask) != 0; |
} |
- |
intptr_t ApiMessageWriter::GetMarkedCObjectMark(Dart_CObject* object) { |
ASSERT(IsCObjectMarked(object)); |
intptr_t mark_value = |
@@ -945,7 +905,6 @@ intptr_t ApiMessageWriter::GetMarkedCObjectMark(Dart_CObject* object) { |
return mark_value - kDartCObjectMarkOffset; |
} |
- |
void ApiMessageWriter::UnmarkAllCObjects(Dart_CObject* object) { |
if (!IsCObjectMarked(object)) return; |
UnmarkCObject(object); |
@@ -957,7 +916,6 @@ void ApiMessageWriter::UnmarkAllCObjects(Dart_CObject* object) { |
} |
} |
- |
void ApiMessageWriter::AddToForwardList(Dart_CObject* object) { |
if (forward_id_ >= forward_list_length_) { |
void* new_list = NULL; |
@@ -977,18 +935,15 @@ void ApiMessageWriter::AddToForwardList(Dart_CObject* object) { |
forward_id_ += 1; |
} |
- |
void ApiMessageWriter::WriteSmi(int64_t value) { |
ASSERT(Smi::IsValid(value)); |
Write<RawObject*>(Smi::New(static_cast<intptr_t>(value))); |
} |
- |
void ApiMessageWriter::WriteNullObject() { |
WriteVMIsolateObject(kNullObject); |
} |
- |
void ApiMessageWriter::WriteMint(Dart_CObject* object, int64_t value) { |
ASSERT(!Smi::IsValid(value)); |
// Write out the serialization header value for mint object. |
@@ -1000,7 +955,6 @@ void ApiMessageWriter::WriteMint(Dart_CObject* object, int64_t value) { |
Write<int64_t>(value); |
} |
- |
void ApiMessageWriter::WriteInt32(Dart_CObject* object) { |
int64_t value = object->value.as_int32; |
if (Smi::IsValid(value)) { |
@@ -1010,7 +964,6 @@ void ApiMessageWriter::WriteInt32(Dart_CObject* object) { |
} |
} |
- |
void ApiMessageWriter::WriteInt64(Dart_CObject* object) { |
int64_t value = object->value.as_int64; |
if (Smi::IsValid(value)) { |
@@ -1020,7 +973,6 @@ void ApiMessageWriter::WriteInt64(Dart_CObject* object) { |
} |
} |
- |
void ApiMessageWriter::WriteInlinedHeader(Dart_CObject* object) { |
// Write out the serialization header value for this object. |
WriteInlinedObjectHeader(kMaxPredefinedObjectIds + object_id_); |
@@ -1030,7 +982,6 @@ void ApiMessageWriter::WriteInlinedHeader(Dart_CObject* object) { |
object_id_++; |
} |
- |
bool ApiMessageWriter::WriteCObject(Dart_CObject* object) { |
if (IsCObjectMarked(object)) { |
intptr_t object_id = GetMarkedCObjectMark(object); |
@@ -1064,7 +1015,6 @@ bool ApiMessageWriter::WriteCObject(Dart_CObject* object) { |
return WriteCObjectInlined(object, type); |
} |
- |
bool ApiMessageWriter::WriteCObjectRef(Dart_CObject* object) { |
if (IsCObjectMarked(object)) { |
intptr_t object_id = GetMarkedCObjectMark(object); |
@@ -1092,7 +1042,6 @@ bool ApiMessageWriter::WriteCObjectRef(Dart_CObject* object) { |
return WriteCObjectInlined(object, type); |
} |
- |
bool ApiMessageWriter::WriteForwardedCObject(Dart_CObject* object) { |
ASSERT(IsCObjectMarked(object)); |
Dart_CObject_Type type = |
@@ -1121,7 +1070,6 @@ bool ApiMessageWriter::WriteForwardedCObject(Dart_CObject* object) { |
return true; |
} |
- |
bool ApiMessageWriter::WriteCObjectInlined(Dart_CObject* object, |
Dart_CObject_Type type) { |
switch (type) { |
@@ -1269,9 +1217,8 @@ bool ApiMessageWriter::WriteCObjectInlined(Dart_CObject* object, |
WriteIndexedObject(kExternalTypedDataUint8ArrayCid); |
WriteTags(0); |
intptr_t length = object->value.as_external_typed_data.length; |
- if (length < 0 || |
- length > |
- ExternalTypedData::MaxElements(kExternalTypedDataUint8ArrayCid)) { |
+ if (length < 0 || length > ExternalTypedData::MaxElements( |
+ kExternalTypedDataUint8ArrayCid)) { |
return false; |
} |
uint8_t* data = object->value.as_external_typed_data.data; |
@@ -1306,7 +1253,6 @@ bool ApiMessageWriter::WriteCObjectInlined(Dart_CObject* object, |
return true; |
} |
- |
bool ApiMessageWriter::WriteCMessage(Dart_CObject* object) { |
bool success = WriteCObject(object); |
if (!success) { |