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

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

Issue 793453004: Reland of "TransitionArray now uses <is_data_property, name, attributes> tuple as a key, which allo… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Post-rebase fixes Created 6 years 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
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.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 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 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 DCHECK(!ExpectedTransitionKey(map).is_null()); 1891 DCHECK(!ExpectedTransitionKey(map).is_null());
1892 return Handle<Map>(map->transitions()->GetTarget( 1892 return Handle<Map>(map->transitions()->GetTarget(
1893 TransitionArray::kSimpleTransitionIndex)); 1893 TransitionArray::kSimpleTransitionIndex));
1894 } 1894 }
1895 1895
1896 1896
1897 Handle<Map> Map::FindTransitionToField(Handle<Map> map, Handle<Name> key) { 1897 Handle<Map> Map::FindTransitionToField(Handle<Map> map, Handle<Name> key) {
1898 DisallowHeapAllocation no_allocation; 1898 DisallowHeapAllocation no_allocation;
1899 if (!map->HasTransitionArray()) return Handle<Map>::null(); 1899 if (!map->HasTransitionArray()) return Handle<Map>::null();
1900 TransitionArray* transitions = map->transitions(); 1900 TransitionArray* transitions = map->transitions();
1901 int transition = transitions->Search(*key); 1901 int transition = transitions->Search(FIELD, *key, NONE);
1902 if (transition == TransitionArray::kNotFound) return Handle<Map>::null(); 1902 if (transition == TransitionArray::kNotFound) return Handle<Map>::null();
1903 PropertyDetails target_details = transitions->GetTargetDetails(transition); 1903 PropertyDetails details = transitions->GetTargetDetails(transition);
1904 if (target_details.type() != FIELD) return Handle<Map>::null(); 1904 if (details.type() != FIELD) return Handle<Map>::null();
1905 if (target_details.attributes() != NONE) return Handle<Map>::null(); 1905 DCHECK_EQ(NONE, details.attributes());
1906 return Handle<Map>(transitions->GetTarget(transition)); 1906 return Handle<Map>(transitions->GetTarget(transition));
1907 } 1907 }
1908 1908
1909 1909
1910 ACCESSORS(Oddball, to_string, String, kToStringOffset) 1910 ACCESSORS(Oddball, to_string, String, kToStringOffset)
1911 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) 1911 ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
1912 1912
1913 1913
1914 byte Oddball::kind() const { 1914 byte Oddball::kind() const {
1915 return Smi::cast(READ_FIELD(this, kKindOffset))->value(); 1915 return Smi::cast(READ_FIELD(this, kKindOffset))->value();
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2996 void Map::LookupDescriptor(JSObject* holder, 2996 void Map::LookupDescriptor(JSObject* holder,
2997 Name* name, 2997 Name* name,
2998 LookupResult* result) { 2998 LookupResult* result) {
2999 DescriptorArray* descriptors = this->instance_descriptors(); 2999 DescriptorArray* descriptors = this->instance_descriptors();
3000 int number = descriptors->SearchWithCache(name, this); 3000 int number = descriptors->SearchWithCache(name, this);
3001 if (number == DescriptorArray::kNotFound) return result->NotFound(); 3001 if (number == DescriptorArray::kNotFound) return result->NotFound();
3002 result->DescriptorResult(holder, descriptors->GetDetails(number), number); 3002 result->DescriptorResult(holder, descriptors->GetDetails(number), number);
3003 } 3003 }
3004 3004
3005 3005
3006 void Map::LookupTransition(JSObject* holder, Name* name, LookupResult* result) { 3006 void Map::LookupTransition(JSObject* holder, Name* name,
3007 int transition_index = this->SearchTransition(name); 3007 PropertyAttributes attributes,
3008 LookupResult* result) {
3009 int transition_index = this->SearchTransition(FIELD, name, attributes);
3008 if (transition_index == TransitionArray::kNotFound) return result->NotFound(); 3010 if (transition_index == TransitionArray::kNotFound) return result->NotFound();
3009 result->TransitionResult(holder, this->GetTransition(transition_index)); 3011 result->TransitionResult(holder, this->GetTransition(transition_index));
3010 } 3012 }
3011 3013
3012 3014
3013 FixedArrayBase* Map::GetInitialElements() { 3015 FixedArrayBase* Map::GetInitialElements() {
3014 if (has_fast_smi_or_object_elements() || 3016 if (has_fast_smi_or_object_elements() ||
3015 has_fast_double_elements()) { 3017 has_fast_double_elements()) {
3016 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); 3018 DCHECK(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
3017 return GetHeap()->empty_fixed_array(); 3019 return GetHeap()->empty_fixed_array();
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after
5344 } 5346 }
5345 5347
5346 5348
5347 bool Map::HasTransitionArray() const { 5349 bool Map::HasTransitionArray() const {
5348 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); 5350 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset);
5349 return object->IsTransitionArray(); 5351 return object->IsTransitionArray();
5350 } 5352 }
5351 5353
5352 5354
5353 Map* Map::elements_transition_map() { 5355 Map* Map::elements_transition_map() {
5354 int index = transitions()->Search(GetHeap()->elements_transition_symbol()); 5356 int index =
5357 transitions()->SearchSpecial(GetHeap()->elements_transition_symbol());
5355 return transitions()->GetTarget(index); 5358 return transitions()->GetTarget(index);
5356 } 5359 }
5357 5360
5358 5361
5359 bool Map::CanHaveMoreTransitions() { 5362 bool Map::CanHaveMoreTransitions() {
5360 if (!HasTransitionArray()) return true; 5363 if (!HasTransitionArray()) return true;
5361 return transitions()->number_of_transitions() < 5364 return transitions()->number_of_transitions() <
5362 TransitionArray::kMaxNumberOfTransitions; 5365 TransitionArray::kMaxNumberOfTransitions;
5363 } 5366 }
5364 5367
5365 5368
5366 Map* Map::GetTransition(int transition_index) { 5369 Map* Map::GetTransition(int transition_index) {
5367 return transitions()->GetTarget(transition_index); 5370 return transitions()->GetTarget(transition_index);
5368 } 5371 }
5369 5372
5370 5373
5371 int Map::SearchTransition(Name* name) { 5374 int Map::SearchSpecialTransition(Symbol* name) {
5372 if (HasTransitionArray()) return transitions()->Search(name); 5375 if (HasTransitionArray()) {
5376 return transitions()->SearchSpecial(name);
5377 }
5373 return TransitionArray::kNotFound; 5378 return TransitionArray::kNotFound;
5374 } 5379 }
5375 5380
5381
5382 int Map::SearchTransition(PropertyType type, Name* name,
5383 PropertyAttributes attributes) {
5384 if (HasTransitionArray()) {
5385 return transitions()->Search(type, name, attributes);
5386 }
5387 return TransitionArray::kNotFound;
5388 }
5389
5376 5390
5377 FixedArray* Map::GetPrototypeTransitions() { 5391 FixedArray* Map::GetPrototypeTransitions() {
5378 if (!HasTransitionArray()) return GetHeap()->empty_fixed_array(); 5392 if (!HasTransitionArray()) return GetHeap()->empty_fixed_array();
5379 if (!transitions()->HasPrototypeTransitions()) { 5393 if (!transitions()->HasPrototypeTransitions()) {
5380 return GetHeap()->empty_fixed_array(); 5394 return GetHeap()->empty_fixed_array();
5381 } 5395 }
5382 return transitions()->GetPrototypeTransitions(); 5396 return transitions()->GetPrototypeTransitions();
5383 } 5397 }
5384 5398
5385 5399
(...skipping 27 matching lines...) Expand all
5413 // Transition arrays are not shared. When one is replaced, it should not 5427 // Transition arrays are not shared. When one is replaced, it should not
5414 // keep referenced objects alive, so we zap it. 5428 // keep referenced objects alive, so we zap it.
5415 // When there is another reference to the array somewhere (e.g. a handle), 5429 // When there is another reference to the array somewhere (e.g. a handle),
5416 // not zapping turns from a waste of memory into a source of crashes. 5430 // not zapping turns from a waste of memory into a source of crashes.
5417 if (HasTransitionArray()) { 5431 if (HasTransitionArray()) {
5418 #ifdef DEBUG 5432 #ifdef DEBUG
5419 for (int i = 0; i < transitions()->number_of_transitions(); i++) { 5433 for (int i = 0; i < transitions()->number_of_transitions(); i++) {
5420 Map* target = transitions()->GetTarget(i); 5434 Map* target = transitions()->GetTarget(i);
5421 if (target->instance_descriptors() == instance_descriptors()) { 5435 if (target->instance_descriptors() == instance_descriptors()) {
5422 Name* key = transitions()->GetKey(i); 5436 Name* key = transitions()->GetKey(i);
5423 int new_target_index = transition_array->Search(key); 5437 int new_target_index;
5424 DCHECK(new_target_index != TransitionArray::kNotFound); 5438 if (TransitionArray::IsSpecialTransition(key)) {
5425 DCHECK(transition_array->GetTarget(new_target_index) == target); 5439 new_target_index = transition_array->SearchSpecial(Symbol::cast(key));
5440 } else {
5441 PropertyDetails details =
5442 TransitionArray::GetTargetDetails(key, target);
5443 new_target_index = transition_array->Search(details.type(), key,
5444 details.attributes());
5445 }
5446 DCHECK_NE(TransitionArray::kNotFound, new_target_index);
5447 DCHECK_EQ(target, transition_array->GetTarget(new_target_index));
5426 } 5448 }
5427 } 5449 }
5428 #endif 5450 #endif
5429 DCHECK(transitions() != transition_array); 5451 DCHECK(transitions() != transition_array);
5430 ZapTransitions(); 5452 ZapTransitions();
5431 } 5453 }
5432 5454
5433 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array); 5455 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array);
5434 CONDITIONAL_WRITE_BARRIER( 5456 CONDITIONAL_WRITE_BARRIER(
5435 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode); 5457 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode);
(...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after
7506 #undef READ_SHORT_FIELD 7528 #undef READ_SHORT_FIELD
7507 #undef WRITE_SHORT_FIELD 7529 #undef WRITE_SHORT_FIELD
7508 #undef READ_BYTE_FIELD 7530 #undef READ_BYTE_FIELD
7509 #undef WRITE_BYTE_FIELD 7531 #undef WRITE_BYTE_FIELD
7510 #undef NOBARRIER_READ_BYTE_FIELD 7532 #undef NOBARRIER_READ_BYTE_FIELD
7511 #undef NOBARRIER_WRITE_BYTE_FIELD 7533 #undef NOBARRIER_WRITE_BYTE_FIELD
7512 7534
7513 } } // namespace v8::internal 7535 } } // namespace v8::internal
7514 7536
7515 #endif // V8_OBJECTS_INL_H_ 7537 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698