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

Side by Side Diff: runtime/vm/object.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 unified diff | Download patch | Annotate | Revision Log
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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 ASSERT(class_class() != null_); 402 ASSERT(class_class() != null_);
403 403
404 // Pre-allocate the Array and OneByteString class in the vm isolate so that 404 // Pre-allocate the Array and OneByteString class in the vm isolate so that
405 // we can create a symbol table and populate it with some frequently used 405 // we can create a symbol table and populate it with some frequently used
406 // strings as symbols. 406 // strings as symbols.
407 cls = Class::New<Array>(); 407 cls = Class::New<Array>();
408 isolate->object_store()->set_array_class(cls); 408 isolate->object_store()->set_array_class(cls);
409 cls = Class::NewStringClass(kOneByteStringCid); 409 cls = Class::NewStringClass(kOneByteStringCid);
410 isolate->object_store()->set_one_byte_string_class(cls); 410 isolate->object_store()->set_one_byte_string_class(cls);
411 cls = Class::NewStringClass(kTwoByteStringCid);
412 isolate->object_store()->set_two_byte_string_class(cls);
411 413
412 // Allocate and initialize the empty_array instance. 414 // Allocate and initialize the empty_array instance.
413 { 415 {
414 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld); 416 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld);
415 empty_array_ = reinterpret_cast<RawArray*>(address + kHeapObjectTag); 417 empty_array_ = reinterpret_cast<RawArray*>(address + kHeapObjectTag);
416 InitializeObject(address, kArrayCid, Array::InstanceSize(0)); 418 InitializeObject(address, kArrayCid, Array::InstanceSize(0));
417 empty_array_->ptr()->length_ = Smi::New(0); 419 empty_array_->ptr()->length_ = Smi::New(0);
418 } 420 }
419 } 421 }
420 422
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 cls = Class::New<Type>(); 585 cls = Class::New<Type>();
584 object_store->set_type_class(cls); 586 object_store->set_type_class(cls);
585 587
586 cls = Class::New<TypeParameter>(); 588 cls = Class::New<TypeParameter>();
587 object_store->set_type_parameter_class(cls); 589 object_store->set_type_parameter_class(cls);
588 590
589 // Pre-allocate the OneByteString class needed by the symbol table. 591 // Pre-allocate the OneByteString class needed by the symbol table.
590 cls = Class::NewStringClass(kOneByteStringCid); 592 cls = Class::NewStringClass(kOneByteStringCid);
591 object_store->set_one_byte_string_class(cls); 593 object_store->set_one_byte_string_class(cls);
592 594
595 // Pre-allocate the TwoByteString class needed by the symbol table.
596 cls = Class::NewStringClass(kTwoByteStringCid);
597 object_store->set_two_byte_string_class(cls);
598
593 // Setup the symbol table for the symbols created in the isolate. 599 // Setup the symbol table for the symbols created in the isolate.
594 Symbols::SetupSymbolTable(isolate); 600 Symbols::SetupSymbolTable(isolate);
595 601
596 // Set up the libraries array before initializing the core library. 602 // Set up the libraries array before initializing the core library.
597 const GrowableObjectArray& libraries = 603 const GrowableObjectArray& libraries =
598 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); 604 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld));
599 object_store->set_libraries(libraries); 605 object_store->set_libraries(libraries);
600 606
601 // Basic infrastructure has been setup, initialize the class dictionary. 607 // Basic infrastructure has been setup, initialize the class dictionary.
602 Library::InitCoreLibrary(isolate); 608 Library::InitCoreLibrary(isolate);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 ASSERT(object_store->immutable_array_class() != object_store->array_class()); 642 ASSERT(object_store->immutable_array_class() != object_store->array_class());
637 name = Symbols::ImmutableArray(); 643 name = Symbols::ImmutableArray();
638 RegisterPrivateClass(cls, name, core_lib); 644 RegisterPrivateClass(cls, name, core_lib);
639 pending_classes.Add(cls, Heap::kOld); 645 pending_classes.Add(cls, Heap::kOld);
640 646
641 cls = object_store->one_byte_string_class(); // Was allocated above. 647 cls = object_store->one_byte_string_class(); // Was allocated above.
642 name = Symbols::OneByteString(); 648 name = Symbols::OneByteString();
643 RegisterPrivateClass(cls, name, core_lib); 649 RegisterPrivateClass(cls, name, core_lib);
644 pending_classes.Add(cls, Heap::kOld); 650 pending_classes.Add(cls, Heap::kOld);
645 651
646 cls = Class::NewStringClass(kTwoByteStringCid); 652 cls = object_store->two_byte_string_class(); // Was allocated above.
647 object_store->set_two_byte_string_class(cls);
648 name = Symbols::TwoByteString(); 653 name = Symbols::TwoByteString();
649 RegisterPrivateClass(cls, name, core_lib); 654 RegisterPrivateClass(cls, name, core_lib);
650 pending_classes.Add(cls, Heap::kOld); 655 pending_classes.Add(cls, Heap::kOld);
651 656
652 cls = Class::NewStringClass(kExternalOneByteStringCid); 657 cls = Class::NewStringClass(kExternalOneByteStringCid);
653 object_store->set_external_one_byte_string_class(cls); 658 object_store->set_external_one_byte_string_class(cls);
654 name = Symbols::ExternalOneByteString(); 659 name = Symbols::ExternalOneByteString();
655 RegisterPrivateClass(cls, name, core_lib); 660 RegisterPrivateClass(cls, name, core_lib);
656 pending_classes.Add(cls, Heap::kOld); 661 pending_classes.Add(cls, Heap::kOld);
657 662
(...skipping 11433 matching lines...) Expand 10 before | Expand all | Expand 10 after
12091 } 12096 }
12092 return result.raw(); 12097 return result.raw();
12093 } 12098 }
12094 12099
12095 12100
12096 const char* WeakProperty::ToCString() const { 12101 const char* WeakProperty::ToCString() const {
12097 return "_WeakProperty"; 12102 return "_WeakProperty";
12098 } 12103 }
12099 12104
12100 } // namespace dart 12105 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/string.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | runtime/vm/snapshot_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698