# HG changeset patch # User Gilles Duboscq # Date 1347030724 -7200 # Node ID e63431ba9a33f24d695c22b959cc27c5d5c65111 # Parent 74560fdffd516ad220fb0a91c89031d312e44a26# Parent 4241af3ec314551bedb2cdfbdeaf8912c098bc28 Merge diff -r 4241af3ec314 -r e63431ba9a33 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompilationResult.java diff -r 4241af3ec314 -r e63431ba9a33 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java Fri Sep 07 15:05:12 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/HotSpotAMD64Backend.java Fri Sep 07 17:12:04 2012 +0200 @@ -158,6 +158,8 @@ LIRFrameState callState = stateFor(x.stateDuring(), null, x instanceof InvokeWithExceptionNode ? getLIRBlock(((InvokeWithExceptionNode) x).exceptionEdge()) : null, x.leafGraphId()); Value result = resultOperandFor(x.node().kind()); + // HotSpot needs the methodOop to be passed around in rbx for direct (inline cache patching) or indirect calls (C2I : the interpreter needs the methodOop) + // for the direct call the methodOop is patched in by the code installer if (!inlineVirtualCall) { assert methodOopNode == null; append(new AMD64DirectCallOp(callTarget.targetMethod(), result, parameters, callState, invokeKind, lir)); diff -r 4241af3ec314 -r e63431ba9a33 graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/LoopUnswitchTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/LoopUnswitchTest.java Fri Sep 07 17:12:04 2012 +0200 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2011, 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. + */ +package com.oracle.graal.compiler.tests; + +import org.junit.*; + +import com.oracle.graal.compiler.phases.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.nodes.*; + +public class LoopUnswitchTest extends GraalCompilerTest { + + @SuppressWarnings("all") + public static int referenceSnippet1(int a) { + int sum = 0; + if (a > 2) { + for (int i = 0; i < 1000; i++) { + sum += 2; + } + } else { + for (int i = 0; i < 1000; i++) { + sum += a; + } + } + return sum; + } + + @SuppressWarnings("all") + public static int test1Snippet(int a) { + int sum = 0; + for (int i = 0; i < 1000; i++) { + if (a > 2) { + sum += 2; + } else { + sum += a; + } + } + return sum; + } + + @Test + public void test1() { + test("test1Snippet", "referenceSnippet1"); + } + + private void test(String snippet, String referenceSnippet) { + final StructuredGraph graph = parse(snippet); + final StructuredGraph referenceGraph = parse(referenceSnippet); + + new LoopTransformLowPhase().apply(graph); + + // Framestates create comparison problems + for (Node stateSplit : graph.getNodes().filterInterface(StateSplit.class)) { + ((StateSplit) stateSplit).setStateAfter(null); + } + for (Node stateSplit : referenceGraph.getNodes().filterInterface(StateSplit.class)) { + ((StateSplit) stateSplit).setStateAfter(null); + } + + new CanonicalizerPhase(null, runtime(), null).apply(graph); + new CanonicalizerPhase(null, runtime(), null).apply(referenceGraph); + Debug.scope("Test", new DebugDumpScope("Test:" + snippet), new Runnable() { + @Override + public void run() { + assertEquals(referenceGraph, graph); + } + }); + } +} diff -r 4241af3ec314 -r e63431ba9a33 mx/commands.py --- a/mx/commands.py Fri Sep 07 15:05:12 2012 +0200 +++ b/mx/commands.py Fri Sep 07 17:12:04 2012 +0200 @@ -814,6 +814,26 @@ mx.log(' ' + str(t.duration) + '\t' + t.title) mx.log(' =======') mx.log(' ' + str(total.duration)) + +def deoptalot(args): + """Bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on + + If the first argument is a number, the process will be repeated + this number of times. All other arguments are passed to the VM.""" + count = 1 + if len(args) > 0 and args[0].isdigit(): + count = int(args[0]) + del args[0] + + for n in range(count): + if not vm(['-XX:+DeoptimizeALot', '-XX:+VerifyOops'] + args + ['-version'], vmbuild='fastdebug') == 0: + mx.abort("Failed") + +def longtests(args): + + deoptalot(['15', '-Xmx48m']) + + dacapo(['100', 'eclipse', '-esa']) def gv(args): """run the Graal Visualizer""" @@ -1001,7 +1021,9 @@ 'site' : [site, '[-options]'], 'vm': [vm, '[-options] class [args...]'], 'vmg': [vmg, '[-options] class [args...]'], - 'vmfg': [vmfg, '[-options] class [args...]'] + 'vmfg': [vmfg, '[-options] class [args...]'], + 'deoptalot' : [deoptalot, '[n]'], + 'longtests' : [longtests, ''] } mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append'])