crowlogic / arb4j

arb4j is a Java API for the arbitrary precision ball arithmetic library found at http://arblib.org
Other
1 stars 0 forks source link

fix recursive stack issue, either an element should be popped off the stack and it hasnt been or the stackmap should be updated to reflect the recursion.. i think the latter is the correct fix #338

Closed crowlogic closed 8 months ago

crowlogic commented 8 months ago

without compute_frames


java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    F.evaluate(Ljava/lang/Object;IILjava/lang/Object;)Ljava/lang/Object; @94: iload_3
  Reason:
    Current frame's stack size doesn't match stackmap.
  Current Frame:
    bci: @94
    flags: { }
    locals: { 'F', 'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { 'arb/RealPolynomial', 'arb/RealPolynomial' }
  Stackmap Frame:
    bci: @94
    flags: { }
    locals: { 'F', 'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { 'arb/RealPolynomial' }
  Bytecode:
    0000000: 2ab4 000e 9a00 072a b600 122b c000 14b6
    0000010: 0018 aa00 0000 0022 0000 0000 0000 0000
    0000020: 0000 0012 2ab4 001c 1904 c000 1e5f b600
    0000030: 22a7 011f 1904 c000 1eb6 0026 2ab4 0029
    0000040: 2bc0 0014 2ab4 001c 1d2a b400 2cb6 0030
    0000050: 1c1d 2ab4 0034 b900 3605 00c0 001e 1d2a
    0000060: b400 39b6 003d 2ab4 0041 2bc0 0014 b500
    0000070: 452a b400 49b6 004f 572a b400 522a b400
    0000080: 1cb6 0055 572a b400 582a b400 5bb6 0055
    0000090: 572a b400 492a b400 412a b400 521d 2ab4
    00000a0: 005e b900 6104 00c0 004b 1db6 0064 572a
    00000b0: b400 52b6 0068 2ab4 0058 b600 6c9e ffd4
    00000c0: 1d2a b400 6fb6 0072 1904 2bc0 0014 2ab4
    00000d0: 001c 1d2a b400 75b6 0030 1d2a b400 78b6
    00000e0: 007c b600 7f2a b400 832b c000 14b5 0085
    00000f0: 2ab4 0088 b600 4f57 2ab4 0052 2ab4 001c
    0000100: b600 5557 2ab4 008b 2ab4 008e b600 5557
    0000110: 2ab4 0088 2ab4 0083 2ab4 0052 1d2a b400
    0000120: 91b9 0061 0400 c000 4b1d b600 6457 2ab4
    0000130: 0052 b600 682a b400 8bb6 006c 9eff d41d
    0000140: 2ab4 0094 b600 971d 1904 c000 1eb6 009a
    0000150: b0                                     
  Stackmap Table:
    same_frame(@11)
    same_frame(@36)
    same_frame(@52)
    same_locals_1_stack_item_frame(@60,Object[#30])
    same_locals_1_stack_item_frame(@94,Object[#30])
    same_frame(@145)
    same_frame_extended(@272)
    same_locals_1_stack_item_frame(@336,Object[#30])

    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3549)
    at java.base/java.lang.Class.getConstructor0(Class.java:3754)
    at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930)
    at arb4j/arb.expressions.Expression.constructNewInstance(Expression.java:1154)
    at arb4j/arb.expressions.Expression.instantiate(Expression.java:1142)
    at arb4j/arb.expressions.Expression.instantiate(Expression.java:126)
    at arb4j/arb.functions.Function.express(Function.java:154)
    at arb4j/arb.functions.real.HypergeometricPolynomialSequence.<init>(HypergeometricPolynomialSequence.java:63)
    at arb4j/arb.functions.real.HypergeometricFunctionSequenceTest.test3F1(HypergeometricFunctionSequenceTest.java:14)

WITH COMPUTE_FRAMES

java.lang.VerifyError: Operand stack underflow
Exception Details:
  Location:
    F.evaluate(Ljava/lang/Object;IILjava/lang/Object;)Ljava/lang/Object; @197: invokevirtual
  Reason:
    Attempt to pop empty stack.
  Current Frame:
    bci: @197
    flags: { }
    locals: { 'F', 'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { integer, 'arb/Real' }
  Bytecode:
    0000000: 2ab4 000e 9a00 072a b600 122a b400 162b
    0000010: c000 18b5 001d 2ab4 0021 b600 2757 2ab4
    0000020: 002a 2ab4 002d b600 3157 2ab4 0034 2ab4
    0000030: 0037 b600 3157 2ab4 0021 2ab4 0016 2ab4
    0000040: 002a 1d2a b400 3ab9 003d 0400 c000 231d
    0000050: b600 4157 2ab4 002a b600 452a b400 34b6
    0000060: 0049 9eff d42a b400 4d2b c000 18b5 004f
    0000070: 2ab4 0052 b600 2757 2ab4 002a 2ab4 002d
    0000080: b600 3157 2ab4 0055 2ab4 0058 b600 3157
    0000090: 2ab4 0052 2ab4 004d 2ab4 002a 1d2a b400
    00000a0: 5bb9 003d 0400 c000 231d b600 4157 2ab4
    00000b0: 002a b600 452a b400 55b6 0049 9eff d41d
    00000c0: 1904 c000 23b6 005f b0                 
  Stackmap Table:
    same_frame(@11)
    same_frame(@54)
    same_frame_extended(@144)

    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3549)
    at java.base/java.lang.Class.getConstructor0(Class.java:3754)
    at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930)
    at arb4j/arb.expressions.Expression.constructNewInstance(Expression.java:1154)
    at arb4j/arb.expressions.Expression.instantiate(Expression.java:1142)
    at arb4j/arb.expressions.Expression.instantiate(Expression.java:126)
    at arb4j/arb.functions.Function.express(Function.java:154)
    at arb4j/arb.expressions.nodes.nary.ProductTest.testRatioOfProducts(ProductTest.java:59)
    at 
crowlogic commented 8 months ago

theres nothing on the stack for the Real.div invocation to consume in the output generated with compute_frames at byte code index 197

  public arb.Real evaluate(arb.Integer, int, int, arb.Real);
    descriptor: (Ljava/lang/Object;IILjava/lang/Object;)Ljava/lang/Object;
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=10, locals=10, args_size=5
         0: aload_0
         1: getfield      #14                 // Field isInitialized:Z
         4: ifne          11
         7: aload_0
         8: invokevirtual #18                 // Method initialize:()V
        11: aload_0
        12: getfield      #22                 // Field factorℝ1:Lfactorℝ1;
        15: aload_1
        16: checkcast     #24                 // class arb/Integer
        19: putfield      #29                 // Field factorℝ1.n:Larb/Integer;
        22: aload_0
        23: getfield      #33                 // Field productℝ1:Larb/Real;
        26: invokevirtual #39                 // Method arb/Real.multiplicativeIdentity:()Larb/Real;
        29: pop
        30: aload_0
        31: getfield      #42                 // Field k:Larb/Integer;
        34: aload_0
        35: getfield      #45                 // Field c1:Larb/Integer;
        38: invokevirtual #49                 // Method arb/Integer.set:(Larb/Integer;)Larb/Integer;
        41: pop
        42: aload_0
        43: getfield      #52                 // Field endIndexℤ1:Larb/Integer;
        46: aload_0
        47: getfield      #55                 // Field p:Larb/Integer;
        50: invokevirtual #49                 // Method arb/Integer.set:(Larb/Integer;)Larb/Integer;
        53: pop
        54: aload_0
        55: getfield      #33                 // Field productℝ1:Larb/Real;
        58: aload_0
        59: getfield      #22                 // Field factorℝ1:Lfactorℝ1;
        62: aload_0
        63: getfield      #42                 // Field k:Larb/Integer;
        66: iload_3
        67: aload_0
        68: getfield      #58                 // Field valueℝ1:Larb/Real;
        71: invokeinterface #61,  4           // InterfaceMethod arb/functions/Function.evaluate:(Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/Object;
        76: checkcast     #35                 // class arb/Real
        79: iload_3
        80: invokevirtual #65                 // Method arb/Real.mul:(Larb/Real;I)Larb/Real;
        83: pop
        84: aload_0
        85: getfield      #42                 // Field k:Larb/Integer;
        88: invokevirtual #69                 // Method arb/Integer.increment:()Larb/Integer;
        91: aload_0
        92: getfield      #52                 // Field endIndexℤ1:Larb/Integer;
        95: invokevirtual #73                 // Method arb/Integer.compareTo:(Larb/Integer;)I
        98: ifle          54
       101: aload_0
       102: getfield      #77                 // Field factorℝ2:Lfactorℝ2;
       105: aload_1
       106: checkcast     #24                 // class arb/Integer
       109: putfield      #79                 // Field factorℝ2.n:Larb/Integer;
       112: aload_0
       113: getfield      #82                 // Field productℝ2:Larb/Real;
       116: invokevirtual #39                 // Method arb/Real.multiplicativeIdentity:()Larb/Real;
       119: pop
       120: aload_0
       121: getfield      #42                 // Field k:Larb/Integer;
       124: aload_0
       125: getfield      #45                 // Field c1:Larb/Integer;
       128: invokevirtual #49                 // Method arb/Integer.set:(Larb/Integer;)Larb/Integer;
       131: pop
       132: aload_0
       133: getfield      #85                 // Field endIndexℤ2:Larb/Integer;
       136: aload_0
       137: getfield      #88                 // Field q:Larb/Integer;
       140: invokevirtual #49                 // Method arb/Integer.set:(Larb/Integer;)Larb/Integer;
       143: pop
       144: aload_0
       145: getfield      #82                 // Field productℝ2:Larb/Real;
       148: aload_0
       149: getfield      #77                 // Field factorℝ2:Lfactorℝ2;
       152: aload_0
       153: getfield      #42                 // Field k:Larb/Integer;
       156: iload_3
       157: aload_0
       158: getfield      #91                 // Field valueℝ2:Larb/Real;
       161: invokeinterface #61,  4           // InterfaceMethod arb/functions/Function.evaluate:(Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/Object;
       166: checkcast     #35                 // class arb/Real
       169: iload_3
       170: invokevirtual #65                 // Method arb/Real.mul:(Larb/Real;I)Larb/Real;
       173: pop
       174: aload_0
       175: getfield      #42                 // Field k:Larb/Integer;
       178: invokevirtual #69                 // Method arb/Integer.increment:()Larb/Integer;
       181: aload_0
       182: getfield      #85                 // Field endIndexℤ2:Larb/Integer;
       185: invokevirtual #73                 // Method arb/Integer.compareTo:(Larb/Integer;)I
       188: ifle          144
       191: iload_3
       192: aload         4
       194: checkcast     #35                 // class arb/Real
       197: invokevirtual #95                 // Method arb/Real.div:(Larb/Real;ILarb/Real;)Larb/Real;
       200: areturn
      StackMapTable: number_of_entries = 3
        frame_type = 11 /* same */
        frame_type = 42 /* same */
        frame_type = 251 /* same_frame_extended */
          offset_delta = 89
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0     201     0  this   LF;
            0     201     1    in   Larb/Integer;
            0     201     2 order   I
            0     201     3  bits   I
            0     201     4 result   Larb/Real;
    Signature: #10                          // (Larb/Integer;IILarb/Real;)Larb/Real;