author | duke |
Wed, 05 Jul 2017 20:05:23 +0200 | |
changeset 27222 | 422e90d83a4e |
parent 7397 | 5b173b4ca846 |
child 46727 | 6e4a84748e2c |
permissions | -rw-r--r-- |
4013 | 1 |
/* |
7397 | 2 |
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. |
4013 | 3 |
* Copyright 2007, 2008 Red Hat, Inc. |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4013
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4013
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4013
diff
changeset
|
22 |
* questions. |
4013 | 23 |
* |
24 |
*/ |
|
25 |
||
7397 | 26 |
#ifndef CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP |
27 |
#define CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP |
|
28 |
||
29 |
#include "memory/allocation.hpp" |
|
30 |
||
4013 | 31 |
class SignatureHandler { |
32 |
public: |
|
33 |
static SignatureHandler *from_handlerAddr(address handlerAddr) { |
|
34 |
return (SignatureHandler *) handlerAddr; |
|
35 |
} |
|
36 |
||
37 |
public: |
|
38 |
ffi_cif* cif() const { |
|
39 |
return (ffi_cif *) this; |
|
40 |
} |
|
41 |
||
42 |
int argument_count() const { |
|
43 |
return cif()->nargs; |
|
44 |
} |
|
45 |
||
46 |
ffi_type** argument_types() const { |
|
47 |
return (ffi_type**) (cif() + 1); |
|
48 |
} |
|
49 |
||
50 |
ffi_type* argument_type(int i) const { |
|
51 |
return argument_types()[i]; |
|
52 |
} |
|
53 |
||
54 |
ffi_type* result_type() const { |
|
55 |
return *(argument_types() + argument_count()); |
|
56 |
} |
|
57 |
||
58 |
protected: |
|
59 |
friend class InterpreterRuntime; |
|
60 |
friend class SignatureHandlerLibrary; |
|
61 |
||
62 |
void finalize(); |
|
63 |
}; |
|
64 |
||
65 |
class SignatureHandlerGeneratorBase : public NativeSignatureIterator { |
|
66 |
private: |
|
67 |
ffi_cif* _cif; |
|
68 |
||
69 |
protected: |
|
70 |
SignatureHandlerGeneratorBase(methodHandle method, ffi_cif *cif) |
|
71 |
: NativeSignatureIterator(method), _cif(cif) { |
|
72 |
_cif->nargs = 0; |
|
73 |
} |
|
74 |
||
75 |
ffi_cif *cif() const { |
|
76 |
return _cif; |
|
77 |
} |
|
78 |
||
79 |
public: |
|
80 |
void generate(uint64_t fingerprint); |
|
81 |
||
82 |
private: |
|
83 |
void pass_int(); |
|
84 |
void pass_long(); |
|
85 |
void pass_float(); |
|
86 |
void pass_double(); |
|
87 |
void pass_object(); |
|
88 |
||
89 |
private: |
|
90 |
void push(BasicType type); |
|
91 |
virtual void push(intptr_t value) = 0; |
|
92 |
}; |
|
93 |
||
94 |
class SignatureHandlerGenerator : public SignatureHandlerGeneratorBase { |
|
95 |
private: |
|
96 |
CodeBuffer* _cb; |
|
97 |
||
98 |
public: |
|
99 |
SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) |
|
6771
3f9a5f169070
6990549: Zero and Shark fixes after 6978355 and 6953144
twisti
parents:
5547
diff
changeset
|
100 |
: SignatureHandlerGeneratorBase(method, (ffi_cif *) buffer->insts_end()), |
4013 | 101 |
_cb(buffer) { |
6771
3f9a5f169070
6990549: Zero and Shark fixes after 6978355 and 6953144
twisti
parents:
5547
diff
changeset
|
102 |
_cb->set_insts_end((address) (cif() + 1)); |
4013 | 103 |
} |
104 |
||
105 |
private: |
|
106 |
void push(intptr_t value) { |
|
6771
3f9a5f169070
6990549: Zero and Shark fixes after 6978355 and 6953144
twisti
parents:
5547
diff
changeset
|
107 |
intptr_t *dst = (intptr_t *) _cb->insts_end(); |
3f9a5f169070
6990549: Zero and Shark fixes after 6978355 and 6953144
twisti
parents:
5547
diff
changeset
|
108 |
_cb->set_insts_end((address) (dst + 1)); |
4013 | 109 |
*dst = value; |
110 |
} |
|
111 |
}; |
|
112 |
||
113 |
class SlowSignatureHandlerGenerator : public SignatureHandlerGeneratorBase { |
|
114 |
private: |
|
115 |
intptr_t *_dst; |
|
116 |
||
117 |
public: |
|
118 |
SlowSignatureHandlerGenerator(methodHandle method, intptr_t* buf) |
|
119 |
: SignatureHandlerGeneratorBase(method, (ffi_cif *) buf) { |
|
120 |
_dst = (intptr_t *) (cif() + 1); |
|
121 |
} |
|
122 |
||
123 |
private: |
|
124 |
void push(intptr_t value) { |
|
125 |
*(_dst++) = value; |
|
126 |
} |
|
127 |
||
128 |
public: |
|
129 |
SignatureHandler *handler() const { |
|
130 |
return (SignatureHandler *) cif(); |
|
131 |
} |
|
132 |
}; |
|
7397 | 133 |
|
134 |
#endif // CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP |