OLD | NEW |
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/hash_table.h" | 9 #include "vm/hash_table.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 return NewSymbol(ConcatString(str1, str2)); | 386 return NewSymbol(ConcatString(str1, str2)); |
387 } | 387 } |
388 | 388 |
389 | 389 |
390 // StringType can be StringSlice, ConcatString, or {Latin1,UTF16,UTF32}Array. | 390 // StringType can be StringSlice, ConcatString, or {Latin1,UTF16,UTF32}Array. |
391 template<typename StringType> | 391 template<typename StringType> |
392 RawString* Symbols::NewSymbol(const StringType& str) { | 392 RawString* Symbols::NewSymbol(const StringType& str) { |
393 Thread* thread = Thread::Current(); | 393 Thread* thread = Thread::Current(); |
394 Isolate* isolate = thread->isolate(); | 394 Isolate* isolate = thread->isolate(); |
395 Zone* zone = thread->zone(); | 395 Zone* zone = thread->zone(); |
396 String& symbol = String::Handle(isolate); | 396 String& symbol = String::Handle(zone); |
397 { | 397 { |
398 Isolate* vm_isolate = Dart::vm_isolate(); | 398 Isolate* vm_isolate = Dart::vm_isolate(); |
399 SymbolTable table(zone, vm_isolate->object_store()->symbol_table()); | 399 SymbolTable table(zone, vm_isolate->object_store()->symbol_table()); |
400 symbol ^= table.GetOrNull(str); | 400 symbol ^= table.GetOrNull(str); |
401 table.Release(); | 401 table.Release(); |
402 } | 402 } |
403 if (symbol.IsNull()) { | 403 if (symbol.IsNull()) { |
404 SymbolTable table(zone, isolate->object_store()->symbol_table()); | 404 SymbolTable table(zone, isolate->object_store()->symbol_table()); |
405 symbol ^= table.InsertNewOrGet(str); | 405 symbol ^= table.InsertNewOrGet(str); |
406 isolate->object_store()->set_symbol_table(table.Release()); | 406 isolate->object_store()->set_symbol_table(table.Release()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 463 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
464 ASSERT(IsVMSymbolId(object_id)); | 464 ASSERT(IsVMSymbolId(object_id)); |
465 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 465 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
466 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 466 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
467 return symbol_handles_[i]->raw(); | 467 return symbol_handles_[i]->raw(); |
468 } | 468 } |
469 return Object::null(); | 469 return Object::null(); |
470 } | 470 } |
471 | 471 |
472 } // namespace dart | 472 } // namespace dart |
OLD | NEW |