faster nativeMethod invocation
authorcg
Sat, 25 Sep 1999 21:13:24 +0000
changeset 611 490fbaed2257
parent 610 1f3f6ca7d71f
child 612 00e005c99126
faster nativeMethod invocation
JavaMethod.st
JavaNativeMethod.st
--- a/JavaMethod.st	Sat Sep 25 21:11:24 1999 +0000
+++ b/JavaMethod.st	Sat Sep 25 21:13:24 1999 +0000
@@ -17,8 +17,7 @@
 	classVariableNames:'AbstractMethodInvokationSignal SignatureTypeCodes
 		ForceByteCodeDisplay UnresolvedClassSignal A_PUBLIC A_PRIVATE
 		A_PROTECTED A_STATIC A_FINAL A_SYNCHRONIZED A_ABSTRACT A_NATIVE
-		A_BREAKPOINT R_VOID R_LONG R_DOUBLE A_HASHANDLER
-		NativeMethodCache'
+		A_BREAKPOINT R_VOID R_LONG R_DOUBLE A_HASHANDLER'
 	poolDictionaries:''
 	category:'Java-Classes'
 !
@@ -1302,11 +1301,11 @@
 
 displayString
     javaClass isNil ifTrue:[
-	^ 'JavaMethod(???)'
+        ^ self class name , '(???)'
     ].
-    ^ 'JavaMethod(' , javaClass displayString , '::' , self signatureName , ')'
+    ^ self class name , '(' , javaClass displayString , '::' , self signatureName , ')'
 
-    "Modified: / 5.11.1998 / 19:49:07 / cg"
+    "Modified: / 25.9.1999 / 23:04:01 / cg"
 !
 
 printStringForBrowserWithSelector:dummySelector
@@ -1418,9 +1417,24 @@
 !JavaMethod methodsFor:'queries'!
 
 handlerFor:anException at:pc
+    "return an exceptionHandlers pc, for an exception of the given type,
+     occurring at pc. Returns nil, if there is none."
+
+    |handlerTable|
+
+    (handlerTable := self exceptionHandlerTable) isNil ifTrue:[^ nil].
+
+    handlerTable do:[:entry |
+        |hpc|
+
+        hpc := entry handlerPCFor:anException at:pc in:self.
+        hpc notNil ifTrue:[^ hpc].
+    ].
+
     ^ nil
 
-    "Created: / 16.10.1998 / 02:06:11 / cg"
+    "Created: / 16.10.1998 / 01:18:40 / cg"
+    "Modified: / 25.9.1999 / 23:07:01 / cg"
 !
 
 hasResource
@@ -1616,39 +1630,9 @@
     "Created: / 8.1.1998 / 19:17:58 / cg"
 ! !
 
-!JavaMethod methodsFor:'vm support'!
-
-nativeMethodInvokation
-    |nm sel mthd|
-
-    NativeMethodCache notNil ifTrue:[
-        mthd := NativeMethodCache at:self ifAbsent:nil.
-        mthd notNil ifTrue:[
-            ^ mthd
-                valueWithReceiver:JavaVM
-                arguments:(Array with:thisContext sender)
-                selector:selector
-                search:JavaVM class
-                sender:nil
-        ]
-    ] ifFalse:[
-        NativeMethodCache := IdentityDictionary new.
-    ].
-
-    nm := selector copyWithoutLast:signature size.
-    sel := ('_' , javaClass lastName , '_' , nm , ':') asSymbol.
-    NativeMethodCache at:self put:(JavaVM class compiledMethodAt:sel).
-        
-    ^ JavaVM 
-        perform:sel
-        with:thisContext sender.
-
-    "Modified: / 25.9.1999 / 22:57:54 / cg"
-! !
-
 !JavaMethod class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.87 1999/09/25 20:58:01 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.88 1999/09/25 21:11:05 cg Exp $'
 ! !
 JavaMethod initialize!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JavaNativeMethod.st	Sat Sep 25 21:13:24 1999 +0000
@@ -0,0 +1,60 @@
+'From Smalltalk/X, Version:3.5.4 on 25-sep-1999 at 11:12:45 pm'                 !
+
+JavaMethodWithHandler variableSubclass:#JavaNativeMethod
+	instanceVariableNames:'nativeImplementation'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Java-Classes'
+!
+
+
+!JavaNativeMethod methodsFor:'accessing'!
+
+nativeImplementation
+    "return the value of the instance variable 'nativeImplementation' (automatically generated)"
+
+    ^ nativeImplementation
+
+    "Created: / 25.9.1999 / 23:08:00 / cg"
+!
+
+nativeImplementation:something
+    "set the value of the instance variable 'nativeImplementation' (automatically generated)"
+
+    nativeImplementation := something.
+
+    "Created: / 25.9.1999 / 23:08:00 / cg"
+! !
+
+!JavaNativeMethod methodsFor:'vm support'!
+
+nativeMethodInvokation
+    |nm sel|
+
+    nativeImplementation isNil ifTrue:[
+        nm := selector copyWithoutLast:signature size.
+        sel := ('_' , javaClass lastName , '_' , nm , ':') asSymbol.
+
+        nativeImplementation := (JavaVM class compiledMethodAt:sel).
+        nativeImplementation isNil ifTrue:[
+            ^ JavaVM 
+                perform:sel
+                with:thisContext sender.
+        ].
+    ].
+
+    ^ nativeImplementation
+        valueWithReceiver:JavaVM
+        arguments:(Array with:thisContext sender)
+        selector:selector
+        search:JavaVM class
+        sender:nil
+
+    "Modified: / 25.9.1999 / 23:10:29 / cg"
+! !
+
+!JavaNativeMethod class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaNativeMethod.st,v 1.1 1999/09/25 21:13:24 cg Exp $'
+! !