changeset 12783:89fbf495e589

HSAIL: fix some assert logic in the argument-gathering code that shows up in non-product builds Contributed-by: Tom Deneau <tom.deneau@amd.com> Summary: * computes parameter_count based on signature and uses that and parameter_index (set by the SignatureIterator) to tell if we are on the last parameter, which requires special handling whether it is an int or an object. * if signature says last parameter is an Object, checks that the real passed in parameter is an Object Array, but for non last-parameters, lets objects go thru. * if signature says last parameter is an int, nothing is pushed (no change to this logic)
author Doug Simon <doug.simon@oracle.com>
date Wed, 20 Nov 2013 01:11:10 +0100
parents 92b7ec34ddfa
children 36bbe5bbe8fd
files src/gpu/hsail/vm/hsailKernelArguments.cpp src/gpu/hsail/vm/hsailKernelArguments.hpp
diffstat 2 files changed, 15 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/gpu/hsail/vm/hsailKernelArguments.cpp	Tue Nov 19 17:44:26 2013 +0100
+++ b/src/gpu/hsail/vm/hsailKernelArguments.cpp	Wed Nov 20 01:11:10 2013 +0100
@@ -93,7 +93,7 @@
 void HSAILKernelArguments::do_int() {
   // The last int is the iteration variable in an IntStream, but we don't pass it
   // since we use the HSAIL workitemid in place of that int value
-  if (_index == _length) {
+  if (_parameter_index == _parameter_count - 1) {
     if (TraceGPUInteraction) {
       tty->print_cr("[HSAIL] HSAILKernelArguments::not pushing trailing int");
     }
@@ -136,17 +136,19 @@
 
 void HSAILKernelArguments::do_object() {
   if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] HSAILKernelArguments::do_object.");
+    tty->print_cr("[HSAIL] HSAILKernelArguments::do_object, _parameter_index=%d", _parameter_index);
   }
-  if (_index == _length) {  
-    // last arg in object stream lambda is  the object stream source array
+  oop arg = _args->obj_at(_index++);
+
+  // check if this is last arg in signature
+  // an object as last parameter requires an object stream source array to be passed
+  if (_parameter_index == _parameter_count - 1) {
     if (TraceGPUInteraction) {
       tty->print_cr("[HSAIL] HSAILKernelArguments::trailing object ref should be object source array ref");
     }
+    assert(arg->is_objArray(), "arg type mismatch");
   }
 
-  oop arg = _args->obj_at(_index++);
-  assert(arg->is_array(), "arg type mismatch");
   if (TraceGPUInteraction) {
     tty->print_cr("[HSAIL] HSAILKernelArguments::do_object, 0x%08x is a %s", (address) arg, arg->klass()->external_name());
   }
@@ -157,24 +159,9 @@
 
 void HSAILKernelArguments::do_object(int begin, int end) {
   if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] HSAILKernelArguments::do_object(int begin, int end).");
-  }
-
-  if ((!_is_static && (_index >=(_length-1))) || (_is_static && (_index >=(_length)))) {
-    // last arg in object stream lambda is  the object stream source array
-    if (TraceGPUInteraction) {
-      tty->print_cr("[HSAIL] HSAILKernelArguments::trailing object ref should be object source array ref");
-    }
+      tty->print_cr("[HSAIL] HSAILKernelArguments::do_object(int begin, int end), begin=%d, end=%d.", begin, end);
   }
-  
-  oop arg = _args->obj_at(_index++);
-  assert(arg->is_array(), "arg type mismatch");
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] HSAILKernelArguments::do_object(int, int), 0x%08x is a %s", (address) arg, arg->klass()->external_name());
-  }
-    
-  bool pushed = gpu::Hsail::_okra_push_object(_kernel, arg);
-  assert(pushed == true, "arg push failed");  
+  do_object();
 }
 
 void HSAILKernelArguments::do_void() {
--- a/src/gpu/hsail/vm/hsailKernelArguments.hpp	Tue Nov 19 17:44:26 2013 +0100
+++ b/src/gpu/hsail/vm/hsailKernelArguments.hpp	Wed Nov 20 01:11:10 2013 +0100
@@ -42,6 +42,8 @@
   int _index;
   // Kernel to push into
   address _kernel;
+  // number of parameters in the signature
+  int _parameter_count;
 
   bool _is_static;
   
@@ -55,8 +57,10 @@
     _args = args;
     _kernel = kernel;
     _is_static = is_static;
-    
+
     _length = args->length();
+    _parameter_count = ArgumentCount(signature).size();
+
     if (TraceGPUInteraction) {
       tty->print_cr("[HSAIL] sig:%s  args length=%d", signature->as_C_string(), _length);
     }