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

Side by Side Diff: runtime/vm/symbols.cc

Issue 247623007: Remove VM isolate new-space allocation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/scavenger.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/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 } 116 }
117 117
118 118
119 void Symbols::SetupSymbolTable(Isolate* isolate) { 119 void Symbols::SetupSymbolTable(Isolate* isolate) {
120 ASSERT(isolate != NULL); 120 ASSERT(isolate != NULL);
121 121
122 // Setup the symbol table used within the String class. 122 // Setup the symbol table used within the String class.
123 const intptr_t initial_size = (isolate == Dart::vm_isolate()) ? 123 const intptr_t initial_size = (isolate == Dart::vm_isolate()) ?
124 kInitialVMIsolateSymtabSize : kInitialSymtabSize; 124 kInitialVMIsolateSymtabSize : kInitialSymtabSize;
125 const Array& array = Array::Handle(Array::New(initial_size + 1)); 125 const Array& array = Array::Handle(Array::New(initial_size + 1, Heap::kOld));
126 126
127 // Last element contains the count of used slots. 127 // Last element contains the count of used slots.
128 array.SetAt(initial_size, Smi::Handle(Smi::New(0))); 128 array.SetAt(initial_size, Smi::Handle(Smi::New(0)));
129 isolate->object_store()->set_symbol_table(array); 129 isolate->object_store()->set_symbol_table(array);
130 } 130 }
131 131
132 132
133 intptr_t Symbols::Size(Isolate* isolate) { 133 intptr_t Symbols::Size(Isolate* isolate) {
134 ASSERT(isolate != NULL); 134 ASSERT(isolate != NULL);
135 Array& symbol_table = Array::Handle(isolate, 135 Array& symbol_table = Array::Handle(isolate,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 OS::Print(" > %" Pd " collisions => %" Pd "\n", i, collision_count_[i]); 332 OS::Print(" > %" Pd " collisions => %" Pd "\n", i, collision_count_[i]);
333 } 333 }
334 } 334 }
335 335
336 336
337 void Symbols::GrowSymbolTable(const Array& symbol_table) { 337 void Symbols::GrowSymbolTable(const Array& symbol_table) {
338 // TODO(iposva): Avoid exponential growth. 338 // TODO(iposva): Avoid exponential growth.
339 num_of_grows_ += 1; 339 num_of_grows_ += 1;
340 intptr_t table_size = symbol_table.Length() - 1; 340 intptr_t table_size = symbol_table.Length() - 1;
341 intptr_t new_table_size = table_size * 2; 341 intptr_t new_table_size = table_size * 2;
342 Array& new_symbol_table = Array::Handle(Array::New(new_table_size + 1)); 342 Array& new_symbol_table =
343 Array::Handle(Array::New(new_table_size + 1, Heap::kOld));
343 // Copy all elements from the original symbol table to the newly allocated 344 // Copy all elements from the original symbol table to the newly allocated
344 // array. 345 // array.
345 String& element = String::Handle(); 346 String& element = String::Handle();
346 dart::Object& new_element = Object::Handle(); 347 dart::Object& new_element = Object::Handle();
347 for (intptr_t i = 0; i < table_size; i++) { 348 for (intptr_t i = 0; i < table_size; i++) {
348 element ^= symbol_table.At(i); 349 element ^= symbol_table.At(i);
349 if (!element.IsNull()) { 350 if (!element.IsNull()) {
350 intptr_t hash = element.Hash(); 351 intptr_t hash = element.Hash();
351 intptr_t index = hash % new_table_size; 352 intptr_t index = hash % new_table_size;
352 new_element = new_symbol_table.At(index); 353 new_element = new_symbol_table.At(index);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { 474 RawObject* Symbols::GetVMSymbol(intptr_t object_id) {
474 ASSERT(IsVMSymbolId(object_id)); 475 ASSERT(IsVMSymbolId(object_id));
475 intptr_t i = (object_id - kMaxPredefinedObjectIds); 476 intptr_t i = (object_id - kMaxPredefinedObjectIds);
476 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { 477 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) {
477 return symbol_handles_[i]->raw(); 478 return symbol_handles_[i]->raw();
478 } 479 }
479 return Object::null(); 480 return Object::null();
480 } 481 }
481 482
482 } // namespace dart 483 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698