Merged 5ea0697eef5f and e4f0dcc42f4a (monitor trace fixes) development
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 11 Oct 2013 18:34:22 +0100
branchdevelopment
changeset 2851 3680bdc3ef00
parent 2847 5ea0697eef5f (current diff)
parent 2850 e4f0dcc42f4a (diff)
child 2852 47083445aaf9
Merged 5ea0697eef5f and e4f0dcc42f4a (monitor trace fixes)
JavaClass.st
JavaObject.st
JavaVM.st
Make.proto
abbrev.stc
libjava.rc
stx_libjava.st
--- a/JavaClass.st	Thu Oct 10 11:25:37 2013 +0100
+++ b/JavaClass.st	Fri Oct 11 18:34:22 2013 +0100
@@ -1014,6 +1014,13 @@
     versions := aWeakArray.
 
     "Created: / 14-04-2013 / 12:28:09 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
+!
+
+versionsArray
+    
+    versions isNil ifTrue: [ ^ Array with: self ] ifFalse: [ ^ self versions ].
+
+    "Created: / 08-10-2013 / 18:38:52 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
 ! !
 
 !JavaClass methodsFor:'accessing - java'!
--- a/JavaClassReloader.st	Thu Oct 10 11:25:37 2013 +0100
+++ b/JavaClassReloader.st	Fri Oct 11 18:34:22 2013 +0100
@@ -352,6 +352,16 @@
     ^ self reload.
 
     "Created: / 20-02-2012 / 23:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+requestRecompile: aClass
+
+    "Created: / 08-10-2013 / 19:26:20 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
+!
+
+requestReload: aClass
+
+    "Created: / 08-10-2013 / 19:26:12 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
 ! !
 
 !JavaClassReloader::SingleClassReloader::FieldMapping class methodsFor:'instance creation'!
--- a/JavaConstantPool.st	Thu Oct 10 11:25:37 2013 +0100
+++ b/JavaConstantPool.st	Fri Oct 11 18:34:22 2013 +0100
@@ -22,7 +22,7 @@
 
 Array variableSubclass:#JavaConstantPool
 	instanceVariableNames:'owner'
-	classVariableNames:'ConstantPools'
+	classVariableNames:''
 	poolDictionaries:''
 	category:'Languages-Java-Reader-Support'
 !
@@ -53,35 +53,19 @@
 "
 ! !
 
-!JavaConstantPool class methodsFor:'accessing'!
-
-allConstantPools
-    "linked list of all constant pools in system"
-    ^ ConstantPools.
-
-    "Created: / 08-04-2011 / 16:53:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 09-04-2011 / 09:24:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-allConstantPools: anOorderedCollection 
-    "linked list of all constant pools in system"
-    
-    ConstantPools := anOorderedCollection.
-
-    "Created: / 08-04-2011 / 17:07:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 09-04-2011 / 09:24:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 11-04-2011 / 18:47:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-
 !JavaConstantPool class methodsFor:'special'!
 
 invalidateForClass: internalJavaClassName 
     "Go over all constant pools and call invalidateForClass on all 
      references. (usable when given class was unloaded etc)"
-    ConstantPools do: [:each | each invalidateForClass: internalJavaClassName].
+    JavaVM registry classesDo: [ :eachClass | 
+        eachClass versionsArray do: [ :eachVersion | 
+            eachVersion constantPool invalidateForClass: internalJavaClassName.
+        ].
+    ].
 
     "Created: / 08-04-2011 / 16:52:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 02-10-2013 / 21:05:44 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
+    "Modified (format): / 08-10-2013 / 18:43:59 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
 ! !
 
 !JavaConstantPool methodsFor:'accessing'!
--- a/JavaMonitor.st	Thu Oct 10 11:25:37 2013 +0100
+++ b/JavaMonitor.st	Fri Oct 11 18:34:22 2013 +0100
@@ -124,17 +124,20 @@
 !
 
 disableWait
-    Logger log: ('Waiting is disabled on monitor for %1' bindWith: ownerPrintString) severity:#debug facility:#JVM.
+    JavaVM monitorTrace ifTrue:[
+        Logger log: ('Waiting is disabled on monitor for %1' bindWith: ownerPrintString) severity:#debug facility:#JVM.
+    ].
     instVarAccess critical: [ waitEnabled := false ].
 
     "Created: / 30-11-2011 / 20:34:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 10-05-2012 / 00:24:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-10-2013 / 11:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 enableWait
-instVarAccess critical: [waitEnabled := true].
+    instVarAccess critical: [waitEnabled := true].
 
     "Created: / 30-11-2011 / 20:34:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified (format): / 11-10-2013 / 11:17:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 increment
@@ -299,15 +302,18 @@
     | thisProcess |
     thisProcess := Processor activeProcess.
     self assert: (self isOwnedBy: thisProcess).
-    Logger 
-        log: ('%1: notifying %2 processes' bindWith: thisProcess printString
-                with: processesWaiting size)
-        severity: #debug
-        facility: #JVM.
+    JavaVM monitorTrace ifTrue:[
+        Logger 
+            log: ('%1: notifying %2 processes' bindWith: thisProcess printString
+                    with: processesWaiting size)
+            severity: #debug
+            facility: #JVM.
+    ].
     waitingSema signal.
     Processor yield.
 
     "Created: / 22-11-2011 / 12:14:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 11-10-2013 / 11:16:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 notifyAll
@@ -316,20 +322,21 @@
     | thisProcess |
     thisProcess := Processor activeProcess.
     self assert: (self isOwnedBy: thisProcess).
-    Logger 
-        log: ('%1: notifying all %2 processes' bindWith: thisProcess printString
-                with: processesWaiting size)
-        severity: #debug
-        facility: #JVM.
+    JavaVM monitorTrace ifTrue:[
+        Logger 
+            log: ('%1: notifying all %2 processes' bindWith: thisProcess printString
+                    with: processesWaiting size)
+            severity: #debug
+            facility: #JVM.
+    ].
     waitingSema signalForAll.
     Processor yield.
 
     "Created: / 22-11-2011 / 12:14:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 11-10-2013 / 11:16:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 release
-    | thisProcess |
-    thisProcess := self activeProcess.
     self assert: (self isOwnedBy: owningProcess).
     count == 1 ifTrue: [
         self clearOwningProcess.
@@ -340,7 +347,7 @@
     ]
 
     "Created: / 20-11-2011 / 13:21:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 27-08-2012 / 11:44:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-10-2013 / 11:18:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 releaseAll
@@ -364,38 +371,44 @@
     thisProcess := Processor activeProcess.
     self assert: (self isOwnedBy: thisProcess).
     self waitEnabled ifFalse: [
-        Logger 
-            log: ('%1 wanted to go to sleep, but it cant, this monitor is for %2 which is already dead' 
-                    bindWith: thisProcess printString
-                    with: ownerPrintString)
-            severity: #debug
-            facility: #JVM.
+        JavaVM monitorTrace ifTrue:[
+            Logger 
+                log: ('%1 wanted to go to sleep, but it cant, this monitor is for %2 which is already dead' 
+                        bindWith: thisProcess printString
+                        with: ownerPrintString)
+                severity: #debug
+                facility: #JVM.
+        ].
         ^ self.
     ].
-    Logger 
-        log: ('%1 is going to wait on %3 for timeout: %2' 
-                bindWith: thisProcess printString
-                with: timeOut
-                with: ownerPrintString printString)
-        severity: #debug
-        facility: #JVM.
+    JavaVM monitorTrace ifTrue:[
+        Logger 
+            log: ('%1 is going to wait on %3 for timeout: %2' 
+                    bindWith: thisProcess printString
+                    with: timeOut
+                    with: ownerPrintString printString)
+            severity: #debug
+            facility: #JVM.
+    ].
     self processesWaitingAdd: thisProcess.
     self releaseAll.
      "JV@2011-11-25: zero timeout means wait without timeout!!!!!!"
     timeOut == 0 ifTrue: [ waitingSema wait ] ifFalse: [
         waitingSema waitWithTimeoutMs: timeOut
     ].
-    Logger 
-        log: ('%1 has been notified and is trying to acquire monitor for %2 which is owned by %3' 
-                bindWith: thisProcess printString with: ownerPrintString printString with: owningProcess printString)
-        severity: #debug
-        facility: #JVM.
+    JavaVM monitorTrace ifTrue:[ 
+        Logger 
+            log: ('%1 has been notified and is trying to acquire monitor for %2 which is owned by %3' 
+                    bindWith: thisProcess printString with: ownerPrintString printString with: owningProcess printString)
+            severity: #debug
+            facility: #JVM.
+    ].
     self acquire.
     self processesWaitingRestore: thisProcess.
 
     "Created: / 22-11-2011 / 12:52:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 01-12-2011 / 10:57:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 10-05-2012 / 00:24:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-10-2013 / 11:20:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaMonitor methodsFor:'queries'!
