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

Unified Diff: runtime/vm/dart_api_message.cc

Issue 1123813002: Move symbol table from per isolate snapshot to vm isolate snapshot, this reduces the per isolate in… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 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/dart_api_message.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_message.cc
===================================================================
--- runtime/vm/dart_api_message.cc (revision 45789)
+++ runtime/vm/dart_api_message.cc (working copy)
@@ -14,11 +14,15 @@
ApiMessageReader::ApiMessageReader(const uint8_t* buffer,
intptr_t length,
- ReAlloc alloc)
+ ReAlloc alloc,
+ bool use_vm_isolate_snapshot)
: BaseReader(buffer, length),
alloc_(alloc),
backward_references_(kNumInitialReferences),
- vm_symbol_references_(NULL) {
+ vm_symbol_references_(NULL),
+ max_vm_isolate_object_id_(
+ use_vm_isolate_snapshot ?
+ Object::vm_isolate_snapshot_object_table().Length() : 0) {
Init();
}
@@ -195,6 +199,11 @@
}
+Dart_CObject* ApiMessageReader::AllocateDartCObjectVmIsolateObj(intptr_t id) {
+ return CreateDartCObjectString(VmIsolateSnapshotObject(id));
+}
+
+
Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectInternal(
Dart_CObject_Internal::Type type) {
Dart_CObject_Internal* value =
@@ -369,13 +378,7 @@
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';
+ object = CreateDartCObjectString(Symbols::GetVMSymbol(object_id));
ASSERT(vm_symbol_references_[symbol_id] == NULL);
vm_symbol_references_[symbol_id] = object;
return object;
@@ -383,10 +386,23 @@
intptr_t ApiMessageReader::NextAvailableObjectId() const {
- return backward_references_.length() + kMaxPredefinedObjectIds;
+ return backward_references_.length() +
+ kMaxPredefinedObjectIds + max_vm_isolate_object_id_;
}
+Dart_CObject* ApiMessageReader::CreateDartCObjectString(RawObject* raw) {
+ ASSERT(RawObject::IsOneByteStringClassId(raw->GetClassId()));
+ RawOneByteString* raw_str = reinterpret_cast<RawOneByteString*>(raw);
+ intptr_t len = Smi::Value(raw_str->ptr()->length_);
+ Dart_CObject* object = AllocateDartCObjectString(len);
+ char* p = object->value.as_string;
+ memmove(p, raw_str->ptr()->data(), len);
+ p[len] = '\0';
+ return object;
+}
+
+
Dart_CObject* ApiMessageReader::ReadObjectRef() {
int64_t value64 = Read<int64_t>();
if ((value64 & kSmiTagMask) == 0) {
@@ -735,6 +751,10 @@
return &dynamic_type_marker;
}
intptr_t index = object_id - kMaxPredefinedObjectIds;
+ if (index < max_vm_isolate_object_id_) {
+ return AllocateDartCObjectVmIsolateObj(index);
+ }
+ index -= max_vm_isolate_object_id_;
ASSERT((0 <= index) && (index < backward_references_.length()));
ASSERT(backward_references_[index]->reference() != NULL);
return backward_references_[index]->reference();
@@ -785,6 +805,8 @@
Dart_CObject* obj,
DeserializeState state) {
intptr_t index = (id - kMaxPredefinedObjectIds);
+ ASSERT(index >= max_vm_isolate_object_id_);
+ index -= max_vm_isolate_object_id_;
ASSERT(index == backward_references_.length());
BackRefNode* node = AllocateBackRefNode(obj, state);
ASSERT(node != NULL);
@@ -795,6 +817,8 @@
Dart_CObject* ApiMessageReader::GetBackRef(intptr_t id) {
ASSERT(id >= kMaxPredefinedObjectIds);
intptr_t index = (id - kMaxPredefinedObjectIds);
+ ASSERT(index >= max_vm_isolate_object_id_);
+ index -= max_vm_isolate_object_id_;
if (index < backward_references_.length()) {
return backward_references_[index]->reference();
}
@@ -932,7 +956,7 @@
void ApiMessageWriter::WriteInlinedHeader(Dart_CObject* object) {
// Write out the serialization header value for this object.
- WriteInlinedObjectHeader(kMaxPredefinedObjectIds + object_id_);
+ WriteInlinedObjectHeader(SnapshotWriter::FirstObjectId() + object_id_);
// Mark object with its object id.
MarkCObject(object, object_id_);
// Advance object id.
@@ -943,7 +967,7 @@
bool ApiMessageWriter::WriteCObject(Dart_CObject* object) {
if (IsCObjectMarked(object)) {
intptr_t object_id = GetMarkedCObjectMark(object);
- WriteIndexedObject(kMaxPredefinedObjectIds + object_id);
+ WriteIndexedObject(SnapshotWriter::FirstObjectId() + object_id);
return true;
}
@@ -978,7 +1002,7 @@
bool ApiMessageWriter::WriteCObjectRef(Dart_CObject* object) {
if (IsCObjectMarked(object)) {
intptr_t object_id = GetMarkedCObjectMark(object);
- WriteIndexedObject(kMaxPredefinedObjectIds + object_id);
+ WriteIndexedObject(SnapshotWriter::FirstObjectId() + object_id);
return true;
}
@@ -1016,7 +1040,7 @@
// Write out the serialization header value for this object.
intptr_t object_id = GetMarkedCObjectMark(object);
- WriteInlinedObjectHeader(kMaxPredefinedObjectIds + object_id);
+ WriteInlinedObjectHeader(SnapshotWriter::FirstObjectId() + object_id);
// Write out the class and tags information.
WriteIndexedObject(kArrayCid);
WriteTags(0);
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698