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

Side by Side Diff: vm/symbols.cc

Issue 10809095: Dump number of symbols in the isolate symbol table before shutting down an isolate under the --trac… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/symbols.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/isolate.h" 7 #include "vm/isolate.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/raw_object.h" 10 #include "vm/raw_object.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const int initial_size = (isolate == Dart::vm_isolate()) ? 53 const int initial_size = (isolate == Dart::vm_isolate()) ?
54 kInitialVMIsolateSymtabSize : kInitialSymtabSize; 54 kInitialVMIsolateSymtabSize : kInitialSymtabSize;
55 const Array& array = Array::Handle(Array::New(initial_size + 1)); 55 const Array& array = Array::Handle(Array::New(initial_size + 1));
56 56
57 // Last element contains the count of used slots. 57 // Last element contains the count of used slots.
58 array.SetAt(initial_size, Smi::Handle(Smi::New(0))); 58 array.SetAt(initial_size, Smi::Handle(Smi::New(0)));
59 isolate->object_store()->set_symbol_table(array); 59 isolate->object_store()->set_symbol_table(array);
60 } 60 }
61 61
62 62
63 intptr_t Symbols::Size(Isolate* isolate) {
64 ASSERT(isolate != NULL);
65 Array& symbol_table = Array::Handle(isolate,
66 isolate->object_store()->symbol_table());
67 intptr_t table_size_index = symbol_table.Length() - 1;
68 Smi& used = Smi::Handle();
69 used ^= symbol_table.At(table_size_index);
70 return used.Value();
71 }
72
73
63 void Symbols::Add(const Array& symbol_table, const String& str) { 74 void Symbols::Add(const Array& symbol_table, const String& str) {
64 // Should only be run by the vm isolate. 75 // Should only be run by the vm isolate.
65 ASSERT(Isolate::Current() == Dart::vm_isolate()); 76 ASSERT(Isolate::Current() == Dart::vm_isolate());
66 intptr_t hash = str.Hash(); 77 intptr_t hash = str.Hash();
67 intptr_t index = FindIndex(symbol_table, str, 0, str.Length(), hash); 78 intptr_t index = FindIndex(symbol_table, str, 0, str.Length(), hash);
68 ASSERT(symbol_table.At(index) == String::null()); 79 ASSERT(symbol_table.At(index) == String::null());
69 InsertIntoSymbolTable(symbol_table, str, index); 80 InsertIntoSymbolTable(symbol_table, str, index);
70 } 81 }
71 82
72 83
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 String& symbol = String::Handle(); 284 String& symbol = String::Handle();
274 symbol ^= symbol_table.At(index); 285 symbol ^= symbol_table.At(index);
275 while (!symbol.IsNull() && !symbol.Equals(str, begin_index, len)) { 286 while (!symbol.IsNull() && !symbol.Equals(str, begin_index, len)) {
276 index = (index + 1) % table_size; // Move to next element. 287 index = (index + 1) % table_size; // Move to next element.
277 symbol ^= symbol_table.At(index); 288 symbol ^= symbol_table.At(index);
278 } 289 }
279 return index; // Index of symbol if found or slot into which to add symbol. 290 return index; // Index of symbol if found or slot into which to add symbol.
280 } 291 }
281 292
282 } // namespace dart 293 } // namespace dart
OLDNEW
« no previous file with comments | « vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698