Skip to content

Commit

Permalink
FEAT(loongarch): Support loongarch with 17.0.10
Browse files Browse the repository at this point in the history
--story=117047250
  • Loading branch information
shouhuanxiaoji authored and shiyuexw committed Apr 19, 2024
1 parent 14858f4 commit ea7e6f8
Show file tree
Hide file tree
Showing 316 changed files with 118,561 additions and 189 deletions.
36 changes: 35 additions & 1 deletion make/autoconf/jvm-features.m4
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
# questions.
#

#
# This file has been modified by Loongson Technology in 2021. These
# modifications are Copyright (c) 2020, 2021, Loongson Technology, and are made
# available on the same license terms set forth above.
#

###############################################################################
# Terminology used in this file:
#
Expand Down Expand Up @@ -242,6 +248,23 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_CDS],
])
])

###############################################################################
# Check if the feature 'compiler1' is available on this platform.
#
AC_DEFUN_ONCE([JVM_FEATURES_CHECK_COMPILER1],
[
JVM_FEATURES_CHECK_AVAILABILITY(compiler1, [
AC_MSG_CHECKING([if platform is supported by COMPILER1])
if test "x$HOTSPOT_TARGET_CPU_ARCH" != "xmips"; then
# Disable compiler1 on mips
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, $OPENJDK_TARGET_OS])
AVAILABLE=false
fi
])
])

