comparison src/gpu/hsail/vm/hsailArgumentsBase.cpp @ 14768:3e9a960f0da1

HSAIL: preliminary deopt support Contributed-by: Tom Deneau <tom.deneau@amd.com>
author Doug Simon <doug.simon@oracle.com>
date Wed, 26 Mar 2014 17:33:54 +0100
parents
children 310994c667a7
comparison
equal deleted inserted replaced
14767:ded08e344e4a 14768:3e9a960f0da1
1 /*
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "hsailArgumentsBase.hpp"
27 #include "runtime/javaCalls.hpp"
28
29
30 // Get next java argument
31 oop HSAILArgumentsBase::next_arg(BasicType expectedType) {
32 assert(_index < _args->length(), "out of bounds");
33
34 oop arg = ((objArrayOop) (_args))->obj_at(_index++);
35 assert(expectedType == T_OBJECT ||
36 java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch");
37
38 return arg;
39 }
40
41 void HSAILArgumentsBase::do_bool() {
42 // Get the boxed value
43 oop arg = _args->obj_at(_index++);
44 assert(java_lang_boxing_object::is_instance(arg, T_BOOLEAN), "arg type mismatch");
45
46 jvalue jValue;
47 java_lang_boxing_object::get_value(arg, &jValue);
48
49 pushBool(jValue.z);
50 }
51
52 void HSAILArgumentsBase::do_byte() {
53 // Get the boxed value
54 oop arg = _args->obj_at(_index++);
55 assert(java_lang_boxing_object::is_instance(arg, T_BYTE), "arg type mismatch");
56
57 jvalue jValue;
58 java_lang_boxing_object::get_value(arg, &jValue);
59
60 pushByte(jValue.b);
61 }
62
63 void HSAILArgumentsBase::do_double() {
64 // Get the boxed value
65 oop arg = _args->obj_at(_index++);
66 assert(java_lang_boxing_object::is_instance(arg, T_DOUBLE), "arg type mismatch");
67
68 jvalue jValue;
69 java_lang_boxing_object::get_value(arg, &jValue);
70 if (TraceGPUInteraction) {
71 tty->print_cr("[HSAIL] %s::do_double, _index=%d, value = %e", argsBuilderName(), _index - 1, jValue.d);
72 }
73 pushDouble(jValue.d);
74 }
75
76 void HSAILArgumentsBase::do_float() {
77 // Get the boxed value
78 oop arg = _args->obj_at(_index++);
79 assert(java_lang_boxing_object::is_instance(arg, T_FLOAT), "arg type mismatch");
80
81 jvalue jValue;
82 java_lang_boxing_object::get_value(arg, &jValue);
83 if (TraceGPUInteraction) {
84 tty->print_cr("[HSAIL] %s::do_float, _index=%d, value = %f", argsBuilderName(), _index - 1, jValue.f);
85 }
86 pushFloat(jValue.f);
87 }
88
89 void HSAILArgumentsBase::do_int() {
90 // If the last parameter is an int, it is handled in a special way
91 // For kernel arguments we don't pass it since we use the HSAIL workitemid in place of that int value
92 // For javaCall arguments we pass the actual workitemid
93 if (isLastParameter()) {
94 handleFinalIntParameter();
95 return;
96 }
97
98 // not the final int parameter, Get the boxed int
99 oop arg = _args->obj_at(_index++);
100 assert(java_lang_boxing_object::is_instance(arg, T_INT), "arg type mismatch");
101
102 jvalue jValue;
103 java_lang_boxing_object::get_value(arg, &jValue);
104 if (TraceGPUInteraction) {
105 tty->print_cr("[HSAIL] %s::do_int, _index=%d, value = %d", argsBuilderName(), _index - 1, jValue.i);
106 }
107
108 pushInt(jValue.i);
109 }
110
111 void HSAILArgumentsBase::do_long() {
112 // Get the boxed value
113 oop arg = _args->obj_at(_index++);
114 assert(java_lang_boxing_object::is_instance(arg, T_LONG), "arg type mismatch");
115
116 jvalue jValue;
117 java_lang_boxing_object::get_value(arg, &jValue);
118 if (TraceGPUInteraction) {
119 tty->print_cr("[HSAIL] %s::do_long, _index=%d, value = %d", argsBuilderName(), _index - 1, jValue.j);
120 }
121
122 pushLong(jValue.j);
123 }
124
125 void HSAILArgumentsBase::do_array(int begin, int end) {
126 oop arg = _args->obj_at(_index++);
127 if (arg == NULL) {
128 recordNullObjectParameter();
129 } else {
130 assert(arg->is_array(), "arg type mismatch");
131 }
132 if (TraceGPUInteraction) {
133 tty->print_cr("[HSAIL] %s::do_array, _index=%d, 0x%08x, is a %s", argsBuilderName(), _index - 1, (address) arg,
134 arg == NULL ? "null" : arg->klass()->external_name());
135 }
136
137 pushObject(arg);
138 }
139
140 void HSAILArgumentsBase::do_object() {
141 bool isLastParam = isLastParameter(); // determine this before incrementing _index
142
143 oop arg = _args->obj_at(_index++);
144 if (TraceGPUInteraction) {
145 tty->print_cr("[HSAIL] %s::do_object, _index=%d, 0x%08x is a %s", argsBuilderName(), _index - 1, (address) arg,
146 arg == NULL ? "null" : arg->klass()->external_name());
147 }
148 if (arg == NULL) {
149 recordNullObjectParameter();
150 }
151
152 // check if this is last arg in signature
153 // an object as last parameter requires special handling
154 if (isLastParam) {
155 if (TraceGPUInteraction) {
156 tty->print_cr("[HSAIL] %s, trailing object ref should be object source array ref", argsBuilderName());
157 }
158 assert(arg->is_objArray(), "arg type mismatch");
159 handleFinalObjParameter(arg);
160 } else {
161 // not the final parameter, just push
162 pushObject(arg);
163 }
164 }
165
166 void HSAILArgumentsBase::do_object(int begin, int end) {
167 do_object();
168 }
169
170 void HSAILArgumentsBase::do_void() {
171 return;
172 }
173
174 // TODO implement other do_*
175