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

Side by Side Diff: src/objects.cc

Issue 2430273007: [runtime] Object.create(null) creates a slow object (Closed)
Patch Set: adding tests Created 4 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
OLDNEW
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
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 13316 matching lines...) Expand 10 before | Expand all | Expand 10 after
16762 } 16763 }
16763 16764
16764 16765
16765 template<typename Derived, typename Shape, typename Key> 16766 template<typename Derived, typename Shape, typename Key>
16766 Handle<Derived> HashTable<Derived, Shape, Key>::New( 16767 Handle<Derived> HashTable<Derived, Shape, Key>::New(
16767 Isolate* isolate, 16768 Isolate* isolate,
16768 int at_least_space_for, 16769 int at_least_space_for,
16769 MinimumCapacity capacity_option, 16770 MinimumCapacity capacity_option,
16770 PretenureFlag pretenure) { 16771 PretenureFlag pretenure) {
16771 DCHECK(0 <= at_least_space_for); 16772 DCHECK(0 <= at_least_space_for);
16772 DCHECK(!capacity_option || base::bits::IsPowerOfTwo32(at_least_space_for)); 16773 DCHECK_IMPLIES(capacity_option == USE_CUSTOM_MINIMUM_CAPACITY,
Igor Sheludko 2016/10/21 07:48:27 FYI: USE_CUSTOM_MINIMUM_CAPACITY does not actually
16774 base::bits::IsPowerOfTwo32(at_least_space_for));
16773 16775
16774 int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY) 16776 int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY)
16775 ? at_least_space_for 16777 ? at_least_space_for
16776 : ComputeCapacity(at_least_space_for); 16778 : ComputeCapacity(at_least_space_for);
16777 if (capacity > HashTable::kMaxCapacity) { 16779 if (capacity > HashTable::kMaxCapacity) {
16778 v8::internal::Heap::FatalProcessOutOfMemory("invalid table size", true); 16780 v8::internal::Heap::FatalProcessOutOfMemory("invalid table size", true);
16779 } 16781 }
16780 16782
16781 Factory* factory = isolate->factory(); 16783 Factory* factory = isolate->factory();
16782 int length = EntryToIndex(capacity); 16784 int length = EntryToIndex(capacity);
(...skipping 3430 matching lines...) Expand 10 before | Expand all | Expand 10 after
20213 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) 20215 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr))
20214 .Check(); 20216 .Check();
20215 } 20217 }
20216 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); 20218 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked();
20217 20219
20218 return ns; 20220 return ns;
20219 } 20221 }
20220 20222
20221 } // namespace internal 20223 } // namespace internal
20222 } // namespace v8 20224 } // namespace v8
OLDNEW
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698