Skip to content

Compiling never end with some code examples #439

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

Closed
MaxGraey opened this issue Jan 26, 2019 · 3 comments
Closed

Compiling never end with some code examples #439

MaxGraey opened this issue Jan 26, 2019 · 3 comments
Labels

Comments

@MaxGraey
Copy link
Member

MaxGraey commented Jan 26, 2019

Minimal example:

const HEX_CHARS: string[] = [
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  'a', 'b', 'c', 'd', 'e', 'f'
];

export class Sha1 {
  hex(): string {
    let 
      h0 = 0,
      h1 = 1,
      h2 = 2;

    return (
      HEX_CHARS[(h0 >> 28) & 0x0f] +
      HEX_CHARS[(h0 >> 24) & 0x0f] +
      HEX_CHARS[(h0 >> 20) & 0x0f] +
      HEX_CHARS[(h0 >> 16) & 0x0f] +
      HEX_CHARS[(h0 >> 12) & 0x0f] +
      HEX_CHARS[(h0 >>  8) & 0x0f] +
      HEX_CHARS[(h0 >>  4) & 0x0f] +
      HEX_CHARS[h0 & 0x0f] +
      HEX_CHARS[(h1 >> 28) & 0x0f] +
      HEX_CHARS[(h1 >> 24) & 0x0f] +
      HEX_CHARS[(h1 >> 20) & 0x0f] +
      HEX_CHARS[(h1 >> 16) & 0x0f] +
      HEX_CHARS[(h1 >> 12) & 0x0f] +
      HEX_CHARS[(h1 >>  8) & 0x0f] +
      HEX_CHARS[(h1 >>  4) & 0x0f] +
      HEX_CHARS[h1 & 0x0f] +
      HEX_CHARS[(h2 >> 28) & 0x0f] +
      HEX_CHARS[(h2 >> 24) & 0x0f] +
      HEX_CHARS[(h2 >> 20) & 0x0f] +
      HEX_CHARS[(h2 >> 16) & 0x0f] +
      HEX_CHARS[(h2 >> 12) & 0x0f] +
      HEX_CHARS[(h2 >>  8) & 0x0f] +
      HEX_CHARS[(h2 >>  4) & 0x0f]
    );
  }
}

Fiddle: https://webassembly.studio/?f=e4eouana0fl

NOTE:
If comment last 8 elements compiler finished but after some unexpected long time

@dcodeIO
Copy link
Member

dcodeIO commented Jan 27, 2019

Seems the LHS (that grows from the left for each binary op) is recompiled over and over again due to: https://github.com/AssemblyScript/assemblyscript/blob/master/src/compiler.ts#L4661

@dcodeIO
Copy link
Member

dcodeIO commented Jan 27, 2019

Indirectly related, because it would aid in implementing calls (here: operator overloads that may be inlined) with less cognitive overhead: WebAssembly/binaryen#1889

@MaxGraey
Copy link
Member Author

It seems with latest changes this issue is gone! Close it

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