Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Rouge Release in #constructor #668

Closed
jtenner opened this issue Jun 14, 2019 · 0 comments
Closed

[Bug] Rouge Release in #constructor #668

jtenner opened this issue Jun 14, 2019 · 0 comments
Labels

Comments

@jtenner
Copy link
Contributor

jtenner commented Jun 14, 2019

Way to reproduce:

export class JValue {
  private byteLength: i32;

  public static Null: JNull = new JNull();
  constructor() {
    this.byteLength = 0;
  }
}


export class JNull extends JValue {
  constructor() { super(); } // remove this line
}

let a = new JNull();

When JNull is constructed without the constructor defined, it results in a release. I used -O3 to optimize the code so it was less confusing to follow. Here is the wat output without the constructor:

 (func $assembly/json/JNull/JNull#constructor (; 59 ;) (type $FUNCSIG$i) (result i32)
  (local $0 i32)
  i32.const 4
  i32.const 4
  call $~lib/rt/tlsf/__alloc
  call $~lib/rt/pure/__retain
  call $assembly/json/JValue/JValue#constructor
  local.tee $0
  call $~lib/rt/pure/__release
  local.get $0
 )
   [Error]: Orphaned Increment Error An orphaned increment has occurred at block: 3600
   [Stack]:     at ~lib/rt/pure/increment (wasm-function[42]:58)
               at ~lib/rt/pure/__retain (wasm-function[43]:14)
               at start:assembly/__tests__/JNull.spec~anonymous|0~anonymous|3 (wasm-function[84]:10)
               at node_modules/as-pect/assembly/internal/call/__call (wasm-function[91]:7)

When adding the constructor, it results in a more optimized output without the release.

 (func $assembly/json/JNull/JNull#constructor (; 59 ;) (type $FUNCSIG$i) (result i32)
  i32.const 4
  i32.const 4
  call $~lib/rt/tlsf/__alloc
  call $~lib/rt/pure/__retain
  call $assembly/json/JValue/JValue#constructor
 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants