mozilla / pluotsorbet

[ARCHIVED] PluotSorbet is a J2ME-compatible virtual machine written in JavaScript.
GNU General Public License v2.0
240 stars 46 forks source link

Add a test to ensure we don't regress https://github.com/mozilla/j2me.js/pull/1325 #1331

Open marco-c opened 9 years ago

marco-c commented 9 years ago

We should add a Jasmin test that does something like this: public synchronized void method() iconst_0 istore_0

This way we override the first local with the integer value 0

marco-c commented 9 years ago

An example of a compiled function is in https://github.com/mozilla/j2me.js/pull/1312#issuecomment-86294585.

The bytecode of the function is:

  public synchronized java.util.TimeZone getInstance(java.lang.String);
    descriptor: (Ljava/lang/String;)Ljava/util/TimeZone;
    flags: ACC_PUBLIC, ACC_SYNCHRONIZED
    Code:
      stack=2, locals=2, args_size=2
         0: aload_1
         1: ifnonnull     33
         4: getstatic     #164                // Field HOME_ID:Ljava/lang/String;
         7: ifnonnull     29
        10: ldc           #4                  // String com.sun.cldc.util.j2me.TimeZoneImpl.timezone
        12: invokestatic  #93                 // Method java/lang/System.getProperty:(Ljava/lang/String;)Ljava/lang/String;
        15: putstatic     #164                // Field HOME_ID:Ljava/lang/String;
        18: getstatic     #164                // Field HOME_ID:Ljava/lang/String;
        21: ifnonnull     29
        24: ldc           #136                // String UTC
        26: putstatic     #164                // Field HOME_ID:Ljava/lang/String;
        29: getstatic     #164                // Field HOME_ID:Ljava/lang/String;
        32: astore_1
        33: iconst_0
        34: istore_0
        35: iload_0
        36: getstatic     #112                // Field zones:[Ljava/util/TimeZone;
        39: arraylength
        40: if_icmpge     73
        43: getstatic     #112                // Field zones:[Ljava/util/TimeZone;
        46: iload_0
        47: aaload
        48: checkcast     #133                // class com/sun/cldc/util/j2me/TimeZoneImpl
        51: getfield      #141                // Field ID:Ljava/lang/String;
        54: aload_1
        55: invokevirtual #89                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
        58: ifeq          67
        61: getstatic     #112                // Field zones:[Ljava/util/TimeZone;
        64: iload_0
        65: aaload
        66: areturn
        67: iinc          0, 1
        70: goto          35
        73: aload_1
        74: invokestatic  #159                // Method parseCustomTimeZone:(Ljava/lang/String;)Ljava/util/TimeZone;
        77: areturn