- JavaRef2 jk_new_structure
authorvranyj1
Mon, 15 Oct 2012 21:26:25 +0000
branchjk_new_structure
changeset 1728 0d275432230d
parent 1727 c23e0b74bc1c
child 1729 44aa9cffed07
- JavaRef2 added: #preResolve #preresolve - JavaClassReader changed: #readConstantPool - JavaMethodRef2 class definition added: #preResolve #preresolve - JavaNameAndType2 added: #preresolve - JavaMethod added: #r_double #r_long #r_void - extensions ...
src/JavaClassReader.st
src/JavaMethod.st
src/JavaMethodRef2.st
src/JavaNameAndType2.st
src/JavaRef2.st
src/libjava.rc
--- a/src/JavaClassReader.st	Mon Oct 15 19:59:35 2012 +0000
+++ b/src/JavaClassReader.st	Mon Oct 15 21:26:25 2012 +0000
@@ -1331,19 +1331,20 @@
                 ifTrue: [ constSlot := constSlot + 2. ]
                 ifFalse: [ constSlot := constSlot + 1. ]].
     constSlot := -1.
-    
-    1 to: constantPoolSize - 1
-        do: 
-            [:i | 
-            | const  value |
-
-            const := constants at: i.
-            const ifNotNil: 
-                    [ "/ kludge for 2-slot constants (which only take 1 slot in ST/X)
-                    (const isKindOf: JavaUnresolvedConstant) 
-                        ifTrue: 
-                            [ value := const preResolve.
-                            value ~~ const ifTrue: [ constants at: i put: value. ] ] ] ].
+
+    constants do:[:ref|ref isJavaRef ifTrue:[ref preResolve]].
+"/    1 to: constantPoolSize - 1
+"/        do: 
+"/            [:i | 
+"/            | const  value |
+"/
+"/            const := constants at: i.
+"/            const notNil ifTrue: 
+"/                    [ "/ kludge for 2-slot constants (which only take 1 slot in ST/X)
+"/                    (const isKindOf: JavaUnresolvedConstant) 
+"/                        ifTrue: 
+"/                            [ value := const preResolve.
+"/                            value ~~ const ifTrue: [ constants at: i put: value. ] ] ] ].
 
     "
      JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
@@ -1351,6 +1352,7 @@
 
     "Modified: / 07-05-1998 / 11:44:06 / cg"
     "Created: / 13-05-2011 / 16:52:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 15-10-2012 / 23:15:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 readConstant_Asciz
@@ -1952,7 +1954,7 @@
 
 readCodeAttributeFor:aJavaMethod
     |attribute_length max_stack max_locals code_length code
-     exception_table_length exception_table unknown1 unknown2|
+     exception_table_length exception_table unknown1 unknown2 |
 
     attribute_length := inStream nextUnsignedLongMSB:msb.
 
@@ -1966,11 +1968,12 @@
         "/ Remember max context size so far, will be used to
         "/ optimize context size as alloca() won't work.
         MaxContextSize := MaxContextSize max: (max_stack + max_locals + 4"safe area").
+"
         MaxContextSize > MaxContextSizeLimit ifTrue:[
             self error:'method''s stack depth overflows VM limit'.
             ^false
         ].
-
+"
 
 "/        unknown1 := inStream nextByte.
 "/        max_stack := inStream nextByte.
@@ -2021,6 +2024,10 @@
         aJavaMethod setExceptionHandlerTable:exception_table.
     ].
 
+    (max_stack + max_locals + 4) > MaxContextSizeLimit ifTrue:[
+	code := nil
+    ].
+
     aJavaMethod 
         setCode:code 
         maxStack:max_stack 
--- a/src/JavaMethod.st	Mon Oct 15 19:59:35 2012 +0000
+++ b/src/JavaMethod.st	Mon Oct 15 21:26:25 2012 +0000
@@ -158,6 +158,24 @@
     "Created: / 27.1.1998 / 21:50:05 / cg"
 !
 
+r_double
+    ^R_DOUBLE
+
+    "Created: / 15-10-2012 / 23:21:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+r_long
+    ^R_LONG
+
+    "Created: / 15-10-2012 / 23:20:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+r_void
+    ^R_VOID
+
+    "Created: / 15-10-2012 / 23:20:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 unresolvedClassSignal
     "return the signal raised when an unresolved class is referenced"
 
