JavaNativeMethod.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 05 Jan 2015 17:10:02 +0100
changeset 3324 a58245c0e83a
parent 3213 d3094b384e55
child 3325 d9297d724fa0
permissions -rw-r--r--
Updated copyright notices.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
     1
"
3324
a58245c0e83a Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3213
diff changeset
     2
 COPYRIGHT (c) 1996-2015 by Claus Gittinger
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
     3
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
     5
3324
a58245c0e83a Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3213
diff changeset
     6
 COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
     8
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
     9
 This software is furnished under a license and may be used
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    10
 only in accordance with the terms of that license and with the
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    12
 be provided or otherwise made available to, or used by, any
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    13
 other person.  No title to or ownership of the software is
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    14
 hereby transferred.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    15
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    18
     see the differences between this version and version stx:libjava
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    19
     as of 1.9.2010
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    20
"
703
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
    21
"{ Package: 'stx:libjava' }"
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
    22
2426
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    23
JavaMethodWithHandler variableSubclass:#JavaNativeMethod
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    24
	instanceVariableNames:'nativeImplementation nCalls'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    25
	classVariableNames:'CacheNativeImplementation Verbose TrampolineSelectors'
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    26
	poolDictionaries:''
2107
f4509f6767fa category change
Claus Gittinger <cg@exept.de>
parents: 2097
diff changeset
    27
	category:'Languages-Java-Classes'
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    28
!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    29
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    30
!JavaNativeMethod class methodsFor:'documentation'!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    31
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    32
copyright
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    33
"
3324
a58245c0e83a Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3213
diff changeset
    34
 COPYRIGHT (c) 1996-2015 by Claus Gittinger
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    35
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    37
3324
a58245c0e83a Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3213
diff changeset
    38
 COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    40
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    41
 This software is furnished under a license and may be used
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    42
 only in accordance with the terms of that license and with the
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    44
 be provided or otherwise made available to, or used by, any
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    45
 other person.  No title to or ownership of the software is
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    46
 hereby transferred.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    47
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    50
     see the differences between this version and version stx:libjava
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    51
     as of 1.9.2010
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    52
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    53
"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    54
! !
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    55
616
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    56
!JavaNativeMethod class methodsFor:'initialization'!
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    57
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    58
cacheNativeImplementation
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    59
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    60
    "For details, see #cacheNativeImplementation:"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    61
    
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    62
    ^CacheNativeImplementation
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    63
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    64
    "Created: / 30-04-2011 / 23:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    65
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    66
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    67
cacheNativeImplementation: aBoolean
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    68
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    69
    "If set, native implementations are cached, resulting
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    70
     in better performance when calling native methods.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    71
     Hower, no change in native method implemenetaion will
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    72
     not be visible then, unless #flushAllCachedNativeMethods
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    73
     is explictely called"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    74
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    75
    CacheNativeImplementation := aBoolean
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    76
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    77
    "Created: / 30-04-2011 / 23:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    78
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    79
616
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    80
initialize
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    81
    "/self flags: ((self flags bitClear: Behavior flagMethod) bitOr: Behavior flagJavaMethod).
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    82
    self flags: ((self flags bitClear: Behavior flagJavaMethod) bitOr: Behavior flagMethod).
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    83
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    84
    self flags bitAnd: Behavior flagJavaMethod
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    85
    self flags bitAnd: Behavior flagMethod
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    86
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    87
    "
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    88
    "By default, do not cache native impls while developing"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    89
    CacheNativeImplementation := Smalltalk isStandAloneApp.
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    90
    Verbose := false.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    91
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    92
    Verbose := true.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    93
    "
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    94
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    95
    TrampolineSelectors := #(
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    96
        "/0
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    97
        #trampoline:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    98
        #trampoline:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    99
        #trampoline:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   100
        #trampoline:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   101
        "/4
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   102
        #trampoline:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   103
        #trampoline:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   104
        #trampoline:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   105
        #trampoline:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   106
        "/8
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   107
        #trampoline:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   108
        #trampoline:_:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   109
        #trampoline:_:_:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   110
        #trampoline:_:_:_:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   111
        "/13    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   112
        #trampoline:_:_:_:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   113
        #trampoline:_:_:_:_:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   114
        #trampoline:_:_:_:_:_:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   115
        #trampoline:_:_:_:_:_:_:_:_:_:_:_:_:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   116
    ).
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   117
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   118
    "Modified (comment): / 03-11-2011 / 10:48:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   119
    "Modified: / 31-01-2013 / 14:40:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   120
