OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 3414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3425 Isolate* isolate = object->GetIsolate(); | 3425 Isolate* isolate = object->GetIsolate(); |
3426 HandleScope scope(isolate); | 3426 HandleScope scope(isolate); |
3427 Handle<Map> map(object->map()); | 3427 Handle<Map> map(object->map()); |
3428 | 3428 |
3429 // Allocate new content. | 3429 // Allocate new content. |
3430 int real_size = map->NumberOfOwnDescriptors(); | 3430 int real_size = map->NumberOfOwnDescriptors(); |
3431 int property_count = real_size; | 3431 int property_count = real_size; |
3432 if (expected_additional_properties > 0) { | 3432 if (expected_additional_properties > 0) { |
3433 property_count += expected_additional_properties; | 3433 property_count += expected_additional_properties; |
3434 } else { | 3434 } else { |
3435 property_count += 2; // Make space for two more properties. | 3435 // Make space for two more properties. |
| 3436 property_count += NameDictionary::kInitialCapacity; |
3436 } | 3437 } |
3437 Handle<NameDictionary> dictionary = | 3438 Handle<NameDictionary> dictionary = |
3438 NameDictionary::New(isolate, property_count); | 3439 NameDictionary::New(isolate, property_count); |
3439 | 3440 |
3440 Handle<DescriptorArray> descs(map->instance_descriptors()); | 3441 Handle<DescriptorArray> descs(map->instance_descriptors()); |
3441 for (int i = 0; i < real_size; i++) { | 3442 for (int i = 0; i < real_size; i++) { |
3442 PropertyDetails details = descs->GetDetails(i); | 3443 PropertyDetails details = descs->GetDetails(i); |
3443 Handle<Name> key(descs->GetKey(i)); | 3444 Handle<Name> key(descs->GetKey(i)); |
3444 switch (details.type()) { | 3445 switch (details.type()) { |
3445 case DATA_CONSTANT: { | 3446 case DATA_CONSTANT: { |
(...skipping 13321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16767 } | 16768 } |
16768 | 16769 |
16769 | 16770 |
16770 template<typename Derived, typename Shape, typename Key> | 16771 template<typename Derived, typename Shape, typename Key> |
16771 Handle<Derived> HashTable<Derived, Shape, Key>::New( | 16772 Handle<Derived> HashTable<Derived, Shape, Key>::New( |
16772 Isolate* isolate, | 16773 Isolate* isolate, |
16773 int at_least_space_for, | 16774 int at_least_space_for, |
16774 MinimumCapacity capacity_option, | 16775 MinimumCapacity capacity_option, |
16775 PretenureFlag pretenure) { | 16776 PretenureFlag pretenure) { |
16776 DCHECK(0 <= at_least_space_for); | 16777 DCHECK(0 <= at_least_space_for); |
16777 DCHECK(!capacity_option || base::bits::IsPowerOfTwo32(at_least_space_for)); | 16778 DCHECK_IMPLIES(capacity_option == USE_CUSTOM_MINIMUM_CAPACITY, |
| 16779 base::bits::IsPowerOfTwo32(at_least_space_for)); |
16778 | 16780 |
16779 int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY) | 16781 int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY) |
16780 ? at_least_space_for | 16782 ? at_least_space_for |
16781 : ComputeCapacity(at_least_space_for); | 16783 : ComputeCapacity(at_least_space_for); |
16782 if (capacity > HashTable::kMaxCapacity) { | 16784 if (capacity > HashTable::kMaxCapacity) { |
16783 v8::internal::Heap::FatalProcessOutOfMemory("invalid table size", true); | 16785 v8::internal::Heap::FatalProcessOutOfMemory("invalid table size", true); |
16784 } | 16786 } |
16785 | 16787 |
16786 Factory* factory = isolate->factory(); | 16788 Factory* factory = isolate->factory(); |
16787 int length = EntryToIndex(capacity); | 16789 int length = EntryToIndex(capacity); |
(...skipping 3430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20218 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) | 20220 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) |
20219 .Check(); | 20221 .Check(); |
20220 } | 20222 } |
20221 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); | 20223 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); |
20222 | 20224 |
20223 return ns; | 20225 return ns; |
20224 } | 20226 } |
20225 | 20227 |
20226 } // namespace internal | 20228 } // namespace internal |
20227 } // namespace v8 | 20229 } // namespace v8 |
OLD | NEW |