--- a/JavaObject.st	Thu Oct 10 11:25:37 2013 +0100
+++ b/JavaObject.st	Fri Oct 11 18:34:22 2013 +0100
@@ -408,6 +408,28 @@
 
 !JavaObject methodsFor:'queries'!
 
+instanceOf: aJavaClassOrJavaClassAccessor
+    "A Smalltalk-friendly version  of Java language `instanceof` operator.
+
+     The difference between #instanceOf and #isKindOf: is that
+     #instanceOf: takes interfaces into an account whereas
+     #isKindOf: not.
+
+     NOTE: It's up to an discussion whethere #isKindOf: sent to
+     a java object should or should not behave as #instanceOf:.
+     Maybe in future they will be the same."
+
+    | class |
+
+    class := aJavaClassOrJavaClassAccessor class == JavaClassAccessor 
+                ifTrue:[aJavaClassOrJavaClassAccessor theClass]
+                ifFalse:[aJavaClassOrJavaClassAccessor].
+    ^ (JavaVM _INSTANCEOF: self _: class) == 1.
+
+    "Created: / 09-10-2013 / 22:36:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 10-10-2013 / 16:35:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 isJavaClassRef
     ^ false
 
--- a/JavaVM.st	Thu Oct 10 11:25:37 2013 +0100
+++ b/JavaVM.st	Fri Oct 11 18:34:22 2013 +0100
@@ -2831,6 +2831,12 @@
 
     "Created: / 25-02-2011 / 08:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified (comment): / 14-09-2013 / 23:59:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+monitorTrace
+    ^ MonitorTrace
+
+    "Created: / 11-10-2013 / 11:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaVM class methodsFor:'debugging-dumping'!
@@ -4814,11 +4820,13 @@
 
     stProcess
         addExitAction: [
-            Logger
-                log: ('%1 is going to die, notifying all waiters and disabling waiting on its monitor'
-                        bindWith: jThread printString)
-                severity: #debug
-                facility: #JVM.
+            MonitorTrace ifTrue:[
+                Logger
+                    log: ('%1 is going to die, notifying all waiters and disabling waiting on its monitor'
+                            bindWith: jThread printString)
+                    severity: #debug
+                    facility: #JVM.
+            ].
             jThread instVarNamed: 'threadStatus' put: 0.
             jThread getJavaMonitor disableWait.
             self acquireMonitorAndNotifyAll: jThread.
@@ -4836,7 +4844,7 @@
     "Modified: / 24-12-1999 / 03:14:33 / cg"
     "Created: / 14-12-2010 / 21:31:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 09-12-2011 / 12:58:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 03-09-2012 / 18:42:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-10-2013 / 11:25:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 unpark: process
--- a/Make.proto	Thu Oct 10 11:25:37 2013 +0100
+++ b/Make.proto	Fri Oct 11 18:34:22 2013 +0100
@@ -21,7 +21,7 @@
 INCLUDE_TOP=$(TOP)/..
 
 # subdirectories where targets are to be made:
-SUBDIRS= experiments libs tools
+SUBDIRS= tools libs experiments
 
 
 # subdirectories where Makefiles are to be made:
--- a/libjava.rc	Thu Oct 10 11:25:37 2013 +0100
+++ b/libjava.rc	Fri Oct 11 18:34:22 2013 +0100
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\nCopyright Jan Vrany, Jan Kurs and Marcel Hlopko\n          SWING Research Group, Czech Technical University In Prague\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Wed, 09 Oct 2013 08:00:14 GMT\0"
+      VALUE "ProductDate", "Thu, 10 Oct 2013 14:52:36 GMT\0"
     END
 
   END
--- a/stx_libjava.st	Thu Oct 10 11:25:37 2013 +0100
+++ b/stx_libjava.st	Fri Oct 11 18:34:22 2013 +0100
@@ -193,9 +193,10 @@
      for those, redefine requiredPrerequisites"
 
     ^ #(
-        #'stx:libjava/experiments'
         #'stx:libjava/libs'
         #'stx:libjava/tools'
+        #'stx:libjava/libs'
+        #'stx:libjava/experiments'
     )
 ! !