###############################################################################
# Check if the feature 'dtrace' is available on this platform.
#
Expand Down Expand Up @@ -295,6 +318,8 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_JVMCI],
AC_MSG_RESULT([yes])
elif test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
AC_MSG_RESULT([yes])
elif test "x$OPENJDK_TARGET_CPU" = "xloongarch64"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
AVAILABLE=false
Expand All @@ -312,7 +337,8 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_SHENANDOAHGC],
if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86" || \
test "x$OPENJDK_TARGET_CPU" = "xaarch64" || \
test "x$OPENJDK_TARGET_CPU" = "xppc64le" || \
test "x$OPENJDK_TARGET_CPU" = "xriscv64"; then
test "x$OPENJDK_TARGET_CPU" = "xriscv64" || \
test "x$OPENJDK_TARGET_CPU" = "xloongarch64"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
Expand Down Expand Up @@ -370,6 +396,13 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_ZGC],
AC_MSG_RESULT([no, $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
AVAILABLE=false
fi
elif test "x$OPENJDK_TARGET_CPU" = "xloongarch64"; then
if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
AVAILABLE=false
fi
else
AC_MSG_RESULT([no, $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
AVAILABLE=false
Expand Down Expand Up @@ -404,6 +437,7 @@ AC_DEFUN_ONCE([JVM_FEATURES_PREPARE_PLATFORM],
# JVM_FEATURES_PLATFORM_UNAVAILABLE.
JVM_FEATURES_CHECK_CDS
JVM_FEATURES_CHECK_COMPILER1
JVM_FEATURES_CHECK_DTRACE
JVM_FEATURES_CHECK_JFR
JVM_FEATURES_CHECK_JVMCI
Expand Down
27 changes: 27 additions & 0 deletions make/autoconf/platform.m4
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
# questions.
#

#
# This file has been modified by Loongson Technology in 2021. These
# modifications are Copyright (c) 2018, 2021, Loongson Technology, and are made
# available on the same license terms set forth above.
#

# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
# Converts autoconf style CPU name to OpenJDK style, into
# VAR_CPU, VAR_CPU_ARCH, VAR_CPU_BITS and VAR_CPU_ENDIAN.
Expand Down Expand Up @@ -539,11 +545,26 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
HOTSPOT_$1_CPU=ppc_64
elif test "x$OPENJDK_$1_CPU" = xppc64le; then
HOTSPOT_$1_CPU=ppc_64
elif test "x$OPENJDK_$1_CPU" = xmips64; then
HOTSPOT_$1_CPU=mips_64
elif test "x$OPENJDK_$1_CPU" = xmips64el; then
HOTSPOT_$1_CPU=mips_64
elif test "x$OPENJDK_$1_CPU" = xloongarch; then
HOTSPOT_$1_CPU=loongarch_64
elif test "x$OPENJDK_$1_CPU" = xloongarch64; then
HOTSPOT_$1_CPU=loongarch_64
fi
AC_SUBST(HOTSPOT_$1_CPU)
# This is identical with OPENJDK_*, but define anyway for consistency.
HOTSPOT_$1_CPU_ARCH=${OPENJDK_$1_CPU_ARCH}
# Override hotspot cpu definitions for MIPS platforms
if test "x$OPENJDK_$1_CPU" = xmips64el; then
HOTSPOT_TARGET_CPU_ARCH=mips
elif test "x$OPENJDK_$1_CPU" = xloongarch64; then
HOTSPOT_TARGET_CPU_ARCH=loongarch
fi
AC_SUBST(HOTSPOT_$1_CPU_ARCH)
# Setup HOTSPOT_$1_CPU_DEFINE
Expand All @@ -563,6 +584,12 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
HOTSPOT_$1_CPU_DEFINE=PPC64
elif test "x$OPENJDK_$1_CPU" = xriscv64; then
HOTSPOT_$1_CPU_DEFINE=RISCV64
elif test "x$OPENJDK_$1_CPU" = xmips64; then
HOTSPOT_$1_CPU_DEFINE=MIPS64
elif test "x$OPENJDK_$1_CPU" = xmips64el; then
HOTSPOT_$1_CPU_DEFINE=MIPS64
elif test "x$OPENJDK_$1_CPU" = xloongarch64; then
HOTSPOT_$1_CPU_DEFINE=LOONGARCH64
# The cpu defines below are for zero, we don't support them directly.
elif test "x$OPENJDK_$1_CPU" = xsparc; then
Expand Down
133 changes: 133 additions & 0 deletions src/hotspot/cpu/loongarch/abstractInterpreter_loongarch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Loongson Technology. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

#include "precompiled.hpp"
#include "ci/ciMethod.hpp"
#include "interpreter/interpreter.hpp"
#include "oops/klass.inline.hpp"
#include "runtime/frame.inline.hpp"

// asm based interpreter deoptimization helpers
int AbstractInterpreter::size_activation(int max_stack,
int temps,
int extra_args,
int monitors,
int callee_params,
int callee_locals,
bool is_top_frame) {
// Note: This calculation must exactly parallel the frame setup
// in AbstractInterpreterGenerator::generate_method_entry.

// fixed size of an interpreter frame:
int overhead = frame::sender_sp_offset -
frame::interpreter_frame_initial_sp_offset;
// Our locals were accounted for by the caller (or last_frame_adjust
// on the transistion) Since the callee parameters already account
// for the callee's params we only need to account for the extra
// locals.
int size = overhead +
(callee_locals - callee_params)*Interpreter::stackElementWords +
monitors * frame::interpreter_frame_monitor_size() +
temps* Interpreter::stackElementWords + extra_args;

return size;
}

// How much stack a method activation needs in words.
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {

const int entry_size = frame::interpreter_frame_monitor_size();

// total overhead size: entry_size + (saved ebp thru expr stack bottom).
// be sure to change this if you add/subtract anything to/from the overhead area
const int overhead_size = -(frame::interpreter_frame_initial_sp_offset) + entry_size;

const int stub_code = 6; // see generate_call_stub
// return overhead_size + method->max_locals() + method->max_stack() + stub_code;
const int method_stack = (method->max_locals() + method->max_stack()) *
Interpreter::stackElementWords;
return overhead_size + method_stack + stub_code;
}

void AbstractInterpreter::layout_activation(Method* method,
int tempcount,
int popframe_extra_args,
int moncount,
int caller_actual_parameters,
int callee_param_count,
int callee_locals,
frame* caller,
frame* interpreter_frame,
bool is_top_frame,
bool is_bottom_frame) {
// Note: This calculation must exactly parallel the frame setup
// in AbstractInterpreterGenerator::generate_method_entry.
// If interpreter_frame!=NULL, set up the method, locals, and monitors.
// The frame interpreter_frame, if not NULL, is guaranteed to be the
// right size, as determined by a previous call to this method.
// It is also guaranteed to be walkable even though it is in a skeletal state

// fixed size of an interpreter frame:

int max_locals = method->max_locals() * Interpreter::stackElementWords;
int extra_locals = (method->max_locals() - method->size_of_parameters()) * Interpreter::stackElementWords;

#ifdef ASSERT
assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
#endif

interpreter_frame->interpreter_frame_set_method(method);
// NOTE the difference in using sender_sp and interpreter_frame_sender_sp
// interpreter_frame_sender_sp is the original sp of the caller (the unextended_sp)
// and sender_sp is fp+8
intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;

#ifdef ASSERT
if (caller->is_interpreted_frame()) {
assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
}
#endif

interpreter_frame->interpreter_frame_set_locals(locals);
BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
BasicObjectLock* monbot = montop - moncount;
interpreter_frame->interpreter_frame_set_monitor_end(montop - moncount);

//set last sp;
intptr_t* esp = (intptr_t*) monbot - tempcount*Interpreter::stackElementWords -
popframe_extra_args;
interpreter_frame->interpreter_frame_set_last_sp(esp);
// All frames but the initial interpreter frame we fill in have a
// value for sender_sp that allows walking the stack but isn't
// truly correct. Correct the value here.
//
if (extra_locals != 0 &&
interpreter_frame->sender_sp() == interpreter_frame->interpreter_frame_sender_sp() ) {
interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() + extra_locals);
}
*interpreter_frame->interpreter_frame_cache_addr() = method->constants()->cache();
*interpreter_frame->interpreter_frame_mirror_addr() = method->method_holder()->java_mirror();
}

Loading

0 comments on commit ea7e6f8

Please sign in to comment.