JavaNativeMethod.st
author Jan Vrany <jan.vrany@labware.com>
Tue, 10 Nov 2020 11:34:28 +0000
changeset 4005 8b5874d7cc58
parent 3860 e87f2f1439e9
permissions -rw-r--r--
Fix details stack trace printing for `JavaContext`s Java methods use Java's variable table to describe methods variables rather than St/X's own debug info. Therefore, `JavaContext >> #argAndVarNames` must be implemented differently. Another fix was needed for `JavaNativeMethod`. Java natives are ordinary smalltalk methods so their activations use (Smalltalk) `Context` and therefore for `Context >> argAndVarNames` to work one must implement `JavaNativeMethod >> dbgVariables`. This commit does all that.
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
4005
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
     3
 COPYRIGHT (c) 2020 LabWare
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
     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
     5
 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
     6
3324
a58245c0e83a Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3213
diff changeset
     7
 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
     8
                            SWING Research Group, Czech Technical University in Prague
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
     9
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    10
 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
    11
 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
    12
 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
    13
 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
    14
 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
    15
 hereby transferred.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    16
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
    17
 [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
    18
     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
    19
     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
    20
     as of 1.9.2010
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    21
"
703
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
    22
"{ Package: 'stx:libjava' }"
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
    23
3325
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
    24
"{ NameSpace: Smalltalk }"
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
    25
2426
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
    26
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
    27
	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
    28
	classVariableNames:'CacheNativeImplementation Verbose TrampolineSelectors'
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    29
	poolDictionaries:''
2107
f4509f6767fa category change
Claus Gittinger <cg@exept.de>
parents: 2097
diff changeset
    30
	category:'Languages-Java-Classes'
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    31
!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    32
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    33
!JavaNativeMethod class methodsFor:'documentation'!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    34
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    35
copyright
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    36
"
3324
a58245c0e83a Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3213
diff changeset
    37
 COPYRIGHT (c) 1996-2015 by Claus Gittinger
4005
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
    38
 COPYRIGHT (c) 2020 LabWare
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
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    40
 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
    41
3324
a58245c0e83a Updated copyright notices.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3213
diff changeset
    42
 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
    43
                            SWING Research Group, Czech Technical University in Prague
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    44
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    45
 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
    46
 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
    47
 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
    48
 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
    49
 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
    50
 hereby transferred.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    51
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
    52
 [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
    53
     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
    54
     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
    55
     as of 1.9.2010
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    56
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    57
"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    58
! !
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    59
616
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    60
!JavaNativeMethod class methodsFor:'initialization'!
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    61
2151
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
    "For details, see #cacheNativeImplementation:"
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
    65
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    66
    ^CacheNativeImplementation
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    67
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    68
    "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
    69
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    70
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    71
cacheNativeImplementation: aBoolean
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    72
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    73
    "If set, native implementations are cached, resulting
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    74
     in better performance when calling native methods.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    75
     Hower, no change in native method implemenetaion will
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    76
     not be visible then, unless #flushAllCachedNativeMethods
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    77
     is explictely called"
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
    CacheNativeImplementation := aBoolean
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    80
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    81
    "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
    82
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    83
616
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    84
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
    85
    "/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
    86
    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
    87
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
    88
    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
    89
    self flags bitAnd: Behavior flagMethod
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    90
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
    91
    "
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    92
    "By default, do not cache native impls while developing"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    93
    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
    94
    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
    95
    "
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
    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
    97
    "
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
    98
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
    99
    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
   100
        "/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
   101
        #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
   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
        "/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
   106
        #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
   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
        "/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
   111
        #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
   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:_:_:_:_:_:_:_:_:_:
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   115
        "/13
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
   116
        #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
   117
        #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
   118
        #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
   119
        #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
   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
    "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
   123
    "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
   124
! !
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
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
!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
   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
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
   129
    "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
   130
     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
   131
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   132
    ^ 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
   133
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   134
    "Created: / 31-01-2013 / 13:26:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
616
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
   135
! !
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
   136
654
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   137
!JavaNativeMethod class methodsFor:'cleanup'!
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   138
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   139
flushAllCachedNativeMethods
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   140
    self allInstancesDo:[:aNativeMethod |
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   141
        aNativeMethod nativeImplementation:nil
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
    "
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   145
     self flushAllCachedNativeMethods
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   146
    "
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   147
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   148
    "Created: / 24.12.1999 / 03:10:38 / cg"
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   149
    "Modified: / 24.12.1999 / 03:10:51 / cg"
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   150
! !
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
   151
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
   152
!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
   153
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   154
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
   155
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   156
    ^ '$Changeset: <not expanded> $'
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   157
! !
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
!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
   160
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   161
messagesSentToSuper
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   162
    ^#()
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   163
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   164
    "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
   165
! !
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   166
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   167
!JavaNativeMethod methodsFor:'accessing'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   168
4005
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   169
dbgInfo
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   170
    "Returns debug info for this method or `nil` if not debug info
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   171
     available."
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   172
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   173
    | l |
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   174
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   175
    "/ See CompiledCode >> literalAt: for details on
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   176
    "/ why this hack is necessary.
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   177
    l := self at: 1.
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   178
    (l isArray and: [self size == 1 and: [l notEmpty]]) ifTrue: [
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   179
        l := l at: 1.
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   180
    ].
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   181
    ^ l isByteArray ifTrue:[ DIInfo decode: l readStream ] ifFalse:[ nil ].
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   182
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   183
    "
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   184
    (Smalltalk class >> #loadPackage:asAutoloaded:) dbgInfo
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   185
    "
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   186
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   187
    "Created: / 10-07-2018 / 13:11:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   188
    "Modified (comment): / 15-07-2018 / 17:10:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   189
    "Modified (format): / 10-11-2020 / 23:01:39 / Jan Vrany <jan.vrany@labware.com>"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   190
!
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   191
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   192
dbgVariableTable
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   193
    "Return a DIVariableTable for this method or nil if not debug info is recorded"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   194
    | info |
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   195
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   196
    info := self dbgInfo.
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   197
    ^ info notNil ifTrue:[ info dbgVariableTable ] ifFalse:[ nil ]
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   198
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   199
    "Created: / 15-07-2018 / 11:52:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   200
    "Modified (comment): / 07-02-2019 / 08:41:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   201
    "Modified: / 27-05-2020 / 15:19:45 / Jan Vrany <jan.vrany@labware.com>"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   202
!
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   203
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   204
dbgVariables
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   205
    "Return a list of variables for this context (as collection 
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   206
     of `DIVariable` instances) or nil if no debug info is recorded"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   207
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   208
    | vartab |
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   209
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   210
    vartab := self dbgVariableTable.
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   211
    ^ vartab notNil ifTrue:[ vartab variables select:[:e | e physicalBlockSourceOffset == 0 ] ] ifFalse:[ nil ]
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   212
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   213
    "Created: / 07-02-2019 / 08:47:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   214
    "Modified: / 27-05-2020 / 15:21:14 / Jan Vrany <jan.vrany@labware.com>"
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   215
!
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   216
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
   217
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
   218
    ^ 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
   219
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   220
    "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
   221
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   222
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   223
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
   224
    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
   225
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   226
    "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
   227
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   228
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   229
nativeImplementation
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   230
    "return the value of the instance variable 'nativeImplementation' (automatically generated)"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   231
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   232
    ^ nativeImplementation
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   233
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   234
    "Created: / 25.9.1999 / 23:08:00 / cg"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   235
!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   236
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   237
nativeImplementation:something
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   238
    "set the value of the instance variable 'nativeImplementation' (automatically generated)"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   239
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   240
    nativeImplementation := something.
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   241
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   242
    "Created: / 25.9.1999 / 23:08:00 / cg"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   243
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   244
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   245
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
   246
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
    ^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
   248
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   249
"/    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
   250
"/    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
   251
"/    ^1
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   252
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   253
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   254
    "
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   255
    ^ (JavaSourceCodeCache new)
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   256
        findLineForMethod:(self selector)
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   257
        inClass:javaClass.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   258
    "
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   259
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   260
    "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
   261
    "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
   262
    "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
   263
! !
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   264
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   265
!JavaNativeMethod methodsFor:'private'!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   266
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   267
compileNativeImplementation:sel dispatchingTo:oldSel
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
   268
    | src  arg  converted  header |
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   269
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
   270
    src := (JavaVM class compiledMethodAt:oldSel) source.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   271
    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
   272
    (src first includesString:'aJavaContext') ifTrue:[
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   273
        arg := 'aJavaContext'
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   274
    ] 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
   275
        (src first includesString:'nativeContext') ifTrue:[
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   276
            arg := 'nativeContext'
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   277
        ]
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   278
    ].
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
   279
    arg isNil ifTrue:[
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   280
        arg := 'nativeContext'.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   281
        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
   282
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   283
                ^ self '
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
   284
                , 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
   285
        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
   286
    ] 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
   287
        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
   288
        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
   289
    ].
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   290
    header := String
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   291
            streamContents:[:s |
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
   292
                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
   293
                    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
   294
                        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
   295
                        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
   296
                        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
   297
                ] 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
   298
                    | 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
   299
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
   300
                    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
   301
                    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
   302
                    s nextPutAll:' this '.
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   303
                    2 to:kw size - 1 do:[:i |
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
   304
                        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
   305
                            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
   306
                            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
   307
                            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
   308
                            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
   309
                            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
   310
                    ].
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   311
                ]
