src/JavaClassReader.st
branchjk_new_structure
changeset 1614 f7d4888fb1a2
parent 1612 ba527b3b17aa
child 1615 dde13d0a263e
--- a/src/JavaClassReader.st	Thu Aug 16 17:16:59 2012 +0000
+++ b/src/JavaClassReader.st	Thu Aug 16 18:19:23 2012 +0000
@@ -25,7 +25,7 @@
 		constSlot classBeingLoaded'
 	classVariableNames:'Verbose AnnotationsVerbose Silent AbsolutelySilent
 		LazyClassLoading InvalidClassFormatSignal ClassLoaderQuerySignal
-		JavaArchiveCache MaxStackDepth'
+		JavaArchiveCache MaxStackDepth MaxStackDepthLimit'
 	poolDictionaries:'JavaConstants'
 	category:'Languages-Java-Support'
 !
@@ -78,6 +78,13 @@
     AnnotationsVerbose := false.
     MaxStackDepth := 0.
 
+    "Maximum stack depth supported by the VM.
+     if you change it, make sure it is equal (or lower)
+     to CONSIZE in jinterpret.c (line 98 or so)
+     Otherwise, VM may crash!!!!!!"
+    MaxStackDepthLimit := 32.
+
+
     "
      JavaClassReader initialize"
 
@@ -85,7 +92,7 @@
     "Modified: / 17-12-2010 / 17:37:45 / Marcel Hlopko <hlopik@gmail.com>"
     "Modified: / 10-05-2011 / 23:59:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 14-08-2012 / 02:01:37 / jv"
-    "Modified: / 14-08-2012 / 21:47:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-08-2012 / 19:14:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaClassReader class methodsFor:'Signal constants'!
@@ -1896,6 +1903,10 @@
         "/ Remember max stack depth so far, will be used to
         "/ optimize context size as alloca() won't work.
         MaxStackDepth := MaxStackDepth max: max_stack.
+        MaxStackDepth > MaxStackDepthLimit ifTrue:[
+            self error:'method''s stack depth overflows VM limit'.
+            ^false
+        ].
         max_locals := inStream nextUnsignedShortMSB:msb.
         code_length := inStream nextUnsignedLongMSB:msb.
 
@@ -1965,7 +1976,7 @@
 
     "Created: / 15-04-1996 / 15:40:17 / cg"
     "Modified: / 16-05-1998 / 01:39:42 / cg"
-    "Modified: / 06-12-2011 / 10:01:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-08-2012 / 19:17:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 readExceptionsAttributeFor:aJavaMethod