! !
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   121
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   122
!JavaNativeMethod class methodsFor:'instance creation'!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   123
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   124
new
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   125
    "Redefined again, since since trampoline methods need
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   126
     literals"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   127
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   128
    ^ self basicNew:1.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   129
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   130
    "Created: / 31-01-2013 / 13:26:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
616
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
   131
! !
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
   132
654
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   133
!JavaNativeMethod class methodsFor:'cleanup'!
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   134
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   135
flushAllCachedNativeMethods
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   136
    self allInstancesDo:[:aNativeMethod |
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   137
        aNativeMethod nativeImplementation:nil
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   138
    ].
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   139
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   140
    "
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   141
     self flushAllCachedNativeMethods
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   142
    "
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   143
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   144
    "Created: / 24.12.1999 / 03:10:38 / cg"
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   145
    "Modified: / 24.12.1999 / 03:10:51 / cg"
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   146
! !
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   147
2435
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   148
!JavaNativeMethod class methodsFor:'others'!
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   149
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   150
version_HG
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   151
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   152
    ^ '$Changeset: <not expanded> $'
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   153
! !
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   154
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   155
!JavaNativeMethod methodsFor:'* As yet uncategorized *'!
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   156
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   157
messagesSentToSuper
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   158
    ^#()
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   159
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   160
    "Created: / 30-03-2013 / 09:58:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2435
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   161
! !
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   162
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   163
!JavaNativeMethod methodsFor:'accessing'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   164
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   165
nCalls
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   166
    ^ nCalls ? 0
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   167
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   168
    "Modified: / 27-10-2012 / 18:05:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   169
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   170
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   171
nCallsReset
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   172
    nCalls := 0
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   173
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   174
    "Modified: / 27-10-2012 / 18:05:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   175
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   176
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   177
nativeImplementation
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   178
    "return the value of the instance variable 'nativeImplementation' (automatically generated)"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   179
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   180
    ^ nativeImplementation
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   181
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   182
    "Created: / 25.9.1999 / 23:08:00 / cg"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   183
!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   184
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   185
nativeImplementation:something
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   186
    "set the value of the instance variable 'nativeImplementation' (automatically generated)"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   187
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   188
    nativeImplementation := something.
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   189
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   190
    "Created: / 25.9.1999 / 23:08:00 / cg"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   191
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   192
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   193
sourceLineNumber
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   194
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   195
    ^super sourceLineNumber
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   196
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   197
"/    ForceByteCodeDisplay == true ifTrue:[ ^ 1].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   198
"/    lineNumberTable notNil ifTrue:[ ^ lineNumberTable at:2].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   199
"/    ^1
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   200
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   201
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   202
    "
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   203
    ^ (JavaSourceCodeCache new) 
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   204
        findLineForMethod:(self selector)
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   205
        inClass:javaClass.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   206
    "
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   207
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   208
    "Modified: / 13-12-2010 / 13:55:55 / Jan Kurs <kurs.jan@post.cz>"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   209
    "Modified: / 13-12-2010 / 23:46:30 / Marcel Hlopko <hlopik@gmail.com>"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   210
    "Created: / 17-12-2010 / 10:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   211
