Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Datadog Syncup Service committed May 8, 2024
2 parents 78a2653 + ad78b7f commit d5ee90a
Show file tree
Hide file tree
Showing 73 changed files with 1,120 additions and 520 deletions.
4 changes: 3 additions & 1 deletion make/modules/jdk.httpserver/Java.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2020, 2024, Oracle and/or its affiliates. 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 All @@ -24,3 +24,5 @@
#

DISABLED_WARNINGS_java += missing-explicit-ctor this-escape

COPY += .ico
10 changes: 10 additions & 0 deletions src/hotspot/cpu/riscv/assembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,16 @@ enum Nf {

#undef INSN

#define INSN(NAME, op, funct3, Vs1, funct6) \
void NAME(VectorRegister Vd, VectorRegister Vs2, VectorMask vm = unmasked) { \
patch_VArith(op, Vd, funct3, Vs1, Vs2, vm, funct6); \
}

// Vector Basic Bit-manipulation (Zvbb) Extension
INSN(vcpop_v, 0b1010111, 0b010, 0b01110, 0b010010);

#undef INSN

#undef patch_VArith

// ====================================
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/riscv/globals_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ define_pd_global(intx, InlineSmallCode, 1000);
product(bool, UseZtso, false, EXPERIMENTAL, "Assume Ztso memory model") \
product(bool, UseZihintpause, false, EXPERIMENTAL, \
"Use Zihintpause instructions") \
product(bool, UseZvbb, false, EXPERIMENTAL, "Use Zvbb instructions") \
product(bool, UseZvfh, false, EXPERIMENTAL, "Use Zvfh instructions") \
product(bool, UseZvkn, false, EXPERIMENTAL, \
"Use Zvkn group extension, Zvkned, Zvknhb, Zvkb, Zvkt") \
Expand Down
34 changes: 34 additions & 0 deletions src/hotspot/cpu/riscv/riscv_v.ad
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ source %{
return false;
}
break;
case Op_PopCountVL:
case Op_PopCountVI:
return UseZvbb;
case Op_LoadVectorGather:
case Op_LoadVectorGatherMasked:
if (is_subword_type(bt)) {
Expand Down Expand Up @@ -3784,6 +3787,37 @@ instruct vconvF2HF(vReg dst, vReg src, vReg vtmp, vRegMask_V0 v0, iRegINoSp tmp)
ins_pipe(pipe_slow);
%}


// ------------------------------ Popcount vector ------------------------------

instruct vpopcount_mask(vReg dst, vReg src, vRegMask_V0 v0) %{
match(Set dst (PopCountVI src v0));
match(Set dst (PopCountVL src v0));
ins_cost(VEC_COST);
format %{ "vcpop_v $dst, $src, $v0\t# vcpop_v with mask" %}
ins_encode %{
BasicType bt = Matcher::vector_element_basic_type(this);
uint vlen = Matcher::vector_length(this);
__ vsetvli_helper(bt, vlen);
__ vcpop_v(as_VectorRegister($dst$$reg), as_VectorRegister($src$$reg), Assembler::v0_t);
%}
ins_pipe(pipe_slow);
%}

instruct vpopcount(vReg dst, vReg src) %{
match(Set dst (PopCountVI src));
match(Set dst (PopCountVL src));
ins_cost(VEC_COST);
format %{ "vcpop_v $dst, $src\t# vcpop_v without mask" %}
ins_encode %{
BasicType bt = Matcher::vector_element_basic_type(this);
uint vlen = Matcher::vector_length(this);
__ vsetvli_helper(bt, vlen);
__ vcpop_v(as_VectorRegister($dst$$reg), as_VectorRegister($src$$reg));
%}
ins_pipe(pipe_slow);
%}

// ------------------------------ Vector Load Gather ---------------------------

instruct gather_load(vReg dst, indirect mem, vReg idx) %{
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/cpu/riscv/vm_version_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ void VM_Version::initialize() {
FLAG_SET_DEFAULT(UseChaCha20Intrinsics, false);
}

// UseZvbb (depends on RVV).
if (UseZvbb && !UseRVV) {
FLAG_SET_DEFAULT(UseZvbb, false);
warning("Cannot enable UseZvbb on cpu without RVV support.");
}

// SHA's
if (FLAG_IS_DEFAULT(UseSHA)) {
FLAG_SET_DEFAULT(UseSHA, true);
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/riscv/vm_version_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class VM_Version : public Abstract_VM_Version {
decl(ext_Ztso , "Ztso" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZtso)) \
decl(ext_Zihintpause , "Zihintpause" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZihintpause)) \
decl(ext_Zacas , "Zacas" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZacas)) \
decl(ext_Zvbb , "Zvbb" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZvbb)) \
decl(ext_Zvfh , "Zvfh" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZvfh)) \
decl(ext_Zvkn , "Zvkn" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZvkn)) \
decl(mvendorid , "VendorId" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \
Expand Down
34 changes: 28 additions & 6 deletions src/hotspot/share/compiler/compilationMemoryStatistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,32 @@ class MemStatEntry : public CHeapObj<mtInternal> {
int _num_recomp;
// Compiling thread. Only for diagnostic purposes. Thread may not be alive anymore.
const Thread* _thread;
// active limit for this compilation, if any
size_t _limit;

// peak usage, bytes, over all arenas
size_t _total;
// usage in node arena when total peaked
size_t _na_at_peak;
// usage in resource area when total peaked
size_t _ra_at_peak;
// number of nodes (c2 only) when total peaked
unsigned _live_nodes_at_peak;
const char* _result;

public:

MemStatEntry(FullMethodName method)
: _method(method), _comptype(compiler_c1),
_time(0), _num_recomp(0), _thread(nullptr),
_time(0), _num_recomp(0), _thread(nullptr), _limit(0),
_total(0), _na_at_peak(0), _ra_at_peak(0), _live_nodes_at_peak(0),
_result(nullptr) {
}

void set_comptype(CompilerType comptype) { _comptype = comptype; }
void set_current_time() { _time = os::elapsedTime(); }
void set_current_thread() { _thread = Thread::current(); }
void set_limit(size_t limit) { _limit = limit; }
void inc_recompilation() { _num_recomp++; }

void set_total(size_t n) { _total = n; }
Expand All @@ -218,14 +225,15 @@ class MemStatEntry : public CHeapObj<mtInternal> {
st->print_cr(" RA : ...how much in resource areas");
st->print_cr(" result : Result: 'ok' finished successfully, 'oom' hit memory limit, 'err' compilation failed");
st->print_cr(" #nodes : ...how many nodes (c2 only)");
st->print_cr(" limit : memory limit, if set");
st->print_cr(" time : time of last compilation (sec)");
st->print_cr(" type : compiler type");
st->print_cr(" #rc : how often recompiled");
st->print_cr(" thread : compiler thread");
}

static void print_header(outputStream* st) {
st->print_cr("total NA RA result #nodes time type #rc thread method");
st->print_cr("total NA RA result #nodes limit time type #rc thread method");
}

void print_on(outputStream* st, bool human_readable) const {
Expand Down Expand Up @@ -260,7 +268,19 @@ class MemStatEntry : public CHeapObj<mtInternal> {
col += 8; st->fill_to(col);

// Number of Nodes when memory peaked
st->print("%u ", _live_nodes_at_peak);
if (_live_nodes_at_peak > 0) {
st->print("%u ", _live_nodes_at_peak);
} else {
st->print("-");
}
col += 8; st->fill_to(col);

// Limit
if (_limit > 0) {
st->print(PROPERFMT " ", PROPERFMTARGS(_limit));
} else {
st->print("-");
}
col += 8; st->fill_to(col);

// TimeStamp
Expand Down Expand Up @@ -322,7 +342,7 @@ class MemStatTable :

void add(const FullMethodName& fmn, CompilerType comptype,
size_t total, size_t na_at_peak, size_t ra_at_peak,
unsigned live_nodes_at_peak, const char* result) {
unsigned live_nodes_at_peak, size_t limit, const char* result) {
assert_lock_strong(NMTCompilationCostHistory_lock);
MemStatTableKey key(fmn, comptype);
MemStatEntry** pe = get(key);
Expand All @@ -343,6 +363,7 @@ class MemStatTable :
e->set_na_at_peak(na_at_peak);
e->set_ra_at_peak(ra_at_peak);
e->set_live_nodes_at_peak(live_nodes_at_peak);
e->set_limit(limit);
e->set_result(result);
}

Expand Down Expand Up @@ -430,6 +451,7 @@ void CompilationMemoryStatistic::on_end_compilation() {
arena_stat->na_at_peak(),
arena_stat->ra_at_peak(),
arena_stat->live_nodes_at_peak(),
arena_stat->limit(),
result);
}
if (print) {
Expand Down Expand Up @@ -521,8 +543,8 @@ void CompilationMemoryStatistic::on_arena_change(ssize_t diff, const Arena* aren
if (ct != compiler_none && name[0] != '\0') {
ss.print("%s %s: ", compilertype2name(ct), name);
}
ss.print("Hit MemLimit %s (limit: %zu now: %zu)",
(hit_limit_before ? "again" : ""),
ss.print("Hit MemLimit %s(limit: %zu now: %zu)",
(hit_limit_before ? "again " : ""),
arena_stat->limit(), arena_stat->peak_since_start());
}

Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/compiler/compileBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "compiler/compilerEvent.hpp"
#include "compiler/compilerOracle.hpp"
#include "compiler/directivesParser.hpp"
#include "gc/shared/memAllocator.hpp"
#include "interpreter/linkResolver.hpp"
#include "jvm.h"
#include "jfr/jfrEvents.hpp"
Expand Down Expand Up @@ -1396,6 +1397,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
assert(!HAS_PENDING_EXCEPTION, "No exception should be present");
// some prerequisites that are compiler specific
if (comp->is_c2() || comp->is_jvmci()) {
InternalOOMEMark iom(THREAD);
method->constants()->resolve_string_constants(CHECK_AND_CLEAR_NONASYNC_NULL);
// Resolve all classes seen in the signature of the method
// we are compiling.
Expand Down
33 changes: 33 additions & 0 deletions src/hotspot/share/compiler/compilerOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@
#include "runtime/os.hpp"
#include "utilities/parseInteger.hpp"

// Default compile commands, if defined, are parsed before any of the
// explicitly defined compile commands. Thus, explicitly defined compile
// commands take precedence over default compile commands. The effect is
// as if the default compile commands had been specified at the start of
// the command line.
static const char* const default_compile_commands[] = {
#ifdef ASSERT
// In debug builds, impose a (generous) per-compilation memory limit
// to catch pathological compilations during testing. The suboption
// "crash" will cause the JVM to assert.
//
// Note: to disable the default limit at the command line,
// set a limit of 0 (e.g. -XX:CompileCommand=MemLimit,*.*,0).
"MemLimit,*.*,1G~crash",
#endif
nullptr };

static const char* optiontype_names[] = {
#define enum_of_types(type, name) name,
OPTION_TYPES(enum_of_types)
Expand Down Expand Up @@ -905,6 +922,14 @@ class LineCopy : StackObj {
}
};

bool CompilerOracle::parse_from_line_quietly(char* line) {
const bool quiet0 = _quiet;
_quiet = true;
const bool result = parse_from_line(line);
_quiet = quiet0;
return result;
}

bool CompilerOracle::parse_from_line(char* line) {
if ((line[0] == '\0') || (line[0] == '#')) {
return true;
Expand Down Expand Up @@ -1107,6 +1132,14 @@ bool CompilerOracle::parse_from_string(const char* str, bool (*parse_line)(char*

bool compilerOracle_init() {
bool success = true;
// Register default compile commands first - any commands specified via CompileCommand will
// supersede these default commands.
for (int i = 0; default_compile_commands[i] != nullptr; i ++) {
char* s = os::strdup(default_compile_commands[i]);
success = CompilerOracle::parse_from_line_quietly(s);
os::free(s);
assert(success, "default compile command \"%s\" failed to parse", default_compile_commands[i]);
}
if (!CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line)) {
success = false;
}
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/compiler/compilerOracle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class CompilerOracle : AllStatic {
// Reads from string instead of file
static bool parse_from_string(const char* option_string, bool (*parser)(char*));
static bool parse_from_line(char* line);
static bool parse_from_line_quietly(char* line);
static bool parse_compile_only(char* line);

// Fast check if there is any option set that compile control needs to know about
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/memAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,21 @@ bool MemAllocator::Allocation::check_out_of_memory() {
}

const char* message = _overhead_limit_exceeded ? "GC overhead limit exceeded" : "Java heap space";
if (!_thread->in_retryable_allocation()) {
if (!_thread->is_in_internal_oome_mark()) {
// -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
report_java_out_of_memory(message);

if (JvmtiExport::should_post_resource_exhausted()) {
JvmtiExport::post_resource_exhausted(
JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
message);
}

oop exception = _overhead_limit_exceeded ?
Universe::out_of_memory_error_gc_overhead_limit() :
Universe::out_of_memory_error_java_heap();
THROW_OOP_(exception, true);
} else {
THROW_OOP_(Universe::out_of_memory_error_retry(), true);
THROW_OOP_(Universe::out_of_memory_error_java_heap_without_backtrace(), true);
}
}

Expand Down
33 changes: 33 additions & 0 deletions src/hotspot/share/gc/shared/memAllocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,37 @@ class ClassAllocator: public MemAllocator {
virtual oop initialize(HeapWord* mem) const;
};

// Manages a scope where a failed heap allocation results in
// suppression of JVMTI "resource exhausted" events and
// throwing a shared, backtrace-less OOME instance.
// Used for OOMEs that will not be propagated to user code.
class InternalOOMEMark: public StackObj {
private:
bool _outer;
JavaThread* _thread;

public:
explicit InternalOOMEMark(JavaThread* thread) {
if (thread != nullptr) {
_outer = thread->is_in_internal_oome_mark();
thread->set_is_in_internal_oome_mark(true);
_thread = thread;
} else {
_outer = false;
_thread = nullptr;
}
}

~InternalOOMEMark() {
if (_thread != nullptr) {
// Check that only InternalOOMEMark sets
// JavaThread::_is_in_internal_oome_mark
assert(_thread->is_in_internal_oome_mark(), "must be");
_thread->set_is_in_internal_oome_mark(_outer);
}
}

JavaThread* thread() const { return _thread; }
};

#endif // SHARE_GC_SHARED_MEMALLOCATOR_HPP
11 changes: 5 additions & 6 deletions src/hotspot/share/gc/shared/space.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ class ContiguousSpace: public CHeapObj<mtGC> {
// Accessors
HeapWord* bottom() const { return _bottom; }
HeapWord* end() const { return _end; }
HeapWord* top() const { return _top; }

void set_bottom(HeapWord* value) { _bottom = value; }
void set_end(HeapWord* value) { _end = value; }
void set_top(HeapWord* value) { _top = value; }

// Testers
bool is_empty() const { return used() == 0; }
Expand Down Expand Up @@ -112,10 +115,6 @@ class ContiguousSpace: public CHeapObj<mtGC> {
// had allocation performed in it, but is now to be considered empty.
void clear(bool mangle_space);

// Accessors
HeapWord* top() const { return _top; }
void set_top(HeapWord* value) { _top = value; }

// Used to save the space's current top for later use during mangling.
void set_top_for_allocations() PRODUCT_RETURN;

Expand All @@ -139,9 +138,9 @@ class ContiguousSpace: public CHeapObj<mtGC> {

// Allocation (return null if full). Assumes the caller has established
// mutually exclusive access to the space.
virtual HeapWord* allocate(size_t word_size);
HeapWord* allocate(size_t word_size);
// Allocation (return null if full). Enforces mutual exclusion internally.
virtual HeapWord* par_allocate(size_t word_size);
HeapWord* par_allocate(size_t word_size);

// Iteration
void object_iterate(ObjectClosure* blk);
Expand Down
Loading

0 comments on commit d5ee90a

Please sign in to comment.