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

Side by Side Diff: src/objects.cc

Issue 753993003: 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
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 3399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3410 } 3410 }
3411 3411
3412 if (isolate->initial_object_prototype()->map() == this) { 3412 if (isolate->initial_object_prototype()->map() == this) {
3413 return true; 3413 return true;
3414 } 3414 }
3415 3415
3416 return false; 3416 return false;
3417 } 3417 }
3418 3418
3419 3419
3420 Handle<WeakCell> Map::WeakCellForMap(Handle<Map> map) {
3421 // TODO(ulan): Cache the weak cell and avoid many allocations.
3422 return map->GetIsolate()->factory()->NewWeakCell(map);
3423 }
3424
3425
3420 static Handle<Map> AddMissingElementsTransitions(Handle<Map> map, 3426 static Handle<Map> AddMissingElementsTransitions(Handle<Map> map,
3421 ElementsKind to_kind) { 3427 ElementsKind to_kind) {
3422 DCHECK(IsTransitionElementsKind(map->elements_kind())); 3428 DCHECK(IsTransitionElementsKind(map->elements_kind()));
3423 3429
3424 Handle<Map> current_map = map; 3430 Handle<Map> current_map = map;
3425 3431
3426 ElementsKind kind = map->elements_kind(); 3432 ElementsKind kind = map->elements_kind();
3427 if (!map->is_prototype_map()) { 3433 if (!map->is_prototype_map()) {
3428 while (kind != to_kind && !IsTerminalElementsKind(kind)) { 3434 while (kind != to_kind && !IsTerminalElementsKind(kind)) {
3429 kind = GetNextTransitionElementsKind(kind); 3435 kind = GetNextTransitionElementsKind(kind);
(...skipping 7104 matching lines...) Expand 10 before | Expand all | Expand 10 after
10534 } 10540 }
10535 10541
10536 10542
10537 Object* Code::FindNthObject(int n, Map* match_map) { 10543 Object* Code::FindNthObject(int n, Map* match_map) {
10538 DCHECK(is_inline_cache_stub()); 10544 DCHECK(is_inline_cache_stub());
10539 DisallowHeapAllocation no_allocation; 10545 DisallowHeapAllocation no_allocation;
10540 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10546 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10541 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10547 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10542 RelocInfo* info = it.rinfo(); 10548 RelocInfo* info = it.rinfo();
10543 Object* object = info->target_object(); 10549 Object* object = info->target_object();
10550 if (object->IsWeakCell()) object = WeakCell::cast(object)->value();
10544 if (object->IsHeapObject()) { 10551 if (object->IsHeapObject()) {
10545 if (HeapObject::cast(object)->map() == match_map) { 10552 if (HeapObject::cast(object)->map() == match_map) {
10546 if (--n == 0) return object; 10553 if (--n == 0) return object;
10547 } 10554 }
10548 } 10555 }
10549 } 10556 }
10550 return NULL; 10557 return NULL;
10551 } 10558 }
10552 10559
10553 10560
(...skipping 12 matching lines...) Expand all
10566 void Code::FindAndReplace(const FindAndReplacePattern& pattern) { 10573 void Code::FindAndReplace(const FindAndReplacePattern& pattern) {
10567 DCHECK(is_inline_cache_stub() || is_handler()); 10574 DCHECK(is_inline_cache_stub() || is_handler());
10568 DisallowHeapAllocation no_allocation; 10575 DisallowHeapAllocation no_allocation;
10569 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10576 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10570 STATIC_ASSERT(FindAndReplacePattern::kMaxCount < 32); 10577 STATIC_ASSERT(FindAndReplacePattern::kMaxCount < 32);
10571 int current_pattern = 0; 10578 int current_pattern = 0;
10572 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10579 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10573 RelocInfo* info = it.rinfo(); 10580 RelocInfo* info = it.rinfo();
10574 Object* object = info->target_object(); 10581 Object* object = info->target_object();
10575 if (object->IsHeapObject()) { 10582 if (object->IsHeapObject()) {
10583 DCHECK(!object->IsWeakCell());
10576 Map* map = HeapObject::cast(object)->map(); 10584 Map* map = HeapObject::cast(object)->map();
10577 if (map == *pattern.find_[current_pattern]) { 10585 if (map == *pattern.find_[current_pattern]) {
10578 info->set_target_object(*pattern.replace_[current_pattern]); 10586 info->set_target_object(*pattern.replace_[current_pattern]);
10579 if (++current_pattern == pattern.count_) return; 10587 if (++current_pattern == pattern.count_) return;
10580 } 10588 }
10581 } 10589 }
10582 } 10590 }
10583 UNREACHABLE(); 10591 UNREACHABLE();
10584 } 10592 }
10585 10593
10586 10594
10587 void Code::FindAllMaps(MapHandleList* maps) { 10595 void Code::FindAllMaps(MapHandleList* maps) {
10588 DCHECK(is_inline_cache_stub()); 10596 DCHECK(is_inline_cache_stub());
10589 DisallowHeapAllocation no_allocation; 10597 DisallowHeapAllocation no_allocation;
10590 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10598 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10591 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10599 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10592 RelocInfo* info = it.rinfo(); 10600 RelocInfo* info = it.rinfo();
10593 Object* object = info->target_object(); 10601 Object* object = info->target_object();
10602 if (object->IsWeakCell()) object = WeakCell::cast(object)->value();
10594 if (object->IsMap()) maps->Add(handle(Map::cast(object))); 10603 if (object->IsMap()) maps->Add(handle(Map::cast(object)));
10595 } 10604 }
10596 } 10605 }
10597 10606
10598 10607
10599 Code* Code::FindFirstHandler() { 10608 Code* Code::FindFirstHandler() {
10600 DCHECK(is_inline_cache_stub()); 10609 DCHECK(is_inline_cache_stub());
10601 DisallowHeapAllocation no_allocation; 10610 DisallowHeapAllocation no_allocation;
10602 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); 10611 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
10603 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10612 for (RelocIterator it(this, mask); !it.done(); it.next()) {
(...skipping 26 matching lines...) Expand all
10630 10639
10631 MaybeHandle<Code> Code::FindHandlerForMap(Map* map) { 10640 MaybeHandle<Code> Code::FindHandlerForMap(Map* map) {
10632 DCHECK(is_inline_cache_stub()); 10641 DCHECK(is_inline_cache_stub());
10633 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | 10642 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
10634 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10643 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10635 bool return_next = false; 10644 bool return_next = false;
10636 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10645 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10637 RelocInfo* info = it.rinfo(); 10646 RelocInfo* info = it.rinfo();
10638 if (info->rmode() == RelocInfo::EMBEDDED_OBJECT) { 10647 if (info->rmode() == RelocInfo::EMBEDDED_OBJECT) {
10639 Object* object = info->target_object(); 10648 Object* object = info->target_object();
10649 if (object->IsWeakCell()) object = WeakCell::cast(object)->value();
10640 if (object == map) return_next = true; 10650 if (object == map) return_next = true;
10641 } else if (return_next) { 10651 } else if (return_next) {
10642 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); 10652 Code* code = Code::GetCodeFromTargetAddress(info->target_address());
10643 DCHECK(code->kind() == Code::HANDLER); 10653 DCHECK(code->kind() == Code::HANDLER);
10644 return handle(code); 10654 return handle(code);
10645 } 10655 }
10646 } 10656 }
10647 return MaybeHandle<Code>(); 10657 return MaybeHandle<Code>();
10648 } 10658 }
10649 10659
(...skipping 6175 matching lines...) Expand 10 before | Expand all | Expand 10 after
16825 Handle<DependentCode> codes = 16835 Handle<DependentCode> codes =
16826 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16836 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16827 DependentCode::kPropertyCellChangedGroup, 16837 DependentCode::kPropertyCellChangedGroup,
16828 info->object_wrapper()); 16838 info->object_wrapper());
16829 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16839 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16830 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16840 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16831 cell, info->zone()); 16841 cell, info->zone());
16832 } 16842 }
16833 16843
16834 } } // namespace v8::internal 16844 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698