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

Side by Side Diff: src/objects.cc

Issue 771033003: Revert of Use weak cells in map checks in polymorphic ICs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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.h ('k') | src/objects-inl.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 break; 1570 break;
1571 } 1571 }
1572 case PROPERTY_CELL_TYPE: { 1572 case PROPERTY_CELL_TYPE: {
1573 os << "PropertyCell for "; 1573 os << "PropertyCell for ";
1574 HeapStringAllocator allocator; 1574 HeapStringAllocator allocator;
1575 StringStream accumulator(&allocator); 1575 StringStream accumulator(&allocator);
1576 PropertyCell::cast(this)->value()->ShortPrint(&accumulator); 1576 PropertyCell::cast(this)->value()->ShortPrint(&accumulator);
1577 os << accumulator.ToCString().get(); 1577 os << accumulator.ToCString().get();
1578 break; 1578 break;
1579 } 1579 }
1580 case WEAK_CELL_TYPE: {
1581 os << "WeakCell for ";
1582 HeapStringAllocator allocator;
1583 StringStream accumulator(&allocator);
1584 WeakCell::cast(this)->value()->ShortPrint(&accumulator);
1585 os << accumulator.ToCString().get();
1586 break;
1587 }
1588 default: 1580 default:
1589 os << "<Other heap object (" << map()->instance_type() << ")>"; 1581 os << "<Other heap object (" << map()->instance_type() << ")>";
1590 break; 1582 break;
1591 } 1583 }
1592 } 1584 }
1593 1585
1594 1586
1595 void HeapObject::Iterate(ObjectVisitor* v) { 1587 void HeapObject::Iterate(ObjectVisitor* v) {
1596 // Handle header 1588 // Handle header
1597 IteratePointer(v, kMapOffset); 1589 IteratePointer(v, kMapOffset);
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after
3426 } 3418 }
3427 3419
3428 if (isolate->initial_object_prototype()->map() == this) { 3420 if (isolate->initial_object_prototype()->map() == this) {
3429 return true; 3421 return true;
3430 } 3422 }
3431 3423
3432 return false; 3424 return false;
3433 } 3425 }
3434 3426
3435 3427
3436 Handle<WeakCell> Map::WeakCellForMap(Handle<Map> map) {
3437 Isolate* isolate = map->GetIsolate();
3438 if (map->code_cache()->IsFixedArray()) {
3439 return isolate->factory()->NewWeakCell(map);
3440 }
3441 Handle<CodeCache> code_cache(CodeCache::cast(map->code_cache()), isolate);
3442 if (code_cache->weak_cell_cache()->IsWeakCell()) {
3443 return Handle<WeakCell>(WeakCell::cast(code_cache->weak_cell_cache()));
3444 }
3445 Handle<WeakCell> weak_cell = isolate->factory()->NewWeakCell(map);
3446 code_cache->set_weak_cell_cache(*weak_cell);
3447 return weak_cell;
3448 }
3449
3450
3451 static Handle<Map> AddMissingElementsTransitions(Handle<Map> map, 3428 static Handle<Map> AddMissingElementsTransitions(Handle<Map> map,
3452 ElementsKind to_kind) { 3429 ElementsKind to_kind) {
3453 DCHECK(IsTransitionElementsKind(map->elements_kind())); 3430 DCHECK(IsTransitionElementsKind(map->elements_kind()));
3454 3431
3455 Handle<Map> current_map = map; 3432 Handle<Map> current_map = map;
3456 3433
3457 ElementsKind kind = map->elements_kind(); 3434 ElementsKind kind = map->elements_kind();
3458 if (!map->is_prototype_map()) { 3435 if (!map->is_prototype_map()) {
3459 while (kind != to_kind && !IsTerminalElementsKind(kind)) { 3436 while (kind != to_kind && !IsTerminalElementsKind(kind)) {
3460 kind = GetNextTransitionElementsKind(kind); 3437 kind = GetNextTransitionElementsKind(kind);
(...skipping 7122 matching lines...) Expand 10 before | Expand all | Expand 10 after
10583 } 10560 }
10584 10561
10585 10562
10586 Object* Code::FindNthObject(int n, Map* match_map) { 10563 Object* Code::FindNthObject(int n, Map* match_map) {
10587 DCHECK(is_inline_cache_stub()); 10564 DCHECK(is_inline_cache_stub());
10588 DisallowHeapAllocation no_allocation; 10565 DisallowHeapAllocation no_allocation;
10589 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10566 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10590 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10567 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10591 RelocInfo* info = it.rinfo(); 10568 RelocInfo* info = it.rinfo();
10592 Object* object = info->target_object(); 10569 Object* object = info->target_object();
10593 if (object->IsWeakCell()) object = WeakCell::cast(object)->value();
10594 if (object->IsHeapObject()) { 10570 if (object->IsHeapObject()) {
10595 if (HeapObject::cast(object)->map() == match_map) { 10571 if (HeapObject::cast(object)->map() == match_map) {
10596 if (--n == 0) return object; 10572 if (--n == 0) return object;
10597 } 10573 }
10598 } 10574 }
10599 } 10575 }
10600 return NULL; 10576 return NULL;
10601 } 10577 }
10602 10578
10603 10579
(...skipping 12 matching lines...) Expand all
10616 void Code::FindAndReplace(const FindAndReplacePattern& pattern) { 10592 void Code::FindAndReplace(const FindAndReplacePattern& pattern) {
10617 DCHECK(is_inline_cache_stub() || is_handler()); 10593 DCHECK(is_inline_cache_stub() || is_handler());
10618 DisallowHeapAllocation no_allocation; 10594 DisallowHeapAllocation no_allocation;
10619 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10595 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10620 STATIC_ASSERT(FindAndReplacePattern::kMaxCount < 32); 10596 STATIC_ASSERT(FindAndReplacePattern::kMaxCount < 32);
10621 int current_pattern = 0; 10597 int current_pattern = 0;
10622 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10598 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10623 RelocInfo* info = it.rinfo(); 10599 RelocInfo* info = it.rinfo();
10624 Object* object = info->target_object(); 10600 Object* object = info->target_object();
10625 if (object->IsHeapObject()) { 10601 if (object->IsHeapObject()) {
10626 DCHECK(!object->IsWeakCell());
10627 Map* map = HeapObject::cast(object)->map(); 10602 Map* map = HeapObject::cast(object)->map();
10628 if (map == *pattern.find_[current_pattern]) { 10603 if (map == *pattern.find_[current_pattern]) {
10629 info->set_target_object(*pattern.replace_[current_pattern]); 10604 info->set_target_object(*pattern.replace_[current_pattern]);
10630 if (++current_pattern == pattern.count_) return; 10605 if (++current_pattern == pattern.count_) return;
10631 } 10606 }
10632 } 10607 }
10633 } 10608 }
10634 UNREACHABLE(); 10609 UNREACHABLE();
10635 } 10610 }
10636 10611
10637 10612
10638 void Code::FindAllMaps(MapHandleList* maps) { 10613 void Code::FindAllMaps(MapHandleList* maps) {
10639 DCHECK(is_inline_cache_stub()); 10614 DCHECK(is_inline_cache_stub());
10640 DisallowHeapAllocation no_allocation; 10615 DisallowHeapAllocation no_allocation;
10641 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10616 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10642 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10617 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10643 RelocInfo* info = it.rinfo(); 10618 RelocInfo* info = it.rinfo();
10644 Object* object = info->target_object(); 10619 Object* object = info->target_object();
10645 if (object->IsWeakCell()) object = WeakCell::cast(object)->value();
10646 if (object->IsMap()) maps->Add(handle(Map::cast(object))); 10620 if (object->IsMap()) maps->Add(handle(Map::cast(object)));
10647 } 10621 }
10648 } 10622 }
10649 10623
10650 10624
10651 Code* Code::FindFirstHandler() { 10625 Code* Code::FindFirstHandler() {
10652 DCHECK(is_inline_cache_stub()); 10626 DCHECK(is_inline_cache_stub());
10653 DisallowHeapAllocation no_allocation; 10627 DisallowHeapAllocation no_allocation;
10654 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | 10628 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
10655 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10656 bool skip_next_handler = false;
10657 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10629 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10658 RelocInfo* info = it.rinfo(); 10630 RelocInfo* info = it.rinfo();
10659 if (info->rmode() == RelocInfo::EMBEDDED_OBJECT) { 10631 Code* code = Code::GetCodeFromTargetAddress(info->target_address());
10660 Object* obj = info->target_object(); 10632 if (code->kind() == Code::HANDLER) return code;
10661 skip_next_handler |= obj->IsWeakCell() && WeakCell::cast(obj)->cleared();
10662 } else {
10663 Code* code = Code::GetCodeFromTargetAddress(info->target_address());
10664 if (code->kind() == Code::HANDLER) {
10665 if (!skip_next_handler) return code;
10666 skip_next_handler = false;
10667 }
10668 }
10669 } 10633 }
10670 return NULL; 10634 return NULL;
10671 } 10635 }
10672 10636
10673 10637
10674 bool Code::FindHandlers(CodeHandleList* code_list, int length) { 10638 bool Code::FindHandlers(CodeHandleList* code_list, int length) {
10675 DCHECK(is_inline_cache_stub()); 10639 DCHECK(is_inline_cache_stub());
10676 DisallowHeapAllocation no_allocation; 10640 DisallowHeapAllocation no_allocation;
10677 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | 10641 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
10678 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10679 bool skip_next_handler = false;
10680 int i = 0; 10642 int i = 0;
10681 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10643 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10682 if (i == length) return true; 10644 if (i == length) return true;
10683 RelocInfo* info = it.rinfo(); 10645 RelocInfo* info = it.rinfo();
10684 if (info->rmode() == RelocInfo::EMBEDDED_OBJECT) { 10646 Code* code = Code::GetCodeFromTargetAddress(info->target_address());
10685 Object* obj = info->target_object(); 10647 // IC stubs with handlers never contain non-handler code objects before
10686 skip_next_handler |= obj->IsWeakCell() && WeakCell::cast(obj)->cleared(); 10648 // handler targets.
10687 } else { 10649 if (code->kind() != Code::HANDLER) break;
10688 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); 10650 code_list->Add(Handle<Code>(code));
10689 // IC stubs with handlers never contain non-handler code objects before 10651 i++;
10690 // handler targets.
10691 if (code->kind() != Code::HANDLER) break;
10692 if (!skip_next_handler) {
10693 code_list->Add(Handle<Code>(code));
10694 i++;
10695 }
10696 skip_next_handler = false;
10697 }
10698 } 10652 }
10699 return i == length; 10653 return i == length;
10700 } 10654 }
10701 10655
10702 10656
10703 MaybeHandle<Code> Code::FindHandlerForMap(Map* map) { 10657 MaybeHandle<Code> Code::FindHandlerForMap(Map* map) {
10704 DCHECK(is_inline_cache_stub()); 10658 DCHECK(is_inline_cache_stub());
10705 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | 10659 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
10706 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10660 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10707 bool return_next = false; 10661 bool return_next = false;
10708 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10662 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10709 RelocInfo* info = it.rinfo(); 10663 RelocInfo* info = it.rinfo();
10710 if (info->rmode() == RelocInfo::EMBEDDED_OBJECT) { 10664 if (info->rmode() == RelocInfo::EMBEDDED_OBJECT) {
10711 Object* object = info->target_object(); 10665 Object* object = info->target_object();
10712 if (object->IsWeakCell()) object = WeakCell::cast(object)->value();
10713 if (object == map) return_next = true; 10666 if (object == map) return_next = true;
10714 } else if (return_next) { 10667 } else if (return_next) {
10715 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); 10668 Code* code = Code::GetCodeFromTargetAddress(info->target_address());
10716 DCHECK(code->kind() == Code::HANDLER); 10669 DCHECK(code->kind() == Code::HANDLER);
10717 return handle(code); 10670 return handle(code);
10718 } 10671 }
10719 } 10672 }
10720 return MaybeHandle<Code>(); 10673 return MaybeHandle<Code>();
10721 } 10674 }
10722 10675
(...skipping 6173 matching lines...) Expand 10 before | Expand all | Expand 10 after
16896 Handle<DependentCode> codes = 16849 Handle<DependentCode> codes =
16897 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16850 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16898 DependentCode::kPropertyCellChangedGroup, 16851 DependentCode::kPropertyCellChangedGroup,
16899 info->object_wrapper()); 16852 info->object_wrapper());
16900 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16853 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16901 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16854 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16902 cell, info->zone()); 16855 cell, info->zone());
16903 } 16856 }
16904 16857
16905 } } // namespace v8::internal 16858 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698