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

Side by Side Diff: vm/dart_api_message.cc

Issue 11667012: Convert all symbols accessor to return read only handles so that it is not necessary to create a ne… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/dart_api_message.h" 5 #include "vm/dart_api_message.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/snapshot_ids.h" 7 #include "vm/snapshot_ids.h"
8 #include "vm/symbols.h" 8 #include "vm/symbols.h"
9 #include "vm/unicode.h" 9 #include "vm/unicode.h"
10 10
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 Dart_CObject* ApiMessageReader::ReadVMSymbol(intptr_t object_id) { 217 Dart_CObject* ApiMessageReader::ReadVMSymbol(intptr_t object_id) {
218 if (Symbols::IsVMSymbolId(object_id)) { 218 if (Symbols::IsVMSymbolId(object_id)) {
219 intptr_t symbol_id = object_id - kMaxPredefinedObjectIds; 219 intptr_t symbol_id = object_id - kMaxPredefinedObjectIds;
220 Dart_CObject* object; 220 Dart_CObject* object;
221 if (vm_symbol_references_ != NULL && 221 if (vm_symbol_references_ != NULL &&
222 (object = vm_symbol_references_[symbol_id]) != NULL) { 222 (object = vm_symbol_references_[symbol_id]) != NULL) {
223 return object; 223 return object;
224 } 224 }
225 225
226 if (vm_symbol_references_ == NULL) { 226 if (vm_symbol_references_ == NULL) {
227 intptr_t size = sizeof(*vm_symbol_references_) * Symbols::kMaxId; 227 intptr_t size =
228 (sizeof(*vm_symbol_references_) * Symbols::kMaxPredefinedId);
228 vm_symbol_references_ = 229 vm_symbol_references_ =
229 reinterpret_cast<Dart_CObject**>(alloc_(NULL, 0, size)); 230 reinterpret_cast<Dart_CObject**>(alloc_(NULL, 0, size));
230 memset(vm_symbol_references_, 0, size); 231 memset(vm_symbol_references_, 0, size);
231 } 232 }
232 233
233 RawOneByteString* str = 234 RawOneByteString* str =
234 reinterpret_cast<RawOneByteString*>(Symbols::GetVMSymbol(object_id)); 235 reinterpret_cast<RawOneByteString*>(Symbols::GetVMSymbol(object_id));
235 intptr_t len = Smi::Value(str->ptr()->length_); 236 intptr_t len = Smi::Value(str->ptr()->length_);
236 object = AllocateDartCObjectString(len); 237 object = AllocateDartCObjectString(len);
237 char* p = object->value.as_string; 238 char* p = object->value.as_string;
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 if (!success) { 898 if (!success) {
898 UnmarkAllCObjects(object); 899 UnmarkAllCObjects(object);
899 return false; 900 return false;
900 } 901 }
901 } 902 }
902 UnmarkAllCObjects(object); 903 UnmarkAllCObjects(object);
903 return true; 904 return true;
904 } 905 }
905 906
906 } // namespace dart 907 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/dart_entry.cc » ('j') | vm/symbols.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698