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

Side by Side Diff: runtime/vm/dart_api_message.cc

Issue 11280059: Always zero-initialize array used for mapping VM symbols to Dart_CObject (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = sizeof(*vm_symbol_references_) * Symbols::kMaxId;
228 vm_symbol_references_ = 228 vm_symbol_references_ =
229 reinterpret_cast<Dart_CObject**>(alloc_(NULL, 0, size)); 229 reinterpret_cast<Dart_CObject**>(alloc_(NULL, 0, size));
230 #ifdef DEBUG
231 memset(vm_symbol_references_, 0, size); 230 memset(vm_symbol_references_, 0, size);
232 #endif
233 } 231 }
234 232
235 RawOneByteString* str = 233 RawOneByteString* str =
236 reinterpret_cast<RawOneByteString*>(Symbols::GetVMSymbol(object_id)); 234 reinterpret_cast<RawOneByteString*>(Symbols::GetVMSymbol(object_id));
237 intptr_t len = Smi::Value(str->ptr()->length_); 235 intptr_t len = Smi::Value(str->ptr()->length_);
238 object = AllocateDartCObjectString(len); 236 object = AllocateDartCObjectString(len);
239 char* p = object->value.as_string; 237 char* p = object->value.as_string;
240 memmove(p, str->ptr()->data_, len); 238 memmove(p, str->ptr()->data_, len);
241 p[len] = '\0'; 239 p[len] = '\0';
242 ASSERT(vm_symbol_references_[symbol_id] == NULL); 240 ASSERT(vm_symbol_references_[symbol_id] == NULL);
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 if (!success) { 882 if (!success) {
885 UnmarkAllCObjects(object); 883 UnmarkAllCObjects(object);
886 return false; 884 return false;
887 } 885 }
888 } 886 }
889 UnmarkAllCObjects(object); 887 UnmarkAllCObjects(object);
890 return true; 888 return true;
891 } 889 }
892 890
893 } // namespace dart 891 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698