Path: blob/master/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java
51719 views
/*1* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 814849026* @summary Test correct saving and restoring of vector registers at safepoints.27*28* @run main/othervm -Xbatch -XX:-TieredCompilation29* -XX:+UnlockDiagnosticVMOptions -XX:+SafepointALot30* -XX:CompileCommand=exclude,compiler.runtime.safepoints.TestRegisterRestoring::main31* compiler.runtime.safepoints.TestRegisterRestoring32*/3334package compiler.runtime.safepoints;3536public class TestRegisterRestoring {37public static void main(String args[]) throws Exception {38// Initialize39float[] array = new float[100];40for (int i = 0; i < array.length; ++i) {41array[i] = 0;42}43// Test44for (int j = 0; j < 20_000; ++j) {45increment(array);46// Check result47for (int i = 0; i < array.length; i++) {48if (array[i] != 10_000) {49throw new RuntimeException("Test failed: array[" + i + "] = " + array[i] + " but should be 10,000");50}51array[i] = 0;52}53}54}5556static void increment(float[] array) {57// Loop with safepoint58for (long l = 0; l < 10_000; l++) {59// Vectorized loop60for (int i = 0; i < array.length; ++i) {61array[i] += 1;62}63}64}65}66676869