| 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/isolate.h" | 9 #include "vm/isolate.h" | 
| 10 #include "vm/object.h" | 10 #include "vm/object.h" | 
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 279 void Symbols::DumpStats() { | 279 void Symbols::DumpStats() { | 
| 280   if (FLAG_dump_symbol_stats) { | 280   if (FLAG_dump_symbol_stats) { | 
| 281     intptr_t table_size = 0; | 281     intptr_t table_size = 0; | 
| 282     dart::Smi& used = Smi::Handle(); | 282     dart::Smi& used = Smi::Handle(); | 
| 283     Array& symbol_table = Array::Handle(Array::null()); | 283     Array& symbol_table = Array::Handle(Array::null()); | 
| 284 | 284 | 
| 285     // First dump VM symbol table stats. | 285     // First dump VM symbol table stats. | 
| 286     symbol_table = Dart::vm_isolate()->object_store()->symbol_table(); | 286     symbol_table = Dart::vm_isolate()->object_store()->symbol_table(); | 
| 287     table_size = symbol_table.Length() - 1; | 287     table_size = symbol_table.Length() - 1; | 
| 288     used ^= symbol_table.At(table_size); | 288     used ^= symbol_table.At(table_size); | 
| 289     OS::Print("VM Isolate: Number of symbols : %"Pd"\n", used.Value()); | 289     OS::Print("VM Isolate: Number of symbols : %" Pd "\n", used.Value()); | 
| 290     OS::Print("VM Isolate: Symbol table capacity : %"Pd"\n", table_size); | 290     OS::Print("VM Isolate: Symbol table capacity : %" Pd "\n", table_size); | 
| 291 | 291 | 
| 292     // Now dump regular isolate symbol table stats. | 292     // Now dump regular isolate symbol table stats. | 
| 293     symbol_table = Isolate::Current()->object_store()->symbol_table(); | 293     symbol_table = Isolate::Current()->object_store()->symbol_table(); | 
| 294     table_size = symbol_table.Length() - 1; | 294     table_size = symbol_table.Length() - 1; | 
| 295     used ^= symbol_table.At(table_size); | 295     used ^= symbol_table.At(table_size); | 
| 296     OS::Print("Isolate: Number of symbols : %"Pd"\n", used.Value()); | 296     OS::Print("Isolate: Number of symbols : %" Pd "\n", used.Value()); | 
| 297     OS::Print("Isolate: Symbol table capacity : %"Pd"\n", table_size); | 297     OS::Print("Isolate: Symbol table capacity : %" Pd "\n", table_size); | 
| 298 | 298 | 
| 299     // Dump overall collision and growth counts. | 299     // Dump overall collision and growth counts. | 
| 300     OS::Print("Number of symbol table grows = %"Pd"\n", num_of_grows_); | 300     OS::Print("Number of symbol table grows = %" Pd "\n", num_of_grows_); | 
| 301     OS::Print("Collision counts on add and lookup :\n"); | 301     OS::Print("Collision counts on add and lookup :\n"); | 
| 302     intptr_t i = 0; | 302     intptr_t i = 0; | 
| 303     for (i = 0; i < (kMaxCollisionBuckets - 1); i++) { | 303     for (i = 0; i < (kMaxCollisionBuckets - 1); i++) { | 
| 304       OS::Print("  %"Pd" collisions => %"Pd"\n", i, collision_count_[i]); | 304       OS::Print("  %" Pd " collisions => %" Pd "\n", i, collision_count_[i]); | 
| 305     } | 305     } | 
| 306     OS::Print("  > %"Pd" collisions => %"Pd"\n", i, collision_count_[i]); | 306     OS::Print("  > %" Pd " collisions => %" Pd "\n", i, collision_count_[i]); | 
| 307   } | 307   } | 
| 308 } | 308 } | 
| 309 | 309 | 
| 310 | 310 | 
| 311 void Symbols::GrowSymbolTable(const Array& symbol_table) { | 311 void Symbols::GrowSymbolTable(const Array& symbol_table) { | 
| 312   // TODO(iposva): Avoid exponential growth. | 312   // TODO(iposva): Avoid exponential growth. | 
| 313   num_of_grows_ += 1; | 313   num_of_grows_ += 1; | 
| 314   intptr_t table_size = symbol_table.Length() - 1; | 314   intptr_t table_size = symbol_table.Length() - 1; | 
| 315   intptr_t new_table_size = table_size * 2; | 315   intptr_t new_table_size = table_size * 2; | 
| 316   Array& new_symbol_table = Array::Handle(Array::New(new_table_size + 1)); | 316   Array& new_symbol_table = Array::Handle(Array::New(new_table_size + 1)); | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 447 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 447 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 
| 448   ASSERT(IsVMSymbolId(object_id)); | 448   ASSERT(IsVMSymbolId(object_id)); | 
| 449   intptr_t i = (object_id - kMaxPredefinedObjectIds); | 449   intptr_t i = (object_id - kMaxPredefinedObjectIds); | 
| 450   if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 450   if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 
| 451     return symbol_handles_[i]->raw(); | 451     return symbol_handles_[i]->raw(); | 
| 452   } | 452   } | 
| 453   return Object::null(); | 453   return Object::null(); | 
| 454 } | 454 } | 
| 455 | 455 | 
| 456 }  // namespace dart | 456 }  // namespace dart | 
| OLD | NEW | 
|---|