d617b4590431 (Class reading) optimization [2/4]: rewrite slow ifNil:... by faster isNil ifTrue:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2841
diff changeset
   312
            ].
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   313
    (JavaVM class compile:(self nativeMethodTemplate
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
   314
                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
   315
                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
   316
                with:src asString)
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   317
        classified:'native - '
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   318
                , ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$.))
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
   319
            package:JavaVM package.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   320
    converted ifTrue:[
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   321
        (JavaVM class compiledMethodAt:oldSel)
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
   322
            category:'native - old-style (converted)'
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   323
    ] ifFalse:[
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   324
        (JavaVM class compiledMethodAt:oldSel)
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
   325
            category:'native - old-style (FAILED to convert)'
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   326
    ]
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   327
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   328
    "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
   329
    "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
   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
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
   333
    | header |
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   334
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
   335
    "/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
   336
    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
   337
915b234397f0 Don't compile native method stub when native implementatio is not initialized.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2426
diff changeset
   338
    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
   339
            | 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
   340
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   341
            kw := sel keywords.
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
   342
            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
   343
            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
   344
            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
   345
                s nextPutAll: (kw at: i); space; nextPut:$a; nextPutAll: (i - 1) printString; space.
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   346
            ].
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
   347
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   348
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   349
3325
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
   350
    Class updateChangeFileQuerySignal answer: false do:[
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   351
        (JavaVM natives class
3325
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
   352
            compile:
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
   353
                (self nativeMethodTemplate bindWith:header with: 'nativeContext' with:('^ JavaVM unimplementedNativeMethodSignal raise'))
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   354
            classified:
3325
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
   355
                'native - ', ((javaClass javaPackage upTo:$$) replaceAll:$/ with:$.))
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
   356
            package: JavaVM package.
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
   357
    ].
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
   358
    self assert: (JavaVM natives respondsTo: sel).
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   359
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   360
    "Created: / 01-05-2011 / 00:08:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3325
