Skip to content
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

Merge openjdk/jdk:master #196

Closed
wants to merge 82 commits into from
Closed
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
e85d00f
8299147: Minor accessibility errors in the specs and man index pages
jonathan-gibbons Dec 20, 2022
3d4d9fd
8298947: compiler/codecache/MHIntrinsicAllocFailureTest.java fails in…
TheRealMDoerr Dec 20, 2022
f7be5b5
8299156: Broken link in jdk.compiler/module-info.java
jonathan-gibbons Dec 20, 2022
92fe304
8298588: WebSockets: HandshakeUrlEncodingTest unnecessarily depends o…
RealCLanger Dec 21, 2022
81933b7
8298642: ParallelGC -XX:+UseNUMA eden spaces allocated on wrong node
nick-arm Dec 21, 2022
7e59a0e
8298971: Move Console implementation into jdk internal package
naotoj Dec 21, 2022
9adc349
8298726: (fs) Change PollingWatchService to record last modified time…
Dec 21, 2022
22007a1
8298893: Rename option UsePolyIntrinsics to UsePoly1305Intrinsics
vpaprotsk Dec 21, 2022
f80face
8202931: [macos] java/awt/Choice/ChoicePopupLocation/ChoicePopupLocat…
Dec 21, 2022
34cdda5
Merge
JesperIRL Dec 21, 2022
fef70d7
8299077: [REDO] JDK-4512626 Non-editable JTextArea provides no visual…
Dec 22, 2022
5012039
8298887: On the latest macOS+XCode the Robot API may report wrong colors
mrserb Dec 22, 2022
a0a09d5
8298176: remove OpaqueZeroTripGuardPostLoop once main-loop disappears
rwestrel Dec 22, 2022
5e001d6
8299207: [Testbug] Add back test/jdk/java/awt/Graphics2D/DrawPrimitiv…
aghaisas Dec 22, 2022
9863f59
8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all b…
ChrisHegarty Dec 22, 2022
a80c91d
8299230: Use https: in links
Dec 22, 2022
a3693cc
8295087: Manual Test to Automated Test Conversion
Dec 22, 2022
62a033e
8299191: Unnecessarily global friend functions for relocInfo
Dec 22, 2022
b378381
8299199: Avoid redundant split calls in FontConfiguration.initReorder…
Dec 22, 2022
6ccee83
8292206: TestCgroupMetrics.java fails as getMemoryUsage() is lower th…
iklam Dec 22, 2022
5e2de89
8299194: CustomTzIDCheckDST.java may fail at future date
Dec 22, 2022
2294f22
8286311: remove boilerplate from use of runTests
jonathan-gibbons Dec 22, 2022
33042a4
8299237: add ArraysSupport.newLength test to a test group
Dec 22, 2022
2f4098e
8299168: RISC-V: Fix MachNode size mismatch for MacroAssembler::_veri…
zhengxiaolinX Dec 23, 2022
19ce23c
Merge
JesperIRL Dec 23, 2022
da75de3
8299172: RISC-V: [TESTBUG] Fix stack alignment logic in jvmci RISCV64…
zhengxiaolinX Dec 23, 2022
188911c
8299241: jdk/jfr/api/consumer/streaming/TestJVMCrash.java generates u…
Dec 23, 2022
fd746a2
8298643: JNI call of getAccessibleRowWithIndex and getAccessibleColum…
savoptik Dec 23, 2022
5e861e3
8298645: JNI works with accessibleSelection on a wrong thread
savoptik Dec 23, 2022
26868c1
8299255: Unexpected round errors in FreetypeFontScaler
Dec 24, 2022
19373b2
Merge
JesperIRL Dec 25, 2022
0459159
8288204: GVN Crash: assert() failed: correct memory chain
y1yang0 Dec 26, 2022
11fd651
8298875: A module requiring "java.base" with flags ACC_SYNTHETIC shou…
Dec 27, 2022
d490f15
8235297: sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.…
MBaesken Dec 28, 2022
6f85a9c
8299387: CompressedClassPointers.java still fails on ppc with 'Narrow…
MBaesken Dec 28, 2022
37f8b05
8298592: Add java man page documentation for ChaCha20 and Poly1305 in…
Dec 29, 2022
684e506
8299260: libawt and libfreetype should export only explicitly request…
djelinski Dec 30, 2022
c2e3d72
8299388: java/util/regex/NegativeArraySize.java fails on Alpine and s…
MBaesken Dec 30, 2022
2ee34f1
4912623: GTK L&F: Folder list of the JFileChooser is allowing multipl…
Jan 2, 2023
18ff1f5
6257207: JTable.getDefaultEditor throws NullPointerException
prsadhuk Jan 2, 2023
95d4db3
8299424: containers/docker/TestMemoryWithCgroupV1.java fails on SLES1…
MBaesken Jan 2, 2023
d812022
8299398: Remove metaprogramming/isConst.hpp
jcking Jan 2, 2023
0532045
8298590: Refactor LambdaForm constructors
JornVernee Jan 2, 2023
e09e243
8299187: (bf) ByteOrder.name should be declared final
minborg Jan 2, 2023
8a10eef
8299193: (bf) Buffer.capacity should be declared final
minborg Jan 2, 2023
c252a85
8298652: G1: Refactor G1MarkAndPushClosure
albertnetymk Jan 2, 2023
9d3d039
8299402: Remove metaprogramming/isVolatile.hpp
jcking Jan 2, 2023
532ccdb
8299396: Remove metaprogramming/removeExtent.hpp
jcking Jan 2, 2023
71a64a1
8299399: Remove metaprogramming/isArray.hpp
jcking Jan 2, 2023
ce6395a
8299397: Remove metaprogramming/isFloatingPoint.hpp
jcking Jan 2, 2023
67086eb
8299030: Refactor ReservedSpace::reserve
albertnetymk Jan 2, 2023
5b5552f
8299483: ProblemList java/text/Format/NumberFormat/CurrencyFormat.java
Jan 2, 2023
417d01e
8299441: Fix typos in some test files under core-libs component
jaikiran Jan 3, 2023
3757433
8295974: jni_FatalError and Xcheck:jni warnings should print the nati…
Jan 3, 2023
a6a903d
8288204: GVN Crash: assert() failed: correct memory chain
TobiHartmann Jan 3, 2023
8afd665
8299395: Remove metaprogramming/removeCV.hpp
jcking Jan 3, 2023
a9ce772
8299437: Make InetSocketAddressHolder shallowly immutable
minborg Jan 3, 2023
245f0cf
8291302: ARM32: nmethod entry barriers support
Jan 3, 2023
3d0db02
Merge
JesperIRL Jan 3, 2023
92dfc73
8294526: sun/security/provider/SubjectCodeSource.java no longer refer…
ryawalla Jan 3, 2023
ea25a56
8299520: TestPrintXML.java output error messages in case compare fails
MBaesken Jan 3, 2023
3eb85d1
8299235: broken link referencing missing id
Jan 3, 2023
031829d
8298324: Unable to run shell test with make
erikj79 Jan 3, 2023
8254cbb
8299483: ProblemList java/text/Format/NumberFormat/CurrencyFormat.java
Jan 3, 2023
38cfc59
8299378: sprintf is deprecated in Xcode 14
XueleiFan Jan 3, 2023
77ff197
7030853: JDK 7 Serializable Swing classes not compatible with JDK 6
prsadhuk Jan 4, 2023
b743519
8293824: gc/whitebox/TestConcMarkCycleWB.java failed "RuntimeExceptio…
Jan 4, 2023
82deb5c
8298601: Refactor archiving of java.lang.Module objects
iklam Jan 4, 2023
a17f505
8299476: PPC64 Zero build fails after JDK-8286302
shipilev Jan 4, 2023
41900b5
8189338: JMX RMI Remote Mbean server connection hangs if the server s…
djelinski Jan 4, 2023
e3035ba
8299079: Better interface nmethod oop accesses
fisk Jan 4, 2023
ccbcea8
8299326: LinkResolver::resolve_field resolved_klass cannot be null
coleenp Jan 4, 2023
c32a34c
8299072: java_lang_ref_Reference::clear_referent should be GC agnostic
fisk Jan 4, 2023
c6588d5
8299158: Improve MD5 intrinsic on AArch64
Jan 4, 2023
4c0f24e
8064931: tools/javac/scope/DupUnsharedTest.java needs to be updated t…
archiecobbs Jan 4, 2023
6a07fd0
8155259: Suspicious buffer allocation in com.sun.tools.javac.file.Bas…
archiecobbs Jan 4, 2023
df1caf9
Merge
JesperIRL Jan 4, 2023
b9758d2
8200610: Compiling fails with java.nio.file.ReadOnlyFileSystemException
archiecobbs Jan 4, 2023
44be5ed
8219810: javac throws NullPointerException
archiecobbs Jan 4, 2023
7dcc689
8299563: Fix typos
Jan 4, 2023
3b374c0
8299439: java/text/Format/NumberFormat/CurrencyFormat.java fails for …
justin-curtis-lu Jan 4, 2023
55fe343
Merge tag 'jdk-21+4' into merge-jdk-21-4
earthling-amzn Jan 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion make/Docs.gmk
Original file line number Diff line number Diff line change
@@ -619,7 +619,7 @@ $(foreach n, 0 1 2, \
$(eval specs_bottom_rel_path := $(specs_bottom_rel_path)../) \
)

