Skip to content

Commit 5f16b76

Browse files
luyahankxxt
andcommitted
deps: V8: backport bbaae8e36164
Original commit message: Reland "[riscv] Fix Check failed in bind_to" This is a reland of commit fdb5de2c741658e94944f2ec1218530e98601c23 Original change's description: > [riscv] Fix Check failed in bind_to > > The trampoline should be emitted before the constant pool. > > Bug: 420232092 > > Change-Id: I3a909b122607e37aca9d8765f28810ec74d5dc0b > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6578135 > Auto-Submit: Yahan Lu (LuYahan) <yahan@iscas.ac.cn> > Reviewed-by: Ji Qiu <qiuji@iscas.ac.cn> > Commit-Queue: Ji Qiu <qiuji@iscas.ac.cn> > Cr-Commit-Position: refs/heads/main@{#100480} Bug: 420232092 Change-Id: I1fac1ed8c349383ef4510abea338b3d695ed57ab Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6595668 Commit-Queue: Ji Qiu <qiuji@iscas.ac.cn> Reviewed-by: Ji Qiu <qiuji@iscas.ac.cn> Cr-Commit-Position: refs/heads/main@{#100745} Refs: v8/v8@bbaae8e Co-authored-by: kxxt <rsworktech@outlook.com>
1 parent 4993bdc commit 5f16b76

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.32',
41+
'v8_embedder_string': '-node.33',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/codegen/riscv/assembler-riscv.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,8 @@ void Assembler::bind_to(Label* L, int pos) {
720720
trampoline_pos = get_trampoline_entry(fixup_pos);
721721
CHECK_NE(trampoline_pos, kInvalidSlotPos);
722722
}
723-
CHECK((trampoline_pos - fixup_pos) <= kMaxBranchOffset);
724723
DEBUG_PRINTF("\t\ttrampolining: %d\n", trampoline_pos);
724+
CHECK((trampoline_pos - fixup_pos) <= kMaxBranchOffset);
725725
target_at_put(fixup_pos, trampoline_pos, false);
726726
fixup_pos = trampoline_pos;
727727
}
@@ -1486,6 +1486,7 @@ void Assembler::BlockTrampolinePoolFor(int instructions) {
14861486
}
14871487

14881488
void Assembler::CheckTrampolinePool() {
1489+
if (trampoline_emitted_) return;
14891490
// Some small sequences of instructions must not be broken up by the
14901491
// insertion of a trampoline pool; such sequences are protected by setting
14911492
// either trampoline_pool_blocked_nesting_ or no_trampoline_pool_before_,
@@ -1507,7 +1508,6 @@ void Assembler::CheckTrampolinePool() {
15071508
return;
15081509
}
15091510

1510-
DCHECK(!trampoline_emitted_);
15111511
DCHECK_GE(unbound_labels_count_, 0);
15121512
if (unbound_labels_count_ > 0) {
15131513
// First we emit jump, then we emit trampoline pool.

deps/v8/src/codegen/riscv/assembler-riscv.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase,
303303
// See Assembler::CheckConstPool for more info.
304304
void EmitPoolGuard();
305305

306+
void FinishCode() { ForceConstantPoolEmissionWithoutJump(); }
307+
306308
#if defined(V8_TARGET_ARCH_RISCV64)
307309
static void set_target_value_at(
308310
Address pc, uint64_t target,
@@ -617,6 +619,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase,
617619
}
618620
}
619621

622+
inline int next_buffer_check() { return next_buffer_check_; }
623+
620624
friend class VectorUnit;
621625
class VectorUnit {
622626
public:
@@ -728,16 +732,19 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase,
728732

729733
// Block the emission of the trampoline pool before pc_offset.
730734
void BlockTrampolinePoolBefore(int pc_offset) {
731-
if (no_trampoline_pool_before_ < pc_offset)
735+
if (no_trampoline_pool_before_ < pc_offset) {
736+
DEBUG_PRINTF("\tBlockTrampolinePoolBefore %d\n", pc_offset);
732737
no_trampoline_pool_before_ = pc_offset;
738+
}
733739
}
734740

735741
void StartBlockTrampolinePool() {
736-
DEBUG_PRINTF("\tStartBlockTrampolinePool\n");
742+
DEBUG_PRINTF("\tStartBlockTrampolinePool %d\n", pc_offset());
737743
trampoline_pool_blocked_nesting_++;
738744
}
739745

740746
void EndBlockTrampolinePool() {
747+
DEBUG_PRINTF("\tEndBlockTrampolinePool\n");
741748
trampoline_pool_blocked_nesting_--;
742749
DEBUG_PRINTF("\ttrampoline_pool_blocked_nesting:%d\n",
743750
trampoline_pool_blocked_nesting_);
@@ -767,6 +774,10 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase,
767774

768775
bool is_buffer_growth_blocked() const { return block_buffer_growth_; }
769776

777+
inline int ConstpoolComputesize() {
778+
return constpool_.ComputeSize(Jump::kOmitted, Alignment::kOmitted);
779+
}
780+
770781
private:
771782
// Avoid overflows for displacements etc.
772783
static const int kMaximalBufferSize = 512 * MB;

deps/v8/src/codegen/riscv/macro-assembler-riscv.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4926,11 +4926,22 @@ void MacroAssembler::LoadRootRegisterOffset(Register destination,
49264926

49274927
void MacroAssembler::Jump(Register target, Condition cond, Register rs,
49284928
const Operand& rt) {
4929-
BlockTrampolinePoolScope block_trampoline_pool(this);
49304929
if (cond == cc_always) {
49314930
jr(target);
4931+
DEBUG_PRINTF("\tCheckTrampolinePool pc_offset:%d %d\n", pc_offset(),
4932+
next_buffer_check() - ConstpoolComputesize());
4933+
if (!is_trampoline_emitted() && v8_flags.debug_code &&
4934+
pc_offset() >= (next_buffer_check() - ConstpoolComputesize())) {
4935+
// Debug mode will emit more instrs than Release mode.
4936+
// so we need to check trampoline pool before Constant pool.
4937+
// Here need to emit trampoline first.
4938+
// Jump(ra, al) will block trampoline pool for 1 instr.
4939+
nop();
4940+
CheckTrampolinePool();
4941+
}
49324942
ForceConstantPoolEmissionWithoutJump();
49334943
} else {
4944+
BlockTrampolinePoolScope block_trampoline_pool(this);
49344945
BRANCH_ARGS_CHECK(cond, rs, rt);
49354946
Branch(kInstrSize * 2, NegateCondition(cond), rs, rt);
49364947
jr(target);
@@ -5342,9 +5353,6 @@ void MacroAssembler::StoreReturnAddressAndCall(Register target) {
53425353

53435354
void MacroAssembler::Ret(Condition cond, Register rs, const Operand& rt) {
53445355
Jump(ra, cond, rs, rt);
5345-
if (cond == al) {
5346-
ForceConstantPoolEmissionWithoutJump();
5347-
}
53485356
}
53495357

53505358
void MacroAssembler::BranchLong(Label* L) {

0 commit comments

Comments
 (0)