changeset 7115:1c76a458616e

simplified TLAB allocation (don't use + and -)
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 30 Nov 2012 12:08:38 +0100
parents acfca8c77dd2
children 84373743fab7
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java src/share/vm/graal/graalCompiler.cpp
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java	Fri Nov 30 11:13:36 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java	Fri Nov 30 12:08:38 2012 +0100
@@ -61,9 +61,9 @@
         Word thread = thread();
         Word top = loadWordFromWord(thread, threadTlabTopOffset());
         Word end = loadWordFromWord(thread, threadTlabEndOffset());
-        Word available = end.minus(top);
-        if (available.aboveOrEqual(Word.fromInt(size))) {
-            Word newTop = top.plus(size);
+        Word newTop = top.plus(size);
+        // this check might lead to problems if the TLAB is within 16GB of the address space end (checked in c++ code)
+        if (newTop.belowOrEqual(end)) {
             storeObject(thread, 0, threadTlabTopOffset(), newTop);
             return top;
         }
--- a/src/share/vm/graal/graalCompiler.cpp	Fri Nov 30 11:13:36 2012 +0100
+++ b/src/share/vm/graal/graalCompiler.cpp	Fri Nov 30 12:08:38 2012 +0100
@@ -49,6 +49,11 @@
   JavaThread* THREAD = JavaThread::current();
   TRACE_graal_1("GraalCompiler::initialize");
 
+  unsigned long heap_end = (long) Universe::heap()->reserved_region().end();
+  unsigned long allocation_end = heap_end + 16l * 1024 * 1024 * 1024;
+  guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)");
+  NOT_LP64(error("check TLAB allocation code for address space conflicts"));
+
   _deopted_leaf_graph_count = 0;
 
   initialize_buffer_blob();