-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8360000: RISC-V: implement aot #26101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
17d1b1e
bd3e9dd
c7da8c5
4b01574
fd5ee8d
3ed885a
db94225
749350d
c6eeb50
ea2138e
8a1afcf
5a9a0a4
b70493e
04e8d70
bc05a32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
|
||
#include "asm/assembler.hpp" | ||
#include "asm/assembler.inline.hpp" | ||
#include "code/aotCodeCache.hpp" | ||
#include "code/compiledIC.hpp" | ||
#include "compiler/disassembler.hpp" | ||
#include "gc/shared/barrierSet.hpp" | ||
|
@@ -758,9 +759,13 @@ void MacroAssembler::resolve_global_jobject(Register value, Register tmp1, Regis | |
} | ||
|
||
void MacroAssembler::stop(const char* msg) { | ||
BLOCK_COMMENT(msg); | ||
// Skip AOT caching C strings in scratch buffer. | ||
const char* str = (code_section()->scratch_emit()) ? msg : AOTCodeCache::add_C_string(msg); | ||
BLOCK_COMMENT(str); | ||
// load msg into c_rarg0 so we can access it from the signal handler | ||
// ExternalAddress enables saving and restoring via the code cache | ||
la(c_rarg0, ExternalAddress((address) str)); | ||
illegal_instruction(Assembler::csr::time); | ||
emit_int64((uintptr_t)msg); | ||
} | ||
|
||
void MacroAssembler::unimplemented(const char* what) { | ||
|
@@ -790,10 +795,9 @@ void MacroAssembler::emit_static_call_stub() { | |
void MacroAssembler::call_VM_leaf_base(address entry_point, | ||
int number_of_arguments, | ||
Label *retaddr) { | ||
int32_t offset = 0; | ||
push_reg(RegSet::of(t1, xmethod), sp); // push << t1 & xmethod >> to sp | ||
movptr(t1, entry_point, offset, t0); | ||
jalr(t1, offset); | ||
movptr(t1, RuntimeAddress(entry_point), t0); | ||
jalr(t1); | ||
if (retaddr != nullptr) { | ||
bind(*retaddr); | ||
} | ||
|
@@ -3395,6 +3399,19 @@ void MacroAssembler::store_klass_gap(Register dst, Register src) { | |
} | ||
} | ||
|
||
void MacroAssembler::decode_klass_not_null_for_aot(Register dst, Register src, Register tmp) { | ||
// we have to load the klass base from the AOT constants area but | ||
// not the shift because it is not allowed to change | ||
int shift = CompressedKlassPointers::shift(); | ||
assert(shift >= 0 && shift <= CompressedKlassPointers::max_shift(), "unexpected compressed klass shift!"); | ||
assert_different_registers(src, tmp); | ||
la(tmp, ExternalAddress(CompressedKlassPointers::base_addr())); | ||
ld(tmp, tmp); | ||
Register t = src == dst ? dst : t0; | ||
assert_different_registers(t, tmp); | ||
shadd(dst, src, tmp, t, shift); | ||
} | ||
|
||
void MacroAssembler::decode_klass_not_null(Register r, Register tmp) { | ||
assert_different_registers(r, tmp); | ||
decode_klass_not_null(r, r, tmp); | ||
|
@@ -3403,6 +3420,11 @@ void MacroAssembler::decode_klass_not_null(Register r, Register tmp) { | |
void MacroAssembler::decode_klass_not_null(Register dst, Register src, Register tmp) { | ||
assert(UseCompressedClassPointers, "should only be used for compressed headers"); | ||
|
||
if (AOTCodeCache::is_on_for_dump()) { | ||
decode_klass_not_null_for_aot(dst, src, tmp); | ||
return; | ||
} | ||
|
||
if (CompressedKlassPointers::base() == nullptr) { | ||
if (CompressedKlassPointers::shift() != 0) { | ||
slli(dst, src, CompressedKlassPointers::shift()); | ||
|
@@ -3429,6 +3451,24 @@ void MacroAssembler::decode_klass_not_null(Register dst, Register src, Register | |
} | ||
} | ||
|
||
void MacroAssembler::encode_klass_not_null_for_aot(Register dst, Register src, Register tmp) { | ||
// we have to load the klass base from the AOT constants area but | ||
// not the shift because it is not allowed to change | ||
int shift = CompressedKlassPointers::shift(); | ||
assert(shift >= 0 && shift <= CompressedKlassPointers::max_shift(), "unexpected compressed klass shift!"); | ||
assert_different_registers(src, tmp); | ||
Register xbase = dst; | ||
if (dst == src) { | ||
xbase = tmp; | ||
} | ||
la(xbase, ExternalAddress(CompressedKlassPointers::base_addr())); | ||
ld(xbase, xbase); | ||
sub(dst, src, xbase); | ||
if (shift != 0) { | ||
srli(dst, dst, shift); | ||
} | ||
} | ||
|
||
void MacroAssembler::encode_klass_not_null(Register r, Register tmp) { | ||
assert_different_registers(r, tmp); | ||
encode_klass_not_null(r, r, tmp); | ||
|
@@ -3437,6 +3477,11 @@ void MacroAssembler::encode_klass_not_null(Register r, Register tmp) { | |
void MacroAssembler::encode_klass_not_null(Register dst, Register src, Register tmp) { | ||
assert(UseCompressedClassPointers, "should only be used for compressed headers"); | ||
|
||
if (AOTCodeCache::is_on_for_dump()) { | ||
encode_klass_not_null_for_aot(dst, src, tmp); | ||
return; | ||
} | ||
|
||
if (CompressedKlassPointers::base() == nullptr) { | ||
if (CompressedKlassPointers::shift() != 0) { | ||
srli(dst, src, CompressedKlassPointers::shift()); | ||
|
@@ -4882,7 +4927,7 @@ void MacroAssembler::get_thread(Register thread) { | |
RegSet::range(x28, x31) + ra - thread; | ||
push_reg(saved_regs, sp); | ||
|
||
mv(t1, CAST_FROM_FN_PTR(address, Thread::current)); | ||
movptr(t1, ExternalAddress(CAST_FROM_FN_PTR(address, Thread::current))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be more consistent with other places in riscv code where we move an ExternalAddress into a register if we do: |
||
jalr(t1); | ||
if (thread != c_rarg0) { | ||
mv(thread, c_rarg0); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
#ifdef COMPILER2 | ||
#include "asm/macroAssembler.hpp" | ||
#include "asm/macroAssembler.inline.hpp" | ||
#include "code/aotCodeCache.hpp" | ||
#include "code/vmreg.hpp" | ||
#include "interpreter/interpreter.hpp" | ||
#include "opto/runtime.hpp" | ||
|
@@ -62,6 +63,11 @@ UncommonTrapBlob* OptoRuntime::generate_uncommon_trap_blob() { | |
ResourceMark rm; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems more reasonable to move this |
||
// Setup code generation tools | ||
const char* name = OptoRuntime::stub_name(OptoStubId::uncommon_trap_id); | ||
CodeBlob* blob = AOTCodeCache::load_code_blob(AOTCodeEntry::C2Blob, (uint)OptoStubId::uncommon_trap_id, name); | ||
if (blob != nullptr) { | ||
return blob->as_uncommon_trap_blob(); | ||
} | ||
|
||
CodeBuffer buffer(name, 2048, 1024); | ||
if (buffer.blob() == nullptr) { | ||
return nullptr; | ||
|
@@ -243,8 +249,10 @@ UncommonTrapBlob* OptoRuntime::generate_uncommon_trap_blob() { | |
// Make sure all code is generated | ||
masm->flush(); | ||
|
||
return UncommonTrapBlob::create(&buffer, oop_maps, | ||
SimpleRuntimeFrame::framesize >> 1); | ||
UncommonTrapBlob *ut_blob = UncommonTrapBlob::create(&buffer, oop_maps, | ||
SimpleRuntimeFrame::framesize >> 1); | ||
AOTCodeCache::store_code_blob(*ut_blob, AOTCodeEntry::C2Blob, (uint)OptoStubId::uncommon_trap_id, name); | ||
return ut_blob; | ||
} | ||
|
||
//------------------------------generate_exception_blob--------------------------- | ||
|
@@ -284,6 +292,11 @@ ExceptionBlob* OptoRuntime::generate_exception_blob() { | |
ResourceMark rm; | ||
// Setup code generation tools | ||
const char* name = OptoRuntime::stub_name(OptoStubId::exception_id); | ||
CodeBlob* blob = AOTCodeCache::load_code_blob(AOTCodeEntry::C2Blob, (uint)OptoStubId::exception_id, name); | ||
if (blob != nullptr) { | ||
return blob->as_exception_blob(); | ||
} | ||
|
||
CodeBuffer buffer(name, 2048, 1024); | ||
if (buffer.blob() == nullptr) { | ||
return nullptr; | ||
|
@@ -382,6 +395,8 @@ ExceptionBlob* OptoRuntime::generate_exception_blob() { | |
masm->flush(); | ||
|
||
// Set exception blob | ||
return ExceptionBlob::create(&buffer, oop_maps, SimpleRuntimeFrame::framesize >> 1); | ||
ExceptionBlob* ex_blob = ExceptionBlob::create(&buffer, oop_maps, SimpleRuntimeFrame::framesize >> 1); | ||
AOTCodeCache::store_code_blob(*ex_blob, AOTCodeEntry::C2Blob, (uint)OptoStubId::exception_id, name); | ||
return ex_blob; | ||
} | ||
#endif // COMPILER2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This movptr + jalr sequence could be further simplified into
rt_call(entry_point)
, which could help save one add instruction.