--- a/src/JavaMethodRef2.st	Mon Oct 15 19:59:35 2012 +0000
+++ b/src/JavaMethodRef2.st	Mon Oct 15 21:26:25 2012 +0000
@@ -21,7 +21,7 @@
 "{ Package: 'stx:libjava' }"
 
 JavaClassContentRef2 subclass:#JavaMethodRef2
-	instanceVariableNames:'selectorCache'
+	instanceVariableNames:'selectorCache numArgSlotsCache returnTypeCache'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Languages-Java-Reader-Support-new'
@@ -103,6 +103,38 @@
     "Created: / 11-04-2011 / 19:56:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
+!JavaMethodRef2 methodsFor:'resolving'!
+
+preResolve
+    "Fill in selectorCache and numArgSlotsCache for these are used
+     by the JIT-compiler"
+
+    | returnTypeChar |
+
+    nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve.
+    nameAndTypeCache isNil ifTrue: [ self breakPoint: #mh ].
+    selectorCache isNil ifTrue: [
+        selectorCache := (nameAndTypeCache name , nameAndTypeCache descriptor) asSymbol
+    ].
+    numArgSlotsCache := JavaMethod numArgsFromSignature: nameAndTypeCache descriptor.
+    returnTypeChar := nameAndTypeCache descriptor last.
+    returnTypeChar == $V ifTrue:[
+        returnTypeCache := JavaMethod r_void.    
+    ] ifFalse:[
+        returnTypeChar == $L ifTrue:[
+            returnTypeCache := JavaMethod r_long.
+        ] ifFalse:[
+            returnTypeChar == $D ifTrue:[
+                returnTypeCache := JavaMethod r_double.
+            ] ifFalse:[
+                returnTypeCache := 0.
+            ]
+        ]
+    ]
+
+    "Created: / 15-10-2012 / 23:13:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaMethodRef2 class methodsFor:'documentation'!
 
 version_SVN
--- a/src/JavaNameAndType2.st	Mon Oct 15 19:59:35 2012 +0000
+++ b/src/JavaNameAndType2.st	Mon Oct 15 21:26:25 2012 +0000
@@ -213,6 +213,12 @@
 
 !JavaNameAndType2 methodsFor:'resolving'!
 
+preresolve
+   self resolve
+
+    "Created: / 15-10-2012 / 23:09:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 resolve
     nameCache := constantPool at: nameIndex.
     descriptorCache := constantPool at: descriptorIndex.
--- a/src/JavaRef2.st	Mon Oct 15 19:59:35 2012 +0000
+++ b/src/JavaRef2.st	Mon Oct 15 21:26:25 2012 +0000
@@ -234,6 +234,26 @@
     "Modified (comment): / 21-02-2012 / 10:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+preResolve
+    "Pre-resolve some caches. Called when the constant pool
+     is loaded. MUST NOT load new nor modify any existing class!!!!!!
+     Ask JV for what this is needed"
+
+    "Nothing by default"
+
+    "Created: / 15-10-2012 / 23:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+preresolve
+    "Pre-resolve some caches. Called when the constant pool
+     is loaded. MUST NOT load new nor modify any existing class!!!!!!
+     Ask JV for what this is needed"
+
+    "Nothing by default"
+
+    "Created: / 15-10-2012 / 23:08:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 resolve
     "
      Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.)
--- a/src/libjava.rc	Mon Oct 15 19:59:35 2012 +0000
+++ b/src/libjava.rc	Mon Oct 15 21:26:25 2012 +0000
@@ -3,7 +3,7 @@
 // automagically generated from the projectDefinition: stx_libjava.
 //
 VS_VERSION_INFO VERSIONINFO
-  FILEVERSION     6,2,2089,2089
+  FILEVERSION     6,2,2098,2098
   PRODUCTVERSION  6,2,3,1
 #if (__BORLANDC__)
   FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
@@ -20,12 +20,12 @@
     BEGIN
       VALUE "CompanyName", "eXept Software AG\0"
       VALUE "FileDescription", "Smalltalk/X Class library (LIB)\0"
-      VALUE "FileVersion", "6.2.2089.2089\0"
+      VALUE "FileVersion", "6.2.2098.2098\0"
       VALUE "InternalName", "stx:libjava\0"
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\nCopyright Jan Vrany, Jan Kurs and Marcel Hlopko\b          SWING Research Group, Czech Technical University In Prague\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.1\0"
-      VALUE "ProductDate", "Mon, 15 Oct 2012 13:35:56 GMT\0"
+      VALUE "ProductDate", "Mon, 15 Oct 2012 21:24:48 GMT\0"
     END
 
   END