Commit 7b43e11c authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: Reland [in-place weak refs] Add in-place weak references & migrate one WeakCell to it.

Port 88062a2c

Original Commit Message:

    Implement in-place weak reference handling in GC.

    Turn FeedbackVector::optimized_code_or_smi into an in-place weak reference (this
    is the only in-place weak reference at this point).

    (See bug for design doc.)

R=marja@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=v8:7308
LOG=N

Change-Id: I00c6aa7c08524b7769d3428d0c18ce334f35a722
Reviewed-on: https://chromium-review.googlesource.com/949368Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#51747}
parent 2ce122e3
...@@ -751,7 +751,7 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -751,7 +751,7 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm,
DCHECK( DCHECK(
!AreAliased(feedback_vector, r3, r4, r6, scratch1, scratch2, scratch3)); !AreAliased(feedback_vector, r3, r4, r6, scratch1, scratch2, scratch3));
Label optimized_code_slot_is_cell, fallthrough; Label optimized_code_slot_is_weak_ref, fallthrough;
Register closure = r4; Register closure = r4;
Register optimized_code_entry = scratch1; Register optimized_code_entry = scratch1;
...@@ -761,9 +761,9 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -761,9 +761,9 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm,
FieldMemOperand(feedback_vector, FeedbackVector::kOptimizedCodeOffset)); FieldMemOperand(feedback_vector, FeedbackVector::kOptimizedCodeOffset));
// Check if the code entry is a Smi. If yes, we interpret it as an // Check if the code entry is a Smi. If yes, we interpret it as an
// optimisation marker. Otherwise, interpret is as a weak cell to a code // optimisation marker. Otherwise, interpret it as a weak reference to a code
// object. // object.
__ JumpIfNotSmi(optimized_code_entry, &optimized_code_slot_is_cell); __ JumpIfNotSmi(optimized_code_entry, &optimized_code_slot_is_weak_ref);
{ {
// Optimized code slot is a Smi optimization marker. // Optimized code slot is a Smi optimization marker.
...@@ -798,12 +798,10 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -798,12 +798,10 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm,
} }
{ {
// Optimized code slot is a WeakCell. // Optimized code slot is a weak reference.
__ bind(&optimized_code_slot_is_cell); __ bind(&optimized_code_slot_is_weak_ref);
__ LoadP(optimized_code_entry, __ LoadWeakValue(optimized_code_entry, optimized_code_entry, &fallthrough);
FieldMemOperand(optimized_code_entry, WeakCell::kValueOffset));
__ JumpIfSmi(optimized_code_entry, &fallthrough);
// Check if the optimized code is marked for deopt. If it is, call the // Check if the optimized code is marked for deopt. If it is, call the
// runtime to clear it. // runtime to clear it.
......
...@@ -754,7 +754,7 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -754,7 +754,7 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm,
DCHECK( DCHECK(
!AreAliased(feedback_vector, r2, r3, r5, scratch1, scratch2, scratch3)); !AreAliased(feedback_vector, r2, r3, r5, scratch1, scratch2, scratch3));
Label optimized_code_slot_is_cell, fallthrough; Label optimized_code_slot_is_weak_ref, fallthrough;
Register closure = r3; Register closure = r3;
Register optimized_code_entry = scratch1; Register optimized_code_entry = scratch1;
...@@ -764,9 +764,9 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -764,9 +764,9 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm,
FieldMemOperand(feedback_vector, FeedbackVector::kOptimizedCodeOffset)); FieldMemOperand(feedback_vector, FeedbackVector::kOptimizedCodeOffset));
// Check if the code entry is a Smi. If yes, we interpret it as an // Check if the code entry is a Smi. If yes, we interpret it as an
// optimisation marker. Otherwise, interpret is as a weak cell to a code // optimisation marker. Otherwise, interpret it as a weak reference to a code
// object. // object.
__ JumpIfNotSmi(optimized_code_entry, &optimized_code_slot_is_cell); __ JumpIfNotSmi(optimized_code_entry, &optimized_code_slot_is_weak_ref);
{ {
// Optimized code slot is a Smi optimization marker. // Optimized code slot is a Smi optimization marker.
...@@ -801,12 +801,10 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -801,12 +801,10 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm,
} }
{ {
// Optimized code slot is a WeakCell. // Optimized code slot is a weak reference.
__ bind(&optimized_code_slot_is_cell); __ bind(&optimized_code_slot_is_weak_ref);
__ LoadP(optimized_code_entry, __ LoadWeakValue(optimized_code_entry, optimized_code_entry, &fallthrough);
FieldMemOperand(optimized_code_entry, WeakCell::kValueOffset));
__ JumpIfSmi(optimized_code_entry, &fallthrough);
// Check if the optimized code is marked for deopt. If it is, call the // Check if the optimized code is marked for deopt. If it is, call the
// runtime to clear it. // runtime to clear it.
......
...@@ -1632,6 +1632,15 @@ void MacroAssembler::JumpToInstructionStream(const InstructionStream* stream) { ...@@ -1632,6 +1632,15 @@ void MacroAssembler::JumpToInstructionStream(const InstructionStream* stream) {
Jump(kOffHeapTrampolineRegister); Jump(kOffHeapTrampolineRegister);
} }
void MacroAssembler::LoadWeakValue(Register out, Register in,
Label* target_if_cleared) {
cmpi(in, Operand(kClearedWeakHeapObject));
beq(target_if_cleared);
mov(r0, Operand(~kWeakHeapObjectMask));
and_(out, in, r0);
}
void MacroAssembler::IncrementCounter(StatsCounter* counter, int value, void MacroAssembler::IncrementCounter(StatsCounter* counter, int value,
Register scratch1, Register scratch2) { Register scratch1, Register scratch2) {
DCHECK_GT(value, 0); DCHECK_GT(value, 0);
......
...@@ -935,6 +935,10 @@ class MacroAssembler : public TurboAssembler { ...@@ -935,6 +935,10 @@ class MacroAssembler : public TurboAssembler {
// Generates a trampoline to jump to the off-heap instruction stream. // Generates a trampoline to jump to the off-heap instruction stream.
void JumpToInstructionStream(const InstructionStream* stream); void JumpToInstructionStream(const InstructionStream* stream);
// ---------------------------------------------------------------------------
// In-place weak references.
void LoadWeakValue(Register out, Register in, Label* target_if_cleared);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// StatsCounter support // StatsCounter support
......
...@@ -1544,6 +1544,14 @@ void MacroAssembler::JumpToInstructionStream(const InstructionStream* stream) { ...@@ -1544,6 +1544,14 @@ void MacroAssembler::JumpToInstructionStream(const InstructionStream* stream) {
Jump(kOffHeapTrampolineRegister); Jump(kOffHeapTrampolineRegister);
} }
void MacroAssembler::LoadWeakValue(Register out, Register in,
Label* target_if_cleared) {
CmpP(in, Operand(kClearedWeakHeapObject));
beq(target_if_cleared);
AndP(out, in, Operand(~kWeakHeapObjectMask));
}
void MacroAssembler::IncrementCounter(StatsCounter* counter, int value, void MacroAssembler::IncrementCounter(StatsCounter* counter, int value,
Register scratch1, Register scratch2) { Register scratch1, Register scratch2) {
DCHECK(value > 0 && is_int8(value)); DCHECK(value > 0 && is_int8(value));
......
...@@ -1108,6 +1108,10 @@ class MacroAssembler : public TurboAssembler { ...@@ -1108,6 +1108,10 @@ class MacroAssembler : public TurboAssembler {
void TryDoubleToInt32Exact(Register result, DoubleRegister double_input, void TryDoubleToInt32Exact(Register result, DoubleRegister double_input,
Register scratch, DoubleRegister double_scratch); Register scratch, DoubleRegister double_scratch);
// ---------------------------------------------------------------------------
// In-place weak references.
void LoadWeakValue(Register out, Register in, Label* target_if_cleared);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// StatsCounter support // StatsCounter support
......
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