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

Side by Side Diff: vm/object.cc

Issue 9232017: Improve function compilation times for swarm application startup. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 11 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
« vm/object.h ('K') | « vm/object.h ('k') | vm/parser.cc » ('j') | 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 for (intptr_t i = 0; i < private_len; i++) { 1560 for (intptr_t i = 0; i < private_len; i++) {
1561 if (name.CharAt(i) != private_name.CharAt(i)) { 1561 if (name.CharAt(i) != private_name.CharAt(i)) {
1562 return false; 1562 return false;
1563 } 1563 }
1564 } 1564 }
1565 return true; 1565 return true;
1566 } 1566 }
1567 1567
1568 1568
1569 RawFunction* Class::LookupFunction(const String& name) const { 1569 RawFunction* Class::LookupFunction(const String& name) const {
1570 Array& funcs = Array::Handle(functions()); 1570 Isolate* isolate = Isolate::Current();
1571 Function& function = Function::Handle(); 1571 Array& funcs = Array::Handle(isolate, functions());
1572 String& function_name = String::Handle(); 1572 Function& function = Function::Handle(isolate, Function::null());
1573 String& function_name = String::Handle(isolate, String::null());
1573 intptr_t len = funcs.Length(); 1574 intptr_t len = funcs.Length();
1574 for (intptr_t i = 0; i < len; i++) { 1575 for (intptr_t i = 0; i < len; i++) {
1575 function ^= funcs.At(i); 1576 function ^= funcs.At(i);
1576 function_name ^= function.name(); 1577 function_name ^= function.name();
1577 if (function_name.Equals(name) || MatchesPrivateName(function_name, name)) { 1578 if (function_name.Equals(name) || MatchesPrivateName(function_name, name)) {
1578 return function.raw(); 1579 return function.raw();
1579 } 1580 }
1580 } 1581 }
1581 1582
1582 // No function found. 1583 // No function found.
(...skipping 25 matching lines...) Expand all
1608 return Field::null(); 1609 return Field::null();
1609 } 1610 }
1610 return field.raw(); 1611 return field.raw();
1611 } 1612 }
1612 // No field found. 1613 // No field found.
1613 return Field::null(); 1614 return Field::null();
1614 } 1615 }
1615 1616
1616 1617
1617 RawField* Class::LookupField(const String& name) const { 1618 RawField* Class::LookupField(const String& name) const {
1618 const Array& flds = Array::Handle(fields()); 1619 Isolate* isolate = Isolate::Current();
1619 Field& field = Field::Handle(); 1620 const Array& flds = Array::Handle(isolate, fields());
1620 String& field_name = String::Handle(); 1621 Field& field = Field::Handle(isolate, Field::null());
1622 String& field_name = String::Handle(isolate, String::null());
1621 intptr_t len = flds.Length(); 1623 intptr_t len = flds.Length();
1622 for (intptr_t i = 0; i < len; i++) { 1624 for (intptr_t i = 0; i < len; i++) {
1623 field ^= flds.At(i); 1625 field ^= flds.At(i);
1624 field_name ^= field.name(); 1626 field_name ^= field.name();
1625 if (field_name.Equals(name) || MatchesPrivateName(field_name, name)) { 1627 if (field_name.Equals(name) || MatchesPrivateName(field_name, name)) {
1626 return field.raw(); 1628 return field.raw();
1627 } 1629 }
1628 } 1630 }
1629 // No field found. 1631 // No field found.
1630 return Field::null(); 1632 return Field::null();
1631 } 1633 }
1632 1634
1633 1635
1634 RawLibraryPrefix* Class::LookupLibraryPrefix(const String& name) const { 1636 RawLibraryPrefix* Class::LookupLibraryPrefix(const String& name) const {
1635 LibraryPrefix& lib_prefix = LibraryPrefix::Handle(); 1637 Isolate* isolate = Isolate::Current();
1636 const Library& lib = Library::Handle(library()); 1638 LibraryPrefix& lib_prefix = LibraryPrefix::Handle(isolate,
1637 Object& obj = Object::Handle(lib.LookupLocalObject(name)); 1639 LibraryPrefix::null());
1640 const Library& lib = Library::Handle(isolate, library());
1641 Object& obj = Object::Handle(isolate, lib.LookupLocalObject(name));
1638 if (!obj.IsNull()) { 1642 if (!obj.IsNull()) {
1639 if (obj.IsLibraryPrefix()) { 1643 if (obj.IsLibraryPrefix()) {
1640 lib_prefix ^= obj.raw(); 1644 lib_prefix ^= obj.raw();
1641 } 1645 }
1642 } 1646 }
1643 return lib_prefix.raw(); 1647 return lib_prefix.raw();
1644 } 1648 }
1645 1649
1646 1650
1647 const char* Class::ToCString() const { 1651 const char* Class::ToCString() const {
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after
3972 3976
3973 3977
3974 void Library::AddClass(const Class& cls) const { 3978 void Library::AddClass(const Class& cls) const {
3975 AddObject(cls, String::Handle(cls.Name())); 3979 AddObject(cls, String::Handle(cls.Name()));
3976 // Link class to this library. 3980 // Link class to this library.
3977 cls.set_library(*this); 3981 cls.set_library(*this);
3978 } 3982 }
3979 3983
3980 3984
3981 RawObject* Library::LookupLocalObject(const String& name) const { 3985 RawObject* Library::LookupLocalObject(const String& name) const {
3982 const Array& dict = Array::Handle(dictionary()); 3986 Isolate* isolate = Isolate::Current();
3987 const Array& dict = Array::Handle(isolate, dictionary());
3983 intptr_t dict_size = dict.Length() - 1; 3988 intptr_t dict_size = dict.Length() - 1;
3984 intptr_t index = name.Hash() % dict_size; 3989 intptr_t index = name.Hash() % dict_size;
3985 3990
3986 Object& entry = Object::Handle(); 3991 Object& entry = Object::Handle(isolate, Object::null());
3987 Class& cls = Class::Handle(); 3992 Class& cls = Class::Handle(isolate, Class::null());
3988 Function& func = Function::Handle(); 3993 Function& func = Function::Handle(isolate, Function::null());
3989 Field& field = Field::Handle(); 3994 Field& field = Field::Handle(isolate, Field::null());
3990 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); 3995 LibraryPrefix& library_prefix = LibraryPrefix::Handle(isolate,
3991 String& entry_name = String::Handle(); 3996 LibraryPrefix::null());
3997 String& entry_name = String::Handle(isolate, String::null());
3992 entry = dict.At(index); 3998 entry = dict.At(index);
3993 // Search the entry in the hash set. 3999 // Search the entry in the hash set.
3994 while (!entry.IsNull()) { 4000 while (!entry.IsNull()) {
3995 // TODO(hausner): find a better way to handle this polymorphism. 4001 // TODO(hausner): find a better way to handle this polymorphism.
3996 // Either introduce a common base class for Class, Function, Field 4002 // Either introduce a common base class for Class, Function, Field
3997 // and LibraryPrefix or make the name() function virtual in Object. 4003 // and LibraryPrefix or make the name() function virtual in Object.
3998 if (entry.IsClass()) { 4004 if (entry.IsClass()) {
3999 cls ^= entry.raw(); 4005 cls ^= entry.raw();
4000 entry_name = cls.Name(); 4006 entry_name = cls.Name();
4001 } else if (entry.IsFunction()) { 4007 } else if (entry.IsFunction()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4044 return Object::null(); 4050 return Object::null();
4045 } 4051 }
4046 4052
4047 4053
4048 RawObject* Library::LookupObject(const String& name) const { 4054 RawObject* Library::LookupObject(const String& name) const {
4049 return LookupObjectFiltered(name, Library::Handle()); 4055 return LookupObjectFiltered(name, Library::Handle());
4050 } 4056 }
4051 4057
4052 4058
4053 RawLibrary* Library::LookupObjectInImporter(const String& name) const { 4059 RawLibrary* Library::LookupObjectInImporter(const String& name) const {
4054 const Array& imported_into_libs = Array::Handle(this->imported_into()); 4060 Isolate* isolate = Isolate::Current();
4055 Library& lib = Library::Handle(); 4061 const Array& imported_into_libs = Array::Handle(isolate,
4056 Object& obj = Object::Handle(); 4062 this->imported_into());
4063 Library& lib = Library::Handle(isolate, Library::null());
4064 Object& obj = Object::Handle(isolate, Object::null());
4057 for (intptr_t i = 0; i < this->num_imported_into(); i++) { 4065 for (intptr_t i = 0; i < this->num_imported_into(); i++) {
4058 lib ^= imported_into_libs.At(i); 4066 lib ^= imported_into_libs.At(i);
4059 obj = lib.LookupObjectFiltered(name, *this); 4067 obj = lib.LookupObjectFiltered(name, *this);
4060 if (!obj.IsNull()) { 4068 if (!obj.IsNull()) {
4061 // If the object found is a class, field or function extract the 4069 // If the object found is a class, field or function extract the
4062 // library in which it is defined as it might be defined in one of 4070 // library in which it is defined as it might be defined in one of
4063 // the imported libraries. 4071 // the imported libraries.
4064 Class& cls = Class::Handle(); 4072 Class& cls = Class::Handle(isolate, Class::null());
4065 Function& func = Function::Handle(); 4073 Function& func = Function::Handle(isolate, Function::null());
4066 Field& field = Field::Handle(); 4074 Field& field = Field::Handle(isolate, Field::null());
4067 if (obj.IsClass()) { 4075 if (obj.IsClass()) {
4068 cls ^= obj.raw(); 4076 cls ^= obj.raw();
4069 lib ^= cls.library(); 4077 lib ^= cls.library();
4070 } else if (obj.IsFunction()) { 4078 } else if (obj.IsFunction()) {
4071 func ^= obj.raw(); 4079 func ^= obj.raw();
4072 cls ^= func.owner(); 4080 cls ^= func.owner();
4073 lib ^= cls.library(); 4081 lib ^= cls.library();
4074 } else if (obj.IsField()) { 4082 } else if (obj.IsField()) {
4075 field ^= obj.raw(); 4083 field ^= obj.raw();
4076 cls ^= field.owner(); 4084 cls ^= field.owner();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4168 anon_array = Array::Grow(anon_array, new_len); 4176 anon_array = Array::Grow(anon_array, new_len);
4169 StorePointer(&raw_ptr()->anonymous_classes_, anon_array.raw()); 4177 StorePointer(&raw_ptr()->anonymous_classes_, anon_array.raw());
4170 } 4178 }
4171 anon_array.SetAt(num_anonymous, cls); 4179 anon_array.SetAt(num_anonymous, cls);
4172 num_anonymous++; 4180 num_anonymous++;
4173 raw_ptr()->num_anonymous_ = num_anonymous; 4181 raw_ptr()->num_anonymous_ = num_anonymous;
4174 } 4182 }
4175 4183
4176 4184
4177 RawLibrary* Library::LookupImport(const String& url) const { 4185 RawLibrary* Library::LookupImport(const String& url) const {
4178 const Array& imports = Array::Handle(this->imports()); 4186 Isolate* isolate = Isolate::Current();
4187 const Array& imports = Array::Handle(isolate, this->imports());
4179 intptr_t num_imports = this->num_imports(); 4188 intptr_t num_imports = this->num_imports();
4180 Library& lib = Library::Handle(); 4189 Library& lib = Library::Handle(isolate, Library::null());
4181 String& import_url = String::Handle(); 4190 String& import_url = String::Handle(isolate, String::null());
4182 for (int i = 0; i < num_imports; i++) { 4191 for (int i = 0; i < num_imports; i++) {
4183 lib ^= imports.At(i); 4192 lib ^= imports.At(i);
4184 import_url = lib.url(); 4193 import_url = lib.url();
4185 if (url.Equals(import_url)) { 4194 if (url.Equals(import_url)) {
4186 return lib.raw(); 4195 return lib.raw();
4187 } 4196 }
4188 } 4197 }
4189 return Library::null(); 4198 return Library::null();
4190 } 4199 }
4191 4200
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4325 "%s%d", 4334 "%s%d",
4326 kNativeWrappersClass, 4335 kNativeWrappersClass,
4327 fld_cnt); 4336 fld_cnt);
4328 cls_name = String::NewSymbol(name_buffer); 4337 cls_name = String::NewSymbol(name_buffer);
4329 Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt); 4338 Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt);
4330 } 4339 }
4331 } 4340 }
4332 4341
4333 4342
4334 RawLibrary* Library::LookupLibrary(const String &url) { 4343 RawLibrary* Library::LookupLibrary(const String &url) {
4335 Library& lib = Library::Handle(); 4344 Isolate* isolate = Isolate::Current();
4336 String& lib_url = String::Handle(); 4345 Library& lib = Library::Handle(isolate, Library::null());
4337 lib = Isolate::Current()->object_store()->registered_libraries(); 4346 String& lib_url = String::Handle(isolate, String::null());
4347 lib = isolate->object_store()->registered_libraries();
4338 while (!lib.IsNull()) { 4348 while (!lib.IsNull()) {
4339 lib_url = lib.url(); 4349 lib_url = lib.url();
4340 if (lib_url.Equals(url)) { 4350 if (lib_url.Equals(url)) {
4341 return lib.raw(); 4351 return lib.raw();
4342 } 4352 }
4343 lib = lib.next_registered(); 4353 lib = lib.next_registered();
4344 } 4354 }
4345 return Library::null(); 4355 return Library::null();
4346 } 4356 }
4347 4357
(...skipping 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after
7613 const String& str = String::Handle(pattern()); 7623 const String& str = String::Handle(pattern());
7614 const char* format = "JSRegExp: pattern=%s flags=%s"; 7624 const char* format = "JSRegExp: pattern=%s flags=%s";
7615 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 7625 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
7616 char* chars = reinterpret_cast<char*>( 7626 char* chars = reinterpret_cast<char*>(
7617 Isolate::Current()->current_zone()->Allocate(len + 1)); 7627 Isolate::Current()->current_zone()->Allocate(len + 1));
7618 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 7628 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
7619 return chars; 7629 return chars;
7620 } 7630 }
7621 7631
7622 } // namespace dart 7632 } // namespace dart
OLDNEW
« vm/object.h ('K') | « vm/object.h ('k') | vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698