! !
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   212
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   213
!JavaNativeMethod methodsFor:'private'!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   214
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   215
compileNativeImplementation:sel dispatchingTo:oldSel 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   216
    | src  arg  converted  header |
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   217
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   218
    src := (JavaVM class compiledMethodAt:oldSel) source.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   219
    src := src asStringCollection.
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   220
    (src first includesString:'aJavaContext') ifTrue:[
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   221
        arg := 'aJavaContext'
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   222
    ] ifFalse:[
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   223
        (src first includesString:'nativeContext') ifTrue:[
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   224
            arg := 'nativeContext'
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   225
        ]
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   226
    ].
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   227
    arg isNil ifTrue:[
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   228
        arg := 'nativeContext'.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   229
        src := '    self breakPoint: #jv info: ''Convert it to new-style natives''.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   230
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   231
                ^ self ' 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   232
                , oldSel , ' nativeContext'.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   233
        converted := false.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   234
    ] ifFalse:[
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   235
        src removeFirst asString.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   236
        converted := true.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   237
    ].
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   238
    header := String 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   239
            streamContents:[:s | 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   240
                sel numArgs == 2 ifTrue:[
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   241
                    s
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   242
                        nextPutAll:sel;
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   243
                        space;
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   244
                        nextPutAll:'this  '.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   245
                ] ifFalse:[
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   246
                    | kw |
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   247
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   248
                    kw := sel keywords.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   249
                    s nextPutAll:kw first.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   250
                    s nextPutAll:' this '.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   251
                    2 to:kw size - 1 do:[:i | 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   252
                        sel
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   253
                            nextPutAll:(kw at:i);
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   254
                            space;
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   255
                            nextPut:$a;
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   256
                            nextPutAll:i printString;
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   257
                            space.
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   258
                    ].
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   259
                ]
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   260
            ].
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   261
    (JavaVM class compile:(self nativeMethodTemplate 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   262
                bindWith:header
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   263
                with:arg
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   264
                with:src asString)
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   265
        classified:'native - ' 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   266
                , ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$.)) 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   267
            package:JavaVM package.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   268
    converted ifTrue:[
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   269
        (JavaVM class compiledMethodAt:oldSel) 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   270
            category:'native - old-style (converted)'
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   271
    ] ifFalse:[
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   272
        (JavaVM class compiledMethodAt:oldSel) 
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   273
            category:'native - old-style (FAILED to convert)'
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   274
    ]
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   275
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   276
    "Created: / 01-05-2011 / 00:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3196
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   277
    "Modified: / 04-08-2014 / 15:51:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   278
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   279
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   280
compileNativeImplementationStub: sel
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   281
    | header |
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   282
2435
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   283
    "/No natives, no fun...
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   284
    JavaVM natives isNil ifTrue:[ ^ self ].
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   285
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   286
    header := String streamContents:[:s|
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   287
            | kw |
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   288
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   289
            kw := sel keywords.            
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   290
            s nextPutAll: kw first.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   291
            s nextPutAll: ' this '.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   292
            2 to: kw size  do:[:i|
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   293
                s nextPutAll: (kw at: i); space; nextPut:$a; nextPutAll: (i - 1) printString; space.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   294
            ].            
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   295
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   296
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   297
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   298
    (JavaVM natives class 
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   299
        compile:
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   300
            (self nativeMethodTemplate bindWith:header with: 'nativeContext' with:('^ JavaVM unimplementedNativeMethodSignal raise'))
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   301
        classified:         
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   302
            'native - ', ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$.))
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   303
        package: JavaVM package.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   304
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   305
    self assert: (JavaVM natives respondsTo: sel).
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   306
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   307
    "Created: / 01-05-2011 / 00:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2435
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   308
    "Modified: / 04-03-2013 / 17:31:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   309
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   310
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   311
nativeMethodTemplate
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   312
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   313
    ^'%1
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   314
2556
31d0c6fa875f Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 2435
diff changeset
   315
    <javanative: ''', javaClass name , ''' name: ''', (selector copyButLast:signature size), '''>
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   316
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   317
    %3'
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   318
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   319
    "Created: / 01-05-2011 / 00:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   320
    "Modified: / 31-01-2013 / 15:07:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   321
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   322
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   323
searchNativeImplementation
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   324
    <resource: #obsolete>
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   325
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   326
    "Returns a SELECTOR of native method implementation.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   327
    For now, two naming schemes are used. The onld one uses
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   328
    just a class name and selector as a name for native method impl.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   329
    The new one uses fully qualified class name.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   330
    "
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   331
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   332
    | nm newStyleSel oldStyleSel |
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   333
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   334
    self error: 'Should no longer be called!!'.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   335
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   336
    nm := selector upTo: $(.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   337
    newStyleSel := ('_' , ((javaClass name copyReplaceAll:$/ with:$_) replaceAll:$$ with:$_), '_' , nm , ':') asSymbol.    
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   338
    (JavaVM natives class canUnderstand: newStyleSel) ifTrue:[
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   339
        "Good, a JavaVM understands new style native selectors"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   340
        ^newStyleSel
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   341
    ].
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   342
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   343
    oldStyleSel := ('_' , (javaClass lastName copyReplaceAll:$$ with:$_) , '_' , nm , ':') asSymbol.
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   344
    (JavaVM natives canUnderstand: oldStyleSel) ifTrue:[
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   345
        "Convert method on the fly only if Im Jan Vrany
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   346
         (to avoid confusion of other developers :-)"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   347
        OperatingSystem getLoginName = 'jv' ifTrue:[
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   348
            "OK, old style method has not yet been converted to a newstyle one.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   349
            Converts old-style method to a new-style one"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   350
            self compileNativeImplementation: newStyleSel dispatchingTo: oldStyleSel.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   351
            ^newStyleSel
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   352
        ] ifFalse:[
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   353
            ^oldStyleSel
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   354
        ]
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   355
    ].
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   356
    self compileNativeImplementationStub: newStyleSel.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   357
    ^newStyleSel
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   358
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   359
    "Created: / 30-04-2011 / 23:50:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   360
    "Modified: / 19-01-2013 / 23:31:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   361
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   362
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   363
searchNativeImplementation: numArgs
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   364
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   365
    "Returns a SELECTOR of native method implementation."
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   366
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   367
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   368
    | nm newStyleSel args |
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   369
    nm := selector upTo: $(.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   370
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   371
    numArgs > 14 ifTrue:[ ^ nil ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   372
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   373
    args := #(
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   374
        "0"  ''
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   375
        "1"  '_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   376
        "2"  '_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   377
        "3"  '_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   378
        "4"  '_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   379
        "5"  '_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   380
        "6"  '_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   381
        "7"  '_:_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   382
        "8"  '_:_:_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   383
        "9"  '_:_:_:_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   384
        "10" '_:_:_:_:_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   385
        "11" '_:_:_:_:_:_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   386
        "12" '_:_:_:_:_:_:_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   387
        "13" '_:_:_:_:_:_:_:_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   388
        "14" '_:_:_:_:_:_:_:_:_:_:_:_:_:_:'
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   389
    ) at: numArgs + 1.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   390
2841
6fa1bcf9c997 JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2731
diff changeset
   391
    newStyleSel := ('_' , ((javaClass binaryName copyReplaceAll:$/ with:$_) replaceAll:$$ with:$_), '_' , nm , ':' , args) asSymbol.    
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   392
    (JavaVM natives class canUnderstand: newStyleSel) ifTrue:[
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   393
        "Good, a JavaVM understands new style native selectors"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   394
        "No checke whether the descriptor is the same."
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   395
        | m a |
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   396
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   397
        m := JavaVM natives class lookupMethodFor: newStyleSel.
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   398
        m isWrapped ifTrue:[ m := m originalMethod ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   399
        a := m annotationsAt: #javanative:name:.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   400
        a do:[:each|
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   401
            each arguments second = selector ifTrue:[
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   402
                ^newStyleSel
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   403
            ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   404
        ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   405
        m mclass == JavaVM natives class ifTrue:[
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   406
            self breakPoint: #jv. "/no descriptor annotation!!!!!!"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   407
            ^newStyleSel.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   408
        ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   409
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   410
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   411
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   412
    self compileNativeImplementationStub: newStyleSel.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   413
    ^newStyleSel
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   414
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   415
    "Created: / 19-01-2013 / 22:11:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2841
6fa1bcf9c997 JavaClass>>#name vs. #binaryName refactoring
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2731
diff changeset
   416
    "Modified: / 09-10-2013 / 01:43:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   417
! !
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   418
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   419
!JavaNativeMethod methodsFor:'private-compiler interface'!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   420
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   421
numberOfArgs:aNumber
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   422
    | args sendTree trampolineTree compiler trampoline |
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   423
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   424
    super numberOfArgs:aNumber.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   425
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   426
    aNumber > 14 ifTrue:[
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   427
        ^self.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   428
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   429
    (self class flags bitAnd:Behavior flagJavaMethod) ~~ 0 ifTrue:[ ^ self ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   430
    javaClass isNil ifTrue:[ 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   431
        self error: 'Cannot install trampoline - no Java class yet'.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   432
        ^self.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   433
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   434
    selector isNil ifTrue:[ 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   435
        self error: 'Cannot install trampoline - no selector yet'.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   436
        ^self.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   437
    ].
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   438
2426
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   439
    MethodNode isNil ifTrue:[
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   440
        self error: 'Cannot install trampoline - no MethodNode class'.
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   441
        ^self.
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   442
    ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   443
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   444
    "Create the trampoline"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   445
    args := (1 to: aNumber) collect:[:i|(VariableNode methodArgumentNamed: ('arg_' , i printString)) index: i].
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   446
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   447
    sendTree := MessageNode 
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   448
                    receiver: (VariableNode globalNamed:#'JavaVM:NativeMethodsImplementation')
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   449
                    selector: (self searchNativeImplementation: aNumber)
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   450
                    args: (Array with: (SelfNode value: #self)) , args.
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   451
    self isSynchronized ifTrue:[
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   452
        sendTree :=
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   453
            MessageNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   454
                receiver: ((BlockNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   455
                            arguments: #()
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   456
                            home: nil
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   457
                            variables: #())
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   458
                            statements: (
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   459
                                (StatementNode expression:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   460
                                    (MessageNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   461
                                        receiver: (VariableNode globalNamed:#'JavaVM')
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   462
                                        selector: #monitorEnter:in:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   463
                                          args: (Array with: (SelfNode value: #self) with: (VariableNode type: #ThisContext  name: #thisContext)  )))
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   464
                                nextStatement: (StatementNode expression:sendTree)
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   465
                                )
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   466
                        )
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   467
                                
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   468
                selector: #ensure:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   469
                args: {
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   470
                        (BlockNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   471
                            arguments: #()
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   472
                            home: nil
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   473
                            variables: #())
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   474
                            statements:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   475
                                (StatementNode expression:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   476
                                    (MessageNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   477
                                        receiver: (VariableNode globalNamed:#'JavaVM')
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   478
                                        selector: #monitorExit:in:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   479
                                        args: (Array with: (SelfNode value: #self) with: (VariableNode type: #ThisContext  name: #thisContext))
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   480
                                    )
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   481
                                )
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   482
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   483
                }
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   484
    ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   485
    trampolineTree := MethodNode new
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   486
        arguments: args;
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   487
        selector: (TrampolineSelectors at: aNumber + 1);
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   488
        statements:
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   489
            { (ReturnNode expression: sendTree) };
2435
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   490
        yourself.
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   491
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   492
    compiler := ByteCodeCompiler new.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   493
    compiler methodClass: Method.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   494
    trampoline := compiler 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   495
                    compileTree: trampolineTree 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   496
                    forClass: javaClass
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   497
                    ifFail:[self error: 'Failed to compile tampoline'].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   498
    "Install the trampoline"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   499
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   500
    self byteCode: trampoline byteCode.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   501
    self literals: trampoline literals.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   502
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   503
%{
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   504
    /* Now, try to bind to C-optimized native method */
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   505
    __jbindnative(self);
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   506
%}.
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   507
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   508
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   509
    "Created: / 31-01-2013 / 12:44:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   510
    "Modified: / 10-03-2013 / 01:39:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   511
! !
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   512
3213
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   513
!JavaNativeMethod methodsFor:'queries'!
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   514
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   515
lineNumberForPC0: pc
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   516
    | src name lineNumber |
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   517
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   518
    src := javaClass source.
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   519
    src notNil ifTrue:[    
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   520
        name := self name.
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   521
        src asStringCollection withIndexDo:[:l :lno|
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   522
            ((l includesString: 'native') and:[l includesString: name]) ifTrue:[
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   523
                lineNumber := lno.
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   524
                ^ lineNumber
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   525
            ].
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   526
        ]. 
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   527
    ].
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   528
    lineNumber := 1.
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   529
    ^ lineNumber
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   530
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   531
    "Created: / 08-08-2014 / 07:30:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   532
! !
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   533
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   534
!JavaNativeMethod methodsFor:'vm support'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   535
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   536
nativeMethodInvokation
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   537
    "Called by the VM when a native method is
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   538
     to be executed - old (slow) implementation"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   539
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   540
    ^self nativeMethodInvokation: thisContext sender.    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   541
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   542
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   543
     JavaNativeMethod flushAllCachedNativeMethods"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   544
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   545
    "Modified: / 27-01-2000 / 13:34:53 / cg"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   546
    "Modified: / 03-11-2011 / 10:47:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   547
    "Modified: / 27-10-2012 / 15:15:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   548
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   549
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   550
nativeMethodInvokation: context
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   551
    "Called by the VM when a native method is
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   552
     to be executed. 
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   553
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   554
     'context' is the context of being-invoked native method"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   555
    
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   556
    | sel  mthd  sender nArgs receiverAndArgsAndContext |
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   557
    nCalls := (nCalls ? 0) + 1.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   558
    receiverAndArgsAndContext := Array new: (nArgs := context numArgs) + 1"receiver".
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   559
    receiverAndArgsAndContext replaceFrom:2 to:1 + nArgs with: context startingAt: context arg1Index.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   560
    receiverAndArgsAndContext at: 1 put: context receiver.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   561
    
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   562
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   563
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   564
    (mthd := nativeImplementation) isNil ifTrue: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   565
        sel := self searchNativeImplementation: nArgs.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   566
        mthd := (JavaVM natives class compiledMethodAt: sel).
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   567
        (mthd isNil or: [ mthd isLazyMethod ]) ifTrue: [
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   568
            sender := context.
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   569
            sender sender selector == #noByteCode ifTrue: [
660
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
   570
                sender := sender sender.
663
c346b0d28deb checkin from browser
cg
parents: 660
diff changeset
   571
                sender := sender sender.
c346b0d28deb checkin from browser
cg
parents: 660
diff changeset
   572
                sender := sender sender.
660
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
   573
            ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   574
            ^ JavaVM natives perform: sel withArguments: receiverAndArgsAndContext 
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
   575
        ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   576
        CacheNativeImplementation ifTrue: [ nativeImplementation := mthd. ]
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   577
    ].
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   578
    Verbose ifTrue: [Logger log: 'Native method invokation: ' , sel severity: #debug facility: #JVM].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   579
    ^ mthd 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   580
        valueWithReceiver: JavaVM natives
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   581
        arguments: receiverAndArgsAndContext 
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   582
        selector: selector
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   583
        search: JavaVM natives class
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   584
        sender: nil
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   585
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   586
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   587
     JavaNativeMethod flushAllCachedNativeMethods"
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   588
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   589
    "Created: / 27-10-2012 / 15:13:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   590
    "Modified: / 21-01-2013 / 17:35:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   591
! !
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   592
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   593
!JavaNativeMethod class methodsFor:'documentation'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   594
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   595
version
2556
31d0c6fa875f Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 2435
diff changeset
   596
    ^ '$Header: /cvs/stx/stx/libjava/JavaNativeMethod.st,v 1.16 2013-04-25 13:11:51 stefan Exp $'
2198
3802e8e6f8d4 initial checkin
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   597
!
3802e8e6f8d4 initial checkin
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   598
3802e8e6f8d4 initial checkin
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   599
version_CVS
2711
a00302fe5083 Added version_CVS to all classes and build files regenerated & cleaned.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2591
diff changeset
   600
    ^ '$Header$'
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   601
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   602
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   603
version_SVN
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   604
    ^ 'Id'
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   605
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   606
! !
2107
f4509f6767fa category change
Claus Gittinger <cg@exept.de>
parents: 2097
diff changeset
   607
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   608
2097
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   609
JavaNativeMethod initialize!