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

Side by Side Diff: vm/symbols.cc

Issue 11519006: Add read only handles for the following predefined symbols (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | « vm/symbols.h ('k') | 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/symbols.h" 5 #include "vm/symbols.h"
6 6
7 #include "vm/handles.h" 7 #include "vm/handles.h"
8 #include "vm/handles_impl.h" 8 #include "vm/handles_impl.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 257
258 RawString* Symbols::FromCharCode(int32_t char_code) { 258 RawString* Symbols::FromCharCode(int32_t char_code) {
259 if (char_code > kMaxOneCharCodeSymbol) { 259 if (char_code > kMaxOneCharCodeSymbol) {
260 return FromUTF32(&char_code, 1); 260 return FromUTF32(&char_code, 1);
261 } 261 }
262 return predefined_[kNullCharId + char_code]; 262 return predefined_[kNullCharId + char_code];
263 } 263 }
264 264
265 265
266 bool Symbols::IsPredefinedHandle(uword address) {
267 return predefined_handles_.IsValidScopedHandle(address);
268 }
269
270
266 void Symbols::GrowSymbolTable(const Array& symbol_table) { 271 void Symbols::GrowSymbolTable(const Array& symbol_table) {
267 // TODO(iposva): Avoid exponential growth. 272 // TODO(iposva): Avoid exponential growth.
268 intptr_t table_size = symbol_table.Length() - 1; 273 intptr_t table_size = symbol_table.Length() - 1;
269 intptr_t new_table_size = table_size * 2; 274 intptr_t new_table_size = table_size * 2;
270 Array& new_symbol_table = Array::Handle(Array::New(new_table_size + 1)); 275 Array& new_symbol_table = Array::Handle(Array::New(new_table_size + 1));
271 // Copy all elements from the original symbol table to the newly allocated 276 // Copy all elements from the original symbol table to the newly allocated
272 // array. 277 // array.
273 String& element = String::Handle(); 278 String& element = String::Handle();
274 dart::Object& new_element = Object::Handle(); 279 dart::Object& new_element = Object::Handle();
275 for (intptr_t i = 0; i < table_size; i++) { 280 for (intptr_t i = 0; i < table_size; i++) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 379 }
375 380
376 381
377 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { 382 RawObject* Symbols::GetVMSymbol(intptr_t object_id) {
378 ASSERT(IsVMSymbolId(object_id)); 383 ASSERT(IsVMSymbolId(object_id));
379 intptr_t i = (object_id - kMaxPredefinedObjectIds); 384 intptr_t i = (object_id - kMaxPredefinedObjectIds);
380 return (i > 0 && i < Symbols::kMaxId) ? predefined_[i] : Object::null(); 385 return (i > 0 && i < Symbols::kMaxId) ? predefined_[i] : Object::null();
381 } 386 }
382 387
383 } // namespace dart 388 } // namespace dart
OLDNEW
« no previous file with comments | « vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698