# HG changeset patch # User Christian Wimmer # Date 1349822232 25200 # Node ID 137b59f4a0ebfc1f9634e1239cf35458161b4241 # Parent 31aa76ffd3bbbcc32a80a7f3646be2419ce4b322 Remove project graal.boot diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot.test/overview.html --- a/graal/com.oracle.graal.boot.test/overview.html Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ - - - - - - - - -Documentation for the com.oracle.graal.boot.test project. - - - diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot.test/src/com/oracle/graal/boot/BigBangTest.java --- a/graal/com.oracle.graal.boot.test/src/com/oracle/graal/boot/BigBangTest.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot; - -import org.junit.*; - -public class BigBangTest { - - //@Test - public void helloWorldTest() { - BootImageGenerator generator = new BootImageGenerator(); - generator.addEntryMethod(TestPrograms.class, "helloWorldTest"); - Assert.assertArrayEquals(generator.getBigBang().printState(), new int[]{3, 148, 66, 24}); - } - - //@Test - public void formattedOutputTest() { - BootImageGenerator generator = new BootImageGenerator(); - generator.addEntryMethod(TestPrograms.class, "formattedOutputTest"); - Assert.assertArrayEquals(generator.getBigBang().printState(), new int[]{19, 1668, 611, 179}); - } - - - @Test - public void newTest() { - BootImageGenerator generator = new BootImageGenerator(); - generator.addEntryMethod(TestPrograms.class, "newTest"); - Assert.assertArrayEquals(generator.getBigBang().printState(), new int[]{0, 3, 0, 0}); - } - - - @Test - public void arraycopyTest() { - BootImageGenerator generator = new BootImageGenerator(); - generator.addEntryMethod(TestPrograms.class, "arraycopyTest"); - Assert.assertArrayEquals(generator.getBigBang().printState(), new int[]{2, 6, 0, 0}); - } - - @Test - public void arrayListTest() { - BootImageGenerator generator = new BootImageGenerator(); - generator.addEntryMethod(TestPrograms.class, "arrayListTest"); - Assert.assertArrayEquals(generator.getBigBang().printState(), new int[]{2, 28, 5, 3}); - } - - //@Test - public void arrayListTestWithCalls() { - BootImageGenerator generator = new BootImageGenerator(); - generator.addEntryMethod(TestPrograms.class, "arrayListTestWithCalls"); - Assert.assertArrayEquals(generator.getBigBang().printState(), new int[]{2, 20, 3, 2}); - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot.test/src/com/oracle/graal/boot/BootImageClassLoaderTest.java --- a/graal/com.oracle.graal.boot.test/src/com/oracle/graal/boot/BootImageClassLoaderTest.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot; - -import java.lang.reflect.*; - -import org.junit.*; - - -public class BootImageClassLoaderTest { - - @Test - public void test() throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException, SecurityException { - - TestClassB.x = 1; - BootImageClassLoader l = new BootImageClassLoader(); - - // Assert that the class definition is really duplicated. - Class bClass = Class.forName(TestClassB.class.getCanonicalName(), true, l); - Assert.assertNotSame(TestClassB.class, bClass); - - // Assert that the class definition is not duplicated more than once. - Assert.assertSame(bClass, l.convert(TestClassB.class)); - - // Set field x such that it is used by the subsequent static initializer for TestClassA. - Field bField = bClass.getFields()[0]; - bField.setAccessible(true); - bField.set(null, 2); - - // Assert that the class definition is duplicated. - Class aClass = l.convert(TestClassA.class); - Assert.assertNotSame(TestClassA.class, aClass); - - // Assert that the original version of TestClassA was initialized correctly. - Assert.assertEquals(1, TestClassA.x); - - // Assert that the duplicated version of TestClassA was initialized correctly. - Field aField = aClass.getFields()[0]; - aField.setAccessible(true); - Assert.assertEquals(2, aField.getInt(null)); - - // Assert that system classes are not duplicated. - Assert.assertSame(Object.class, l.convert(Object.class)); - Assert.assertSame(Object.class, Class.forName(Object.class.getCanonicalName(), true, l)); - } - -} - -class TestClassA { - public static int x; - - static { - x = TestClassB.x; - } -} - -class TestClassB { - public static int x; -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot.test/src/com/oracle/graal/boot/TestPrograms.java --- a/graal/com.oracle.graal.boot.test/src/com/oracle/graal/boot/TestPrograms.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot; - -import java.util.*; - -//JaCoCo Exclude - -public class TestPrograms { - public static void helloWorldTest() { - System.out.println("Hello world!"); - } - - public static void formattedOutputTest() { - System.out.printf("%s %s!", "Hello", "world"); - } - - @SuppressWarnings("unused") - public static void newTest() { - Integer x = new Integer(5); - } - - public static void arraycopyTest() { - Object[] arr = new Object[1]; - arr[0] = new TestObject(); - TestObject[] newArr = Arrays.copyOf(arr, 1, TestObject[].class); - newArr[0].testMethod(); - } - - @SuppressWarnings("unchecked") - public static void arrayListTest() { - ArrayList list = new ArrayList(); - list.add(new TestObject()); - TestObject[] newArr = (TestObject[]) list.toArray(new TestObject[0]); - newArr[0].testMethod(); - } - - @SuppressWarnings("unchecked") - public static void arrayListTestWithCalls() { - ArrayList list = createNewArrayList(); - list.add(new TestObject()); - TestObject[] newArr = (TestObject[]) list.toArray(new TestObject[0]); - TestObject t2 = newArr[0].testMethod(); - t2.testMethod2(); - } - - private static ArrayList createNewArrayList() { - return new ArrayList(); - } - - public static class TestObject { - public TestObject testMethod() { - return new TestObject(); - } - - public void testMethod2() { - - } - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/overview.html --- a/graal/com.oracle.graal.boot/overview.html Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ - - - - - - - - -Documentation for the com.oracle.graal.boot project. - - - diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/BigBang.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/BigBang.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; -import java.util.concurrent.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.boot.meta.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.java.*; - -public class BigBang { - - public static final PrintStream out; - static { - if (Boolean.getBoolean("BigBang.verbose")) { - out = System.out; - } else { - OutputStream sink = new OutputStream() { - @Override - public void write(int b) throws IOException { - } - }; - out = new PrintStream(sink); - } - } - - private static final int THREADS = 4; - - private MetaAccessProvider metaAccessProvider; - private int postedOperationCount; - - // Mappings from Graal IR and Graal meta-data to element instances. - private Map sinkMap = new IdentityHashMap<>(); - private Map fieldMap = new IdentityHashMap<>(); - private Map methodMap = new IdentityHashMap<>(); - private Map arrayTypeMap = new IdentityHashMap<>(); - - // Processing queue. - private ThreadPoolExecutor executor = new ThreadPoolExecutor(THREADS, THREADS, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), Executors.defaultThreadFactory()); - - public BigBang(MetaAccessProvider metaAccessProvider) { - this.metaAccessProvider = metaAccessProvider; - } - - public synchronized FieldElement getProcessedField(ResolvedJavaField field) { - assert field != null; - if (!fieldMap.containsKey(field)) { - fieldMap.put(field, new FieldElement(field)); - } - return fieldMap.get(field); - } - - public synchronized MethodElement getProcessedMethod(ResolvedJavaMethod method) { - assert method != null; - if (!methodMap.containsKey(method)) { - methodMap.put(method, new MethodElement(method)); - } - return methodMap.get(method); - } - - public synchronized ArrayTypeElement getProcessedArrayType(ResolvedJavaType type) { - assert type != null; - if (!arrayTypeMap.containsKey(type)) { - arrayTypeMap.put(type, new ArrayTypeElement(type)); - } - return arrayTypeMap.get(type); - } - - public synchronized Element getSinkElement(Node node, Node sourceNode) { - if (!sinkMap.containsKey(node)) { - Element resultElement = Element.BLACK_HOLE; - if (node instanceof PhiNode) { - PhiNode phiNode = (PhiNode) node; - resultElement = new PhiElement(phiNode); - } else if (node instanceof CheckCastNode) { - CheckCastNode checkCastNode = (CheckCastNode) node; - resultElement = new CastElement(checkCastNode); - } else if (node instanceof ValueProxyNode) { - ValueProxyNode proxyNode = (ValueProxyNode) node; - resultElement = new ProxyElement(proxyNode); - } else if (node instanceof StoreFieldNode) { - StoreFieldNode storeFieldNode = (StoreFieldNode) node; - resultElement = getProcessedField(storeFieldNode.field()); - } else if (node instanceof StoreIndexedNode) { - StoreIndexedNode storeIndexedNode = (StoreIndexedNode) node; - if (storeIndexedNode.elementKind() == Kind.Object) { - resultElement = getProcessedArrayType(metaAccessProvider.lookupJavaType(Object[].class)); - } - } else if (node instanceof ReturnNode) { - ReturnNode returnNode = (ReturnNode) node; - ResolvedJavaMethod method = ((StructuredGraph) returnNode.graph()).method(); - resultElement = getProcessedMethod(method); - } else { - if (node instanceof FrameState || node instanceof MonitorEnterNode || node instanceof MonitorExitNode || node instanceof LoadFieldNode || node instanceof IsNullNode || node instanceof InstanceOfNode) { - // OK. - } else { - BigBang.out.println("Unknown sink - black hole? " + node); - } - } - - sinkMap.put(node, resultElement); - } - - if (node instanceof StoreIndexedNode) { - StoreIndexedNode storeIndexedNode = (StoreIndexedNode) node; - if (storeIndexedNode.value() != sourceNode) { - return Element.BLACK_HOLE; - } - } - - if (node instanceof StoreFieldNode) { - StoreFieldNode storeFieldNode = (StoreFieldNode) node; - if (storeFieldNode.value() != sourceNode) { - return Element.BLACK_HOLE; - } - } - return sinkMap.get(node); - } - - public synchronized void registerSourceCallTargetNode(MethodCallTargetNode methodCallTargetNode) { - InvokeElement invokeElement = new InvokeElement(methodCallTargetNode); - sinkMap.put(methodCallTargetNode, invokeElement); - invokeElement.expandStaticMethod(this); - } - - public synchronized void registerSourceNode(Node node) { - Element resultElement = null; - if (node instanceof LoadFieldNode) { - LoadFieldNode loadFieldNode = (LoadFieldNode) node; - resultElement = getProcessedField(loadFieldNode.field()); - } else if (node instanceof LoadIndexedNode) { - LoadIndexedNode loadIndexedNode = (LoadIndexedNode) node; - if (loadIndexedNode.kind() == Kind.Object) { - resultElement = getProcessedArrayType(metaAccessProvider.lookupJavaType(Object[].class)); - } - } else if (node instanceof LocalNode) { - LocalNode localNode = (LocalNode) node; - if (localNode.kind() == Kind.Object) { - ResolvedJavaMethod method = ((StructuredGraph) localNode.graph()).method(); - resultElement = getProcessedMethod(method).getParameter(localNode.index()); - BigBang.out.println("resultElement = " + resultElement + " index= " + localNode.index() + ", node=" + node); - } - } - - if (resultElement != null) { - resultElement.postAddUsage(this, node); - } - } - - public synchronized void postOperation(UniverseExpansionOp operation) { - BigBang.out.println("posting operation " + operation); - executor.execute(operation); - postedOperationCount++; - } - - public MetaAccessProvider getMetaAccess() { - return metaAccessProvider; - } - - public void finish() { - while (true) { - try { - Thread.sleep(10); - boolean terminated; - int oldPostedOperationCount; - synchronized (this) { - terminated = (executor.getCompletedTaskCount() == postedOperationCount); - oldPostedOperationCount = postedOperationCount; - } - - if (terminated) { - checkObjectGraph(); - synchronized (this) { - if (postedOperationCount == oldPostedOperationCount) { - System.out.printf("Big bang simulation completed in %d operations.\n", postedOperationCount); - executor.shutdown(); - break; - } - } - } - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - } - - private void checkObjectGraph() { - List originalRoots = new ArrayList<>(); - synchronized (this) { - for (FieldElement field : fieldMap.values()) { - if (field.isStatic()) { - originalRoots.add(field); - } - } - } - - Map scannedObjects = new IdentityHashMap<>(); - for (FieldElement field : originalRoots) { - assert field.isStatic(); - if (field.getUsageCount() > 0 && field.getJavaField().getKind() == Kind.Object) { - Object value = field.getJavaField().readValue(null).asObject(); - BigBang.out.printf("Root field %s: %s\n", field, value); - scanField(scannedObjects, field, value); - } - } - } - - private void scanField(Map scannedObjects, FieldElement field, Object value) { - if (value != null && field.getUsageCount() > 0) { - field.registerNewValue(this, value); - scan(scannedObjects, value); - } - } - - private void scan(Map scannedObjects, Object value) { - assert value != null; - if (scannedObjects.containsKey(value)) { - return; - } - - scannedObjects.put(value, Boolean.TRUE); - ResolvedJavaType type = getMetaAccess().lookupJavaType(value.getClass()); - scan(scannedObjects, value, type); - } - - private void scan(Map scannedObjects, Object value, ResolvedJavaType type) { - if (type.getSuperclass() != null) { - scan(scannedObjects, value, type.getSuperclass()); - } - - ResolvedJavaField[] declaredFields = type.getDeclaredFields(); - for (ResolvedJavaField field : declaredFields) { - if (field.getKind() == Kind.Object) { - FieldElement fieldElement = getProcessedField(field); - Object fieldValue = field.readValue(Constant.forObject(value)).asObject(); - scanField(scannedObjects, fieldElement, fieldValue); - } - } - - } - - public synchronized int[] printState() { - - int nativeMethodCount = 0; - for (MethodElement methodElement : methodMap.values()) { - if (methodElement.hasGraph()) { - if (Modifier.isNative(methodElement.getResolvedJavaMethod().getModifiers())) { - BigBang.out.println("Included native method: " + methodElement.getResolvedJavaMethod()); - nativeMethodCount++; - } - } - } - - int methodCount = 0; - for (MethodElement methodElement : methodMap.values()) { - if (methodElement.hasGraph()) { - if (!Modifier.isNative(methodElement.getResolvedJavaMethod().getModifiers())) { - BigBang.out.println("Included method: " + methodElement.getResolvedJavaMethod()); - methodCount++; - } - } - } - - Set includedTypes = new HashSet<>(); - int fieldCount = 0; - for (FieldElement fieldElement : fieldMap.values()) { - if (fieldElement.getUsageCount() > 0) { - BigBang.out.print("Included field: " + fieldElement.getJavaField() + " / "); - fieldElement.printSeenTypes(); - BigBang.out.println(); - fieldCount++; - includedTypes.add(fieldElement.getJavaField().getDeclaringClass()); - } - } - - for (ResolvedJavaType type : includedTypes) { - BigBang.out.println("Included type: " + type); - } - - System.out.println("Number of included native methods: " + nativeMethodCount); - System.out.println("Number of included method: " + methodCount); - System.out.println("Number of included fields: " + fieldCount); - System.out.println("Number of included types: " + includedTypes.size()); - return new int[]{nativeMethodCount, methodCount, fieldCount, includedTypes.size()}; - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/BootImageClassLoader.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/BootImageClassLoader.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot; - -import java.io.*; - -public class BootImageClassLoader extends ClassLoader { - - @Override - protected java.lang.Class< ? > loadClass(String name, boolean resolve) throws ClassNotFoundException { - synchronized (getClassLoadingLock(name)) { - Class< ? > result = findLoadedClass(name); - if (result == null) { - result = super.loadClass(name, resolve); - assert result.getName().equals(name); - return duplicate(result); - } - return result; - } - } - - private Class< ? > duplicate(Class< ? > result) { - // This is a class in the bootclasspath => share. - if (result.getClassLoader() == null) { - return result; - } - - // Duplicate class definition. - InputStream inputStream = result.getClassLoader().getResourceAsStream(result.getName().replace('.', '/').concat(".class")); - try { - byte[] byteCodes = new byte[inputStream.available()]; - inputStream.read(byteCodes); - return this.defineClass(result.getName(), byteCodes, 0, byteCodes.length); - } catch (IOException e) { - throw new RuntimeException("Could not access class bytes for " + result.getName()); - } - } - - public Class< ? > convert(Class< ? > clazz) { - synchronized (getClassLoadingLock(clazz.getCanonicalName())) { - // This class has this class loader => no conversion necessary. - if (clazz.getClassLoader() == this) { - return clazz; - } - - Class< ? > thisClazz = findLoadedClass(clazz.getName()); - if (thisClazz != null) { - return thisClazz; - } - - return duplicate(clazz); - } - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/BootImageGenerator.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/BootImageGenerator.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot; - -import java.lang.reflect.*; - -import com.oracle.graal.api.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.boot.meta.*; - - -public class BootImageGenerator { - - private final BootImageClassLoader classLoader = new BootImageClassLoader(); - private final MetaAccessProvider metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class); - private final BigBang bigbang = new BigBang(metaAccess); - - public void addEntryMethod(Class clazz, String name, Class ... parameterTypes) { - Class convertedClass = classLoader.convert(clazz); - Method method; - try { - method = convertedClass.getDeclaredMethod(name, parameterTypes); - } catch (NoSuchMethodException | SecurityException e) { - throw new RuntimeException("Could not find method " + name + " with parameter types " + parameterTypes + " in class " + convertedClass.getCanonicalName()); - } - BigBang.out.printf("Adding method %s.%s to the boot image\n", method.getDeclaringClass().getName(), method.getName()); - addEntryMethod(metaAccess.lookupJavaMethod(method)); - } - - - private void addEntryMethod(ResolvedJavaMethod javaMethod) { - MethodElement methodElement = bigbang.getProcessedMethod(javaMethod); - methodElement.postParseGraph(bigbang); - bigbang.finish(); - } - - public BigBang getBigBang() { - return bigbang; - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/UniverseExpansionOp.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/UniverseExpansionOp.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot; - - -public abstract class UniverseExpansionOp implements Runnable { - - public void post(BigBang store) { - store.postOperation(this); - } - - @Override - public void run() { - expand(); - } - - protected abstract void expand(); -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/ArrayTypeElement.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/ArrayTypeElement.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot.meta; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.boot.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.java.*; - - -public class ArrayTypeElement extends Element { - - private ResolvedJavaType javaType; - - public ArrayTypeElement(ResolvedJavaType javaType) { - super(javaType.getComponentType()); - this.javaType = javaType; - } - - @Override - public String toString() { - return "arrayTypeElement: " + javaType; - } - - @Override - protected void propagateTypesToUsage(BigBang bb, Node use, Set set, Element element) { - LoadIndexedNode load = (LoadIndexedNode) use; - ResolvedJavaType type = load.array().objectStamp().type(); - if (type == null) { - BigBang.out.println("FATAL error: Array access without type!"); - BigBang.out.println(load.array()); - if (load.array() instanceof ValueProxyNode) { - ValueProxyNode valueProxyNode = (ValueProxyNode) load.array(); - BigBang.out.println("value proxy node stamp " + valueProxyNode.stamp()); - BigBang.out.println("value proxy node stamp type " + valueProxyNode.objectStamp().type()); - BigBang.out.println("value proxy source: " + valueProxyNode.value()); - BigBang.out.println("value proxy source stamp: " + valueProxyNode.value().stamp()); - } - BigBang.out.println(((StructuredGraph) load.graph()).method()); - System.exit(-1); - } - ResolvedJavaType componentType = type.getComponentType(); - Set newSet = new HashSet<>(); - for (ResolvedJavaType myType : set) { - if (myType.isSubtypeOf(componentType)) { - newSet.add(myType); - } - } - if (newSet.size() > 0) { - super.propagateTypesToUsage(bb, use, newSet, element); - } - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/CastElement.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/CastElement.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot.meta; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.boot.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.java.*; - - -public class CastElement extends Element { - - private CheckCastNode checkCastNode; - - public CastElement(CheckCastNode checkCastNode) { - super(checkCastNode.targetClass()); - this.checkCastNode = checkCastNode; - this.usages.add(checkCastNode); - } - - @Override - protected synchronized void unionTypes(BigBang bb, Node sourceNode, Set newSeenTypes) { - Set newSet = new HashSet<>(); - // Filter through checkcast. - for (ResolvedJavaType type : newSeenTypes) { - if (type.isSubtypeOf(checkCastNode.targetClass())) { - newSet.add(type); - } else { - BigBang.out.println("filtering " + type + " vs " + checkCastNode.targetClass()); - } - } - super.unionTypes(bb, sourceNode, newSet); - } - - @Override - public String toString() { - return "cast " + checkCastNode.targetClass(); - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/Element.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/Element.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -/* - * 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.boot.meta; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.boot.*; -import com.oracle.graal.graph.*; - - -public class Element { - - public static final Element BLACK_HOLE = new Element(null); - - protected List usages = new ArrayList<>(4); - protected Set seenTypes = new HashSet<>(); - private ResolvedJavaType declaredType; - - protected Element(ResolvedJavaType declaredType) { - this.declaredType = declaredType; - } - - public void postUnionTypes(final BigBang bb, final Node sourceNode, final Set newSeenTypes) { - new UniverseExpansionOp() { - @Override - protected void expand() { - unionTypes(bb, sourceNode, newSeenTypes); - } - - @Override - public String toString() { - return String.format("Add new seen types %s from source node %s to element %s", newSeenTypes, sourceNode, Element.this); - } - }.post(bb); - } - - public void postAddUsage(final BigBang bb, final Node usage) { - new UniverseExpansionOp() { - @Override - protected void expand() { - addUsage(bb, usage); - } - - @Override - public String toString() { - return String.format("Add usage %s to element %s", usage, Element.this); - } - }.post(bb); - } - - protected synchronized void unionTypes(BigBang bb, @SuppressWarnings("unused") Node sourceNode, Set newSeenTypes) { - if (!seenTypes.containsAll(newSeenTypes)) { - if (declaredType != null) { - for (ResolvedJavaType seenType : newSeenTypes) { - if (!seenType.isSubtypeOf(declaredType)) { - BigBang.out.println("Wrong type found " + seenType + " where declared type of element " + this + " is " + declaredType); - System.exit(-1); - } - } - } - seenTypes.addAll(newSeenTypes); - propagateTypes(bb, newSeenTypes); - } - } - - protected synchronized void propagateTypes(BigBang bb, Set newSeenTypes) { - for (Node n : usages) { - propagateTypes(bb, n, newSeenTypes); - } - } - - public synchronized int getUsageCount() { - return usages.size(); - } - - protected synchronized void addUsage(BigBang bb, Node usage) { - if (!usages.contains(usage)) { - usages.add(usage); - propagateTypes(bb, usage, seenTypes); - } - } - - public void propagateTypes(BigBang bb, Node n, Set types) { - if (types.size() != 0) { - Set newSet = new HashSet<>(types); - for (Node use : n.usages()) { - Element element = bb.getSinkElement(use, n); - assert element != null; - if (element != BLACK_HOLE) { - propagateTypesToUsage(bb, n, newSet, element); - } - } - } - } - - protected void propagateTypesToUsage(BigBang bb, Node use, Set newSet, Element element) { - element.postUnionTypes(bb, use, newSet); - } - - - public synchronized void printSeenTypes() { - for (ResolvedJavaType type : seenTypes) { - BigBang.out.print(type.getName() + " "); - } - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/FieldElement.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/FieldElement.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot.meta; - -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.boot.*; - - -public class FieldElement extends Element { - - protected ResolvedJavaField javaField; - - public FieldElement(ResolvedJavaField javaField) { - super(javaField.getType().resolve(javaField.getDeclaringClass())); - this.javaField = javaField; - } - - public boolean isStatic() { - return Modifier.isStatic(javaField.getModifiers()); - } - - public ResolvedJavaField getJavaField() { - return javaField; - } - - @Override - public String toString() { - return "Field[" + javaField + "]"; - } - - public synchronized void registerNewValue(BigBang bb, Object value) { - if (value != null) { - Class clazz = value.getClass(); - ResolvedJavaType resolvedType = bb.getMetaAccess().lookupJavaType(clazz); - if (seenTypes.add(resolvedType)) { - Set newSeenTypes = new HashSet<>(); - newSeenTypes.add(resolvedType); - super.propagateTypes(bb, newSeenTypes); - } - } - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/InvokeElement.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/InvokeElement.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot.meta; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.boot.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.java.*; - - -public class InvokeElement extends Element { - - private MethodCallTargetNode methodCallTarget; - private Set concreteTargets = new HashSet<>(); - private Set[] parameterTypes; - - @SuppressWarnings("unchecked") - public InvokeElement(MethodCallTargetNode methodCallTarget) { - super(methodCallTarget.isStatic() ? null : methodCallTarget.targetMethod().getDeclaringClass()); - this.methodCallTarget = methodCallTarget; - parameterTypes = new Set[methodCallTarget.arguments().size()]; - } - - @Override - protected synchronized void unionTypes(BigBang bb, Node sourceNode, Set newSeenTypes) { - - BigBang.out.println("union invoke element " + this + " new types = " + newSeenTypes + " sourceNode= " + sourceNode); - int index = 0; - for (Node arg : methodCallTarget.arguments()) { - if (arg == sourceNode) { - BigBang.out.println("source node " + sourceNode + " is at index " + index + " stamp=" + ((ValueNode) sourceNode).stamp()); - unionTypes(bb, sourceNode, newSeenTypes, index); - } - ++index; - } - } - - @Override - public String toString() { - return "Invoke[bci=" + methodCallTarget.invoke().stateAfter().method() + "," + methodCallTarget.targetMethod() + "]"; - } - - public synchronized void expandStaticMethod(BigBang bb) { - if (methodCallTarget.isStatic()) { - ResolvedJavaMethod method = methodCallTarget.targetMethod(); - concreteTargets.add(method); - MethodElement processedMethod = bb.getProcessedMethod(method); - processedMethod.addUsage(bb, this.methodCallTarget.invoke().node()); - processedMethod.postParseGraph(bb); - } - } - - private void unionTypes(BigBang bb, @SuppressWarnings("unused") Node sourceNode, Set newSeenTypes, int index) { - if (index == 0 && !methodCallTarget.isStatic()) { - for (ResolvedJavaType type : newSeenTypes) { - if (seenTypes.add(type)) { - // There is a new receiver type! - ResolvedJavaMethod method = type.resolveMethod(methodCallTarget.targetMethod()); - BigBang.out.println("resolved method " + method + " for type " + type + " and method " + methodCallTarget.targetMethod()); - if (method == null) { - BigBang.out.println("!!! type = " + type + " / " + methodCallTarget.targetMethod()); - } - if (!concreteTargets.contains(method)) { - concreteTargets.add(method); - // New concrete method. - MethodElement processedMethod = bb.getProcessedMethod(method); - processedMethod.postParseGraph(bb); - // Propagate types that were previously found for the parameters. - for (int i = 0; i < parameterTypes.length; ++i) { - if (parameterTypes[i] != null) { - HashSet newSeenTypesTemp = new HashSet<>(parameterTypes[i]); - bb.getProcessedMethod(method).getParameter(i).postUnionTypes(bb, null, newSeenTypesTemp); - } - } - processedMethod.addUsage(bb, this.methodCallTarget.invoke().node()); - } - - // Register new type for receiver. - HashSet newSeenTypesTemp = new HashSet<>(); - newSeenTypesTemp.add(type); - bb.getProcessedMethod(method).getParameter(index).postUnionTypes(bb, null, newSeenTypesTemp); - } - } - } else { - if (parameterTypes[index] == null) { - parameterTypes[index] = new HashSet<>(); - } - if (parameterTypes[index].addAll(newSeenTypes)) { - for (ResolvedJavaMethod method : concreteTargets) { - HashSet newSeenTypesTemp = new HashSet<>(newSeenTypes); - bb.getProcessedMethod(method).getParameter(index).postUnionTypes(bb, null, newSeenTypesTemp); - } - } - } - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/MethodElement.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/MethodElement.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot.meta; - -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.boot.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.java.*; -import com.oracle.graal.java.GraphBuilderConfiguration.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.java.*; -import com.oracle.graal.phases.*; -import com.oracle.graal.phases.common.*; - - -public class MethodElement extends Element { - - private ParameterElement[] parameters; - private Graph graph; - private ResolvedJavaMethod resolvedJavaMethod; - - public MethodElement(ResolvedJavaMethod javaMethod) { - super(javaMethod.getSignature().getReturnType(javaMethod.getDeclaringClass()).resolve(javaMethod.getDeclaringClass())); - assert javaMethod != null; - this.resolvedJavaMethod = javaMethod; - int parameterCount = resolvedJavaMethod.getSignature().getParameterCount(!Modifier.isStatic(resolvedJavaMethod.getModifiers())); - parameters = new ParameterElement[parameterCount]; - for (int i = 0; i < parameters.length; ++i) { - parameters[i] = new ParameterElement(resolvedJavaMethod, i); - } - } - - public ParameterElement getParameter(int index) { - return parameters[index]; - } - - public synchronized boolean hasGraph() { - return graph != null; - } - - public void postParseGraph(final BigBang bb) { - synchronized (this) { - if (graph != null) { - return; - } - } - new UniverseExpansionOp() { - @Override - protected void expand() { - parseGraph(bb); - } - - @Override - public String toString() { - return String.format("Parsing method %s", resolvedJavaMethod); - } - }.post(bb); - } - - protected void parseGraph(final BigBang bb) { - StructuredGraph newGraph = null; - synchronized (this) { - if (graph != null) { - // Graph already exists => quit operation. - return; - } - newGraph = new StructuredGraph(resolvedJavaMethod); - this.graph = newGraph; - } - - if (Modifier.isNative(resolvedJavaMethod.getModifiers())) { - BigBang.out.println("NATIVE METHOD " + resolvedJavaMethod); - return; - } - - BigBang.out.println("parsing graph " + resolvedJavaMethod + ", locals=" + resolvedJavaMethod.getMaxLocals()); - GraphBuilderConfiguration config = new GraphBuilderConfiguration(ResolvePolicy.Eager, null); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(bb.getMetaAccess(), config, OptimisticOptimizations.NONE); - graphBuilderPhase.apply(newGraph); - new PhiStampPhase().apply(newGraph); - - for (MethodCallTargetNode callTargetNode : newGraph.getNodes(MethodCallTargetNode.class)) { - bb.registerSourceCallTargetNode(callTargetNode); - } - - for (Node node : newGraph.getNodes()) { - bb.registerSourceNode(node); - } - - for (NewInstanceNode newInstance : newGraph.getNodes(NewInstanceNode.class)) { - Set types = new HashSet<>(); - types.add(newInstance.instanceClass()); - BigBang.out.println("propagate new instance " + newInstance + ", " + newInstance.instanceClass()); - for (Node use : newInstance.usages()) { - Element element = bb.getSinkElement(use, newInstance); - assert element != null; - if (element != BLACK_HOLE) { - element.postUnionTypes(bb, newInstance, types); - } - } - } - } - - public ResolvedJavaMethod getResolvedJavaMethod() { - return resolvedJavaMethod; - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/ParameterElement.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/ParameterElement.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot.meta; - -import java.lang.reflect.*; - -import com.oracle.graal.api.meta.*; - - -public class ParameterElement extends Element { - - private int index; - private ResolvedJavaMethod method; - - public ParameterElement(ResolvedJavaMethod method, int index) { - super(calculateDeclaredType(method, index)); - this.method = method; - this.index = index; - } - - private static ResolvedJavaType calculateDeclaredType(ResolvedJavaMethod m, int i) { - if (Modifier.isStatic(m.getModifiers())) { - return m.getSignature().getParameterType(i, m.getDeclaringClass()).resolve(m.getDeclaringClass()); - } else { - if (i == 0) { - return m.getDeclaringClass(); - } - return m.getSignature().getParameterType(i - 1, m.getDeclaringClass()).resolve(m.getDeclaringClass()); - } - } - - @Override - public String toString() { - return "[Parameter, index= " + index + " of method " + method + "]"; - } - -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/PhiElement.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/PhiElement.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot.meta; - -import com.oracle.graal.nodes.*; - - -public class PhiElement extends Element { - - private PhiNode phi; - - public PhiElement(PhiNode phi) { - super(null); - this.phi = phi; - usages.add(phi); - } - - @Override - public String toString() { - return "phi " + phi; - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/ProxyElement.java --- a/graal/com.oracle.graal.boot/src/com/oracle/graal/boot/meta/ProxyElement.java Tue Oct 09 15:32:45 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2012, 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.boot.meta; - -import com.oracle.graal.nodes.*; - - -public class ProxyElement extends Element { - - private ValueProxyNode proxy; - - public ProxyElement(ValueProxyNode proxy) { - super(null); - this.proxy = proxy; - usages.add(proxy); - } - - @Override - public String toString() { - return "value proxy " + proxy; - } -} diff -r 31aa76ffd3bb -r 137b59f4a0eb mx/projects --- a/mx/projects Tue Oct 09 15:32:45 2012 -0700 +++ b/mx/projects Tue Oct 09 15:37:12 2012 -0700 @@ -186,20 +186,6 @@ project@com.oracle.graal.compiler.amd64@checkstyle=com.oracle.graal.graph project@com.oracle.graal.compiler.amd64@javaCompliance=1.7 -# graal.boot -project@com.oracle.graal.boot@subDir=graal -project@com.oracle.graal.boot@sourceDirs=src -project@com.oracle.graal.boot@dependencies=com.oracle.graal.java,com.oracle.graal.api.runtime,com.oracle.graal.phases.common -project@com.oracle.graal.boot@checkstyle=com.oracle.graal.graph -project@com.oracle.graal.boot@javaCompliance=1.7 - -# graal.boot.test -project@com.oracle.graal.boot.test@subDir=graal -project@com.oracle.graal.boot.test@sourceDirs=src -project@com.oracle.graal.boot.test@dependencies=JUNIT,com.oracle.graal.boot -project@com.oracle.graal.boot.test@checkstyle=com.oracle.graal.graph -project@com.oracle.graal.boot.test@javaCompliance=1.7 - # graal.bytecode project@com.oracle.graal.bytecode@subDir=graal project@com.oracle.graal.bytecode@sourceDirs=src