Skip to content

Commit

Permalink
add encode_heap_oop_not_null for riscv
Browse files Browse the repository at this point in the history
  • Loading branch information
feilongjiang committed Jun 29, 2024
1 parent bb18498 commit acc04b1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
47 changes: 46 additions & 1 deletion src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, 2024, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -2495,6 +2495,51 @@ void MacroAssembler::encode_heap_oop(Register d, Register s) {
}
}

void MacroAssembler::encode_heap_oop_not_null(Register r) {
#ifdef ASSERT
if (CheckCompressedOops) {
Label ok;
bnez(r, ok);
stop("null oop passed to encode_heap_oop_not_null");
bind(ok);
}
#endif
verify_oop_msg(r, "broken oop in encode_heap_oop_not_null");
if (CompressedOops::base() != nullptr) {
sub(r, r, xheapbase);
}
if (CompressedOops::shift() != 0) {
assert(LogMinObjAlignmentInBytes == CompressedOops::shift(), "decode alg wrong");
srli(r, r, LogMinObjAlignmentInBytes);
}
}

void MacroAssembler::encode_heap_oop_not_null(Register dst, Register src) {
#ifdef ASSERT
if (CheckCompressedOops) {
Label ok;
bnez(src, ok);
stop("null oop passed to encode_heap_oop_not_null2");
bind(ok);
}
#endif
verify_oop_msg(src, "broken oop in encode_heap_oop_not_null2");

Register data = src;
if (CompressedOops::base() != nullptr) {
sub(dst, src, xheapbase);
data = dst;
}
if (CompressedOops::shift() != 0) {
assert(LogMinObjAlignmentInBytes == CompressedOops::shift(), "decode alg wrong");
srli(dst, data, LogMinObjAlignmentInBytes);
data = dst;
}
if (data == src) {
mv(dst, src);
}
}

void MacroAssembler::load_klass(Register dst, Register src, Register tmp) {
assert_different_registers(dst, tmp);
assert_different_registers(src, tmp);
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, 2024, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -206,6 +206,8 @@ class MacroAssembler: public Assembler {
void decode_heap_oop_not_null(Register dst, Register src);
void decode_heap_oop(Register d, Register s);
void decode_heap_oop(Register r) { decode_heap_oop(r, r); }
void encode_heap_oop_not_null(Register r);
void encode_heap_oop_not_null(Register dst, Register src);
void encode_heap_oop(Register d, Register s);
void encode_heap_oop(Register r) { encode_heap_oop(r, r); };
void load_heap_oop(Register dst, Address src, Register tmp1,
Expand Down
14 changes: 13 additions & 1 deletion src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
// Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
// Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
// Copyright (c) 2020, 2024, Huawei Technologies Co., Ltd. All rights reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -8404,6 +8404,7 @@ instruct round_float_reg(iRegINoSp dst, fRegF src, fRegF ftmp) %{

// Convert oop pointer into compressed form
instruct encodeHeapOop(iRegNNoSp dst, iRegP src) %{
predicate(n->bottom_type()->make_ptr()->ptr() != TypePtr::NotNull);
match(Set dst (EncodeP src));
ins_cost(ALU_COST);
format %{ "encode_heap_oop $dst, $src\t#@encodeHeapOop" %}
Expand All @@ -8415,6 +8416,17 @@ instruct encodeHeapOop(iRegNNoSp dst, iRegP src) %{
ins_pipe(pipe_class_default);
%}

instruct encodeHeapOop_not_null(iRegNNoSp dst, iRegP src) {
predicate(n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull);
match(Set dst (EncodeP src));
ins_cost(ALU_COST);
format %{ "encode_heap_oop_not_null $dst, $src\t#@encodeHeapOop_not_null" %}
ins_encode %{
__ encode_heap_oop_not_null($dst$$Register, $src$$Register);
%}
ins_pipe(pipe_class_default);
}

instruct decodeHeapOop(iRegPNoSp dst, iRegN src) %{
predicate(n->bottom_type()->is_ptr()->ptr() != TypePtr::NotNull &&
n->bottom_type()->is_ptr()->ptr() != TypePtr::Constant);
Expand Down

0 comments on commit acc04b1

Please sign in to comment.