SPECS_TOP := $(if $(filter true, $(IS_DRAFT)), <header class="draft-header">$(DRAFT_TEXT)</header>)
SPECS_TOP := $(if $(filter true, $(IS_DRAFT)), <header class="draft-header" role="banner">$(DRAFT_TEXT)</header>)

# For all html files in $module/share/specs directories, copy and add the
# copyright footer.
2 changes: 1 addition & 1 deletion make/RunTests.gmk
Original file line number Diff line number Diff line change
@@ -352,7 +352,7 @@ ExpandJtregPath = \
# with test id: dir/Test.java#selection -> Test.java#selection -> .java#selection -> #selection
# without: dir/Test.java -> Test.java -> .java -> <<empty string>>
TestID = \
$(subst .java,,$(suffix $(notdir $1)))
$(subst .sh,,$(subst .html,,$(subst .java,,$(suffix $(notdir $1)))))

# The test id starting with a hash (#testid) will be stripped by all
# evals in ParseJtregTestSelectionInner and will be reinserted by calling
3 changes: 0 additions & 3 deletions make/common/modules/LibCommon.gmk
Original file line number Diff line number Diff line change
@@ -41,15 +41,12 @@ ifeq ($(TOOLCHAIN_TYPE), gcc)
CFLAGS_JDKLIB += -fvisibility=hidden
CXXFLAGS_JDKLIB += -fvisibility=hidden
LDFLAGS_JDKLIB += -Wl,--exclude-libs,ALL
EXPORT_ALL_SYMBOLS := -fvisibility=default
else ifeq ($(TOOLCHAIN_TYPE), clang)
CFLAGS_JDKLIB += -fvisibility=hidden
CXXFLAGS_JDKLIB += -fvisibility=hidden
EXPORT_ALL_SYMBOLS := -fvisibility=default
else ifeq ($(TOOLCHAIN_TYPE), xlc)
CFLAGS_JDKLIB += -qvisibility=hidden
CXXFLAGS_JDKLIB += -qvisibility=hidden
EXPORT_ALL_SYMBOLS := -qvisibility=default
endif

