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

Side by Side Diff: src/objects-inl.h

Issue 2430273007: [runtime] Object.create(null) creates a slow object (Closed)
Patch Set: addressing comments Created 4 years, 2 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 3155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3166 3166
3167 3167
3168 void HashTableBase::ElementsRemoved(int n) { 3168 void HashTableBase::ElementsRemoved(int n) {
3169 SetNumberOfElements(NumberOfElements() - n); 3169 SetNumberOfElements(NumberOfElements() - n);
3170 SetNumberOfDeletedElements(NumberOfDeletedElements() + n); 3170 SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
3171 } 3171 }
3172 3172
3173 3173
3174 // static 3174 // static
3175 int HashTableBase::ComputeCapacity(int at_least_space_for) { 3175 int HashTableBase::ComputeCapacity(int at_least_space_for) {
3176 const int kMinCapacity = 4;
3177 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2); 3176 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2);
3178 return Max(capacity, kMinCapacity); 3177 return Max(capacity, kMinCapacity);
3179 } 3178 }
3180 3179
3181 bool HashTableBase::IsKey(Isolate* isolate, Object* k) { 3180 bool HashTableBase::IsKey(Isolate* isolate, Object* k) {
3182 Heap* heap = isolate->heap(); 3181 Heap* heap = isolate->heap();
3183 return k != heap->the_hole_value() && k != heap->undefined_value(); 3182 return k != heap->the_hole_value() && k != heap->undefined_value();
3184 } 3183 }
3185 3184
3186 bool HashTableBase::IsKey(Object* k) { 3185 bool HashTableBase::IsKey(Object* k) {
(...skipping 4381 matching lines...) Expand 10 before | Expand all | Expand 10 after
7568 if (map()->is_dictionary_map()) { 7567 if (map()->is_dictionary_map()) {
7569 WRITE_FIELD(this, kPropertiesOffset, 7568 WRITE_FIELD(this, kPropertiesOffset,
7570 GetHeap()->empty_properties_dictionary()); 7569 GetHeap()->empty_properties_dictionary());
7571 } else { 7570 } else {
7572 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array()); 7571 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array());
7573 } 7572 }
7574 } 7573 }
7575 7574
7576 7575
7577 bool JSReceiver::HasFastProperties() { 7576 bool JSReceiver::HasFastProperties() {
7578 DCHECK(properties()->IsDictionary() == map()->is_dictionary_map()); 7577 DCHECK_EQ(properties()->IsDictionary(), map()->is_dictionary_map());
7579 return !properties()->IsDictionary(); 7578 return !properties()->IsDictionary();
7580 } 7579 }
7581 7580
7582 7581
7583 NameDictionary* JSReceiver::property_dictionary() { 7582 NameDictionary* JSReceiver::property_dictionary() {
7584 DCHECK(!HasFastProperties()); 7583 DCHECK(!HasFastProperties());
7585 DCHECK(!IsJSGlobalObject()); 7584 DCHECK(!IsJSGlobalObject());
7586 return NameDictionary::cast(properties()); 7585 return NameDictionary::cast(properties());
7587 } 7586 }
7588 7587
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
8414 #undef WRITE_INT64_FIELD 8413 #undef WRITE_INT64_FIELD
8415 #undef READ_BYTE_FIELD 8414 #undef READ_BYTE_FIELD
8416 #undef WRITE_BYTE_FIELD 8415 #undef WRITE_BYTE_FIELD
8417 #undef NOBARRIER_READ_BYTE_FIELD 8416 #undef NOBARRIER_READ_BYTE_FIELD
8418 #undef NOBARRIER_WRITE_BYTE_FIELD 8417 #undef NOBARRIER_WRITE_BYTE_FIELD
8419 8418
8420 } // namespace internal 8419 } // namespace internal
8421 } // namespace v8 8420 } // namespace v8
8422 8421
8423 #endif // V8_OBJECTS_INL_H_ 8422 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/objects.h ('K') | « src/objects.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698