comparison src/gpu/hsail/vm/hsailArgumentsBase.hpp @ 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 06eedda53e14
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 #ifndef BASE_ARGUMENTS_HSAIL_HPP
26 #define BASE_ARGUMENTS_HSAIL_HPP
27
28 #include "runtime/signature.hpp"
29
30
31 /***
32 * Base class which iterates thru a signature and pulls from a
33 * objArrayOop of boxed values. Used as base for HSAILKernelArguments
34 * and HSAILJavaCallArguments The derived classes specify how to push
35 * args onto their data structure
36 ***/
37
38 class HSAILArgumentsBase : public SignatureIterator {
39
40 public:
41
42 private:
43 // Array of java argument oops
44 objArrayOop _args;
45 // Length of args array
46 int _length;
47 // Current index into _args
48 int _index;
49 // number of parameters in the signature
50 int _parameter_count;
51
52 Symbol * _signature;
53 bool _is_static;
54
55 // records first null parameter seen
56 int _first_null_parameter_index;
57
58 // Get next java argument
59 oop next_arg(BasicType expectedType);
60
61 virtual char *argsBuilderName() = 0;
62 virtual void pushObject(void * obj) = 0;
63 virtual void pushBool(jboolean z) = 0;
64 virtual void pushByte(jbyte b) = 0;
65 virtual void pushDouble(jdouble d) = 0;
66 virtual void pushFloat(jfloat f) = 0;
67 virtual void pushInt(jint i) = 0;
68 virtual void pushLong(jlong j) = 0;
69 virtual void handleFinalIntParameter() = 0;
70 virtual void handleFinalObjParameter(void *obj) = 0;
71 virtual void pushTrailingArgs() = 0;
72
73 void recordNullObjectParameter() {
74 if (_first_null_parameter_index == -1) _first_null_parameter_index = _parameter_index;
75 }
76
77 public:
78 HSAILArgumentsBase(Symbol* signature, objArrayOop args, bool is_static) : SignatureIterator(signature) {
79 this->_return_type = T_ILLEGAL;
80 _index = 0;
81 _args = args;
82 _is_static = is_static;
83 _signature = signature;
84
85 _length = args->length();
86 _parameter_count = ArgumentCount(signature).size();
87
88 _first_null_parameter_index = -1;
89
90 }
91
92 int getFirstNullParameterIndex() {
93 return _first_null_parameter_index;
94 }
95
96 void collectArgs() {
97 if (TraceGPUInteraction) {
98 tty->print_cr("[HSAIL] %s::collectArgs, sig:%s args length=%d", argsBuilderName(), _signature->as_C_string(), _length);
99 }
100 if (!_is_static) {
101 // First object in args should be 'this'
102 oop arg = _args->obj_at(_index++);
103 assert(arg->is_instance() && (! arg->is_array()), "First arg should be 'this'");
104 if (TraceGPUInteraction) {
105 tty->print_cr("[HSAIL] %s, instance method, this " PTR_FORMAT ", is a %s", argsBuilderName(), (address) arg, arg->klass()->external_name());
106 }
107 pushObject(arg);
108 } else {
109 if (TraceGPUInteraction) {
110 tty->print_cr("[HSAIL] %s, static method", argsBuilderName());
111 }
112 }
113 // Iterate over the entire signature
114 iterate();
115
116 pushTrailingArgs();
117 }
118
119 void do_bool();
120 void do_byte();
121 void do_double();
122 void do_float();
123 void do_int();
124 void do_long();
125 void do_array(int begin, int end);
126 void do_object();
127 void do_object(int begin, int end);
128
129 void do_void();
130
131 inline void do_char() {
132 /* TODO : To be implemented */
133 guarantee(false, "do_char:NYI");
134 }
135 inline void do_short() {
136 /* TODO : To be implemented */
137 guarantee(false, "do_short:NYI");
138 }
139
140 bool isLastParameter() {
141 return (_index == (_is_static ? _parameter_count - 1 : _parameter_count));
142 }
143
144 };
145
146 #endif // BASE_ARGUMENTS_HSAIL_HPP