Skip to content

Compiling never end with some code examples #439

Description

@MaxGraey

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

Activity

  1. dcodeIO commented on Jan 27, 2019

    @dcodeIO
    Member

    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

  2. dcodeIO commented on Jan 27, 2019

    @dcodeIO
    Member

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

  3. MaxGraey commented on Sep 10, 2019

    @MaxGraey
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions