changeset 5616:310ed6650682

added check to ensure fast path allocation is never used for types that don't allow it
author Doug Simon <doug.simon@oracle.com>
date Fri, 15 Jun 2012 12:04:26 +0200
parents ff7961661b96
children 19ca9e48cd31
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotXirGenerator.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java src/share/vm/graal/graalCompiler.cpp
diffstat 4 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java	Thu Jun 14 17:03:22 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java	Fri Jun 15 12:04:26 2012 +0200
@@ -200,6 +200,11 @@
         return constantPool;
     }
 
+    /**
+     * Gets the instance size of this type. If an instance of this type cannot
+     * be fast path allocated, then the returned value is negative (its absolute
+     * value gives the size).
+     */
     public int instanceSize() {
         return instanceSize;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotXirGenerator.java	Thu Jun 14 17:03:22 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotXirGenerator.java	Fri Jun 15 12:04:26 2012 +0200
@@ -783,6 +783,7 @@
     public XirSnippet genNewInstance(XirSite site, JavaType type) {
         HotSpotResolvedJavaType resolvedType = (HotSpotResolvedJavaType) type;
         int instanceSize = resolvedType.instanceSize();
+        assert instanceSize >= 0;
         return new XirSnippet(newInstanceTemplates.get(site, instanceSize), XirArgument.forObject(resolvedType.klassOop()));
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java	Thu Jun 14 17:03:22 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java	Fri Jun 15 12:04:26 2012 +0200
@@ -189,6 +189,8 @@
             HotSpotResolvedJavaType type = (HotSpotResolvedJavaType) newInstanceNode.instanceClass();
             HotSpotKlassOop hub = type.klassOop();
             int instanceSize = type.instanceSize();
+            assert (instanceSize % wordSize()) == 0;
+            assert instanceSize >= 0;
             Key key = new Key(newInstance).add("size", instanceSize).add("checkInit", !type.isInitialized()).add("useTLAB", useTLAB).add("logType", LOG_ALLOCATION ? type.name() : null);
             Arguments arguments = arguments("hub", hub);
             SnippetTemplate template = cache.get(key);
--- a/src/share/vm/graal/graalCompiler.cpp	Thu Jun 14 17:03:22 2012 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp	Fri Jun 15 12:04:26 2012 +0200
@@ -278,8 +278,12 @@
   if (klass->oop_is_javaArray()) {
     HotSpotResolvedJavaType::set_isArrayClass(obj, true);
   } else {
+    int size = instanceKlass::cast(klass())->size_helper() * HeapWordSize;
+    if (!instanceKlass::cast(klass())->can_be_fastpath_allocated()) {
+      size = -size;
+    }
     HotSpotResolvedJavaType::set_isArrayClass(obj, false);
-    HotSpotResolvedJavaType::set_instanceSize(obj, instanceKlass::cast(klass())->size_helper() * HeapWordSize);
+    HotSpotResolvedJavaType::set_instanceSize(obj, size);
     HotSpotResolvedJavaType::set_hasFinalizer(obj, klass->has_finalizer());
   }