author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 06 Feb 2013 21:52:03 +0100 | |
branch | development |
changeset 2029 | cdc3a79c8a58 |
parent 2020 | 985ca70cdcad |
child 2046 | 3309a3bc8615 |
permissions | -rw-r--r-- |
877 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 5 |
|
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
||
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
877 | 20 |
" |
752 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
23 |
JavaMethodWithHandler variableSubclass:#JavaNativeMethod |
|
1749 | 24 |
instanceVariableNames:'nativeImplementation nCalls' |
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
25 |
classVariableNames:'CacheNativeImplementation Verbose TrampolineSelectors' |
752 | 26 |
poolDictionaries:'' |
27 |
category:'Languages-Java-Classes' |
|
28 |
! |
|
29 |
||
877 | 30 |
!JavaNativeMethod class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 35 |
|
1155 | 36 |
New code and modifications done at SWING Research Group [1]: |
1152 | 37 |
|
877 | 38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
39 |
SWING Research Group, Czech Technical University in Prague |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
1155 | 48 |
[1] Code written at SWING Research Group contains a signature |
49 |
of one of the above copright owners. For exact set of such code, |
|
50 |
see the differences between this version and version stx:libjava |
|
1152 | 51 |
as of 1.9.2010 |
877 | 52 |
|
53 |
" |
|
54 |
! ! |
|
752 | 55 |
|
56 |
!JavaNativeMethod class methodsFor:'initialization'! |
|
57 |
||
761 | 58 |
cacheNativeImplementation |
59 |
||
60 |
"For details, see #cacheNativeImplementation:" |
|
61 |
||
62 |
^CacheNativeImplementation |
|
63 |
||
64 |
"Created: / 30-04-2011 / 23:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
65 |
! |
|
66 |
||
67 |
cacheNativeImplementation: aBoolean |
|
68 |
||
69 |
"If set, native implementations are cached, resulting |
|
70 |
in better performance when calling native methods. |
|
71 |
Hower, no change in native method implemenetaion will |
|
72 |
not be visible then, unless #flushAllCachedNativeMethods |
|
73 |
is explictely called" |
|
74 |
||
75 |
CacheNativeImplementation := aBoolean |
|
76 |
||
77 |
"Created: / 30-04-2011 / 23:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
78 |
! |
|
79 |
||
752 | 80 |
initialize |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
81 |
"/self flags: ((self flags bitClear: Behavior flagMethod) bitOr: Behavior flagJavaMethod). |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
82 |
self flags: ((self flags bitClear: Behavior flagJavaMethod) bitOr: Behavior flagMethod). |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
83 |
" |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
84 |
self flags bitAnd: Behavior flagJavaMethod |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
85 |
self flags bitAnd: Behavior flagMethod |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
86 |
|
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
87 |
" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
88 |
"By default, do not cache native impls while developing" |
761 | 89 |
CacheNativeImplementation := Smalltalk isStandAloneApp. |
1075
927aeb3649fc
Fix in native method imp -> class loading java tests all pass.. I'm getting drunk tonight :)
hlopkmar
parents:
1073
diff
changeset
|
90 |
Verbose := false. |
927aeb3649fc
Fix in native method imp -> class loading java tests all pass.. I'm getting drunk tonight :)
hlopkmar
parents:
1073
diff
changeset
|
91 |
" |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
92 |
Verbose := true. |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
93 |
" |
761 | 94 |
|
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
95 |
TrampolineSelectors := #( |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
96 |
"/0 |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
97 |
#trampoline: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
98 |
#trampoline:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
99 |
#trampoline:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
100 |
#trampoline:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
101 |
"/4 |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
102 |
#trampoline:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
103 |
#trampoline:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
104 |
#trampoline:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
105 |
#trampoline:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
106 |
"/8 |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
107 |
#trampoline:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
108 |
#trampoline:_:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
109 |
#trampoline:_:_:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
110 |
#trampoline:_:_:_:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
111 |
"/13 |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
112 |
#trampoline:_:_:_:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
113 |
#trampoline:_:_:_:_:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
114 |
#trampoline:_:_:_:_:_:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
115 |
#trampoline:_:_:_:_:_:_:_:_:_:_:_:_: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
116 |
). |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
117 |
|
1075
927aeb3649fc
Fix in native method imp -> class loading java tests all pass.. I'm getting drunk tonight :)
hlopkmar
parents:
1073
diff
changeset
|
118 |
"Modified (comment): / 03-11-2011 / 10:48:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
119 |
"Modified: / 31-01-2013 / 14:40:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
120 |
! ! |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
121 |
|
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
122 |
!JavaNativeMethod class methodsFor:'instance creation'! |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
123 |
|
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
124 |
new |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
125 |
"Redefined again, since since trampoline methods need |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
126 |
literals" |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
127 |
|
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
128 |
^ self basicNew:1. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
129 |
|
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
130 |
"Created: / 31-01-2013 / 13:26:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 131 |
! ! |
132 |
||
133 |
!JavaNativeMethod class methodsFor:'cleanup'! |
|
134 |
||
135 |
flushAllCachedNativeMethods |
|
136 |
self allInstancesDo:[:aNativeMethod | |
|
137 |
aNativeMethod nativeImplementation:nil |
|
138 |
]. |
|
139 |
||
140 |
" |
|
141 |
self flushAllCachedNativeMethods |
|
142 |
" |
|
143 |
||
144 |
"Created: / 24.12.1999 / 03:10:38 / cg" |
|
145 |
"Modified: / 24.12.1999 / 03:10:51 / cg" |
|
146 |
! ! |
|
147 |
||
148 |
!JavaNativeMethod methodsFor:'accessing'! |
|
149 |
||
1749 | 150 |
nCalls |
151 |
^ nCalls ? 0 |
|
152 |
||
153 |
"Modified: / 27-10-2012 / 18:05:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
154 |
! |
|
155 |
||
1754
b3cde0c1c2b1
- do not enforce Java native code optimization off
vranyj1
parents:
1749
diff
changeset
|
156 |
nCallsReset |
b3cde0c1c2b1
- do not enforce Java native code optimization off
vranyj1
parents:
1749
diff
changeset
|
157 |
nCalls := 0 |
b3cde0c1c2b1
- do not enforce Java native code optimization off
vranyj1
parents:
1749
diff
changeset
|
158 |
|
b3cde0c1c2b1
- do not enforce Java native code optimization off
vranyj1
parents:
1749
diff
changeset
|
159 |
"Modified: / 27-10-2012 / 18:05:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
b3cde0c1c2b1
- do not enforce Java native code optimization off
vranyj1
parents:
1749
diff
changeset
|
160 |
! |
b3cde0c1c2b1
- do not enforce Java native code optimization off
vranyj1
parents:
1749
diff
changeset
|
161 |
|
752 | 162 |
nativeImplementation |
163 |
"return the value of the instance variable 'nativeImplementation' (automatically generated)" |
|
164 |
||
165 |
^ nativeImplementation |
|
166 |
||
167 |
"Created: / 25.9.1999 / 23:08:00 / cg" |
|
168 |
! |
|
169 |
||
170 |
nativeImplementation:something |
|
171 |
"set the value of the instance variable 'nativeImplementation' (automatically generated)" |
|
172 |
||
173 |
nativeImplementation := something. |
|
174 |
||
175 |
"Created: / 25.9.1999 / 23:08:00 / cg" |
|
176 |
! |
|
177 |
||
178 |
sourceLineNumber |
|
1213
fc90769151e8
- fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents:
1155
diff
changeset
|
179 |
|
fc90769151e8
- fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents:
1155
diff
changeset
|
180 |
^super sourceLineNumber |
fc90769151e8
- fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents:
1155
diff
changeset
|
181 |
|
fc90769151e8
- fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents:
1155
diff
changeset
|
182 |
"/ ForceByteCodeDisplay == true ifTrue:[ ^ 1]. |
fc90769151e8
- fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents:
1155
diff
changeset
|
183 |
"/ lineNumberTable notNil ifTrue:[ ^ lineNumberTable at:2]. |
fc90769151e8
- fix in reflection over methods (signature is nil for non-generic methods)
vranyj1
parents:
1155
diff
changeset
|
184 |
"/ ^1 |
752 | 185 |
|
186 |
||
187 |
" |
|
188 |
^ (JavaSourceCodeCache new) |
|
189 |
findLineForMethod:(self selector) |
|
190 |
inClass:javaClass. |
|
191 |
" |
|
192 |
||
193 |
"Modified: / 13-12-2010 / 13:55:55 / Jan Kurs <kurs.jan@post.cz>" |
|
194 |
"Modified: / 13-12-2010 / 23:46:30 / Marcel Hlopko <hlopik@gmail.com>" |
|
195 |
"Created: / 17-12-2010 / 10:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
196 |
! ! |
|
197 |
||
761 | 198 |
!JavaNativeMethod methodsFor:'private'! |
199 |
||
200 |
compileNativeImplementation: sel dispatchingTo: oldSel |
|
201 |
||
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
202 |
| src arg converted header | |
761 | 203 |
src := (JavaVM class compiledMethodAt: oldSel) source. |
204 |
src := src asStringCollection. |
|
205 |
(src first includesString: 'aJavaContext') ifTrue:[ |
|
206 |
arg := 'aJavaContext' |
|
207 |
] ifFalse:[ |
|
208 |
(src first includesString: 'nativeContext') ifTrue:[ |
|
209 |
arg := 'nativeContext' |
|
210 |
] |
|
211 |
]. |
|
212 |
arg ifNotNil:[ |
|
213 |
src removeFirst asString. |
|
214 |
converted := true. |
|
215 |
] ifNil:[ |
|
216 |
arg := 'nativeContext'. |
|
217 |
src := ' self breakPoint: #jv info: ''Convert it to new-style natives''. |
|
218 |
||
219 |
^ self ', oldSel, ' nativeContext'. |
|
220 |
converted := false. |
|
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
221 |
]. |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
222 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
223 |
header := String streamContents:[:s| |
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
224 |
sel numArgs == 2 ifTrue:[ |
2010
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
225 |
s nextPutAll: sel; space; nextPutAll: 'this '. |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
226 |
] ifFalse:[ |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
227 |
| kw | |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
228 |
|
2010
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
229 |
kw := sel keywords. |
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
230 |
s nextPutAll: kw first. |
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
231 |
s nextPutAll: ' this '. |
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
232 |
2 to: kw size - 1 do:[:i| |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
233 |
sel nextPutAll: (kw at: i); space; nextPut:$a; nextPutAll: i printString; space. |
2010
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
234 |
]. |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
235 |
] |
761 | 236 |
]. |
237 |
||
238 |
(JavaVM class |
|
239 |
compile: |
|
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
240 |
(self nativeMethodTemplate bindWith:header with: arg with: src asString) |
761 | 241 |
classified: |
242 |
'native - ', ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$. )) |
|
243 |
package: JavaVM package. |
|
244 |
||
245 |
converted ifTrue:[ |
|
246 |
(JavaVM class compiledMethodAt: oldSel) category: 'native - old-style (converted)' |
|
247 |
] ifFalse:[ |
|
248 |
(JavaVM class compiledMethodAt: oldSel) category: 'native - old-style (FAILED to convert)' |
|
249 |
] |
|
250 |
||
251 |
"Created: / 01-05-2011 / 00:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
252 |
"Modified: / 19-01-2013 / 23:29:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
761 | 253 |
! |
254 |
||
255 |
compileNativeImplementationStub: sel |
|
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
256 |
| header | |
761 | 257 |
|
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
258 |
header := String streamContents:[:s| |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
259 |
| kw | |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
260 |
|
2010
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
261 |
kw := sel keywords. |
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
262 |
s nextPutAll: kw first. |
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
263 |
s nextPutAll: ' this '. |
2029
cdc3a79c8a58
Native method stup generation fixed. A bunch of new natives (85) for Open JDK 6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2020
diff
changeset
|
264 |
2 to: kw size do:[:i| |
1990
f37fb2129089
Fixed natives. Java VM boots & Groovy 1+1 works.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1986
diff
changeset
|
265 |
s nextPutAll: (kw at: i); space; nextPut:$a; nextPutAll: (i - 1) printString; space. |
2010
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
266 |
]. |
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
267 |
|
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
268 |
]. |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
269 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
270 |
(JavaVM natives class |
761 | 271 |
compile: |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
272 |
(self nativeMethodTemplate bindWith:header with: 'nativeContext' with:('^ JavaVM unimplementedNativeMethodSignal raise')) |
761 | 273 |
classified: |
274 |
'native - ', ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$.)) |
|
2029
cdc3a79c8a58
Native method stup generation fixed. A bunch of new natives (85) for Open JDK 6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2020
diff
changeset
|
275 |
package: JavaVM package. |
cdc3a79c8a58
Native method stup generation fixed. A bunch of new natives (85) for Open JDK 6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2020
diff
changeset
|
276 |
|
cdc3a79c8a58
Native method stup generation fixed. A bunch of new natives (85) for Open JDK 6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2020
diff
changeset
|
277 |
self assert: (JavaVM natives respondsTo: sel). |
761 | 278 |
|
279 |
"Created: / 01-05-2011 / 00:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2029
cdc3a79c8a58
Native method stup generation fixed. A bunch of new natives (85) for Open JDK 6.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2020
diff
changeset
|
280 |
"Modified: / 06-02-2013 / 21:48:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
761 | 281 |
! |
282 |
||
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
283 |
installTrampoline: trampoline |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
284 |
| l m | |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
285 |
|
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
286 |
m := trampoline asByteCodeMethod. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
287 |
m ~~ trampoline ifTrue:[ |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
288 |
"Cache it" |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
289 |
self class methodDictionary at: trampoline selector put: m. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
290 |
]. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
291 |
l := m literals. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
292 |
1 to: l size do:[:i| |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
293 |
(l at: i) == #__placeholder__ ifTrue:[ |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
294 |
l at: i put: self. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
295 |
]. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
296 |
]. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
297 |
m isNil ifTrue:[ |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
298 |
self error: 'Cannot find trampoline method'. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
299 |
]. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
300 |
self byteCode: m byteCode. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
301 |
self literals: l. |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
302 |
|
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
303 |
"Created: / 31-01-2013 / 13:31:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
304 |
! |
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
305 |
|
761 | 306 |
nativeMethodTemplate |
307 |
||
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
308 |
^'%1 |
761 | 309 |
|
310 |
<javanative: ''', javaClass name , ''' name: ''', (selector copyWithoutLast:signature size), '''> |
|
311 |
||
312 |
%3' |
|
313 |
||
314 |
"Created: / 01-05-2011 / 00:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
315 |
"Modified: / 31-01-2013 / 15:07:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
761 | 316 |
! |
317 |
||
318 |
searchNativeImplementation |
|
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
319 |
<resource: #obsolete> |
761 | 320 |
|
321 |
"Returns a SELECTOR of native method implementation. |
|
322 |
For now, two naming schemes are used. The onld one uses |
|
323 |
just a class name and selector as a name for native method impl. |
|
324 |
The new one uses fully qualified class name. |
|
325 |
" |
|
326 |
||
327 |
| nm newStyleSel oldStyleSel | |
|
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
328 |
|
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
329 |
self error: 'Should no longer be called!!'. |
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
330 |
|
912
e651488f5741
Many fixes in reflection, expecially for generic types support
vranyj1
parents:
877
diff
changeset
|
331 |
nm := selector upTo: $(. |
761 | 332 |
newStyleSel := ('_' , ((javaClass name copyReplaceAll:$/ with:$_) replaceAll:$$ with:$_), '_' , nm , ':') asSymbol. |
1974 | 333 |
(JavaVM natives class canUnderstand: newStyleSel) ifTrue:[ |
334 |
"Good, a JavaVM understands new style native selectors" |
|
335 |
^newStyleSel |
|
336 |
]. |
|
761 | 337 |
|
338 |
oldStyleSel := ('_' , (javaClass lastName copyReplaceAll:$$ with:$_) , '_' , nm , ':') asSymbol. |
|
1974 | 339 |
(JavaVM natives canUnderstand: oldStyleSel) ifTrue:[ |
761 | 340 |
"Convert method on the fly only if Im Jan Vrany |
341 |
(to avoid confusion of other developers :-)" |
|
342 |
OperatingSystem getLoginName = 'jv' ifTrue:[ |
|
343 |
"OK, old style method has not yet been converted to a newstyle one. |
|
344 |
Converts old-style method to a new-style one" |
|
345 |
self compileNativeImplementation: newStyleSel dispatchingTo: oldStyleSel. |
|
346 |
^newStyleSel |
|
347 |
] ifFalse:[ |
|
348 |
^oldStyleSel |
|
1974 | 349 |
] |
350 |
]. |
|
761 | 351 |
self compileNativeImplementationStub: newStyleSel. |
352 |
^newStyleSel |
|
353 |
||
354 |
"Created: / 30-04-2011 / 23:50:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
355 |
"Modified: / 19-01-2013 / 23:31:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
356 |
! |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
357 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
358 |
searchNativeImplementation: numArgs |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
359 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
360 |
"Returns a SELECTOR of native method implementation." |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
361 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
362 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
363 |
| nm newStyleSel args | |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
364 |
nm := selector upTo: $(. |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
365 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
366 |
args := #( |
2010
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
367 |
"0" '' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
368 |
"1" '_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
369 |
"2" '_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
370 |
"3" '_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
371 |
"4" '_:_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
372 |
"5" '_:_:_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
373 |
"6" '_:_:_:_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
374 |
"7" '_:_:_:_:_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
375 |
"8" '_:_:_:_:_:_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
376 |
"9" '_:_:_:_:_:_:_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
377 |
"10" '_:_:_:_:_:_:_:_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
378 |
"11" '_:_:_:_:_:_:_:_:_:_:_:' |
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
379 |
"12" '_:_:_:_:_:_:_:_:_:_:_:_:' |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
380 |
) at: numArgs + 1. |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
381 |
|
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
382 |
newStyleSel := ('_' , ((javaClass name copyReplaceAll:$/ with:$_) replaceAll:$$ with:$_), '_' , nm , ':' , args) asSymbol. |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
383 |
(JavaVM natives class canUnderstand: newStyleSel) ifTrue:[ |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
384 |
"Good, a JavaVM understands new style native selectors" |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
385 |
^newStyleSel |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
386 |
]. |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
387 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
388 |
self compileNativeImplementationStub: newStyleSel. |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
389 |
^newStyleSel |
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
390 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
391 |
"Created: / 19-01-2013 / 22:11:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
392 |
"Modified: / 19-01-2013 / 23:39:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
761 | 393 |
! ! |
394 |
||
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
395 |
!JavaNativeMethod methodsFor:'private-compiler interface'! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
396 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
397 |
numberOfArgs:aNumber |
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
398 |
| args trampolineTree compiler trampoline | |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
399 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
400 |
super numberOfArgs:aNumber. |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
401 |
(self class flags bitAnd:Behavior flagJavaMethod) ~~ 0 ifTrue:[ ^ self ]. |
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
402 |
javaClass isNil ifTrue:[ |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
403 |
self error: 'Cannot install trampoline - no Java class yet'. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
404 |
^self. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
405 |
]. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
406 |
selector isNil ifTrue:[ |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
407 |
self error: 'Cannot install trampoline - no selector yet'. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
408 |
^self. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
409 |
]. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
410 |
|
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
411 |
"Create the trampoline" |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
412 |
args := (1 to: aNumber) collect:[:i|(VariableNode methodArgumentNamed: ('arg_' , i printString)) index: i]. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
413 |
trampolineTree := MethodNode new |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
414 |
arguments: args; |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
415 |
selector: (TrampolineSelectors at: aNumber + 1); |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
416 |
statements: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
417 |
{ (ReturnNode expression: |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
418 |
(MessageNode |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
419 |
receiver: (VariableNode globalNamed:#'JavaVM:NativeMethodsImplementation') |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
420 |
selector: (self searchNativeImplementation: aNumber) |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
421 |
args: (Array with: (SelfNode value: #self)) , args)) }. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
422 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
423 |
|
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
424 |
compiler := ByteCodeCompiler new. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
425 |
compiler methodClass: Method. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
426 |
trampoline := compiler |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
427 |
compileTree: trampolineTree |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
428 |
forClass: javaClass |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
429 |
ifFail:[self error: 'Failed to compile tampoline']. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
430 |
"Install the trampoline" |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
431 |
|
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
432 |
self byteCode: trampoline byteCode. |
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
433 |
self literals: trampoline literals. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
434 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
435 |
"Created: / 31-01-2013 / 12:44:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2020
985ca70cdcad
Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2019
diff
changeset
|
436 |
"Modified: / 31-01-2013 / 15:09:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
437 |
! ! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
438 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
439 |
!JavaNativeMethod methodsFor:'private-trampolines'! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
440 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
441 |
trampolineUncached |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
442 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
443 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
444 |
"Created: / 31-01-2013 / 12:55:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
445 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
446 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
447 |
trampolineUncached: a1 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
448 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
449 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
450 |
"Created: / 31-01-2013 / 12:55:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
451 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
452 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
453 |
trampolineUncached: a1 _: a2 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
454 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
455 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
456 |
"Created: / 31-01-2013 / 12:55:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
457 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
458 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
459 |
trampolineUncached: a1 _: a2 _: a3 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
460 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
461 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
462 |
"Created: / 31-01-2013 / 12:55:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
463 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
464 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
465 |
trampolineUncached: a1 _: a2 _: a3 _: a4 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
466 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
467 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
468 |
"Created: / 31-01-2013 / 12:55:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
469 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
470 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
471 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
472 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
473 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
474 |
"Created: / 31-01-2013 / 12:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
475 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
476 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
477 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
478 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
479 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
480 |
"Created: / 31-01-2013 / 12:55:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
481 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
482 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
483 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
484 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
485 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
486 |
"Created: / 31-01-2013 / 12:55:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
487 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
488 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
489 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
490 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
491 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
492 |
"Created: / 31-01-2013 / 12:56:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
493 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
494 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
495 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
496 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
497 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
498 |
"Created: / 31-01-2013 / 12:56:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
499 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
500 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
501 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 _: a10 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
502 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
503 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
504 |
"Created: / 31-01-2013 / 12:56:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
505 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
506 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
507 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 _: a10 _: a11 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
508 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
509 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
510 |
"Created: / 31-01-2013 / 12:56:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
511 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
512 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
513 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 _: a10 _: a11 _: a12 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
514 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
515 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
516 |
"Created: / 31-01-2013 / 12:56:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
517 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
518 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
519 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 _: a10 _: a11 _: a12 _: a13 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
520 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
521 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
522 |
"Created: / 31-01-2013 / 12:56:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
523 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
524 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
525 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 _: a10 _: a11 _: a12 _: a13 _: a14 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
526 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
527 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
528 |
"Created: / 31-01-2013 / 12:56:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
529 |
! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
530 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
531 |
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 _: a10 _: a11 _: a12 _: a13 _: a14 _: a15 |
2019
e1291a81f215
Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2016
diff
changeset
|
532 |
^#__placeholder__ nativeMethodInvokation: thisContext. |
2016
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
533 |
|
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
534 |
"Created: / 31-01-2013 / 12:56:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
535 |
! ! |
6afb298c7403
Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2010
diff
changeset
|
536 |
|
752 | 537 |
!JavaNativeMethod methodsFor:'vm support'! |
538 |
||
539 |
nativeMethodInvokation |
|
761 | 540 |
"Called by the VM when a native method is |
1748 | 541 |
to be executed - old (slow) implementation" |
542 |
||
543 |
^self nativeMethodInvokation: thisContext sender. |
|
544 |
||
545 |
" |
|
546 |
JavaNativeMethod flushAllCachedNativeMethods" |
|
547 |
||
548 |
"Modified: / 27-01-2000 / 13:34:53 / cg" |
|
549 |
"Modified: / 03-11-2011 / 10:47:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
550 |
"Modified: / 27-10-2012 / 15:15:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
551 |
! |
|
552 |
||
553 |
nativeMethodInvokation: context |
|
554 |
"Called by the VM when a native method is |
|
555 |
to be executed. |
|
556 |
||
557 |
'context' is the context of being-invoked native method" |
|
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
558 |
|
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
559 |
| sel mthd sender nArgs receiverAndArgsAndContext | |
1749 | 560 |
nCalls := (nCalls ? 0) + 1. |
2010
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
561 |
receiverAndArgsAndContext := Array new: (nArgs := context numArgs) + 1"receiver". |
1993
6cb676a913a8
Native methods now use arguments instead of fetching them from context.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1990
diff
changeset
|
562 |
receiverAndArgsAndContext replaceFrom:2 to:1 + nArgs with: context startingAt: context arg1Index. |
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
563 |
receiverAndArgsAndContext at: 1 put: context receiver. |
2010
9bacff8c53de
The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1993
diff
changeset
|
564 |
|
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
565 |
|
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
566 |
|
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
567 |
(mthd := nativeImplementation) isNil ifTrue: [ |
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
568 |
sel := self searchNativeImplementation: nArgs. |
1971
e75c1790521c
Java native implementation refactoring (phase 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1864
diff
changeset
|
569 |
mthd := (JavaVM natives class compiledMethodAt: sel). |
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
570 |
(mthd isNil or: [ mthd isLazyMethod ]) ifTrue: [ |
1748 | 571 |
sender := context. |
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
572 |
sender sender selector == #noByteCode ifTrue: [ |
752 | 573 |
sender := sender sender. |
574 |
sender := sender sender. |
|
575 |
sender := sender sender. |
|
576 |
]. |
|
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
577 |
^ JavaVM natives perform: sel withArguments: receiverAndArgsAndContext |
752 | 578 |
]. |
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
579 |
CacheNativeImplementation ifTrue: [ nativeImplementation := mthd. ] |
752 | 580 |
]. |
1075
927aeb3649fc
Fix in native method imp -> class loading java tests all pass.. I'm getting drunk tonight :)
hlopkmar
parents:
1073
diff
changeset
|
581 |
Verbose ifTrue: [Logger log: 'Native method invokation: ' , sel severity: #debug facility: #JVM]. |
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
582 |
^ mthd |
1971
e75c1790521c
Java native implementation refactoring (phase 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1864
diff
changeset
|
583 |
valueWithReceiver: JavaVM natives |
1986
9e63ab553922
JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1985
diff
changeset
|
584 |
arguments: receiverAndArgsAndContext |
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
585 |
selector: selector |
1971
e75c1790521c
Java native implementation refactoring (phase 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1864
diff
changeset
|
586 |
search: JavaVM natives class |
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
587 |
sender: nil |
752 | 588 |
|
1073
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
589 |
" |
e842ab17fe16
quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents:
1022
diff
changeset
|
590 |
JavaNativeMethod flushAllCachedNativeMethods" |
752 | 591 |
|
1748 | 592 |
"Created: / 27-10-2012 / 15:13:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1993
6cb676a913a8
Native methods now use arguments instead of fetching them from context.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1990
diff
changeset
|
593 |
"Modified: / 21-01-2013 / 17:35:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 594 |
! ! |
595 |
||
596 |
!JavaNativeMethod class methodsFor:'documentation'! |
|
597 |
||
598 |
version |
|
1864 | 599 |
^ '$Header$' |
600 |
! |
|
601 |
||
602 |
version_HG |
|
603 |
||
604 |
^ '$Changeset: <not expanded> $' |
|
752 | 605 |
! |
606 |
||
607 |
version_SVN |
|
1864 | 608 |
^ '§Id§' |
923 | 609 |
|
752 | 610 |
! ! |
611 |
||
1985
7c5a14d663ba
Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
612 |
|
752 | 613 |
JavaNativeMethod initialize! |