Merge branch 'openjdk'
# Conflicts:
# make/windows/makefiles/sa.make
diff --git a/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java b/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java
index a539310..b1f8d83 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java
@@ -113,7 +113,8 @@
private String coreFilename;
private void doUsage() {
- System.out.println("Usage: java CLHSDB [[pid] | [path-to-java-executable [path-to-corefile]] | help ]");
+ // With JDK-8059038 launchers for this class exist. Print usage for those launchers.
+ System.out.println("Usage: clhsdb [[pid] | [path-to-java-executable [path-to-corefile]] | help | -help ]");
System.out.println(" pid: attach to the process whose id is 'pid'");
System.out.println(" path-to-java-executable: Debug a core file produced by this program");
System.out.println(" path-to-corefile: Debug this corefile. The default is 'core'");
diff --git a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
index 9ae362b..97726c4 100644
--- a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
+++ b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java
@@ -82,7 +82,8 @@
private String coreFilename;
private void doUsage() {
- System.out.println("Usage: java HSDB [[pid] | [path-to-java-executable [path-to-corefile]] | help ]");
+ // With JDK-8059038 launchers for this class exist. Print usage for those launchers.
+ System.out.println("Usage: hsdb [[pid] | [path-to-java-executable [path-to-corefile]] | help | -help ]");
System.out.println(" pid: attach to the process whose id is 'pid'");
System.out.println(" path-to-java-executable: Debug a core file produced by this program");
System.out.println(" path-to-corefile: Debug this corefile. The default is 'core'");
diff --git a/make/aix/makefiles/mapfile-vers-debug b/make/aix/makefiles/mapfile-vers-debug
index 0a9d3e9..8f28690 100644
--- a/make/aix/makefiles/mapfile-vers-debug
+++ b/make/aix/makefiles/mapfile-vers-debug
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2018, 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
@@ -63,6 +63,7 @@
JVM_ConstantPoolGetSize;
JVM_ConstantPoolGetStringAt;
JVM_ConstantPoolGetUTF8At;
+ JVM_CopySwapMemory;
JVM_CountStackFrames;
JVM_CurrentClassLoader;
JVM_CurrentLoadedClass;
diff --git a/make/aix/makefiles/mapfile-vers-product b/make/aix/makefiles/mapfile-vers-product
index f748a10..adcb3fc 100644
--- a/make/aix/makefiles/mapfile-vers-product
+++ b/make/aix/makefiles/mapfile-vers-product
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2018, 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
@@ -63,6 +63,7 @@
JVM_ConstantPoolGetSize;
JVM_ConstantPoolGetStringAt;
JVM_ConstantPoolGetUTF8At;
+ JVM_CopySwapMemory;
JVM_CountStackFrames;
JVM_CurrentClassLoader;
JVM_CurrentLoadedClass;
diff --git a/make/bsd/makefiles/mapfile-vers-debug b/make/bsd/makefiles/mapfile-vers-debug
index a94bf88..5e4a6a5 100644
--- a/make/bsd/makefiles/mapfile-vers-debug
+++ b/make/bsd/makefiles/mapfile-vers-debug
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2018, 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
@@ -61,6 +61,7 @@
_JVM_ConstantPoolGetSize
_JVM_ConstantPoolGetStringAt
_JVM_ConstantPoolGetUTF8At
+ _JVM_CopySwapMemory
_JVM_CountStackFrames
_JVM_CurrentClassLoader
_JVM_CurrentLoadedClass
diff --git a/make/bsd/makefiles/mapfile-vers-product b/make/bsd/makefiles/mapfile-vers-product
index 6be8042..b8a83d6 100644
--- a/make/bsd/makefiles/mapfile-vers-product
+++ b/make/bsd/makefiles/mapfile-vers-product
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2018, 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
@@ -61,6 +61,7 @@
_JVM_ConstantPoolGetSize
_JVM_ConstantPoolGetStringAt
_JVM_ConstantPoolGetUTF8At
+ _JVM_CopySwapMemory
_JVM_CountStackFrames
_JVM_CurrentClassLoader
_JVM_CurrentLoadedClass
diff --git a/make/linux/makefiles/mapfile-vers-debug b/make/linux/makefiles/mapfile-vers-debug
index 2da4b7d..f16822b 100644
--- a/make/linux/makefiles/mapfile-vers-debug
+++ b/make/linux/makefiles/mapfile-vers-debug
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2018, 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
@@ -63,6 +63,7 @@
JVM_ConstantPoolGetSize;
JVM_ConstantPoolGetStringAt;
JVM_ConstantPoolGetUTF8At;
+ JVM_CopySwapMemory;
JVM_CountStackFrames;
JVM_CurrentClassLoader;
JVM_CurrentLoadedClass;
diff --git a/make/linux/makefiles/mapfile-vers-product b/make/linux/makefiles/mapfile-vers-product
index 4ec3d5b..f96c86b 100644
--- a/make/linux/makefiles/mapfile-vers-product
+++ b/make/linux/makefiles/mapfile-vers-product
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2018, 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
@@ -63,6 +63,7 @@
JVM_ConstantPoolGetSize;
JVM_ConstantPoolGetStringAt;
JVM_ConstantPoolGetUTF8At;
+ JVM_CopySwapMemory;
JVM_CountStackFrames;
JVM_CurrentClassLoader;
JVM_CurrentLoadedClass;
diff --git a/make/linux/makefiles/saproc.make b/make/linux/makefiles/saproc.make
index d6fa6a9..ffc0ec5 100644
--- a/make/linux/makefiles/saproc.make
+++ b/make/linux/makefiles/saproc.make
@@ -59,6 +59,11 @@
SA_DEBUG_CFLAGS = -g
endif
+# Optimize saproc lib at level -O3 unless it's a slowdebug build
+ifneq ($(BUILD_FLAVOR), debug)
+ SA_OPT_FLAGS = $(OPT_CFLAGS)
+endif
+
# if $(AGENT_DIR) does not exist, we don't build SA
# also, we don't build SA on Itanium or zero.
@@ -95,6 +100,7 @@
$(SASRCFILES) \
$(SA_LFLAGS) \
$(SA_DEBUG_CFLAGS) \
+ $(SA_OPT_FLAGS) \
$(EXTRA_CFLAGS) \
-o $@ \
-lthread_db -ldl
diff --git a/make/solaris/makefiles/mapfile-vers b/make/solaris/makefiles/mapfile-vers
index 7ebaaaa..d76be6c 100644
--- a/make/solaris/makefiles/mapfile-vers
+++ b/make/solaris/makefiles/mapfile-vers
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2018, 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
@@ -64,6 +64,7 @@
JVM_ConstantPoolGetStringAt;
JVM_ConstantPoolGetUTF8At;
JVM_CountStackFrames;
+ JVM_CopySwapMemory;
JVM_CurrentClassLoader;
JVM_CurrentLoadedClass;
JVM_CurrentThread;
diff --git a/make/windows/makefiles/sa.make b/make/windows/makefiles/sa.make
index 5242b33..3cf42e6 100644
--- a/make/windows/makefiles/sa.make
+++ b/make/windows/makefiles/sa.make
@@ -81,22 +81,38 @@
checkAndBuildSA:: $(SAWINDBG)
-# These do not need to be optimized (don't run a lot of code) and it
-# will be useful to have the assertion checks in place
+!if "$(BUILD_FLAVOR)" == "debug"
+SA_EXTRA_CFLAGS = -Od -D "_DEBUG"
+!if "$(BUILDARCH)" == "i486"
+SA_EXTRA_CFLAGS = $(SA_EXTRA_CFLAGS) -RTC1
+!endif
+!elseif "$(BUILD_FLAVOR)" == "fastdebug"
+SA_EXTRA_CFLAGS = -O2 -D "_DEBUG"
+!else
+SA_EXTRA_CFLAGS = -O2
+!endif
!if "$(BUILDARCH)" == "ia64"
-SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -c
+SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_CONSOLE" -D "_MBCS" -YX -FD -c
!elseif "$(BUILDARCH)" == "amd64"
-SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -c
+SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_CONSOLE" -D "_MBCS" -YX -FD -c
+!if "$(COMPILER_NAME)" == "VS2005"
+# On amd64, VS2005 compiler requires bufferoverflowU.lib on the link command line,
+# otherwise we get missing __security_check_cookie externals at link time.
+SA_LD_FLAGS = bufferoverflowU.lib
+!endif
!else
-SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -RTC1 -c
+SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 -Gm $(GX_OPTION) -D "WIN32" -D "_WINDOWS" -D "_CONSOLE" -D "_MBCS" -YX -FD -c
!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
-SA_CFLAGS = $(SA_CFLAGS) -ZI
+# -ZI is incompatible with -O2 used for release/fastdebug builds.
+# Using -Zi instead.
+SA_CFLAGS = $(SA_CFLAGS) -Zi
!endif
!endif
!if "$(MT)" != ""
SA_LD_FLAGS = -manifest $(SA_LD_FLAGS)
!endif
+SA_CFLAGS = $(SA_CFLAGS) $(SA_EXTRA_CFLAGS)
SASRCFILES = $(AGENT_DIR)/src/os/win32/windbg/sawindbg.cpp \
$(AGENT_DIR)/src/share/native/sadis.c
diff --git a/src/cpu/ppc/vm/assembler_ppc.hpp b/src/cpu/ppc/vm/assembler_ppc.hpp
index aeee163..ddd0751 100644
--- a/src/cpu/ppc/vm/assembler_ppc.hpp
+++ b/src/cpu/ppc/vm/assembler_ppc.hpp
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, 2013 SAP AG. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, SAP SE. 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
@@ -1838,7 +1838,7 @@
inline void vperm( VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c);
inline void vsel( VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c);
inline void vsl( VectorRegister d, VectorRegister a, VectorRegister b);
- inline void vsldoi( VectorRegister d, VectorRegister a, VectorRegister b, int si4);
+ inline void vsldoi( VectorRegister d, VectorRegister a, VectorRegister b, int ui4);
inline void vslo( VectorRegister d, VectorRegister a, VectorRegister b);
inline void vsr( VectorRegister d, VectorRegister a, VectorRegister b);
inline void vsro( VectorRegister d, VectorRegister a, VectorRegister b);
diff --git a/src/cpu/ppc/vm/assembler_ppc.inline.hpp b/src/cpu/ppc/vm/assembler_ppc.inline.hpp
index 7f9c72b..3c66cbb 100644
--- a/src/cpu/ppc/vm/assembler_ppc.inline.hpp
+++ b/src/cpu/ppc/vm/assembler_ppc.inline.hpp
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, 2014 SAP AG. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, SAP SE. 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
@@ -657,7 +657,7 @@
inline void Assembler::vperm( VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c){ emit_int32( VPERM_OPCODE | vrt(d) | vra(a) | vrb(b) | vrc(c)); }
inline void Assembler::vsel( VectorRegister d, VectorRegister a, VectorRegister b, VectorRegister c){ emit_int32( VSEL_OPCODE | vrt(d) | vra(a) | vrb(b) | vrc(c)); }
inline void Assembler::vsl( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSL_OPCODE | vrt(d) | vra(a) | vrb(b)); }
-inline void Assembler::vsldoi( VectorRegister d, VectorRegister a, VectorRegister b, int si4) { emit_int32( VSLDOI_OPCODE| vrt(d) | vra(a) | vrb(b) | vsldoi_shb(simm(si4,4))); }
+inline void Assembler::vsldoi( VectorRegister d, VectorRegister a, VectorRegister b, int ui4) { emit_int32( VSLDOI_OPCODE| vrt(d) | vra(a) | vrb(b) | vsldoi_shb(uimm(ui4,4))); }
inline void Assembler::vslo( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSLO_OPCODE | vrt(d) | vra(a) | vrb(b)); }
inline void Assembler::vsr( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSR_OPCODE | vrt(d) | vra(a) | vrb(b)); }
inline void Assembler::vsro( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VSRO_OPCODE | vrt(d) | vra(a) | vrb(b)); }
diff --git a/src/cpu/ppc/vm/macroAssembler_ppc.cpp b/src/cpu/ppc/vm/macroAssembler_ppc.cpp
index 5b621cf..a140b36 100644
--- a/src/cpu/ppc/vm/macroAssembler_ppc.cpp
+++ b/src/cpu/ppc/vm/macroAssembler_ppc.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, 2017 SAP AG. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, SAP SE. 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
@@ -3570,12 +3570,12 @@
vspltisw(VR0, -1);
vsldoi(mask_32bit, zeroes, VR0, 4);
- vsldoi(mask_64bit, zeroes, VR0, -8);
+ vsldoi(mask_64bit, zeroes, VR0, 8);
// Get the initial value into v8
vxor(VR8, VR8, VR8);
mtvrd(VR8, crc);
- vsldoi(VR8, zeroes, VR8, -8); // shift into bottom 32 bits
+ vsldoi(VR8, zeroes, VR8, 8); // shift into bottom 32 bits
li (rLoaded, 0);
@@ -3924,7 +3924,7 @@
addi(barretConstants, barretConstants, 16);
lvx(const2, barretConstants);
- vsldoi(VR1, VR0, VR0, -8);
+ vsldoi(VR1, VR0, VR0, 8);
vxor(VR0, VR0, VR1); // xor two 64 bit results together
// shift left one bit
diff --git a/src/cpu/ppc/vm/stubGenerator_ppc.cpp b/src/cpu/ppc/vm/stubGenerator_ppc.cpp
index 58dca0b..1b7fb41 100644
--- a/src/cpu/ppc/vm/stubGenerator_ppc.cpp
+++ b/src/cpu/ppc/vm/stubGenerator_ppc.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, 2014 SAP AG. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, SAP SE. 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
@@ -2023,7 +2023,7 @@
__ vspltisb (vTmp2, -16);
__ vrld (keyPerm, keyPerm, vTmp2);
__ vrld (keyPerm, keyPerm, vTmp2);
- __ vsldoi (keyPerm, keyPerm, keyPerm, -8);
+ __ vsldoi (keyPerm, keyPerm, keyPerm, 8);
// load the 1st round key to vKey1
__ li (keypos, 0);
@@ -2223,7 +2223,7 @@
__ vspltisb (vTmp2, -16);
__ vrld (keyPerm, keyPerm, vTmp2);
__ vrld (keyPerm, keyPerm, vTmp2);
- __ vsldoi (keyPerm, keyPerm, keyPerm, -8);
+ __ vsldoi (keyPerm, keyPerm, keyPerm, 8);
__ cmpwi (CCR0, keylen, 44);
__ beq (CCR0, L_do44);
diff --git a/src/cpu/x86/vm/interp_masm_x86_32.cpp b/src/cpu/x86/vm/interp_masm_x86_32.cpp
index 8a132c1..84cdc94 100644
--- a/src/cpu/x86/vm/interp_masm_x86_32.cpp
+++ b/src/cpu/x86/vm/interp_masm_x86_32.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -1445,5 +1445,7 @@
incrementl(scratch, increment);
movl(counter_addr, scratch);
andl(scratch, mask);
- jcc(cond, *where);
+ if (where != NULL) {
+ jcc(cond, *where);
+ }
}
diff --git a/src/cpu/x86/vm/interp_masm_x86_64.cpp b/src/cpu/x86/vm/interp_masm_x86_64.cpp
index 693ac79..727207e 100644
--- a/src/cpu/x86/vm/interp_masm_x86_64.cpp
+++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -1505,5 +1505,7 @@
incrementl(scratch, increment);
movl(counter_addr, scratch);
andl(scratch, mask);
- jcc(cond, *where);
+ if (where != NULL) {
+ jcc(cond, *where);
+ }
}
diff --git a/src/cpu/x86/vm/templateTable_x86_32.cpp b/src/cpu/x86/vm/templateTable_x86_32.cpp
index df49786..5d33add 100644
--- a/src/cpu/x86/vm/templateTable_x86_32.cpp
+++ b/src/cpu/x86/vm/templateTable_x86_32.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -1640,15 +1640,16 @@
// Increment the MDO backedge counter
const Address mdo_backedge_counter(rbx, in_bytes(MethodData::backedge_counter_offset()) +
in_bytes(InvocationCounter::counter_offset()));
- __ increment_mask_and_jump(mdo_backedge_counter, increment, mask,
- rax, false, Assembler::zero, &backedge_counter_overflow);
+ __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, rax, false, Assembler::zero,
+ UseOnStackReplacement ? &backedge_counter_overflow : NULL);
__ jmp(dispatch);
}
__ bind(no_mdo);
// Increment backedge counter in MethodCounters*
__ movptr(rcx, Address(rcx, Method::method_counters_offset()));
__ increment_mask_and_jump(Address(rcx, be_offset), increment, mask,
- rax, false, Assembler::zero, &backedge_counter_overflow);
+ rax, false, Assembler::zero,
+ UseOnStackReplacement ? &backedge_counter_overflow : NULL);
} else {
// increment counter
__ movptr(rcx, Address(rcx, Method::method_counters_offset()));
diff --git a/src/cpu/x86/vm/templateTable_x86_64.cpp b/src/cpu/x86/vm/templateTable_x86_64.cpp
index 301acb4..a619f44 100644
--- a/src/cpu/x86/vm/templateTable_x86_64.cpp
+++ b/src/cpu/x86/vm/templateTable_x86_64.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -1665,15 +1665,16 @@
// Increment the MDO backedge counter
const Address mdo_backedge_counter(rbx, in_bytes(MethodData::backedge_counter_offset()) +
in_bytes(InvocationCounter::counter_offset()));
- __ increment_mask_and_jump(mdo_backedge_counter, increment, mask,
- rax, false, Assembler::zero, &backedge_counter_overflow);
+ __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, rax, false, Assembler::zero,
+ UseOnStackReplacement ? &backedge_counter_overflow : NULL);
__ jmp(dispatch);
}
__ bind(no_mdo);
// Increment backedge counter in MethodCounters*
__ movptr(rcx, Address(rcx, Method::method_counters_offset()));
__ increment_mask_and_jump(Address(rcx, be_offset), increment, mask,
- rax, false, Assembler::zero, &backedge_counter_overflow);
+ rax, false, Assembler::zero,
+ UseOnStackReplacement ? &backedge_counter_overflow : NULL);
} else {
// increment counter
__ movptr(rcx, Address(rcx, Method::method_counters_offset()));
diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp
index 387ff03..4d4dad0 100644
--- a/src/os/linux/vm/os_linux.cpp
+++ b/src/os/linux/vm/os_linux.cpp
@@ -724,6 +724,10 @@
}
}
+void os::Linux::expand_stack_to(address bottom) {
+ _expand_stack_to(bottom);
+}
+
bool os::Linux::manually_expand_stack(JavaThread * t, address addr) {
assert(t!=NULL, "just checking");
assert(t->osthread()->expanding_stack(), "expand should be set");
diff --git a/src/os/linux/vm/os_linux.hpp b/src/os/linux/vm/os_linux.hpp
index 046d712..e207dcc 100644
--- a/src/os/linux/vm/os_linux.hpp
+++ b/src/os/linux/vm/os_linux.hpp
@@ -249,6 +249,8 @@
static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
private:
+ static void expand_stack_to(address bottom);
+
typedef int (*sched_getcpu_func_t)(void);
typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
typedef int (*numa_max_node_func_t)(void);
diff --git a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
index 0f38292..1a7375a 100644
--- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
+++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
@@ -892,6 +892,27 @@
void os::workaround_expand_exec_shield_cs_limit() {
#if defined(IA32)
size_t page_size = os::vm_page_size();
+
+ /*
+ * JDK-8197429
+ *
+ * Expand the stack mapping to the end of the initial stack before
+ * attempting to install the codebuf. This is needed because newer
+ * Linux kernels impose a distance of a megabyte between stack
+ * memory and other memory regions. If we try to install the
+ * codebuf before expanding the stack the installation will appear
+ * to succeed but we'll get a segfault later if we expand the stack
+ * in Java code.
+ *
+ */
+ if (os::is_primordial_thread()) {
+ address limit = Linux::initial_thread_stack_bottom();
+ if (! DisablePrimordialThreadGuardPages) {
+ limit += (StackYellowPages + StackRedPages) * page_size;
+ }
+ os::Linux::expand_stack_to(limit);
+ }
+
/*
* Take the highest VA the OS will give us and exec
*
@@ -910,6 +931,16 @@
char* hint = (char*) (Linux::initial_thread_stack_bottom() -
((StackYellowPages + StackRedPages + 1) * page_size));
char* codebuf = os::attempt_reserve_memory_at(page_size, hint);
+
+ if (codebuf == NULL) {
+ // JDK-8197429: There may be a stack gap of one megabyte between
+ // the limit of the stack and the nearest memory region: this is a
+ // Linux kernel workaround for CVE-2017-1000364. If we failed to
+ // map our codebuf, try again at an address one megabyte lower.
+ hint -= 1 * M;
+ codebuf = os::attempt_reserve_memory_at(page_size, hint);
+ }
+
if ( (codebuf == NULL) || (!os::commit_memory(codebuf, page_size, true)) ) {
return; // No matter, we tried, best effort.
}
diff --git a/src/share/vm/asm/assembler.hpp b/src/share/vm/asm/assembler.hpp
index ec8ec5e..ac39e6a 100644
--- a/src/share/vm/asm/assembler.hpp
+++ b/src/share/vm/asm/assembler.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -169,6 +169,14 @@
Label() {
init();
}
+
+ ~Label() {
+ assert(is_bound() || is_unused(), "Label was never bound to a location, but it was used as a jmp target");
+ }
+
+ void reset() {
+ init(); //leave _patch_overflow because it points to CodeBuffer.
+ }
};
// A union type for code which has to assemble both constant and
diff --git a/src/share/vm/c1/c1_LIRAssembler.cpp b/src/share/vm/c1/c1_LIRAssembler.cpp
index 3447e07..a2cf5f2 100644
--- a/src/share/vm/c1/c1_LIRAssembler.cpp
+++ b/src/share/vm/c1/c1_LIRAssembler.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, 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
@@ -128,6 +128,9 @@
LIR_Assembler::~LIR_Assembler() {
+ // The unwind handler label may be unbound if this destructor is invoked because of a bail-out.
+ // Reset it here to avoid an assertion.
+ _unwind_handler_entry.reset();
}
diff --git a/src/share/vm/memory/metaspace.hpp b/src/share/vm/memory/metaspace.hpp
index 36b00a5..e1979ff 100644
--- a/src/share/vm/memory/metaspace.hpp
+++ b/src/share/vm/memory/metaspace.hpp
@@ -259,7 +259,7 @@
// Debugging support
void verify();
- static void print_compressed_class_space(outputStream* st, const char* requested_addr = 0);
+ static void print_compressed_class_space(outputStream* st, const char* requested_addr = 0) NOT_LP64({});
class AllocRecordClosure : public StackObj {
public:
diff --git a/src/share/vm/prims/jvm.cpp b/src/share/vm/prims/jvm.cpp
index f346153..c9d8cc8 100644
--- a/src/share/vm/prims/jvm.cpp
+++ b/src/share/vm/prims/jvm.cpp
@@ -759,6 +759,79 @@
JVM_END
+// java.nio.Bits ///////////////////////////////////////////////////////////////
+
+#define MAX_OBJECT_SIZE \
+ ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \
+ + ((julong)max_jint * sizeof(double)) )
+
+static inline jlong field_offset_to_byte_offset(jlong field_offset) {
+ return field_offset;
+}
+
+static inline void assert_field_offset_sane(oop p, jlong field_offset) {
+#ifdef ASSERT
+ jlong byte_offset = field_offset_to_byte_offset(field_offset);
+
+ if (p != NULL) {
+ assert(byte_offset >= 0 && byte_offset <= (jlong)MAX_OBJECT_SIZE, "sane offset");
+ if (byte_offset == (jint)byte_offset) {
+ void* ptr_plus_disp = (address)p + byte_offset;
+ assert((void*)p->obj_field_addr<oop>((jint)byte_offset) == ptr_plus_disp,
+ "raw [ptr+disp] must be consistent with oop::field_base");
+ }
+ jlong p_size = HeapWordSize * (jlong)(p->size());
+ assert(byte_offset < p_size, err_msg("Unsafe access: offset " INT64_FORMAT
+ " > object's size " INT64_FORMAT,
+ (int64_t)byte_offset, (int64_t)p_size));
+ }
+#endif
+}
+
+static inline void* index_oop_from_field_offset_long(oop p, jlong field_offset) {
+ assert_field_offset_sane(p, field_offset);
+ jlong byte_offset = field_offset_to_byte_offset(field_offset);
+
+ if (sizeof(char*) == sizeof(jint)) { // (this constant folds!)
+ return (address)p + (jint) byte_offset;
+ } else {
+ return (address)p + byte_offset;
+ }
+}
+
+// This function is a leaf since if the source and destination are both in native memory
+// the copy may potentially be very large, and we don't want to disable GC if we can avoid it.
+// If either source or destination (or both) are on the heap, the function will enter VM using
+// JVM_ENTRY_FROM_LEAF
+JVM_LEAF(void, JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset,
+ jobject dstObj, jlong dstOffset, jlong size,
+ jlong elemSize)) {
+
+ size_t sz = (size_t)size;
+ size_t esz = (size_t)elemSize;
+
+ if (srcObj == NULL && dstObj == NULL) {
+ // Both src & dst are in native memory
+ address src = (address)srcOffset;
+ address dst = (address)dstOffset;
+
+ Copy::conjoint_swap(src, dst, sz, esz);
+ } else {
+ // At least one of src/dst are on heap, transition to VM to access raw pointers
+
+ JVM_ENTRY_FROM_LEAF(env, void, JVM_CopySwapMemory) {
+ oop srcp = JNIHandles::resolve(srcObj);
+ oop dstp = JNIHandles::resolve(dstObj);
+
+ address src = (address)index_oop_from_field_offset_long(srcp, srcOffset);
+ address dst = (address)index_oop_from_field_offset_long(dstp, dstOffset);
+
+ Copy::conjoint_swap(src, dst, sz, esz);
+ } JVM_END
+ }
+} JVM_END
+
+
// Misc. class handling ///////////////////////////////////////////////////////////
diff --git a/src/share/vm/prims/jvm.h b/src/share/vm/prims/jvm.h
index 3b36b73..2c64341 100644
--- a/src/share/vm/prims/jvm.h
+++ b/src/share/vm/prims/jvm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -145,6 +145,14 @@
JVM_OnExit(void (*func)(void));
/*
+ * java.nio.Bits
+ */
+JNIEXPORT void JNICALL
+JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset,
+ jobject dstObj, jlong dstOffset, jlong size,
+ jlong elemSize);
+
+/*
* java.lang.Runtime
*/
JNIEXPORT void JNICALL
diff --git a/src/share/vm/runtime/fprofiler.cpp b/src/share/vm/runtime/fprofiler.cpp
index a4d01b8..4290a5d 100644
--- a/src/share/vm/runtime/fprofiler.cpp
+++ b/src/share/vm/runtime/fprofiler.cpp
@@ -775,7 +775,7 @@
}
void ThreadProfiler::vm_update(TickPosition where) {
- vm_update(NULL, where);
+ vm_update("", where);
}
void ThreadProfiler::vm_update(const char* name, TickPosition where) {
diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
index 5b44955..421a3ba 100644
--- a/src/share/vm/runtime/globals.hpp
+++ b/src/share/vm/runtime/globals.hpp
@@ -768,8 +768,8 @@
"Time out and warn or fail after SafepointTimeoutDelay " \
"milliseconds if failed to reach safepoint") \
\
- develop(bool, DieOnSafepointTimeout, false, \
- "Die upon failure to reach safepoint (see SafepointTimeout)") \
+ diagnostic(bool, AbortVMOnSafepointTimeout, false, \
+ "Abort upon failure to reach safepoint (see SafepointTimeout)") \
\
/* 50 retries * (5 * current_retry_count) millis = ~6.375 seconds */ \
/* typically, at most a few retries are needed */ \
diff --git a/src/share/vm/runtime/interfaceSupport.hpp b/src/share/vm/runtime/interfaceSupport.hpp
index fa9ad5e..7a20fba 100644
--- a/src/share/vm/runtime/interfaceSupport.hpp
+++ b/src/share/vm/runtime/interfaceSupport.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -431,6 +431,14 @@
os::verify_stack_alignment(); \
/* begin of body */
+#define VM_ENTRY_BASE_FROM_LEAF(result_type, header, thread) \
+ TRACE_CALL(result_type, header) \
+ debug_only(ResetNoHandleMark __rnhm;) \
+ HandleMarkCleaner __hm(thread); \
+ Thread* THREAD = thread; \
+ os::verify_stack_alignment(); \
+ /* begin of body */
+
// ENTRY routines may lock, GC and throw exceptions
@@ -592,6 +600,14 @@
VM_LEAF_BASE(result_type, header)
+#define JVM_ENTRY_FROM_LEAF(env, result_type, header) \
+ { { \
+ JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
+ ThreadInVMfromNative __tiv(thread); \
+ debug_only(VMNativeEntryWrapper __vew;) \
+ VM_ENTRY_BASE_FROM_LEAF(result_type, header, thread)
+
+
#define JVM_END } }
#endif // SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
diff --git a/src/share/vm/runtime/safepoint.cpp b/src/share/vm/runtime/safepoint.cpp
index 1d75cae..be4bb45 100644
--- a/src/share/vm/runtime/safepoint.cpp
+++ b/src/share/vm/runtime/safepoint.cpp
@@ -790,9 +790,9 @@
tty->print_cr("# SafepointSynchronize::begin: (End of list)");
}
- // To debug the long safepoint, specify both DieOnSafepointTimeout &
+ // To debug the long safepoint, specify both AbortVMOnSafepointTimeout &
// ShowMessageBoxOnError.
- if (DieOnSafepointTimeout) {
+ if (AbortVMOnSafepointTimeout) {
char msg[1024];
VM_Operation *op = VMThread::vm_operation();
sprintf(msg, "Safepoint sync time longer than " INTX_FORMAT "ms detected when executing %s.",
diff --git a/src/share/vm/utilities/copy.cpp b/src/share/vm/utilities/copy.cpp
index 56e1cfc..0d64178 100644
--- a/src/share/vm/utilities/copy.cpp
+++ b/src/share/vm/utilities/copy.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -53,6 +53,175 @@
}
}
+class CopySwap : AllStatic {
+public:
+ /**
+ * Copy and byte swap elements
+ *
+ * @param src address of source
+ * @param dst address of destination
+ * @param byte_count number of bytes to copy
+ * @param elem_size size of the elements to copy-swap
+ */
+ static void conjoint_swap(address src, address dst, size_t byte_count, size_t elem_size) {
+ assert(src != NULL, "address must not be NULL");
+ assert(dst != NULL, "address must not be NULL");
+ assert(elem_size == 2 || elem_size == 4 || elem_size == 8,
+ err_msg("incorrect element size: " SIZE_FORMAT, elem_size));
+ assert(is_size_aligned(byte_count, elem_size),
+ err_msg("byte_count " SIZE_FORMAT " must be multiple of element size " SIZE_FORMAT, byte_count, elem_size));
+
+ address src_end = src + byte_count;
+
+ if (dst <= src || dst >= src_end) {
+ do_conjoint_swap<RIGHT>(src, dst, byte_count, elem_size);
+ } else {
+ do_conjoint_swap<LEFT>(src, dst, byte_count, elem_size);
+ }
+ }
+
+private:
+ /**
+ * Byte swap a 16-bit value
+ */
+ static uint16_t byte_swap(uint16_t x) {
+ return (x << 8) | (x >> 8);
+ }
+
+ /**
+ * Byte swap a 32-bit value
+ */
+ static uint32_t byte_swap(uint32_t x) {
+ uint16_t lo = (uint16_t)x;
+ uint16_t hi = (uint16_t)(x >> 16);
+
+ return ((uint32_t)byte_swap(lo) << 16) | (uint32_t)byte_swap(hi);
+ }
+
+ /**
+ * Byte swap a 64-bit value
+ */
+ static uint64_t byte_swap(uint64_t x) {
+ uint32_t lo = (uint32_t)x;
+ uint32_t hi = (uint32_t)(x >> 32);
+
+ return ((uint64_t)byte_swap(lo) << 32) | (uint64_t)byte_swap(hi);
+ }
+
+ enum CopyDirection {
+ RIGHT, // lower -> higher address
+ LEFT // higher -> lower address
+ };
+
+ /**
+ * Copy and byte swap elements
+ *
+ * <T> - type of element to copy
+ * <D> - copy direction
+ * <is_src_aligned> - true if src argument is aligned to element size
+ * <is_dst_aligned> - true if dst argument is aligned to element size
+ *
+ * @param src address of source
+ * @param dst address of destination
+ * @param byte_count number of bytes to copy
+ */
+ template <typename T, CopyDirection D, bool is_src_aligned, bool is_dst_aligned>
+ static void do_conjoint_swap(address src, address dst, size_t byte_count) {
+ address cur_src, cur_dst;
+
+ switch (D) {
+ case RIGHT:
+ cur_src = src;
+ cur_dst = dst;
+ break;
+ case LEFT:
+ cur_src = src + byte_count - sizeof(T);
+ cur_dst = dst + byte_count - sizeof(T);
+ break;
+ }
+
+ for (size_t i = 0; i < byte_count / sizeof(T); i++) {
+ T tmp;
+
+ if (is_src_aligned) {
+ tmp = *(T*)cur_src;
+ } else {
+ memcpy(&tmp, cur_src, sizeof(T));
+ }
+
+ tmp = byte_swap(tmp);
+
+ if (is_dst_aligned) {
+ *(T*)cur_dst = tmp;
+ } else {
+ memcpy(cur_dst, &tmp, sizeof(T));
+ }
+
+ switch (D) {
+ case RIGHT:
+ cur_src += sizeof(T);
+ cur_dst += sizeof(T);
+ break;
+ case LEFT:
+ cur_src -= sizeof(T);
+ cur_dst -= sizeof(T);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Copy and byte swap elements
+ *
+ * <T> - type of element to copy
+ * <D> - copy direction
+ *
+ * @param src address of source
+ * @param dst address of destination
+ * @param byte_count number of bytes to copy
+ */
+ template <typename T, CopyDirection direction>
+ static void do_conjoint_swap(address src, address dst, size_t byte_count) {
+ if (is_ptr_aligned(src, sizeof(T))) {
+ if (is_ptr_aligned(dst, sizeof(T))) {
+ do_conjoint_swap<T,direction,true,true>(src, dst, byte_count);
+ } else {
+ do_conjoint_swap<T,direction,true,false>(src, dst, byte_count);
+ }
+ } else {
+ if (is_ptr_aligned(dst, sizeof(T))) {
+ do_conjoint_swap<T,direction,false,true>(src, dst, byte_count);
+ } else {
+ do_conjoint_swap<T,direction,false,false>(src, dst, byte_count);
+ }
+ }
+ }
+
+
+ /**
+ * Copy and byte swap elements
+ *
+ * <D> - copy direction
+ *
+ * @param src address of source
+ * @param dst address of destination
+ * @param byte_count number of bytes to copy
+ * @param elem_size size of the elements to copy-swap
+ */
+ template <CopyDirection D>
+ static void do_conjoint_swap(address src, address dst, size_t byte_count, size_t elem_size) {
+ switch (elem_size) {
+ case 2: do_conjoint_swap<uint16_t,D>(src, dst, byte_count); break;
+ case 4: do_conjoint_swap<uint32_t,D>(src, dst, byte_count); break;
+ case 8: do_conjoint_swap<uint64_t,D>(src, dst, byte_count); break;
+ default: guarantee(false, err_msg("do_conjoint_swap: Invalid elem_size %zd\n", elem_size));
+ }
+ }
+};
+
+void Copy::conjoint_swap(address src, address dst, size_t byte_count, size_t elem_size) {
+ CopySwap::conjoint_swap(src, dst, byte_count, elem_size);
+}
// Fill bytes; larger units are filled atomically if everything is aligned.
void Copy::fill_to_memory_atomic(void* to, size_t size, jubyte value) {
diff --git a/src/share/vm/utilities/copy.hpp b/src/share/vm/utilities/copy.hpp
index 3dcbfee..66f9887 100644
--- a/src/share/vm/utilities/copy.hpp
+++ b/src/share/vm/utilities/copy.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -227,6 +227,16 @@
}
}
+ /**
+ * Copy and *unconditionally* byte swap elements
+ *
+ * @param src address of source
+ * @param dst address of destination
+ * @param byte_count number of bytes to copy
+ * @param elem_size size of the elements to copy-swap
+ */
+ static void conjoint_swap(address src, address dst, size_t byte_count, size_t elem_size);
+
// Fill methods
// Fill word-aligned words, not atomic on each word
diff --git a/test/runtime/StackGap/T.java b/test/runtime/StackGap/T.java
new file mode 100644
index 0000000..7d46348
--- /dev/null
+++ b/test/runtime/StackGap/T.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2018, Red Hat, Inc. 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.
+ */
+
+public class T {
+
+ public static void test(int n) {
+ if (n == 0) return;
+ System.out.println (n);
+ test (n - 1);
+
+ }
+
+}
diff --git a/test/runtime/StackGap/exestack-gap.c b/test/runtime/StackGap/exestack-gap.c
new file mode 100644
index 0000000..ebb7b1d
--- /dev/null
+++ b/test/runtime/StackGap/exestack-gap.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018, Red Hat, Inc. 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 <jni.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+JNIEnv* create_vm(JavaVM **jvm, char *extra_option)
+{
+ JNIEnv* env;
+ JavaVMInitArgs args;
+ JavaVMOption options[4];
+ args.version = JNI_VERSION_1_8;
+ args.nOptions = 3 + (extra_option != NULL);
+ options[0].optionString = "-Xss2048k";
+ char classpath[4096];
+ snprintf(classpath, sizeof classpath,
+ "-Djava.class.path=%s", getenv("CLASSPATH"));
+ options[1].optionString = classpath;
+ options[2].optionString = "-XX:+UnlockExperimentalVMOptions";
+ if (extra_option) {
+ options[3].optionString = extra_option;
+ }
+ args.options = &options[0];
+ args.ignoreUnrecognized = 0;
+ int rv;
+ rv = JNI_CreateJavaVM(jvm, (void**)&env, &args);
+ if (rv < 0) return NULL;
+ return env;
+}
+
+void run(char *extra_arg) {
+ JavaVM *jvm;
+ jclass T_class;
+ jmethodID test_method;
+ JNIEnv *env = create_vm(&jvm, extra_arg);
+ if (env == NULL)
+ exit(1);
+ T_class = (*env)->FindClass(env, "T");
+ if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
+ (*env)->ExceptionDescribe(env);
+ exit(1);
+ }
+ test_method = (*env)->GetStaticMethodID(env, T_class, "test", "(I)V");
+ if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
+ (*env)->ExceptionDescribe(env);
+ exit(1);
+ }
+ (*env)->CallStaticVoidMethod(env, T_class, test_method, 1000);
+}
+
+
+int main(int argc, char **argv)
+{
+ if (argc > 1) {
+ run(argv[1]);
+ } else {
+ run(NULL);
+ }
+
+ return 0;
+}
diff --git a/test/runtime/StackGap/testme.sh b/test/runtime/StackGap/testme.sh
new file mode 100644
index 0000000..90265e6
--- /dev/null
+++ b/test/runtime/StackGap/testme.sh
@@ -0,0 +1,73 @@
+# Copyright (c) 2014, 2018, 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
+# 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.
+#!/bin/sh
+
+#
+# @test testme.sh
+# @bug 8197429
+# @summary Linux kernel stack guard should not cause segfaults on x86-32
+# @compile T.java
+# @run shell testme.sh
+#
+
+if [ "${TESTSRC}" = "" ]
+then
+ TESTSRC=${PWD}
+ echo "TESTSRC not set. Using "${TESTSRC}" as default"
+fi
+echo "TESTSRC=${TESTSRC}"
+## Adding common setup Variables for running shell tests.
+. ${TESTSRC}/../../test_env.sh
+
+if [ "${VM_OS}" != "linux" ]
+then
+ echo "Test only valid for Linux"
+ exit 0
+fi
+
+gcc_cmd=`which gcc`
+if [ "x$gcc_cmd" = "x" ]; then
+ echo "WARNING: gcc not found. Cannot execute test." 2>&1
+ 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
+
+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 \
+ -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
+ -L${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
+ -ljvm -lpthread exestack-gap.c
+
+./stack-gap || exit $?
+./stack-gap -XX:+DisablePrimordialThreadGuardPages || exit $?