JavaNativeMethod.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 31 Jan 2013 15:18:11 +0000
branchrefactoring-vmdata
changeset 2020 985ca70cdcad
parent 2019 e1291a81f215
child 2029 cdc3a79c8a58
permissions -rw-r--r--
Trampoline code finished. Fast trampoline is generated when the method is read from .class file. As a sideeffect, native stubs re generated when the native method is loaded. not when executed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
     1
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1075
diff changeset
     3
1155
vranyj1
parents: 1152
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1075
diff changeset
     5
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
     8
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
     9
 This software is furnished under a license and may be used
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    10
 only in accordance with the terms of that license and with the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    12
 be provided or otherwise made available to, or used by, any
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    13
 other person.  No title to or ownership of the software is
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    14
 hereby transferred.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    15
1155
vranyj1
parents: 1152
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    18
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1075
diff changeset
    19
     as of 1.9.2010
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    20
"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    22
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    23
JavaMethodWithHandler variableSubclass:#JavaNativeMethod
1749
2a942f354a94 - JavaNativeMethod
vranyj1
parents: 1748
diff changeset
    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
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Classes'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    28
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    29
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    30
!JavaNativeMethod class methodsFor:'documentation'!
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    31
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    32
copyright
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    33
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1075
diff changeset
    35
1155
vranyj1
parents: 1152
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1075
diff changeset
    37
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    40
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    41
 This software is furnished under a license and may be used
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    42
 only in accordance with the terms of that license and with the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    44
 be provided or otherwise made available to, or used by, any
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    45
 other person.  No title to or ownership of the software is
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    46
 hereby transferred.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    47
1155
vranyj1
parents: 1152
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    50
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1075
diff changeset
    51
     as of 1.9.2010
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    52
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    53
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 772
diff changeset
    54
! !
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    55
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    56
!JavaNativeMethod class methodsFor:'initialization'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    57
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    58
cacheNativeImplementation
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    59
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    60
    "For details, see #cacheNativeImplementation:"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    61
    
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    62
    ^CacheNativeImplementation
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    63
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    64
    "Created: / 30-04-2011 / 23:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    65
!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    66
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    67
cacheNativeImplementation: aBoolean
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    68
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    69
    "If set, native implementations are cached, resulting
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    70
     in better performance when calling native methods.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    71
     Hower, no change in native method implemenetaion will
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    72
     not be visible then, unless #flushAllCachedNativeMethods
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    73
     is explictely called"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    74
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    75
    CacheNativeImplementation := aBoolean
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    76
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    77
    "Created: / 30-04-2011 / 23:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    78
!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    79
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
    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
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   131
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   132
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   133
!JavaNativeMethod class methodsFor:'cleanup'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   134
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   135
flushAllCachedNativeMethods
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   136
    self allInstancesDo:[:aNativeMethod |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   137
        aNativeMethod nativeImplementation:nil
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   138
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   139
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   140
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   141
     self flushAllCachedNativeMethods
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   142
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   143
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   144
    "Created: / 24.12.1999 / 03:10:38 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   145
    "Modified: / 24.12.1999 / 03:10:51 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   146
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   147
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   148
!JavaNativeMethod methodsFor:'accessing'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   149
1749
2a942f354a94 - JavaNativeMethod
vranyj1
parents: 1748
diff changeset
   150
nCalls
2a942f354a94 - JavaNativeMethod
vranyj1
parents: 1748
diff changeset
   151
    ^ nCalls ? 0
2a942f354a94 - JavaNativeMethod
vranyj1
parents: 1748
diff changeset
   152
2a942f354a94 - JavaNativeMethod
vranyj1
parents: 1748
diff changeset
   153
    "Modified: / 27-10-2012 / 18:05:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2a942f354a94 - JavaNativeMethod
vranyj1
parents: 1748
diff changeset
   154
!
2a942f354a94 - JavaNativeMethod
vranyj1
parents: 1748
diff changeset
   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
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   162
nativeImplementation
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   163
    "return the value of the instance variable 'nativeImplementation' (automatically generated)"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   164
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   165
    ^ nativeImplementation
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   166
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   167
    "Created: / 25.9.1999 / 23:08:00 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   168
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   169
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   170
nativeImplementation:something
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   171
    "set the value of the instance variable 'nativeImplementation' (automatically generated)"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   172
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   173
    nativeImplementation := something.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   174
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   175
    "Created: / 25.9.1999 / 23:08:00 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   176
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   177
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   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
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   185
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   186
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   187
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   188
    ^ (JavaSourceCodeCache new) 
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   189
        findLineForMethod:(self selector)
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   190
        inClass:javaClass.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   191
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   192
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   193
    "Modified: / 13-12-2010 / 13:55:55 / Jan Kurs <kurs.jan@post.cz>"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   194
    "Modified: / 13-12-2010 / 23:46:30 / Marcel Hlopko <hlopik@gmail.com>"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   195
    "Created: / 17-12-2010 / 10:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   196
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   197
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   198
!JavaNativeMethod methodsFor:'private'!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   199
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   200
compileNativeImplementation: sel dispatchingTo: oldSel
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   203
    src := (JavaVM class compiledMethodAt: oldSel) source.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   204
    src := src asStringCollection.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   205
    (src first includesString: 'aJavaContext') ifTrue:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   206
        arg := 'aJavaContext'
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   207
    ] ifFalse:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   208
        (src first includesString: 'nativeContext') ifTrue:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   209
            arg := 'nativeContext'
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   210
        ]
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   211
    ].
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   212
    arg ifNotNil:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   213
        src removeFirst asString.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   214
        converted := true.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   215
    ] ifNil:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   216
        arg := 'nativeContext'.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   217
        src := '    self breakPoint: #jv info: ''Convert it to new-style natives''.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   218
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   219
                ^ self ', oldSel, ' nativeContext'.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   236
    ].
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   237
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   238
    (JavaVM class 
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   241
        classified:         
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   242
            'native - ', ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$. ))
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   243
        package: JavaVM package.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   244
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   245
    converted ifTrue:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   246
        (JavaVM class compiledMethodAt: oldSel) category: 'native - old-style (converted)'
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   247
    ] ifFalse:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   248
       (JavaVM class compiledMethodAt: oldSel) category:  'native - old-style (FAILED to convert)'
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   249
    ]
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   250
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   253
!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   254
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   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 '.
9e63ab553922 JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1985
diff changeset
   264
            2 to: kw size - 1 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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   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
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   273
        classified:         
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   274
            'native - ', ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$.))
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   275
        package: JavaVM package
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   276
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   277
    "Created: / 01-05-2011 / 00:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2020
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   278
    "Modified: / 31-01-2013 / 15:09:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   279
