Commit d2e54925 authored by ulan's avatar ulan Committed by Commit bot

Reland remaining parts of 'Use weak cells in map checks in polymorphic ICs'

BUG=v8:3663
LOG=N

Review URL: https://codereview.chromium.org/792543003

Cr-Commit-Position: refs/heads/master@{#25739}
parent 3834b784
......@@ -263,9 +263,7 @@ void StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget(Heap* heap,
// to be serialized.
if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub() &&
!target->is_call_stub() &&
(target->ic_state() == MEGAMORPHIC || target->ic_state() == GENERIC ||
target->ic_state() == POLYMORPHIC ||
(heap->flush_monomorphic_ics() && !target->is_weak_stub()) ||
((heap->flush_monomorphic_ics() && !target->is_weak_stub()) ||
heap->isolate()->serializer_enabled() ||
target->ic_age() != heap->global_ic_age() ||
target->is_invalidated_weak_stub())) {
......
......@@ -72,8 +72,8 @@ Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
Handle<Map> map = IC::TypeToMap(*type, isolate());
if (!map->is_deprecated()) {
number_of_handled_maps++;
__ mov(ip, Operand(map));
__ cmp(map_reg, ip);
Handle<WeakCell> cell = Map::WeakCellForMap(map);
__ CmpWeakValue(map_reg, cell, scratch2());
if (type->Is(HeapType::Number())) {
DCHECK(!number_case.is_unused());
__ bind(&number_case);
......@@ -100,16 +100,18 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
__ JumpIfSmi(receiver(), &miss);
int receiver_count = receiver_maps->length();
__ ldr(scratch1(), FieldMemOperand(receiver(), HeapObject::kMapOffset));
Register map_reg = scratch1();
__ ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset));
for (int i = 0; i < receiver_count; ++i) {
__ mov(ip, Operand(receiver_maps->at(i)));
__ cmp(scratch1(), ip);
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i));
__ CmpWeakValue(map_reg, cell, scratch2());
if (transitioned_maps->at(i).is_null()) {
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq);
} else {
Label next_map;
__ b(ne, &next_map);
__ mov(transition_map(), Operand(transitioned_maps->at(i)));
Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i));
__ LoadWeakValue(transition_map(), cell, &miss);
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, al);
__ bind(&next_map);
}
......
......@@ -71,8 +71,9 @@ Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
Handle<Map> map = IC::TypeToMap(*type, isolate());
if (!map->is_deprecated()) {
number_of_handled_maps++;
Handle<WeakCell> cell = Map::WeakCellForMap(map);
__ CmpWeakValue(map_reg, cell, scratch2());
Label try_next;
__ Cmp(map_reg, Operand(map));
__ B(ne, &try_next);
if (type->Is(HeapType::Number())) {
DCHECK(!number_case.is_unused());
......@@ -104,16 +105,18 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
__ JumpIfSmi(receiver(), &miss);
int receiver_count = receiver_maps->length();
__ Ldr(scratch1(), FieldMemOperand(receiver(), HeapObject::kMapOffset));
Register map_reg = scratch1();
__ Ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset));
for (int i = 0; i < receiver_count; i++) {
__ Cmp(scratch1(), Operand(receiver_maps->at(i)));
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i));
__ CmpWeakValue(map_reg, cell, scratch2());
Label skip;
__ B(&skip, ne);
if (!transitioned_maps->at(i).is_null()) {
// This argument is used by the handler stub. For example, see
// ElementsTransitionGenerator::GenerateMapChangeElementsTransition.
__ Mov(transition_map(), Operand(transitioned_maps->at(i)));
Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i));
__ LoadWeakValue(transition_map(), cell, &miss);
}
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET);
__ Bind(&skip);
......
......@@ -75,7 +75,8 @@ Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
Handle<Map> map = IC::TypeToMap(*type, isolate());
if (!map->is_deprecated()) {
number_of_handled_maps++;
__ cmp(map_reg, map);
Handle<WeakCell> cell = Map::WeakCellForMap(map);
__ CmpWeakValue(map_reg, cell, scratch2());
if (type->Is(HeapType::Number())) {
DCHECK(!number_case.is_unused());
__ bind(&number_case);
......@@ -99,16 +100,19 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
MapHandleList* receiver_maps, CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps) {
Label miss;
__ JumpIfSmi(receiver(), &miss, Label::kNear);
__ mov(scratch1(), FieldOperand(receiver(), HeapObject::kMapOffset));
__ JumpIfSmi(receiver(), &miss);
Register map_reg = scratch1();
__ mov(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset));
for (int i = 0; i < receiver_maps->length(); ++i) {
__ cmp(scratch1(), receiver_maps->at(i));
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i));
__ CmpWeakValue(map_reg, cell, scratch2());
if (transitioned_maps->at(i).is_null()) {
__ j(equal, handler_stubs->at(i));
} else {
Label next_map;
__ j(not_equal, &next_map, Label::kNear);
__ mov(transition_map(), Immediate(transitioned_maps->at(i)));
Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i));
__ LoadWeakValue(transition_map(), cell, &miss);
__ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
__ bind(&next_map);
}
......
......@@ -57,7 +57,8 @@ Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
number_of_handled_maps++;
// Check map and tail call if there's a match.
// Separate compare from branch, to provide path for above JumpIfSmi().
__ Subu(match, map_reg, Operand(map));
Handle<WeakCell> cell = Map::WeakCellForMap(map);
__ CmpWeakValue(match, map_reg, cell);
if (type->Is(HeapType::Number())) {
DCHECK(!number_case.is_unused());
__ bind(&number_case);
......@@ -85,15 +86,20 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
__ JumpIfSmi(receiver(), &miss);
int receiver_count = receiver_maps->length();
__ lw(scratch1(), FieldMemOperand(receiver(), HeapObject::kMapOffset));
Register map_reg = scratch1();
Register match = scratch2();
__ lw(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset));
for (int i = 0; i < receiver_count; ++i) {
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i));
__ CmpWeakValue(match, map_reg, cell);
if (transitioned_maps->at(i).is_null()) {
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq, scratch1(),
Operand(receiver_maps->at(i)));
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq, match,
Operand(zero_reg));
} else {
Label next_map;
__ Branch(&next_map, ne, scratch1(), Operand(receiver_maps->at(i)));
__ li(transition_map(), Operand(transitioned_maps->at(i)));
__ Branch(&next_map, ne, match, Operand(zero_reg));
Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i));
__ LoadWeakValue(transition_map(), cell, &miss);
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET);
__ bind(&next_map);
}
......
......@@ -57,7 +57,8 @@ Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
number_of_handled_maps++;
// Check map and tail call if there's a match.
// Separate compare from branch, to provide path for above JumpIfSmi().
__ Dsubu(match, map_reg, Operand(map));
Handle<WeakCell> cell = Map::WeakCellForMap(map);
__ CmpWeakValue(match, map_reg, cell);
if (type->Is(HeapType::Number())) {
DCHECK(!number_case.is_unused());
__ bind(&number_case);
......@@ -85,15 +86,20 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
__ JumpIfSmi(receiver(), &miss);
int receiver_count = receiver_maps->length();
__ ld(scratch1(), FieldMemOperand(receiver(), HeapObject::kMapOffset));
Register map_reg = scratch1();
Register match = scratch2();
__ ld(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset));
for (int i = 0; i < receiver_count; ++i) {
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i));
__ CmpWeakValue(match, map_reg, cell);
if (transitioned_maps->at(i).is_null()) {
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq, scratch1(),
Operand(receiver_maps->at(i)));
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq, match,
Operand(zero_reg));
} else {
Label next_map;
__ Branch(&next_map, ne, scratch1(), Operand(receiver_maps->at(i)));
__ li(transition_map(), Operand(transitioned_maps->at(i)));
__ Branch(&next_map, ne, match, Operand(zero_reg));
Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i));
__ LoadWeakValue(transition_map(), cell, &miss);
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET);
__ bind(&next_map);
}
......
......@@ -42,20 +42,22 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
MapHandleList* receiver_maps, CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps) {
Label miss;
__ JumpIfSmi(receiver(), &miss, Label::kNear);
__ JumpIfSmi(receiver(), &miss);
__ movp(scratch1(), FieldOperand(receiver(), HeapObject::kMapOffset));
Register map_reg = scratch1();
__ movp(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset));
int receiver_count = receiver_maps->length();
for (int i = 0; i < receiver_count; ++i) {
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i));
// Check map and tail call if there's a match
__ Cmp(scratch1(), receiver_maps->at(i));
__ CmpWeakValue(map_reg, cell, scratch2());
if (transitioned_maps->at(i).is_null()) {
__ j(equal, handler_stubs->at(i), RelocInfo::CODE_TARGET);
} else {
Label next_map;
__ j(not_equal, &next_map, Label::kNear);
__ Move(transition_map(), transitioned_maps->at(i),
RelocInfo::EMBEDDED_OBJECT);
Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i));
__ LoadWeakValue(transition_map(), cell, &miss);
__ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
__ bind(&next_map);
}
......@@ -109,8 +111,9 @@ Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
Handle<Map> map = IC::TypeToMap(*type, isolate());
if (!map->is_deprecated()) {
number_of_handled_maps++;
Handle<WeakCell> cell = Map::WeakCellForMap(map);
// Check map and tail call if there's a match
__ Cmp(map_reg, map);
__ CmpWeakValue(map_reg, cell, scratch2());
if (type->Is(HeapType::Number())) {
DCHECK(!number_case.is_unused());
__ bind(&number_case);
......
......@@ -75,7 +75,8 @@ Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
Handle<Map> map = IC::TypeToMap(*type, isolate());
if (!map->is_deprecated()) {
number_of_handled_maps++;
__ cmp(map_reg, map);
Handle<WeakCell> cell = Map::WeakCellForMap(map);
__ CmpWeakValue(map_reg, cell, scratch2());
if (type->Is(HeapType::Number())) {
DCHECK(!number_case.is_unused());
__ bind(&number_case);
......@@ -100,15 +101,18 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
MapHandleList* transitioned_maps) {
Label miss;
__ JumpIfSmi(receiver(), &miss, Label::kNear);
__ mov(scratch1(), FieldOperand(receiver(), HeapObject::kMapOffset));
Register map_reg = scratch1();
__ mov(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset));
for (int i = 0; i < receiver_maps->length(); ++i) {
__ cmp(scratch1(), receiver_maps->at(i));
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i));
__ CmpWeakValue(map_reg, cell, scratch2());
if (transitioned_maps->at(i).is_null()) {
__ j(equal, handler_stubs->at(i));
} else {
Label next_map;
__ j(not_equal, &next_map, Label::kNear);
__ mov(transition_map(), Immediate(transitioned_maps->at(i)));
Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i));
__ LoadWeakValue(transition_map(), cell, &miss);
__ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
__ bind(&next_map);
}
......
......@@ -78,14 +78,6 @@
'test-debug/RecursiveBreakpoints': [PASS, FLAKY],
'test-debug/RecursiveBreakpointsGlobal': [PASS, FLAKY],
# BUG(3629). Known memory leak.
'test-heap/WeakMapInPolymorphicStoreIC': [SKIP],
# BUG(3663).
'test-heap/WeakMapInPolymorphicLoadIC': [SKIP],
'test-heap/WeakMapInPolymorphicKeyedLoadIC': [SKIP],
'test-heap/WeakMapInPolymorphicKeyedStoreIC': [SKIP],
'test-heap/IncrementalMarkingPreservesPolymorphicIC': [SKIP],
##############################################################################
# TurboFan compiler failures.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment