| 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 Isolate* isolate = thread->isolate(); | 557 Isolate* isolate = thread->isolate(); |
| 558 Zone* zone = thread->zone(); | 558 Zone* zone = thread->zone(); |
| 559 String& symbol = String::Handle(zone); | 559 String& symbol = String::Handle(zone); |
| 560 { | 560 { |
| 561 Isolate* vm_isolate = Dart::vm_isolate(); | 561 Isolate* vm_isolate = Dart::vm_isolate(); |
| 562 SymbolTable table(zone, vm_isolate->object_store()->symbol_table()); | 562 SymbolTable table(zone, vm_isolate->object_store()->symbol_table()); |
| 563 symbol ^= table.GetOrNull(str); | 563 symbol ^= table.GetOrNull(str); |
| 564 table.Release(); | 564 table.Release(); |
| 565 } | 565 } |
| 566 if (symbol.IsNull()) { | 566 if (symbol.IsNull()) { |
| 567 SafepointMutexLocker ml(isolate->symbols_mutex()); |
| 567 SymbolTable table(zone, isolate->object_store()->symbol_table()); | 568 SymbolTable table(zone, isolate->object_store()->symbol_table()); |
| 568 symbol ^= table.InsertNewOrGet(str); | 569 symbol ^= table.InsertNewOrGet(str); |
| 569 isolate->object_store()->set_symbol_table(table.Release()); | 570 isolate->object_store()->set_symbol_table(table.Release()); |
| 570 } | 571 } |
| 571 ASSERT(symbol.IsSymbol()); | 572 ASSERT(symbol.IsSymbol()); |
| 572 ASSERT(symbol.HasHash()); | 573 ASSERT(symbol.HasHash()); |
| 573 return symbol.raw(); | 574 return symbol.raw(); |
| 574 } | 575 } |
| 575 | 576 |
| 576 | 577 |
| 577 template<typename StringType> | 578 template<typename StringType> |
| 578 RawString* Symbols::Lookup(const StringType& str) { | 579 RawString* Symbols::Lookup(const StringType& str) { |
| 579 Thread* thread = Thread::Current(); | 580 Thread* thread = Thread::Current(); |
| 580 Isolate* isolate = thread->isolate(); | 581 Isolate* isolate = thread->isolate(); |
| 581 Zone* zone = thread->zone(); | 582 Zone* zone = thread->zone(); |
| 582 String& symbol = String::Handle(zone); | 583 String& symbol = String::Handle(zone); |
| 583 { | 584 { |
| 584 Isolate* vm_isolate = Dart::vm_isolate(); | 585 Isolate* vm_isolate = Dart::vm_isolate(); |
| 585 SymbolTable table(zone, vm_isolate->object_store()->symbol_table()); | 586 SymbolTable table(zone, vm_isolate->object_store()->symbol_table()); |
| 586 symbol ^= table.GetOrNull(str); | 587 symbol ^= table.GetOrNull(str); |
| 587 table.Release(); | 588 table.Release(); |
| 588 } | 589 } |
| 589 if (symbol.IsNull()) { | 590 if (symbol.IsNull()) { |
| 591 SafepointMutexLocker ml(isolate->symbols_mutex()); |
| 590 SymbolTable table(zone, isolate->object_store()->symbol_table()); | 592 SymbolTable table(zone, isolate->object_store()->symbol_table()); |
| 591 symbol ^= table.GetOrNull(str); | 593 symbol ^= table.GetOrNull(str); |
| 592 table.Release(); | 594 table.Release(); |
| 593 } | 595 } |
| 594 | 596 |
| 595 ASSERT(symbol.IsNull() || symbol.IsSymbol()); | 597 ASSERT(symbol.IsNull() || symbol.IsSymbol()); |
| 596 ASSERT(symbol.IsNull() || symbol.HasHash()); | 598 ASSERT(symbol.IsNull() || symbol.HasHash()); |
| 597 return symbol.raw(); | 599 return symbol.raw(); |
| 598 } | 600 } |
| 599 | 601 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 688 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
| 687 ASSERT(IsVMSymbolId(object_id)); | 689 ASSERT(IsVMSymbolId(object_id)); |
| 688 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 690 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
| 689 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 691 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
| 690 return symbol_handles_[i]->raw(); | 692 return symbol_handles_[i]->raw(); |
| 691 } | 693 } |
| 692 return Object::null(); | 694 return Object::null(); |
| 693 } | 695 } |
| 694 | 696 |
| 695 } // namespace dart | 697 } // namespace dart |
| OLD | NEW |