!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   280
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   281
installTrampoline: trampoline
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   282
    | l m |
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   283
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   284
    m := trampoline asByteCodeMethod.
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   285
    m ~~ trampoline ifTrue:[
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   286
        "Cache it"
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   287
        self class methodDictionary at: trampoline selector put: m.
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   288
    ].
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   289
    l := m literals.
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   290
    1 to: l size do:[:i|
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   291
        (l at: i) == #__placeholder__ ifTrue:[
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   292
            l at: i put: self.
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   293
        ].
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   294
    ].
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   295
    m isNil ifTrue:[
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   296
        self error: 'Cannot find trampoline method'.
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   297
    ].
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   298
    self byteCode: m byteCode.
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   299
    self literals: l.
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   300
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   301
    "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
   302
!
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   303
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   304
nativeMethodTemplate
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   305
2020
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   306
    ^'%1
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   307
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   308
    <javanative: ''', javaClass name , ''' name: ''', (selector copyWithoutLast:signature size), '''>
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   309
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   310
    %3'
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   311
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   312
    "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
   313
    "Modified: / 31-01-2013 / 15:07:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   314
!
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   315
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   316
searchNativeImplementation
1986
9e63ab553922 JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1985
diff changeset
   317
    <resource: #obsolete>
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   318
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   319
    "Returns a SELECTOR of native method implementation.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   320
    For now, two naming schemes are used. The onld one uses
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   321
    just a class name and selector as a name for native method impl.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   322
    The new one uses fully qualified class name.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   323
    "
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   324
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   325
    | nm newStyleSel oldStyleSel |
1986
9e63ab553922 JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1985
diff changeset
   326
9e63ab553922 JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1985
diff changeset
   327
    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
   328
