Chromium Code Reviews| 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/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/become.h" | 10 #include "vm/become.h" |
| (...skipping 4503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4514 } | 4514 } |
| 4515 | 4515 |
| 4516 | 4516 |
| 4517 void Class::InsertCanonicalNumber(Zone* zone, | 4517 void Class::InsertCanonicalNumber(Zone* zone, |
| 4518 intptr_t index, | 4518 intptr_t index, |
| 4519 const Number& constant) const { | 4519 const Number& constant) const { |
| 4520 // The constant needs to be added to the list. Grow the list if it is full. | 4520 // The constant needs to be added to the list. Grow the list if it is full. |
| 4521 Array& canonical_list = Array::Handle(zone, constants()); | 4521 Array& canonical_list = Array::Handle(zone, constants()); |
| 4522 const intptr_t list_len = canonical_list.Length(); | 4522 const intptr_t list_len = canonical_list.Length(); |
| 4523 if (index >= list_len) { | 4523 if (index >= list_len) { |
| 4524 const intptr_t new_length = (list_len == 0) ? 4 : list_len + 4; | 4524 const intptr_t new_length = list_len + 4 + (list_len >> 2); |
|
regis
2017/04/24 16:08:07
Why a factor of 5? How many canonical numbers are
regis
2017/04/24 17:18:14
As Martin pointed out, this is a right shift, so %
| |
| 4525 canonical_list ^= Array::Grow(canonical_list, new_length, Heap::kOld); | 4525 canonical_list ^= Array::Grow(canonical_list, new_length, Heap::kOld); |
| 4526 set_constants(canonical_list); | 4526 set_constants(canonical_list); |
| 4527 } | 4527 } |
| 4528 canonical_list.SetAt(index, constant); | 4528 canonical_list.SetAt(index, constant); |
| 4529 } | 4529 } |
| 4530 | 4530 |
| 4531 | 4531 |
| 4532 void Class::RehashConstants(Zone* zone) const { | 4532 void Class::RehashConstants(Zone* zone) const { |
| 4533 intptr_t cid = id(); | 4533 intptr_t cid = id(); |
| 4534 if ((cid == kMintCid) || (cid == kBigintCid) || (cid == kDoubleCid)) { | 4534 if ((cid == kMintCid) || (cid == kBigintCid) || (cid == kDoubleCid)) { |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5081 } | 5081 } |
| 5082 // Instantiation did not result in bound error. Canonicalize type arguments. | 5082 // Instantiation did not result in bound error. Canonicalize type arguments. |
| 5083 result = result.Canonicalize(); | 5083 result = result.Canonicalize(); |
| 5084 // InstantiateAndCanonicalizeFrom is not reentrant. It cannot have been called | 5084 // InstantiateAndCanonicalizeFrom is not reentrant. It cannot have been called |
| 5085 // indirectly, so the prior_instantiations array cannot have grown. | 5085 // indirectly, so the prior_instantiations array cannot have grown. |
| 5086 ASSERT(prior_instantiations.raw() == instantiations()); | 5086 ASSERT(prior_instantiations.raw() == instantiations()); |
| 5087 // Add instantiator and function type args and result to instantiations array. | 5087 // Add instantiator and function type args and result to instantiations array. |
| 5088 intptr_t length = prior_instantiations.Length(); | 5088 intptr_t length = prior_instantiations.Length(); |
| 5089 if ((index + StubCode::kInstantiationSizeInWords) >= length) { | 5089 if ((index + StubCode::kInstantiationSizeInWords) >= length) { |
| 5090 // TODO(regis): Should we limit the number of cached instantiations? | 5090 // TODO(regis): Should we limit the number of cached instantiations? |
| 5091 // Grow the instantiations array. | 5091 // Grow the instantiations array by about 50%, but at least by 1. |
|
regis
2017/04/24 16:08:07
50%? Your change looks rather like a factor 2 to m
regis
2017/04/24 17:18:14
Never mind. Right shift again.
| |
| 5092 // The initial array is Object::zero_array() of length 1. | 5092 // The initial array is Object::zero_array() of length 1. |
| 5093 length = (length > 64) | 5093 intptr_t entries = (length - 1) / StubCode::kInstantiationSizeInWords; |
| 5094 ? (length + 64) | 5094 intptr_t new_entries = entries + (entries >> 1) + 1; |
| 5095 : ((length == 1) ? StubCode::kInstantiationSizeInWords + 1 | 5095 length = new_entries * StubCode::kInstantiationSizeInWords + 1; |
| 5096 : ((length - 1) * 2 + 1)); | |
| 5097 prior_instantiations = | 5096 prior_instantiations = |
| 5098 Array::Grow(prior_instantiations, length, Heap::kOld); | 5097 Array::Grow(prior_instantiations, length, Heap::kOld); |
| 5099 set_instantiations(prior_instantiations); | 5098 set_instantiations(prior_instantiations); |
| 5100 ASSERT((index + StubCode::kInstantiationSizeInWords) < length); | 5099 ASSERT((index + StubCode::kInstantiationSizeInWords) < length); |
| 5101 } | 5100 } |
| 5102 prior_instantiations.SetAt(index + 0, instantiator_type_arguments); | 5101 prior_instantiations.SetAt(index + 0, instantiator_type_arguments); |
| 5103 prior_instantiations.SetAt(index + 1, function_type_arguments); | 5102 prior_instantiations.SetAt(index + 1, function_type_arguments); |
| 5104 prior_instantiations.SetAt(index + 2, result); | 5103 prior_instantiations.SetAt(index + 2, result); |
| 5105 prior_instantiations.SetAt(index + 3, | 5104 prior_instantiations.SetAt(index + 3, |
| 5106 Smi::Handle(Smi::New(StubCode::kNoInstantiator))); | 5105 Smi::Handle(Smi::New(StubCode::kNoInstantiator))); |
| (...skipping 5759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10866 StorePointer(&raw_ptr()->resolved_names_, Array::null()); | 10865 StorePointer(&raw_ptr()->resolved_names_, Array::null()); |
| 10867 StorePointer(&raw_ptr()->exported_names_, Array::null()); | 10866 StorePointer(&raw_ptr()->exported_names_, Array::null()); |
| 10868 StorePointer(&raw_ptr()->loaded_scripts_, Array::null()); | 10867 StorePointer(&raw_ptr()->loaded_scripts_, Array::null()); |
| 10869 } | 10868 } |
| 10870 | 10869 |
| 10871 | 10870 |
| 10872 void Library::AddImport(const Namespace& ns) const { | 10871 void Library::AddImport(const Namespace& ns) const { |
| 10873 Array& imports = Array::Handle(this->imports()); | 10872 Array& imports = Array::Handle(this->imports()); |
| 10874 intptr_t capacity = imports.Length(); | 10873 intptr_t capacity = imports.Length(); |
| 10875 if (num_imports() == capacity) { | 10874 if (num_imports() == capacity) { |
| 10876 capacity = capacity + kImportsCapacityIncrement; | 10875 capacity = capacity + kImportsCapacityIncrement + (capacity >> 2); |
|
regis
2017/04/24 16:08:07
Factor 3?
regis
2017/04/24 17:18:14
No.
| |
| 10877 imports = Array::Grow(imports, capacity); | 10876 imports = Array::Grow(imports, capacity); |
| 10878 StorePointer(&raw_ptr()->imports_, imports.raw()); | 10877 StorePointer(&raw_ptr()->imports_, imports.raw()); |
| 10879 } | 10878 } |
| 10880 intptr_t index = num_imports(); | 10879 intptr_t index = num_imports(); |
| 10881 imports.SetAt(index, ns); | 10880 imports.SetAt(index, ns); |
| 10882 set_num_imports(index + 1); | 10881 set_num_imports(index + 1); |
| 10883 } | 10882 } |
| 10884 | 10883 |
| 10885 | 10884 |
| 10886 // Convenience function to determine whether the export list is | 10885 // Convenience function to determine whether the export list is |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11426 intptr_t num_current_imports = num_imports(); | 11425 intptr_t num_current_imports = num_imports(); |
| 11427 | 11426 |
| 11428 // Prefixes with deferred libraries can only contain one library. | 11427 // Prefixes with deferred libraries can only contain one library. |
| 11429 ASSERT((num_current_imports == 0) || !is_deferred_load()); | 11428 ASSERT((num_current_imports == 0) || !is_deferred_load()); |
| 11430 | 11429 |
| 11431 // The library needs to be added to the list. | 11430 // The library needs to be added to the list. |
| 11432 Array& imports = Array::Handle(this->imports()); | 11431 Array& imports = Array::Handle(this->imports()); |
| 11433 const intptr_t length = (imports.IsNull()) ? 0 : imports.Length(); | 11432 const intptr_t length = (imports.IsNull()) ? 0 : imports.Length(); |
| 11434 // Grow the list if it is full. | 11433 // Grow the list if it is full. |
| 11435 if (num_current_imports >= length) { | 11434 if (num_current_imports >= length) { |
| 11436 const intptr_t new_length = length + kIncrementSize; | 11435 const intptr_t new_length = length + kIncrementSize + (length >> 2); |
|
regis
2017/04/24 16:08:07
ditto
| |
| 11437 imports = Array::Grow(imports, new_length, Heap::kOld); | 11436 imports = Array::Grow(imports, new_length, Heap::kOld); |
| 11438 set_imports(imports); | 11437 set_imports(imports); |
| 11439 } | 11438 } |
| 11440 imports.SetAt(num_current_imports, import); | 11439 imports.SetAt(num_current_imports, import); |
| 11441 set_num_imports(num_current_imports + 1); | 11440 set_num_imports(num_current_imports + 1); |
| 11442 } | 11441 } |
| 11443 | 11442 |
| 11444 | 11443 |
| 11445 RawObject* LibraryPrefix::LookupObject(const String& name) const { | 11444 RawObject* LibraryPrefix::LookupObject(const String& name) const { |
| 11446 if (!is_loaded() && !FLAG_load_deferred_eagerly) { | 11445 if (!is_loaded() && !FLAG_load_deferred_eagerly) { |
| (...skipping 11850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 23297 return UserTag::null(); | 23296 return UserTag::null(); |
| 23298 } | 23297 } |
| 23299 | 23298 |
| 23300 | 23299 |
| 23301 const char* UserTag::ToCString() const { | 23300 const char* UserTag::ToCString() const { |
| 23302 const String& tag_label = String::Handle(label()); | 23301 const String& tag_label = String::Handle(label()); |
| 23303 return tag_label.ToCString(); | 23302 return tag_label.ToCString(); |
| 23304 } | 23303 } |
| 23305 | 23304 |
| 23306 } // namespace dart | 23305 } // namespace dart |
| OLD | NEW |