# Put the libraries here.
7 changes: 1 addition & 6 deletions make/modules/java.desktop/lib/Awt2dLibraries.gmk
Original file line number Diff line number Diff line change
@@ -120,11 +120,6 @@ ifeq ($(call isTargetOs, windows), true)
LIBAWT_VERSIONINFO_RESOURCE := $(TOPDIR)/src/$(MODULE)/windows/native/libawt/windows/awt.rc
endif

ifeq ($(call isTargetOs, linux), true)
# FIXME: This is probably not what we want to do, but keep it now for compatibility.
LIBAWT_CFLAGS += $(EXPORT_ALL_SYMBOLS)
endif

# Turn off all warnings for debug_mem.c This is needed because the specific warning
# about initializing a declared 'extern' cannot be turned off individually. Only
# applies to debug builds. This limitation in gcc is tracked in
@@ -414,7 +409,7 @@ ifeq ($(FREETYPE_TO_USE), system)
LIBFREETYPE_LIBS := $(FREETYPE_LIBS)
else
BUILD_LIBFREETYPE_HEADER_DIRS := $(TOPDIR)/src/$(MODULE)/share/native/libfreetype/include
BUILD_LIBFREETYPE_CFLAGS := -DFT2_BUILD_LIBRARY $(EXPORT_ALL_SYMBOLS)
BUILD_LIBFREETYPE_CFLAGS := -DFT2_BUILD_LIBRARY