d9297d724fa0 Fix for D116331: Do not write to a changefile when compiling new native method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3324
diff changeset
   361
    "Modified: / 06-01-2015 / 09:14:57 / 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
   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
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   364
nativeMethodTemplate
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   365
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
   366
    ^'%1
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   367
2556
31d0c6fa875f Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 2435
diff changeset
   368
    <javanative: ''', javaClass name , ''' name: ''', (selector copyButLast:signature size), '''>
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   369
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   370
    %3'
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   371
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   372
    "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
   373
    "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
   374
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   375
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   376
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
   377
    <resource: #obsolete>
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   378
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   379
    "Returns a SELECTOR of native method implementation.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   380
    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
   381
    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
   382
    The new one uses fully qualified class name.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   383
    "
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   384
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   385
    | 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
   386
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
    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
   388
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   389
    nm := selector upTo: $(.
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   390
    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
   391
    (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
   392
        "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
   393
        ^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
   394
    ].
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   395
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   396
    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
   397
    (JavaVM natives canUnderstand: oldStyleSel) ifTrue:[
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   398
        "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
   399
         (to avoid confusion of other developers :-)"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   400
        OperatingSystem getLoginName = 'jv' ifTrue:[
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   401
            "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
   402
            Converts old-style method to a new-style one"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   403
            self compileNativeImplementation: newStyleSel dispatchingTo: oldStyleSel.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   404
            ^newStyleSel
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   405
        ] ifFalse:[
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   406
            ^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
   407
        ]
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
    ].
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   409
    self compileNativeImplementationStub: newStyleSel.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   410
    ^newStyleSel
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   411
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   412
    "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
   413
    "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
   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
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   416
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
   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
    "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
   419
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
    | 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
   422
    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
   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
    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
   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
    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
   427
        "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
   428
        "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
   429
        "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
   430
        "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
   431
        "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
   432
        "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
   433
        "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
   434
        "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
   435
        "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
   436
        "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
   437
        "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
   438
        "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
   439
        "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
   440
        "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
   441
        "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
   442
    ) 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
   443
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   444
    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
   445
    (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
   446
        "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
   447
        "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
   448
        | 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
   449
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   450
        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
   451
        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
   452
        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
   453
        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
   454
            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
   455
                ^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
   456
            ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   457
        ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   458
        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
   459
            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
   460
            ^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
   461
        ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   462
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   463
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   464
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   465
    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
   466
    ^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
   467
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   468
    "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
   469
    "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
   470
! !
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   471
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   472
!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
   473
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   474
numberOfArgs:aNumber
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   475
    | 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
   476
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   477
    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
   478
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   479
    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
   480
        ^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
   481
    ].
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   482
    (self class flags bitAnd:Behavior flagJavaMethod) ~~ 0 ifTrue:[ ^ self ].
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   483
    javaClass isNil ifTrue:[
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
   484
        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
   485
        ^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
   486
    ].
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   487
    selector isNil ifTrue:[
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
   488
        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
   489
        ^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
   490
    ].
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   491
2426
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   492
    MethodNode isNil ifTrue:[
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   493
        self error: 'Cannot install trampoline - no MethodNode class'.
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   494
        ^self.
d302dc873c0c class: JavaNativeMethod
Claus Gittinger <cg@exept.de>
parents: 2396
diff changeset
   495
    ].
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
   496
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
    "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
   498
    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
   499
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   500
    sendTree := MessageNode
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   501
                    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
   502
                    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
   503
                    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
   504
    self isSynchronized ifTrue:[
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   505
        sendTree :=
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   506
            MessageNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   507
                receiver: ((BlockNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   508
                            arguments: #()
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   509
                            home: nil
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   510
                            variables: #())
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   511
                            statements: (
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   512
                                (StatementNode expression:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   513
                                    (MessageNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   514
                                        receiver: (VariableNode globalNamed:#'JavaVM')
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   515
                                        selector: #_MONITORENTER:
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   516
                                          args: (Array with: (SelfNode value: #self) )))
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   517
                                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
   518
                                )
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   519
                        )
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   520
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   521
                selector: #ensure:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   522
                args: {
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   523
                        (BlockNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   524
                            arguments: #()
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   525
                            home: nil
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   526
                            variables: #())
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   527
                            statements:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   528
                                (StatementNode expression:
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   529
                                    (MessageNode
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   530
                                        receiver: (VariableNode globalNamed:#'JavaVM')
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   531
                                        selector: #_MONITOREXIT:
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   532
                                        args: (Array with: (SelfNode value: #self))
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   533
                                    )
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   534
                                )
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   535
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   536
                }
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   537
    ].
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
    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
   539
        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
   540
        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
   541
        statements:
3493
4c7b405cf1ca Workaround for stc bug ({} arrays are sometimes mis-compiled)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3384
diff changeset
   542
            (Array with: (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
   543
        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
   544
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
    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
   546
    compiler methodClass: Method.
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   547
    trampoline := compiler
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   548
                    compileTree: trampolineTree
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
   549
                    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
   550
                    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
   551
    "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
   552
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   553
    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
   554
    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
   555
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   556
%{
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   557
    /* 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
   558
    __jbindnative(self);
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   559
%}.
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
   560
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
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   562
    "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
   563
    "Modified: / 10-03-2013 / 01:39:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4005
8b5874d7cc58 Fix details stack trace printing for `JavaContext`s
Jan Vrany <jan.vrany@labware.com>
parents: 3860
diff changeset
   564
    "Modified: / 10-11-2020 / 22:18:35 / Jan Vrany <jan.vrany@labware.com>"
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   565
! !
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   566
3213
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   567
!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
   568
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   569
lineNumberForPC0: pc
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   570
    | 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
   571
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   572
    src := javaClass source.
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   573
    src notNil ifTrue:[
3213
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   574
        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
   575
        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
   576
            ((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
   577
                lineNumber := lno.
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   578
                ^ lineNumber
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   579
            ].
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   580
        ].
3213
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   581
    ].
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   582
    lineNumber := 1.
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   583
    ^ lineNumber
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   584
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   585
    "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
   586
! !
d3094b384e55 Fix in JavaNativeMethod: compute line number by searching the source.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3196
diff changeset
   587
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   588
!JavaNativeMethod methodsFor:'vm support'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   589
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   590
nativeMethodInvokation
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   591
    "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
   592
     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
   593
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   594
    ^self nativeMethodInvokation: thisContext sender.
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
   595
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   596
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   597
     JavaNativeMethod flushAllCachedNativeMethods"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   598
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
   599
    "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
   600
    "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
   601
    "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
   602
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   603
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   604
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
   605
    "Called by the VM when a native method is
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   606
     to be executed.
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
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
     'context' is the context of being-invoked native method"
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   609
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
   610
    | 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
   611
    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
   612
    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
   613
    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
   614
    receiverAndArgsAndContext at: 1 put: context receiver.
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   615
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   616
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
   617
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   618
    (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
   619
        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
   620
        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
   621
        (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
   622
            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
   623
            sender sender selector == #noByteCode ifTrue: [
660
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
   624
                sender := sender sender.
663
c346b0d28deb checkin from browser
cg
parents: 660
diff changeset
   625
                sender := sender sender.
c346b0d28deb checkin from browser
cg
parents: 660
diff changeset
   626
                sender := sender sender.
660
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
   627
            ].
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   628
            ^ JavaVM natives perform: sel withArguments: receiverAndArgsAndContext
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
   629
        ].
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
   630
        CacheNativeImplementation ifTrue: [ nativeImplementation := mthd. ]
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   631
    ].
3384
98eb8443f4f4 Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3325
diff changeset
   632
    Verbose ifTrue: [Logger log: 'Native method invokation: ' , sel severity: Logger severityDEBUG facility: #JVM].
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   633
    ^ mthd
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
   634
        valueWithReceiver: JavaVM natives
3781
5948124e57ee Issue #94 [8/x]: use JavaMonitor directly from natives and instruction helpers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   635
        arguments: receiverAndArgsAndContext
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
   636
        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
   637
        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
   638
        sender: nil
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   639
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
   640
    "
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2272
diff changeset
   641
     JavaNativeMethod flushAllCachedNativeMethods"
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   642
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
   643
    "Created: / 27-10-2012 / 15:13:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3384
98eb8443f4f4 Use new Logger API (use Logger severityXXX instead of symbols)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3325
diff changeset
   644
    "Modified: / 02-03-2015 / 14:06:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   645
! !
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   646
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   647
!JavaNativeMethod class methodsFor:'documentation'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   648
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   649
version
3431
82790b1e6d54 Merged with mercurial revision 4f3cc813be4 (8 changesets total)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3430
diff changeset
   650
    ^ '$Header: /cvs/stx/stx/libjava/JavaNativeMethod.st,v 1.20 2015-03-20 12:08:00 vrany Exp $'
2198
3802e8e6f8d4 initial checkin
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   651
!
3802e8e6f8d4 initial checkin
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   652
3802e8e6f8d4 initial checkin
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   653
version_CVS
3431
82790b1e6d54 Merged with mercurial revision 4f3cc813be4 (8 changesets total)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3430
diff changeset
   654
    ^ '$Header: /cvs/stx/stx/libjava/JavaNativeMethod.st,v 1.20 2015-03-20 12:08:00 vrany Exp $'
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   655
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   656
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2107
diff changeset
   657
version_SVN
2678
c865275e48a7 Updated to match Mercurial revision a00302fe5083 with two tweaks:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2556
diff changeset
   658
    ^ '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
   659
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
   660
! !
2107
f4509f6767fa category change
Claus Gittinger <cg@exept.de>
parents: 2097
diff changeset
   661
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
   662
2097
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   663
JavaNativeMethod initialize!