< prev index next >

test/compiler/uncommontrap/UncommonTrapStackBang.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 /**
  26  * @test
  27  * @bug 8026775
  28  * @summary Uncommon trap blob did not bang all the stack shadow pages
  29  *
  30  * @run main/othervm UncommonTrapStackBang
  31  *


  32  * Note: This test does not reproduce the problem with absolute
  33  * certainty. Empirically the bug reproduces on Windows some 80+% of
  34  * the time. Setting everything up to fail in 100% of the cases turns
  35  * out to be tricky at best.
  36  *
  37  *
  38  * The goal of this test is to set up the following stack:
  39  *
  40  * doIt()
  41  * eatStack()
  42  * ...
  43  * eatStack()
  44  * run()
  45  *
  46  *
  47  * When doIt() gets executed it will hit an uncommon trap and expand
  48  * into a huge interpreter frame. The doIt method then calls the
  49  * compiled version of StringBuilder.<init>() which does a single
  50  * stack bang StackShadowPages down.
  51  *
  52  * The uncommon trap blob is supposed to prepare for the interpreter
  53  * by pre-touching stack pages. The bug was that it didn't correctly
  54  * pre-touch all the stack shadow pages, leaving a "hole" on the stack
  55  * which raises an exception on Windows when the stack bang in
  56  * StringBuilder is performed.
  57  */



  58 public class UncommonTrapStackBang extends Thread {
  59     class Foo { }
  60 
  61     public static void main(String[] args) throws Exception {
  62         doWarmup();
  63 
  64         // Fork off a new thread to increase odds of the stack being unmapped
  65         UncommonTrapStackBang htsb = new UncommonTrapStackBang();
  66         htsb.run();
  67         htsb.join();
  68     }
  69 
  70     // Make sure:
  71     //
  72     // a) StringBuilder.<init>()V is compiled
  73     // b) doIt() is compiled with an uncommon trap in the unlikely path
  74     public static void doWarmup() {
  75         for (int i = 0; i < 100_000; i++) {
  76             new StringBuilder();
  77 




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 /**
  26  * @test
  27  * @bug 8026775
  28  * @summary Uncommon trap blob did not bang all the stack shadow pages
  29  *
  30  * @run main/othervm compiler.uncommontrap.UncommonTrapStackBang
  31  */
  32 
  33 /*
  34  * Note: This test does not reproduce the problem with absolute
  35  * certainty. Empirically the bug reproduces on Windows some 80+% of
  36  * the time. Setting everything up to fail in 100% of the cases turns
  37  * out to be tricky at best.
  38  *
  39  *
  40  * The goal of this test is to set up the following stack:
  41  *
  42  * doIt()
  43  * eatStack()
  44  * ...
  45  * eatStack()
  46  * run()
  47  *
  48  *
  49  * When doIt() gets executed it will hit an uncommon trap and expand
  50  * into a huge interpreter frame. The doIt method then calls the
  51  * compiled version of StringBuilder.<init>() which does a single
  52  * stack bang StackShadowPages down.
  53  *
  54  * The uncommon trap blob is supposed to prepare for the interpreter
  55  * by pre-touching stack pages. The bug was that it didn't correctly
  56  * pre-touch all the stack shadow pages, leaving a "hole" on the stack
  57  * which raises an exception on Windows when the stack bang in
  58  * StringBuilder is performed.
  59  */
  60 
  61 package compiler.uncommontrap;
  62 
  63 public class UncommonTrapStackBang extends Thread {
  64     class Foo { }
  65 
  66     public static void main(String[] args) throws Exception {
  67         doWarmup();
  68 
  69         // Fork off a new thread to increase odds of the stack being unmapped
  70         UncommonTrapStackBang htsb = new UncommonTrapStackBang();
  71         htsb.run();
  72         htsb.join();
  73     }
  74 
  75     // Make sure:
  76     //
  77     // a) StringBuilder.<init>()V is compiled
  78     // b) doIt() is compiled with an uncommon trap in the unlikely path
  79     public static void doWarmup() {
  80         for (int i = 0; i < 100_000; i++) {
  81             new StringBuilder();
  82 


< prev index next >