912
e651488f5741 Many fixes in reflection, expecially for generic types support
vranyj1
parents: 877
diff changeset
   329
    nm := selector upTo: $(.
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   330
    newStyleSel := ('_' , ((javaClass name copyReplaceAll:$/ with:$_) replaceAll:$$ with:$_), '_' , nm , ':') asSymbol.    
1974
9dc799a359ac - JavaTestsLoader
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1971
diff changeset
   331
    (JavaVM natives class canUnderstand: newStyleSel) ifTrue:[
9dc799a359ac - JavaTestsLoader
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1971
diff changeset
   332
        "Good, a JavaVM understands new style native selectors"
9dc799a359ac - JavaTestsLoader
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1971
diff changeset
   333
        ^newStyleSel
9dc799a359ac - JavaTestsLoader
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1971
diff changeset
   334
    ].
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   335
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   336
    oldStyleSel := ('_' , (javaClass lastName copyReplaceAll:$$ with:$_) , '_' , nm , ':') asSymbol.
1974
9dc799a359ac - JavaTestsLoader
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1971
diff changeset
   337
    (JavaVM natives canUnderstand: oldStyleSel) ifTrue:[
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   338
        "Convert method on the fly only if Im Jan Vrany
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   339
         (to avoid confusion of other developers :-)"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   340
        OperatingSystem getLoginName = 'jv' ifTrue:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   341
            "OK, old style method has not yet been converted to a newstyle one.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   342
            Converts old-style method to a new-style one"
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   343
            self compileNativeImplementation: newStyleSel dispatchingTo: oldStyleSel.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   344
            ^newStyleSel
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   345
        ] ifFalse:[
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   346
            ^oldStyleSel
1974
9dc799a359ac - JavaTestsLoader
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1971
diff changeset
   347
        ]
9dc799a359ac - JavaTestsLoader
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1971
diff changeset
   348
    ].
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   349
    self compileNativeImplementationStub: newStyleSel.
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   350
    ^newStyleSel
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   351
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   352
    "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
   353
    "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
   354
!
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   355
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   356
searchNativeImplementation: numArgs
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
    "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
   359
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   360
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   361
    | 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
   362
    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
   363
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   364
    args := #(
2010
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   365
        "0"  ''
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   366
        "1"  '_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   367
        "2"  '_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   368
        "3"  '_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   369
        "4"  '_:_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   370
        "5"  '_:_:_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   371
        "6"  '_:_:_:_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   372
        "7"  '_:_:_:_:_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   373
        "8"  '_:_:_:_:_:_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   374
        "9"  '_:_:_:_:_:_:_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   375
        "10" '_:_:_:_:_:_:_:_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   376
        "11" '_:_:_:_:_:_:_:_:_:_:_:'
9bacff8c53de The 'nativeContext' argument removed from all native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1993
diff changeset
   377
        "12" '_:_:_:_:_:_:_:_:_:_:_:_:'
1985
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   378
    ) 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
   379
1986
9e63ab553922 JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1985
diff changeset
   380
    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
   381
    (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
   382
        "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
   383
        ^newStyleSel
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   384
    ].
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   385
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   386
    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
   387
    ^newStyleSel
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   388
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   389
    "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
   390
    "Modified: / 19-01-2013 / 23:39:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   391
