Index: runtime/vm/message.h |
diff --git a/runtime/vm/message.h b/runtime/vm/message.h |
index 42a1eb1e1a353a1bb681b27ba33b56aa29301d57..ddb74f4c225bd549f3c28d9ae117913d7113a329 100644 |
--- a/runtime/vm/message.h |
+++ b/runtime/vm/message.h |
@@ -8,6 +8,7 @@ |
#include "platform/assert.h" |
#include "vm/allocation.h" |
#include "vm/globals.h" |
+#include "vm/raw_object.h" |
// Duplicated from dart_api.h to avoid including the whole header. |
typedef int64_t Dart_Port; |
@@ -57,16 +58,43 @@ class Message { |
ASSERT((priority == kNormalPriority) || |
(delivery_failure_port == kIllegalPort)); |
} |
+ Message(Dart_Port dest_port, |
+ RawObject* raw_obj, |
+ Priority priority, |
+ Dart_Port delivery_failure_port = kIllegalPort) |
+ : next_(NULL), |
+ dest_port_(dest_port), |
+ delivery_failure_port_(delivery_failure_port), |
+ data_(reinterpret_cast<uint8_t*>(raw_obj)), |
+ len_(0), |
+ priority_(priority) { |
+ ASSERT((priority == kNormalPriority) || |
Ivan Posva
2015/12/09 22:35:29
Also please assert that raw_obj is not a heap obje
zra
2015/12/10 00:07:29
Done.
|
+ (delivery_failure_port == kIllegalPort)); |
+ } |
~Message() { |
ASSERT(delivery_failure_port_ == kIllegalPort); |
- free(data_); |
+ if (len_ > 0) { |
+ free(data_); |
+ } |
} |
Dart_Port dest_port() const { return dest_port_; } |
- uint8_t* data() const { return data_; } |
- intptr_t len() const { return len_; } |
+ uint8_t* data() const { |
+ ASSERT(len_ > 0); |
+ return data_; |
+ } |
+ intptr_t len() const { |
+ return len_; |
+ } |
+ RawObject* raw_obj() const { |
+ ASSERT(len_ == 0); |
+ return reinterpret_cast<RawObject*>(data_); |
+ } |
Priority priority() const { return priority_; } |
+ bool IsData() const { return len_ > 0; } |
+ bool IsRawObject() const { return len_ == 0; } |
+ |
bool IsOOB() const { return priority_ == Message::kOOBPriority; } |
bool RedirectToDeliveryFailurePort(); |