# For use by libfontmanager:
LIBFREETYPE_CFLAGS := -I$(BUILD_LIBFREETYPE_HEADER_DIRS)
3 changes: 2 additions & 1 deletion make/test/JtregNativeHotspot.gmk
Original file line number Diff line number Diff line change
@@ -874,7 +874,7 @@ BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exesigtest := -ljvm

ifeq ($(call isTargetOs, windows), true)
BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT
BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c libTestJNI.c libCompleteExit.c libTestPsig.c
BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c libTestJNI.c libCompleteExit.c libTestPsig.c libnativeStack.c
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libatExit := jvm.lib
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exedaemonDestroy := jvm.lib
else
@@ -1515,6 +1515,7 @@ else
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libterminatedThread += -lpthread
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libatExit += -ljvm
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libCompleteExit += -lpthread
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libnativeStack += -lpthread
endif

# This evaluation is expensive and should only be done if this target was
14 changes: 7 additions & 7 deletions src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
@@ -3246,7 +3246,7 @@ class StubGenerator: public StubCodeGenerator {
__ addw(rscratch4, r1, rscratch2);
__ ldrw(rscratch1, Address(buf, k*4));
__ eorw(rscratch3, rscratch3, r4);
__ addw(rscratch3, rscratch3, rscratch1);
__ addw(rscratch4, rscratch4, rscratch1);
__ addw(rscratch3, rscratch3, rscratch4);
__ rorw(rscratch2, rscratch3, 32 - s);
__ addw(r1, rscratch2, r2);
@@ -3257,13 +3257,13 @@ class StubGenerator: public StubCodeGenerator {
Register rscratch3 = r10;
Register rscratch4 = r11;

__ eorw(rscratch2, r2, r3);
__ andw(rscratch3, r2, r4);
__ bicw(rscratch4, r3, r4);
__ ldrw(rscratch1, Address(buf, k*4));
__ andw(rscratch3, rscratch2, r4);
__ movw(rscratch2, t);
__ eorw(rscratch3, rscratch3, r3);
__ orrw(rscratch3, rscratch3, rscratch4);
__ addw(rscratch4, r1, rscratch2);
__ addw(rscratch3, rscratch3, rscratch1);
__ addw(rscratch4, rscratch4, rscratch1);
__ addw(rscratch3, rscratch3, rscratch4);
__ rorw(rscratch2, rscratch3, 32 - s);
__ addw(r1, rscratch2, r2);
@@ -3279,7 +3279,7 @@ class StubGenerator: public StubCodeGenerator {
__ addw(rscratch4, r1, rscratch2);
__ ldrw(rscratch1, Address(buf, k*4));
__ eorw(rscratch3, rscratch3, r2);
__ addw(rscratch3, rscratch3, rscratch1);
__ addw(rscratch4, rscratch4, rscratch1);
__ addw(rscratch3, rscratch3, rscratch4);
__ rorw(rscratch2, rscratch3, 32 - s);
__ addw(r1, rscratch2, r2);
@@ -3295,7 +3295,7 @@ class StubGenerator: public StubCodeGenerator {
__ addw(rscratch4, r1, rscratch3);
__ ldrw(rscratch1, Address(buf, k*4));
__ eorw(rscratch3, rscratch2, r3);
__ addw(rscratch3, rscratch3, rscratch1);
__ addw(rscratch4, rscratch4, rscratch1);
__ addw(rscratch3, rscratch3, rscratch4);
__ rorw(rscratch2, rscratch3, 32 - s);
__ addw(r1, rscratch2, r2);
19 changes: 19 additions & 0 deletions src/hotspot/cpu/arm/arm.ad
Original file line number Diff line number Diff line change
@@ -59,6 +59,9 @@ source_hpp %{
// To keep related declarations/definitions/uses close together,
// we switch between source %{ }% and source_hpp %{ }% freely as needed.

#include "asm/macroAssembler.hpp"
#include "gc/shared/barrierSetAssembler.hpp"

// Does destination need to be loaded in a register then passed to a
// branch instruction?
extern bool maybe_far_call(const CallNode *n);
@@ -286,6 +289,17 @@ void MachPrologNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
if (framesize != 0) {
st->print ("SUB R_SP, R_SP, " SIZE_FORMAT,framesize);
}

if (C->stub_function() == NULL && BarrierSet::barrier_set()->barrier_set_nmethod() != NULL) {
st->print("ldr t0, [guard]\n\t");
st->print("ldr t1, [Rthread, #thread_disarmed_offset]\n\t");
st->print("cmp t0, t1\n\t");
st->print("beq skip\n\t");
st->print("blr #nmethod_entry_barrier_stub\n\t");
st->print("b skip\n\t");
st->print("guard: int\n\t");
st->print("skip:\n\t");
}
}
#endif

@@ -318,6 +332,11 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
__ sub_slow(SP, SP, framesize);
}

if (C->stub_function() == NULL) {
BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
bs->nmethod_entry_barrier(&_masm);
}

// offset from scratch buffer is not valid
if (strcmp(cbuf.name(), "Compile::Fill_buffer") == 0) {
C->output()->set_frame_complete( __ offset() );
6 changes: 6 additions & 0 deletions src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@
#include "precompiled.hpp"
#include "c1/c1_MacroAssembler.hpp"
#include "c1/c1_Runtime1.hpp"
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/barrierSetAssembler.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/tlab_globals.hpp"
#include "interpreter/interpreter.hpp"
@@ -62,6 +64,10 @@ void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_by
// if this method contains a methodHandle call site
raw_push(FP, LR);
sub_slow(SP, SP, frame_size_in_bytes);

// Insert nmethod entry barrier into frame.
BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
bs->nmethod_entry_barrier(this);
}

void C1_MacroAssembler::remove_frame(int frame_size_in_bytes) {
47 changes: 47 additions & 0 deletions src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp
Original file line number Diff line number Diff line change
@@ -23,10 +23,13 @@
*/

#include "precompiled.hpp"
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/barrierSetAssembler.hpp"
#include "gc/shared/barrierSetNMethod.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "memory/universe.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/stubRoutines.hpp"

#define __ masm->

@@ -195,3 +198,47 @@ void BarrierSetAssembler::incr_allocated_bytes(MacroAssembler* masm, RegisterOrC
// Unborrow the Rthread
__ sub(Rthread, Ralloc, in_bytes(JavaThread::allocated_bytes_offset()));
}

void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) {

BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();

Register tmp0 = Rtemp;
Register tmp1 = R5; // must be callee-save register

if (bs_nm == NULL) {
return;
}

// The are no GCs that require memory barrier on arm32 now
#ifdef ASSERT
NMethodPatchingType patching_type = nmethod_patching_type();
assert(patching_type == NMethodPatchingType::stw_instruction_and_data_patch, "Unsupported patching type");
#endif

Label skip, guard;
Address thread_disarmed_addr(Rthread, in_bytes(bs_nm->thread_disarmed_offset()));

__ block_comment("nmethod_barrier begin");
__ ldr_label(tmp0, guard);

// No memory barrier here
__ ldr(tmp1, thread_disarmed_addr);
__ cmp(tmp0, tmp1);
__ b(skip, eq);

__ mov_address(tmp0, StubRoutines::Arm::method_entry_barrier());
__ call(tmp0);
__ b(skip);

__ bind(guard);

// nmethod guard value. Skipped over in common case.
//
// Put a debug value to make any offsets skew
// clearly visible in coredump
__ emit_int32(0xDEADBEAF);

__ bind(skip);
__ block_comment("nmethod_barrier end");
}
6 changes: 6 additions & 0 deletions src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp
Original file line number Diff line number Diff line change
@@ -29,6 +29,10 @@
#include "memory/allocation.hpp"
#include "oops/access.hpp"

enum class NMethodPatchingType {
stw_instruction_and_data_patch,
};

class BarrierSetAssembler: public CHeapObj<mtGC> {
private:
void incr_allocated_bytes(MacroAssembler* masm,
@@ -56,6 +60,8 @@ class BarrierSetAssembler: public CHeapObj<mtGC> {
);

virtual void barrier_stubs_init() {}
virtual NMethodPatchingType nmethod_patching_type() { return NMethodPatchingType::stw_instruction_and_data_patch; }
virtual void nmethod_entry_barrier(MacroAssembler* masm);
};

#endif // CPU_ARM_GC_SHARED_BARRIERSETASSEMBLER_ARM_HPP
114 changes: 110 additions & 4 deletions src/hotspot/cpu/arm/gc/shared/barrierSetNMethod_arm.cpp
Original file line number Diff line number Diff line change
@@ -23,18 +23,124 @@
*/

#include "precompiled.hpp"
#include "code/nativeInst.hpp"
#include "gc/shared/barrierSetAssembler.hpp"
#include "gc/shared/barrierSetNMethod.hpp"
#include "logging/log.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/registerMap.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"

// The constant below reflects the size of the barrier
// in barrierSetAssembler_arm.cpp
static const int entry_barrier_bytes = 9 * NativeInstruction::size();

class NativeNMethodBarrier: public NativeInstruction {
address instruction_address() const { return addr_at(0); }

int *guard_addr() const {
// Last instruction in a barrier
return reinterpret_cast<int*>(instruction_address() + entry_barrier_bytes - wordSize);
}

public:
int get_value() {
return Atomic::load_acquire(guard_addr());
}

void set_value(int value) {
Atomic::release_store(guard_addr(), value);
}

void verify() const;
};

// Check the first instruction of the nmethod entry barrier
// to make sure that the offsets are not skewed.
void NativeNMethodBarrier::verify() const {
NativeInstruction *ni = (NativeInstruction *) instruction_address();
if (!ni->is_ldr()) {
uint32_t *addr = (uint32_t *) ni;
tty->print_cr("Addr: " INTPTR_FORMAT " Code: 0x%x", (intptr_t) addr, (uint32_t) *addr);
fatal("not an ldr instruction.");
}
}

static NativeNMethodBarrier* native_nmethod_barrier(nmethod* nm) {
address barrier_address = nm->code_begin() + nm->frame_complete_offset() - entry_barrier_bytes;
NativeNMethodBarrier* barrier = reinterpret_cast<NativeNMethodBarrier*>(barrier_address);
debug_only(barrier->verify());
return barrier;
}

/* We're called from an nmethod when we need to deoptimize it. We do
this by throwing away the nmethod's frame and jumping to the
ic_miss stub. This looks like there has been an IC miss at the
entry of the nmethod, so we resolve the call, which will fall back
to the interpreter if the nmethod has been unloaded. */
void BarrierSetNMethod::deoptimize(nmethod* nm, address* return_address_ptr) {
ShouldNotReachHere();

typedef struct {
intptr_t *sp; intptr_t *fp; address lr; address pc;
} frame_pointers_t;

frame_pointers_t *new_frame = (frame_pointers_t *)(return_address_ptr - 5);

JavaThread *thread = JavaThread::current();
RegisterMap reg_map(thread,
RegisterMap::UpdateMap::skip,
RegisterMap::ProcessFrames::include,
RegisterMap::WalkContinuation::skip);
frame frame = thread->last_frame();

assert(frame.is_compiled_frame() || frame.is_native_frame(), "must be");
assert(frame.cb() == nm, "must be");
frame = frame.sender(&reg_map);

LogTarget(Trace, nmethod, barrier) out;
if (out.is_enabled()) {
ResourceMark mark;
log_trace(nmethod, barrier)("deoptimize(nmethod: %s(%p), return_addr: %p, osr: %d, thread: %p(%s), making rsp: %p) -> %p",
nm->method()->name_and_sig_as_C_string(),
nm, *(address *) return_address_ptr, nm->is_osr_method(), thread,
thread->name(), frame.sp(), nm->verified_entry_point());
}

new_frame->sp = frame.sp();
new_frame->fp = frame.fp();
new_frame->lr = frame.pc();
new_frame->pc = SharedRuntime::get_handle_wrong_method_stub();
}

void BarrierSetNMethod::disarm(nmethod* nm) {
ShouldNotReachHere();
if (!supports_entry_barrier(nm)) {
return;
}

// Disarms the nmethod guard emitted by BarrierSetAssembler::nmethod_entry_barrier.
// Symmetric "LDR; DMB ISHLD" is in the nmethod barrier.
NativeNMethodBarrier* barrier = native_nmethod_barrier(nm);
barrier->set_value(disarmed_value());
}

void BarrierSetNMethod::arm(nmethod* nm, int arm_value) {
if (!supports_entry_barrier(nm)) {
return;
}

NativeNMethodBarrier* barrier = native_nmethod_barrier(nm);
barrier->set_value(arm_value);
}

bool BarrierSetNMethod::is_armed(nmethod* nm) {
ShouldNotReachHere();
return false;
if (!supports_entry_barrier(nm)) {
return false;
}

NativeNMethodBarrier* barrier = native_nmethod_barrier(nm);
return barrier->get_value() != disarmed_value();
}
Loading