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

Unified Diff: vm/dart_api_message.cc

Issue 11745022: - Make Boolean 'true' and 'false' singleton VM isolate objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 12 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 | « vm/dart_api_message.h ('k') | vm/dart_api_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart_api_message.cc
===================================================================
--- vm/dart_api_message.cc (revision 16591)
+++ vm/dart_api_message.cc (working copy)
@@ -215,35 +215,32 @@
Dart_CObject* ApiMessageReader::ReadVMSymbol(intptr_t object_id) {
- if (Symbols::IsVMSymbolId(object_id)) {
- intptr_t symbol_id = object_id - kMaxPredefinedObjectIds;
- Dart_CObject* object;
- if (vm_symbol_references_ != NULL &&
- (object = vm_symbol_references_[symbol_id]) != NULL) {
- return object;
- }
+ ASSERT(Symbols::IsVMSymbolId(object_id));
+ intptr_t symbol_id = object_id - kMaxPredefinedObjectIds;
+ Dart_CObject* object;
+ if (vm_symbol_references_ != NULL &&
+ (object = vm_symbol_references_[symbol_id]) != NULL) {
+ return object;
+ }
- if (vm_symbol_references_ == NULL) {
- intptr_t size =
- (sizeof(*vm_symbol_references_) * Symbols::kMaxPredefinedId);
- vm_symbol_references_ =
- reinterpret_cast<Dart_CObject**>(alloc_(NULL, 0, size));
- memset(vm_symbol_references_, 0, size);
- }
+ if (vm_symbol_references_ == NULL) {
+ intptr_t size =
+ (sizeof(*vm_symbol_references_) * Symbols::kMaxPredefinedId);
+ vm_symbol_references_ =
+ reinterpret_cast<Dart_CObject**>(alloc_(NULL, 0, size));
+ memset(vm_symbol_references_, 0, size);
+ }
- RawOneByteString* str =
- reinterpret_cast<RawOneByteString*>(Symbols::GetVMSymbol(object_id));
- intptr_t len = Smi::Value(str->ptr()->length_);
- object = AllocateDartCObjectString(len);
- char* p = object->value.as_string;
- memmove(p, str->ptr()->data_, len);
- p[len] = '\0';
- ASSERT(vm_symbol_references_[symbol_id] == NULL);
- vm_symbol_references_[symbol_id] = object;
- return object;
- }
- // No other VM isolate objects are supported.
- return AllocateDartCObjectNull();
+ RawOneByteString* str =
+ reinterpret_cast<RawOneByteString*>(Symbols::GetVMSymbol(object_id));
+ intptr_t len = Smi::Value(str->ptr()->length_);
+ object = AllocateDartCObjectString(len);
+ char* p = object->value.as_string;
+ memmove(p, str->ptr()->data_, len);
+ p[len] = '\0';
+ ASSERT(vm_symbol_references_[symbol_id] == NULL);
+ vm_symbol_references_[symbol_id] = object;
+ return object;
}
@@ -259,11 +256,7 @@
}
ASSERT((value <= kIntptrMax) && (value >= kIntptrMin));
if (IsVMIsolateObject(value)) {
- intptr_t object_id = GetVMIsolateObjectId(value);
- if (object_id == kNullObject) {
- return AllocateDartCObjectNull();
- }
- return ReadVMSymbol(object_id);
+ return ReadVMIsolateObject(value);
}
if (SerializedHeaderTag::decode(value) == kObjectId) {
return ReadIndexedObject(SerializedHeaderData::decode(value));
@@ -294,6 +287,25 @@
}
+Dart_CObject* ApiMessageReader::ReadVMIsolateObject(intptr_t value) {
+ intptr_t object_id = GetVMIsolateObjectId(value);
+ if (object_id == kNullObject) {
+ return AllocateDartCObjectNull();
+ }
+ if (object_id == kTrueValue) {
+ return AllocateDartCObjectBool(true);
+ }
+ if (object_id == kFalseValue) {
+ return AllocateDartCObjectBool(false);
+ }
+ if (Symbols::IsVMSymbolId(object_id)) {
+ return ReadVMSymbol(object_id);
+ }
+ // No other VM isolate objects are supported.
+ return AllocateDartCObjectNull();
+}
+
+
Dart_CObject* ApiMessageReader::ReadInternalVMObject(intptr_t class_id,
intptr_t object_id) {
switch (class_id) {
@@ -460,12 +472,6 @@
Dart_CObject* ApiMessageReader::ReadIndexedObject(intptr_t object_id) {
- if (object_id == kTrueValue) {
- return AllocateDartCObjectBool(true);
- }
- if (object_id == kFalseValue) {
- return AllocateDartCObjectBool(false);
- }
if (object_id == kDynamicType ||
object_id == kDoubleType ||
object_id == kIntType ||
@@ -505,11 +511,7 @@
}
ASSERT((value <= kIntptrMax) && (value >= kIntptrMin));
if (IsVMIsolateObject(value)) {
- intptr_t object_id = GetVMIsolateObjectId(value);
- if (object_id == kNullObject) {
- return AllocateDartCObjectNull();
- }
- return ReadVMSymbol(object_id);
+ return ReadVMIsolateObject(value);
}
if (SerializedHeaderTag::decode(value) == kObjectId) {
return ReadIndexedObject(SerializedHeaderData::decode(value));
@@ -761,9 +763,9 @@
break;
case Dart_CObject::kBool:
if (object->value.as_bool) {
- WriteIndexedObject(kTrueValue);
+ WriteVMIsolateObject(kTrueValue);
} else {
- WriteIndexedObject(kFalseValue);
+ WriteVMIsolateObject(kFalseValue);
}
break;
case Dart_CObject::kInt32:
« no previous file with comments | « vm/dart_api_message.h ('k') | vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698