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

Unified Diff: runtime/vm/symbols.cc

Issue 1934263003: - Add a new constructor to the hash table classes that allow handles to be passed in instead of cre… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review-comments Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/reusable_handles.h ('k') | runtime/vm/thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/symbols.cc
diff --git a/runtime/vm/symbols.cc b/runtime/vm/symbols.cc
index 04d608851332e2eabc183c1afc7cebe1c91927db..a138437c23d4e3739df28e0f96bb4b2f530df4e5 100644
--- a/runtime/vm/symbols.cc
+++ b/runtime/vm/symbols.cc
@@ -11,6 +11,7 @@
#include "vm/object.h"
#include "vm/object_store.h"
#include "vm/raw_object.h"
+#include "vm/reusable_handles.h"
#include "vm/snapshot_ids.h"
#include "vm/unicode.h"
#include "vm/visitor.h"
@@ -602,18 +603,25 @@ RawString* Symbols::FromConcatAll(Thread* thread,
// StringType can be StringSlice, ConcatString, or {Latin1,UTF16,UTF32}Array.
template<typename StringType>
RawString* Symbols::NewSymbol(Thread* thread, const StringType& str) {
- Zone* zone = thread->zone();
- String& symbol = String::Handle(zone);
+ REUSABLE_OBJECT_HANDLESCOPE(thread);
+ REUSABLE_SMI_HANDLESCOPE(thread);
+ REUSABLE_ARRAY_HANDLESCOPE(thread);
+ String& symbol = String::Handle(thread->zone());
+ dart::Object& key = thread->ObjectHandle();
+ Smi& value = thread->SmiHandle();
+ Array& data = thread->ArrayHandle();
{
Isolate* vm_isolate = Dart::vm_isolate();
- SymbolTable table(zone, vm_isolate->object_store()->symbol_table());
+ data ^= vm_isolate->object_store()->symbol_table();
+ SymbolTable table(&key, &value, &data);
symbol ^= table.GetOrNull(str);
table.Release();
}
if (symbol.IsNull()) {
Isolate* isolate = thread->isolate();
SafepointMutexLocker ml(isolate->symbols_mutex());
- SymbolTable table(zone, isolate->object_store()->symbol_table());
+ data ^= isolate->object_store()->symbol_table();
+ SymbolTable table(&key, &value, &data);
symbol ^= table.InsertNewOrGet(str);
isolate->object_store()->set_symbol_table(table.Release());
}
@@ -625,18 +633,25 @@ RawString* Symbols::NewSymbol(Thread* thread, const StringType& str) {
template<typename StringType>
RawString* Symbols::Lookup(Thread* thread, const StringType& str) {
- Isolate* isolate = thread->isolate();
- Zone* zone = thread->zone();
- String& symbol = String::Handle(zone);
+ REUSABLE_OBJECT_HANDLESCOPE(thread);
+ REUSABLE_SMI_HANDLESCOPE(thread);
+ REUSABLE_ARRAY_HANDLESCOPE(thread);
+ String& symbol = String::Handle(thread->zone());
+ dart::Object& key = thread->ObjectHandle();
+ Smi& value = thread->SmiHandle();
+ Array& data = thread->ArrayHandle();
{
Isolate* vm_isolate = Dart::vm_isolate();
- SymbolTable table(zone, vm_isolate->object_store()->symbol_table());
+ data ^= vm_isolate->object_store()->symbol_table();
+ SymbolTable table(&key, &value, &data);
symbol ^= table.GetOrNull(str);
table.Release();
}
if (symbol.IsNull()) {
+ Isolate* isolate = thread->isolate();
SafepointMutexLocker ml(isolate->symbols_mutex());
- SymbolTable table(zone, isolate->object_store()->symbol_table());
+ data ^= isolate->object_store()->symbol_table();
+ SymbolTable table(&key, &value, &data);
symbol ^= table.GetOrNull(str);
table.Release();
}
« no previous file with comments | « runtime/vm/reusable_handles.h ('k') | runtime/vm/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698