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

Unified Diff: runtime/vm/symbols.cc

Issue 11369259: Add one-char string table for faster String.charAt to the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: added characters 0x80..0xff 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 side-by-side diff with in-line comments
Download patch
« runtime/vm/symbols.h ('K') | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/symbols.cc
===================================================================
--- runtime/vm/symbols.cc (revision 14980)
+++ runtime/vm/symbols.cc (working copy)
@@ -26,8 +26,8 @@
};
-const char* Symbols::Name(intptr_t symbol) {
- ASSERT((symbol > kIllegal) && (symbol < kMaxId));
+const char* Symbols::Name(SymbolId symbol) {
+ ASSERT((symbol > kIllegal) && (symbol < kMaxPredefinedId));
return names[symbol];
}
@@ -40,12 +40,12 @@
SetupSymbolTable(isolate);
// Create all predefined symbols.
- ASSERT((sizeof(names) / sizeof(const char*)) == Symbols::kMaxId);
+ ASSERT((sizeof(names) / sizeof(const char*)) == Symbols::kMaxPredefinedId);
ObjectStore* object_store = isolate->object_store();
Array& symbol_table = Array::Handle();
dart::String& str = String::Handle();
- for (intptr_t i = 1; i < Symbols::kMaxId; i++) {
+ for (intptr_t i = 1; i < Symbols::kMaxPredefinedId; i++) {
// The symbol_table needs to be reloaded as it might have grown in the
// previous iteration.
symbol_table = object_store->symbol_table();
@@ -54,6 +54,11 @@
predefined_[i] = str.raw();
}
Object::RegisterSingletonClassNames();
+
+ for (uint32_t c = 0; c <= kMaxOneByteCharCode; c++) {
+ ASSERT(kMaxPredefinedId + c < kMaxId);
+ predefined_[kMaxPredefinedId + c] = New(&c, 1);
+ }
}
@@ -117,7 +122,6 @@
template<typename T>
RawString* Symbols::New(const T* characters, intptr_t len) {
Isolate* isolate = Isolate::Current();
- ASSERT(isolate != Dart::vm_isolate());
String& symbol = String::Handle(isolate, String::null());
Array& symbol_table = Array::Handle(isolate, Array::null());
@@ -200,6 +204,14 @@
}
+RawString* Symbols::FromCharCode(uint32_t char_code) {
+ if (char_code > kMaxOneByteCharCode) {
+ return New(&char_code, 1);
+ }
+ return predefined_[kNullCharId + char_code];
+}
+
+
void Symbols::GrowSymbolTable(const Array& symbol_table) {
// TODO(iposva): Avoid exponential growth.
intptr_t table_size = symbol_table.Length() - 1;
« runtime/vm/symbols.h ('K') | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698