Skip to content

Commit

Permalink
Merge branch 'master' into 8129827
Browse files Browse the repository at this point in the history
  • Loading branch information
caojoshua committed Nov 18, 2022
2 parents f144ec0 + 9cb8752 commit df90481
Show file tree
Hide file tree
Showing 91 changed files with 3,723 additions and 2,353 deletions.
276 changes: 160 additions & 116 deletions .github/workflows/submit.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hotspot/src/share/vm/opto/compile.cpp
Expand Up @@ -791,7 +791,7 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr
}
if (failing()) return;
if (cg == NULL) {
record_method_not_compilable_all_tiers("cannot parse method");
record_method_not_compilable("cannot parse method");
return;
}
JVMState* jvms = build_start_state(start(), tf());
Expand Down
10 changes: 3 additions & 7 deletions hotspot/src/share/vm/opto/compile.hpp
Expand Up @@ -733,16 +733,12 @@ class Compile : public Phase {
bool failure_reason_is(const char* r) { return (r==_failure_reason) || (r!=NULL && _failure_reason!=NULL && strcmp(r, _failure_reason)==0); }

void record_failure(const char* reason);
void record_method_not_compilable(const char* reason, bool all_tiers = false) {
// All bailouts cover "all_tiers" when TieredCompilation is off.
if (!TieredCompilation) all_tiers = true;
env()->record_method_not_compilable(reason, all_tiers);
void record_method_not_compilable(const char* reason) {
// Bailouts cover "all_tiers" when TieredCompilation is off.
env()->record_method_not_compilable(reason, !TieredCompilation);
// Record failure reason.
record_failure(reason);
}
void record_method_not_compilable_all_tiers(const char* reason) {
record_method_not_compilable(reason, true);
}
bool check_node_count(uint margin, const char* reason) {
if (live_nodes() + margin > max_node_limit()) {
record_method_not_compilable(reason);
Expand Down
8 changes: 4 additions & 4 deletions hotspot/src/share/vm/opto/matcher.cpp
Expand Up @@ -137,7 +137,7 @@ OptoReg::Name Matcher::warp_incoming_stk_arg( VMReg reg ) {
_in_arg_limit = OptoReg::add(warped, 1); // Bump max stack slot seen
if (!RegMask::can_represent_arg(warped)) {
// the compiler cannot represent this method's calling sequence
C->record_method_not_compilable_all_tiers("unsupported incoming calling sequence");
C->record_method_not_compilable("unsupported incoming calling sequence");
return OptoReg::Bad;
}
return warped;
Expand Down Expand Up @@ -1139,7 +1139,7 @@ OptoReg::Name Matcher::warp_outgoing_stk_arg( VMReg reg, OptoReg::Name begin_out
if( warped >= out_arg_limit_per_call )
out_arg_limit_per_call = OptoReg::add(warped,1);
if (!RegMask::can_represent_arg(warped)) {
C->record_method_not_compilable_all_tiers("unsupported calling sequence");
C->record_method_not_compilable("unsupported calling sequence");
return OptoReg::Bad;
}
return warped;
Expand Down Expand Up @@ -1318,7 +1318,7 @@ MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
uint r_cnt = mcall->tf()->range()->cnt();
MachProjNode *proj = new (C) MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
C->record_method_not_compilable_all_tiers("unsupported outgoing calling sequence");
C->record_method_not_compilable("unsupported outgoing calling sequence");
} else {
for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
proj->_rout.Insert(OptoReg::Name(i));
Expand Down Expand Up @@ -1506,7 +1506,7 @@ Node *Matcher::Label_Root( const Node *n, State *svec, Node *control, const Node
// out of stack space. See bugs 6272980 & 6227033 for more info.
LabelRootDepth++;
if (LabelRootDepth > MaxLabelRootDepth) {
C->record_method_not_compilable_all_tiers("Out of stack space, increase MaxLabelRootDepth");
C->record_method_not_compilable("Out of stack space, increase MaxLabelRootDepth");
return NULL;
}
uint care = 0; // Edges matcher cares about
Expand Down
4 changes: 2 additions & 2 deletions hotspot/src/share/vm/opto/parse1.cpp
Expand Up @@ -415,7 +415,7 @@ Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses)
_iter.reset_to_method(method());
_flow = method()->get_flow_analysis();
if (_flow->failing()) {
C->record_method_not_compilable_all_tiers(_flow->failure_reason());
C->record_method_not_compilable(_flow->failure_reason());
}

#ifndef PRODUCT
Expand Down Expand Up @@ -1080,7 +1080,7 @@ SafePointNode* Parse::create_entry_map() {
// Check for really stupid bail-out cases.
uint len = TypeFunc::Parms + method()->max_locals() + method()->max_stack();
if (len >= 32760) {
C->record_method_not_compilable_all_tiers("too many local variables");
C->record_method_not_compilable("too many local variables");
return NULL;
}

Expand Down
53 changes: 51 additions & 2 deletions hotspot/src/share/vm/opto/stringopts.cpp
Expand Up @@ -61,7 +61,8 @@ class StringConcat : public ResourceObj {
StringMode,
IntMode,
CharMode,
StringNullCheckMode
StringNullCheckMode,
NegativeIntCheckMode
};

StringConcat(PhaseStringOpts* stringopts, CallStaticJavaNode* end):
Expand Down Expand Up @@ -118,12 +119,19 @@ class StringConcat : public ResourceObj {
void push_string(Node* value) {
push(value, StringMode);
}

void push_string_null_check(Node* value) {
push(value, StringNullCheckMode);
}

void push_negative_int_check(Node* value) {
push(value, NegativeIntCheckMode);
}

void push_int(Node* value) {
push(value, IntMode);
}

void push_char(Node* value) {
push(value, CharMode);
}
Expand Down Expand Up @@ -484,13 +492,35 @@ StringConcat* PhaseStringOpts::build_candidate(CallStaticJavaNode* call) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("giving up because StringBuilder(null) throws exception");
alloc->jvms()->dump_spec(tty); tty->cr();
alloc->jvms()->dump_spec(tty);
tty->cr();
}
#endif
return NULL;
}
// StringBuilder(str) argument needs null check.
sc->push_string_null_check(use->in(TypeFunc::Parms + 1));
} else if (sig == ciSymbol::int_void_signature()) {
// StringBuilder(int) case.
Node* parm = use->in(TypeFunc::Parms + 1);
assert(parm != NULL, "must exist");
const TypeInt* type = _gvn->type(parm)->is_int();
if (type->_hi < 0) {
// Initial capacity argument is always negative in which case StringBuilder(int) throws
// a NegativeArraySizeException. Bail out from string opts.
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("giving up because a negative argument is passed to StringBuilder(int) which "
"throws a NegativeArraySizeException");
alloc->jvms()->dump_spec(tty);
tty->cr();
}
#endif
return NULL;
} else if (type->_lo < 0) {
// Argument could be negative: We need a runtime check to throw NegativeArraySizeException in that case.
sc->push_negative_int_check(parm);
}
}
// The int variant takes an initial size for the backing
// array so just treat it like the void version.
Expand Down Expand Up @@ -1477,6 +1507,23 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) {
for (int argi = 0; argi < sc->num_arguments(); argi++) {
Node* arg = sc->argument(argi);
switch (sc->mode(argi)) {
case StringConcat::NegativeIntCheckMode: {
// Initial capacity argument might be negative in which case StringBuilder(int) throws
// a NegativeArraySizeException. Insert a runtime check with an uncommon trap.
const TypeInt* type = kit.gvn().type(arg)->is_int();
assert(type->_hi >= 0 && type->_lo < 0, "no runtime int check needed");
Node* p = __ Bool(__ CmpI(arg, kit.intcon(0)), BoolTest::ge);
IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_MIN, COUNT_UNKNOWN);
{
// Negative int -> uncommon trap.
PreserveJVMState pjvms(&kit);
kit.set_control(__ IfFalse(iff));
kit.uncommon_trap(Deoptimization::Reason_intrinsic,
Deoptimization::Action_maybe_recompile);
}
kit.set_control(__ IfTrue(iff));
break;
}
case StringConcat::IntMode: {
Node* string_size = int_stringSize(kit, arg);

Expand Down Expand Up @@ -1601,6 +1648,8 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) {
for (int argi = 0; argi < sc->num_arguments(); argi++) {
Node* arg = sc->argument(argi);
switch (sc->mode(argi)) {
case StringConcat::NegativeIntCheckMode:
break; // Nothing to do, was only needed to add a runtime check earlier.
case StringConcat::IntMode: {
Node* end = __ AddI(start, string_sizes->in(argi));
// getChars words backwards so pass the ending point as well as the start
Expand Down
5 changes: 5 additions & 0 deletions hotspot/src/share/vm/runtime/os.cpp
Expand Up @@ -632,6 +632,11 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
NMT_TrackingLevel level = MemTracker::tracking_level();
size_t nmt_header_size = MemTracker::malloc_header_size(level);

// Check for overflow.
if (size + nmt_header_size < size) {
return NULL;
}

#ifndef ASSERT
const size_t alloc_size = size + nmt_header_size;
#else
Expand Down
54 changes: 13 additions & 41 deletions hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp
Expand Up @@ -35,13 +35,17 @@
# include <string.h>
# include <stdarg.h>
# include <stdlib.h>
# include <stdint.h>
# include <stddef.h>// for offsetof
# include <io.h> // for stream.cpp
# include <float.h> // for _isnan
# include <stdio.h> // for va_list
# include <time.h>
# include <fcntl.h>
# include <limits.h>
#if _MSC_VER >= 1800
# include <inttypes.h>
#endif
// Need this on windows to get the math constants (e.g., M_PI).
#define _USE_MATH_DEFINES
# include <math.h>
Expand Down Expand Up @@ -77,53 +81,19 @@
// pointer is stored as integer value.
#define NULL_WORD NULL

// Some MS Visual Studio versions do not seem to have INT64_C and UINT64_C
// even with __STDC_CONSTANT_MACROS defined.
#ifndef INT64_C
#define INT64_C(c) (c ## i64)
#endif
#ifndef UINT64_C
#define UINT64_C(c) (c ## ui64)
#endif

// Compiler-specific primitive types
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;

#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
#ifdef _WIN64
typedef signed __int64 intptr_t;
typedef signed __int64 ssize_t;
typedef int64_t ssize_t;
#else
typedef signed int intptr_t;
typedef signed int ssize_t;
#endif

#ifndef UINTPTR_MAX
#ifdef _WIN64
#define UINTPTR_MAX _UI64_MAX
#else
#define UINTPTR_MAX _UI32_MAX
#endif
typedef int32_t ssize_t;
#endif

//----------------------------------------------------------------------------------------------------
// Additional Java basic types

typedef unsigned char jubyte;
typedef unsigned short jushort;
typedef unsigned int juint;
typedef unsigned __int64 julong;
typedef uint8_t jubyte;
typedef uint16_t jushort;
typedef uint32_t juint;
typedef uint64_t julong;


//----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -210,8 +180,9 @@ const jlong max_jlong = CONST64(0x7fffffffffffffff);
// Formatting.
#define FORMAT64_MODIFIER "I64"

// Visual Studio doesn't provide inttypes.h so provide appropriate definitions here.
// Visual Studio 2010-2012 doesn't provide inttypes.h so provide appropriate definitions here.
// The 32 bits ones might need I32 but seem to work ok without it.
#if _MSC_VER < 1800
#define PRId32 "d"
#define PRIu32 "u"
#define PRIx32 "x"
Expand All @@ -229,6 +200,7 @@ const jlong max_jlong = CONST64(0x7fffffffffffffff);
#define PRIuPTR "u"
#define PRIxPTR "x"
#endif
#endif

#define offset_of(klass,field) offsetof(klass,field)

Expand Down
5 changes: 5 additions & 0 deletions hotspot/test/ProblemList.txt
Expand Up @@ -64,3 +64,8 @@ compiler/rtm/locking/TestRTMSpinLoopCount.java 8183263 generic-x64
compiler/rtm/locking/TestUseRTMDeopt.java 8183263 generic-x64
compiler/rtm/locking/TestUseRTMXendForLockBusy.java 8183263 generic-x64
compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java 8183263 generic-x64
compiler/rtm/locking/TestRTMTotalCountIncrRate.java 8183263 generic-x64,generic-i586
compiler/rtm/locking/TestUseRTMAfterLockInflation.java 8183263 generic-x64,generic-i586
compiler/rtm/locking/TestUseRTMForInflatedLocks.java 8183263 generic-x64,generic-i586
compiler/rtm/locking/TestUseRTMForStackLocks.java 8183263 generic-x64,generic-i586
compiler/rtm/method_options/TestUseRTMLockElidingOption.java 8183263 generic-x64,generic-i586
Expand Up @@ -73,7 +73,7 @@ THIS_DIR=.
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
${TESTJAVA}${FS}bin${FS}javac *.java

$cc_cmd -fPIC -shared -o libCNCheckLongArgs.so \
$cc_cmd ${CFLAGBITS} -fPIC -shared -o libCNCheckLongArgs.so \
-I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
${TESTSRC}${FS}libCNCheckLongArgs.c

Expand Down
2 changes: 1 addition & 1 deletion hotspot/test/runtime/7107135/Test7107135.sh
Expand Up @@ -65,7 +65,7 @@ THIS_DIR=.
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
${TESTJAVA}${FS}bin${FS}javac *.java

$gcc_cmd -fPIC -shared -c -o test.o \
$gcc_cmd ${CFLAGBITS} -fPIC -shared -c -o test.o \
-I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
${TESTSRC}${FS}test.c

Expand Down
5 changes: 1 addition & 4 deletions hotspot/test/runtime/InitialThreadOverflow/testme.sh
Expand Up @@ -49,8 +49,6 @@ if [ "x$gcc_cmd" = "x" ]; then
exit 0;
fi

CFLAGS="-m${VM_BITS}"

LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

Expand All @@ -59,12 +57,11 @@ cp ${TESTSRC}${FS}invoke.cxx .
# Copy the result of our @compile action:
cp ${TESTCLASSES}${FS}DoOverflow.class .

echo "Compilation flag: ${COMP_FLAG}"
# Note pthread may not be found thus invoke creation will fail to be created.
# Check to ensure you have a /usr/lib/libpthread.so if you don't please look
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.

$gcc_cmd -DLINUX ${CFLAGS} -o invoke \
$gcc_cmd -DLINUX ${CFLAGBITS} -o invoke \
-I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
-L${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
-ljvm -lpthread invoke.cxx
Expand Down
8 changes: 1 addition & 7 deletions hotspot/test/runtime/StackGap/testme.sh
Expand Up @@ -49,11 +49,6 @@ if [ "x$gcc_cmd" = "x" ]; then
exit 0;
fi

if [ "x${VM_CPU}" != "xaarch64" ];
then
CFLAGS="-m${VM_BITS}"
fi

LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

Expand All @@ -62,12 +57,11 @@ cp ${TESTSRC}${FS}exestack-gap.c .
# Copy the result of our @compile action:
cp ${TESTCLASSES}${FS}T.class .

echo "Compilation flag: ${COMP_FLAG}"
# Note pthread may not be found thus invoke creation will fail to be created.
# Check to ensure you have a /usr/lib/libpthread.so if you don't please look
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.

$gcc_cmd -DLINUX ${CFLAGS} -o stack-gap \
$gcc_cmd -DLINUX ${CFLAGBITS} -o stack-gap \
-I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
-L${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
exestack-gap.c \
Expand Down
2 changes: 1 addition & 1 deletion hotspot/test/runtime/jni/CallWithJNIWeak/test.sh
Expand Up @@ -68,7 +68,7 @@ THIS_DIR=.
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
${TESTJAVA}${FS}bin${FS}javac *.java

$cc_cmd -fPIC -shared -o libCallWithJNIWeak.so \
$cc_cmd ${CFLAGBITS} -fPIC -shared -o libCallWithJNIWeak.so \
-I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
${TESTSRC}${FS}CallWithJNIWeak.c

Expand Down
2 changes: 1 addition & 1 deletion hotspot/test/runtime/jni/ReturnJNIWeak/test.sh
Expand Up @@ -68,7 +68,7 @@ THIS_DIR=.
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
${TESTJAVA}${FS}bin${FS}javac *.java

$cc_cmd -fPIC -shared -o libReturnJNIWeak.so \
$cc_cmd ${CFLAGBITS} -fPIC -shared -o libReturnJNIWeak.so \
-I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
${TESTSRC}${FS}ReturnJNIWeak.c

Expand Down
2 changes: 1 addition & 1 deletion hotspot/test/runtime/jsig/Test8017498.sh
Expand Up @@ -70,7 +70,7 @@ THIS_DIR=.
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
${TESTJAVA}${FS}bin${FS}javac *.java

$gcc_cmd -DLINUX -fPIC -shared \
$gcc_cmd -DLINUX ${CFLAGBITS} -fPIC -shared \
-o ${TESTSRC}${FS}libTestJNI.so \
-I${TESTJAVA}${FS}include \
-I${TESTJAVA}${FS}include${FS}linux \
Expand Down

0 comments on commit df90481

Please sign in to comment.