! !
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   392
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   393
!JavaNativeMethod methodsFor:'private-compiler interface'!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   394
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   395
numberOfArgs:aNumber
2020
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   396
    | args trampolineTree compiler trampoline |
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   397
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   398
    super numberOfArgs:aNumber.
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   399
    (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
   400
    javaClass isNil ifTrue:[ 
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   401
        self error: 'Cannot install trampoline - no Java class yet'.
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   402
        ^self.
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   403
    ].
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   404
    selector isNil ifTrue:[ 
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   405
        self error: 'Cannot install trampoline - no selector yet'.
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   406
        ^self.
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   407
    ].
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   408
2020
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   409
    "Create the trampoline"
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   410
    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
   411
    trampolineTree := MethodNode new
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   412
        arguments: args;
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   413
        selector: (TrampolineSelectors at: aNumber + 1);
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   414
        statements:
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   415
            { (ReturnNode expression:
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   416
                (MessageNode 
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   417
                    receiver: (VariableNode globalNamed:#'JavaVM:NativeMethodsImplementation')
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   418
                    selector: (self searchNativeImplementation: aNumber)
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   419
                    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
   420
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   421
2020
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   422
    compiler := ByteCodeCompiler new.
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   423
    compiler methodClass: Method.
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   424
    trampoline := compiler 
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   425
                    compileTree: trampolineTree 
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   426
                    forClass: javaClass
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   427
                    ifFail:[self error: 'Failed to compile tampoline'].
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   428
    "Install the trampoline"
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   429
2020
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   430
    self byteCode: trampoline byteCode.
985ca70cdcad Trampoline code finished.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2019
diff changeset
   431
    self literals: trampoline literals.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   432
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   433
    "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
   434
    "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
   435
! !
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   436
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   437
!JavaNativeMethod methodsFor:'private-trampolines'!
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
trampolineUncached
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   440
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   441
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   442
    "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
   443
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   444
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   445
trampolineUncached: a1
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   446
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   447
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   448
    "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
   449
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   450
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   451
trampolineUncached: a1 _: a2
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   452
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   453
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   454
    "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
   455
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   456
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   457
trampolineUncached: a1 _: a2 _: a3
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   458
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   459
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   460
    "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
   461
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   462
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   463
trampolineUncached: a1 _: a2 _: a3 _: a4
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   464
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   465
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   466
    "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
   467
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   468
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   469
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   470
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   471
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   472
    "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
   473
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   474
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   475
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   476
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   477
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   478
    "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
   479
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   480
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   481
trampolineUncached: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7
2019
e1291a81f215 Finished uncached trampoline.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2016
diff changeset
   482
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   483
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   484
    "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
   485
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   486
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   487
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
   488
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   489
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   490
    "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
   491
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   492
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   493
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
   494
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   495
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   496
    "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
   497
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   498
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   499
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
   500
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   501
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   502
    "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
   503
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   504
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   505
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
   506
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   507
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   508
    "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
   509
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   510
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   511
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
   512
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   513
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   514
    "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
   515
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   516
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   517
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
   518
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   519
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   520
    "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
   521
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   522
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   523
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
   524
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   525
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   526
    "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
   527
!
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   528
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   529
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
   530
    ^#__placeholder__ nativeMethodInvokation: thisContext.
2016
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   531
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   532
    "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
   533
! !
6afb298c7403 Added simple trampoline methods to JavaNativeMethod.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2010
diff changeset
   534
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   535
!JavaNativeMethod methodsFor:'vm support'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   536
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   537
nativeMethodInvokation
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 752
diff changeset
   538
    "Called by the VM when a native method is
1748
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   539
     to be executed - old (slow) implementation"
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   540
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   541
    ^self nativeMethodInvokation: thisContext sender.    
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   542
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   543
    "
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   544
     JavaNativeMethod flushAllCachedNativeMethods"
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   545
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   546
    "Modified: / 27-01-2000 / 13:34:53 / cg"
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   547
    "Modified: / 03-11-2011 / 10:47:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   548
    "Modified: / 27-10-2012 / 15:15:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   549
!
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   550
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   551
nativeMethodInvokation: context
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   552
    "Called by the VM when a native method is
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   553
     to be executed. 
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   554
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   555
     '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
   556
    
1986
9e63ab553922 JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1985
diff changeset
   557
    | sel  mthd  sender nArgs receiverAndArgsAndContext |
1749
2a942f354a94 - JavaNativeMethod
vranyj1
parents: 1748
diff changeset
   558
    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
   559
    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
   560
    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
   561
    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
   562
    
1985
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   563
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   564
1073
e842ab17fe16 quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents: 1022
diff changeset
   565
    (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
   566
        sel := self searchNativeImplementation: nArgs.
1971
e75c1790521c Java native implementation refactoring (phase 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1864
diff changeset
   567
        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
   568
        (mthd isNil or: [ mthd isLazyMethod ]) ifTrue: [
1748
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   569
            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
   570
            sender sender selector == #noByteCode ifTrue: [
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   571
                sender := sender sender.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   572
                sender := sender sender.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   573
                sender := sender sender.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   574
            ].
1986
9e63ab553922 JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1985
diff changeset
   575
            ^ JavaVM natives perform: sel withArguments: receiverAndArgsAndContext 
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   576
        ].
1073
e842ab17fe16 quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents: 1022
diff changeset
   577
        CacheNativeImplementation ifTrue: [ nativeImplementation := mthd. ]
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   578
    ].
1075
927aeb3649fc Fix in native method imp -> class loading java tests all pass.. I'm getting drunk tonight :)
hlopkmar
parents: 1073
diff changeset
   579
    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
   580
    ^ mthd 
1971
e75c1790521c Java native implementation refactoring (phase 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1864
diff changeset
   581
        valueWithReceiver: JavaVM natives
1986
9e63ab553922 JavaNativeMethod & their implementation transformed to pass a reveiver.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1985
diff changeset
   582
        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
   583
        selector: selector
1971
e75c1790521c Java native implementation refactoring (phase 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1864
diff changeset
   584
        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
   585
        sender: nil
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   586
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
    "
e842ab17fe16 quite big class loaders rewrite.. javavm/groovy boots, almost all tests pass.. hope you will like it..
hlopkmar
parents: 1022
diff changeset
   588
     JavaNativeMethod flushAllCachedNativeMethods"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   589
1748
ff89096bf12f - JavaNativeMethod
vranyj1
parents: 1213
diff changeset
   590
    "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
   591
    "Modified: / 21-01-2013 / 17:35:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   592
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   593
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   594
!JavaNativeMethod class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   595
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   596
version
1864
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   597
    ^ '$Header$'
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   598
!
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   599
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   600
version_HG
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   601
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   602
    ^ '$Changeset: <not expanded> $'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   603
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   604
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   605
version_SVN
1864
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   606
    ^ '§Id§'
923
b922537eea2a Merged with CVS version
vranyj1
parents: 912
diff changeset
   607
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   608
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   609
1985
7c5a14d663ba Temporary commit. JavaNativeMethod refactored to use new-style native methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1974
diff changeset
   610
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   611
JavaNativeMethod initialize!