1. 29 May, 2017 1 commit
    • Clemens Hammacher's avatar
      [wasm] Avoid reporting of unrelated compiler errors · ff7bf332
      Clemens Hammacher authored
      It happens frequently that unrelated compiler errors lead to the
      instantiation of {read_leb_tail} with an invalid {byte_index}, which
      again triggers compiler errors.
      This change fixes this, such that illegal instantiation just triggers a
      static_assert and nothing more. This helps to spot the actual error.
      
      Drive-by: Mark {Min} and {Max} constexpr, such that they can produce
      constexpr results. Note that the result will only be constexpr if both
      arguments are constexpr.
      
      R=ahaas@chromium.org
      
      Change-Id: I35d6865a7f569d72ace0debb045ac615cfd87d92
      Reviewed-on: https://chromium-review.googlesource.com/518005Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
      Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#45558}
      ff7bf332
  2. 17 May, 2017 1 commit
    • Andreas Haas's avatar
      [wasm] Refactor the module decoder to work with section bytes · a8424d59
      Andreas Haas authored
      This CL refactors the module decoder so that it can process a list of
      section buffers instead of one module buffer. This change is needed for
      streaming compilation. Streaming compilation may require additional
      changes.
      
      This CL introduces the following interface to the module decoder:
      StartDecoding -- starts the decoding
      DecodeModuleHeader -- decodes the module header
      DecodeSection -- decodes the section
      FinishDecoding -- finishes the decoding and returns the WasmModule
      
      Aside from the different interface the biggest change to the module
      decoder is the introduction of a buffer_offset, which is the offset
      of the current section buffer of the module decoder in the module bytes.
      This buffer_offset is used to translate from section offsets to module
      offsets and back.
      
      Another nice change is that the module decoder does not have a zone
      anymore. Instead the zone is stored directly in the WasmModule where
      it belongs. Zone ownership is also more obvious now.
      
      R=mtrofin@chromium.org, clemensh@chromium.org
      
      Change-Id: I815d777ec380f4c617c39e828ea0c9746c0bae20
      Reviewed-on: https://chromium-review.googlesource.com/505490
      Commit-Queue: Andreas Haas <ahaas@chromium.org>
      Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#45374}
      a8424d59
  3. 15 May, 2017 1 commit
    • Clemens Hammacher's avatar
      [wasm] Speed up LEB decoding · 79b075be
      Clemens Hammacher authored
      Speed up LEB decoding by forcing the decoding loop to be unrolled.
      Even though the compiler was free to unroll the loop before, clang did
      not do so. We now manually unroll by using a template function which
      calls itself recursively, passing the byte index to be decoded next.
      For efficient execution, we still depend on the compiler to inline the
      recursive calls (which clang does).
      
      This optimization speeds up interpreted execution of the Jetstream
      benchmarks by 15 percent.
      Speedup on module decoding is negligible though.
      
      Drive-by: Change "unsigned" to "uint32_t".
      
      R=ahaas@chromium.org
      BUG=v8:5822
      
      Change-Id: I06d4230f92bfb2a80cdc5029d965fc3bf84ca1cc
      Reviewed-on: https://chromium-review.googlesource.com/506188
      Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
      Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#45308}
      79b075be
  4. 11 May, 2017 1 commit
    • Andreas Haas's avatar
      [wasm] Change the error_pc in the decoder to error_offset · 47e6e260
      Andreas Haas authored
      The error_pc was only used to calculated the relative error offset.
      Switching to an error_offset directly will allow us later to give the
      decoder a base offset. Thereby we can get correct error
      positions even when the decoder is executed on multiple memory chunks,
      which will happen with streaming compilation. With this change I also
      had to provide "kind of" reasonable error position in the
      StreamingDecoder.
      
      R=clemensh@chromium.org
      
      Change-Id: I736fa082c51c64334d23771061acf97e2c47778e
      Reviewed-on: https://chromium-review.googlesource.com/502909
      Commit-Queue: Andreas Haas <ahaas@chromium.org>
      Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#45264}
      47e6e260
  5. 28 Apr, 2017 1 commit
  6. 11 Apr, 2017 1 commit
    • kmackay's avatar
      Add some missing stdarg includes · f7e76cde
      kmackay authored
      One of our internal Chromecast builds was failing due to undefined
      va_list in wasm-result.h. I also searched for other files where va_list
      was used without including stdarg.h and added it as necessary (since
      include-what-you-use is a thing).
      
      BUG=chromium:706443
      
      Review-Url: https://codereview.chromium.org/2780913002
      Cr-Commit-Position: refs/heads/master@{#44588}
      f7e76cde
  7. 10 Apr, 2017 3 commits
    • Clemens Hammacher's avatar
      [wasm] Stop decoding sections once an error occured · 88e169dc
      Clemens Hammacher authored
      We went on decoding the next section, which happened to be the start
      section. But since the function section had an error, the signature
      pointer was not still {nullptr} on the start function, leading to a
      segfault.
      
      Drive-by fix: Improve decoder trace output.
      
      R=ahaas@chromium.org
      BUG=chromium:708714, chromium:708787
      
      Change-Id: I5ae2adb32764b9d154f1ca878019f26ac31839b4
      Reviewed-on: https://chromium-review.googlesource.com/472847Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
      Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#44521}
      88e169dc
    • Clemens Hammacher's avatar
      [wasm] Refactor wasm::Result type · d50ebde7
      Clemens Hammacher authored
      - Store std::string instead of std::unique_ptr<char[]> for the error
        message.
      - Remove ErrorCode, which was just kSuccess and kError anyway. Error is
        now detected on whether error_msg_ is empty or not.
      - Refactor constructors for perfect forwarding; this will allow us to
        implement Result<std::unique_ptr<X*>>.
      - Refactor Decoder::toResult for perfect forwarding.
      - Remove output operators (operator<<) for Result; it was only used in
        the error case anyway. Print error message directly instead.
        The operator was problematic since it assumed the existence of an
        output operator for every T which is used in Result<T>.
      - Remove ModuleError and FunctionError, introduce general static
        Result<T>::Error method instead.
      
      R=ahaas@chromium.org
      
      Change-Id: I1e0f602a61ee9780fee2a3ed33147d431fb092ba
      Reviewed-on: https://chromium-review.googlesource.com/472748
      Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
      Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#44518}
      d50ebde7
    • Andreas Haas's avatar
      [wasm] Refactor the Result object · e313bc17
      Andreas Haas authored
      Instead of storing {start} and {error_pc} we now store the
      {error_offset}, which is anyways the only value we use.
      
      R=clemensh@chromium.org
      
      Change-Id: Ifd9791eff5c9efce2e7e2a1989bf3b5eaa464a02
      Reviewed-on: https://chromium-review.googlesource.com/471527
      Commit-Queue: Andreas Haas <ahaas@chromium.org>
      Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#44510}
      e313bc17
  8. 05 Apr, 2017 2 commits
    • Clemens Hammacher's avatar
      [wasm] [decoder] Templatize decode function for unchecked decoding · eeaceccb
      Clemens Hammacher authored
      In the C++ wasm interpreter, we decode LEB encoded immediates each time
      we execute the respective instruction. The whole instruction sequence
      was validated before, thus we know that all integers are valid.
      This CL refactors several Decoder methods to allow for either checked
      or unchecked decoding. In the checked case, an error is set if a check
      fails, in the unchecked case, a DCHECK will fail.
      
      This improves performance of the interpreter by 20.5%.
      
      R=ahaas@chromium.org
      BUG=v8:5822
      
      Change-Id: If69efd4f6fbe19d84bfc2f4aa000f429a8e22bf5
      Reviewed-on: https://chromium-review.googlesource.com/468786
      Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
      Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#44406}
      eeaceccb
    • Clemens Hammacher's avatar
      [wasm] [decoder] Merge checked_read_leb and consume_leb · 02b4d0e6
      Clemens Hammacher authored
      Both methods decoded a LEB128 encoded integer, but only consume_leb
      incremented the pc pointer accordingly.
      This CL implements consume_leb by using checked_read_leb.
      
      It also refactors a few things:
      1) It removes error_pt, which was only avaible in checked_read_leb.
      2) It renames the error method to errorf, since it receives a format
         string. This also avoids a name clash.
      3) It implements sign extension directly in checked_read_leb instead of
         doing this in the caller.
      
      R=ahaas@chromium.org
      BUG=v8:5822
      
      Change-Id: I8058f57418493861e5df26d4949041f6766d5138
      Reviewed-on: https://chromium-review.googlesource.com/467150
      Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
      Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#44405}
      02b4d0e6
  9. 02 Feb, 2017 1 commit
  10. 24 Jan, 2017 1 commit
  11. 06 Jan, 2017 3 commits
  12. 12 Oct, 2016 1 commit
    • clemensh's avatar
      [wasm] Fix decoder for null data · e7a00891
      clemensh authored
      If passing <nullptr, 0> to the decoder and trying to decode something,
      it correctly detects the error and sets an error message, but still
      returns true on ok(), and returns a valid result.
      I triggered this error by passing a null Vector, returned by FindSection(), to
      the decoder.
      
      R=titzer@chromium.org
      
      Review-Url: https://codereview.chromium.org/2410913002
      Cr-Commit-Position: refs/heads/master@{#40204}
      e7a00891
  13. 11 Oct, 2016 1 commit
  14. 27 Sep, 2016 1 commit
    • titzer's avatar
      [wasm] Master CL for Binary 0xC changes. · 28392ab1
      titzer authored
      [0xC] Convert to stack machine semantics.
      [0xC] Use section codes instead of names.
      [0xC] Add elements section decoding.
      [0xC] Decoding of globals section.
      [0xC] Decoding of memory section.
      [0xC] Decoding of imports section.
      [0xC] Decoding of exports section.
      [0xC] Decoding of data section.
      [0xC] Remove CallImport bytecode.
      [0xC] Function bodies have an implicit block.
      [0xC] Remove the bottom label from loops.
      [0xC] Add signatures to blocks.
      [0xC] Remove arities from branches.
      Add tests for init expression decoding.
      Rework compilation of import wrappers and how they are patched.
      Rework function indices in debugging.
      Fix ASM->WASM builder for stack machine.
      Reorganize asm.js foreign functions due to import indices change.
      
      R=ahaas@chromium.org,rossberg@chromium.org,bradnelson@chromium.org
      BUG=chromium:575167
      LOG=Y
      
      Committed: https://crrev.com/76eb976a67273b8c03c744f64ad850b0432554b9
      Review-Url: https://codereview.chromium.org/2345593003
      Cr-Original-Commit-Position: refs/heads/master@{#39678}
      Cr-Commit-Position: refs/heads/master@{#39795}
      28392ab1
  15. 23 Sep, 2016 2 commits
    • machenbach's avatar
      Revert of [wasm] Master CL for Binary 0xC changes. (patchset #26 id:490001 of... · e1eee748
      machenbach authored
      Revert of [wasm] Master CL for Binary 0xC changes. (patchset #26 id:490001 of https://codereview.chromium.org/2345593003/ )
      
      Reason for revert:
      Main suspect for tsan:
      https://build.chromium.org/p/client.v8/builders/V8%20Linux64%20TSAN/builds/11893
      
      Also changes layout tests:
      https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064/builds/10036
      
      +mips builder:
      https://build.chromium.org/p/client.v8.ports/builders/V8%20Mips%20-%20builder/builds/4032
      
      Original issue's description:
      > [wasm] Master CL for Binary 0xC changes.
      >
      > [0xC] Convert to stack machine semantics.
      > [0xC] Use section codes instead of names.
      > [0xC] Add elements section decoding.
      > [0xC] Decoding of globals section.
      > [0xC] Decoding of memory section.
      > [0xC] Decoding of imports section.
      > [0xC] Decoding of exports section.
      > [0xC] Decoding of data section.
      > [0xC] Remove CallImport bytecode.
      > [0xC] Function bodies have an implicit block.
      > [0xC] Remove the bottom label from loops.
      > [0xC] Add signatures to blocks.
      > [0xC] Remove arities from branches.
      > Add tests for init expression decoding.
      > Rework compilation of import wrappers and how they are patched.
      > Rework function indices in debugging.
      > Fix ASM->WASM builder for stack machine.
      > Reorganize asm.js foreign functions due to import indices change.
      >
      > R=ahaas@chromium.org,rossberg@chromium.org,bradnelson@chromium.org
      > BUG=chromium:575167
      > LOG=Y
      >
      > Committed: https://crrev.com/76eb976a67273b8c03c744f64ad850b0432554b9
      > Cr-Commit-Position: refs/heads/master@{#39678}
      
      TBR=ahaas@chromium.org,bradnelson@chromium.org,mtrofin@chromium.org,rossberg@chromium.org,bradnelson@google.com,titzer@chromium.org
      # Skipping CQ checks because original CL landed less than 1 days ago.
      NOPRESUBMIT=true
      NOTREECHECKS=true
      NOTRY=true
      BUG=chromium:575167
      
      Review-Url: https://codereview.chromium.org/2361053004
      Cr-Commit-Position: refs/heads/master@{#39685}
      e1eee748
    • titzer's avatar
      [wasm] Master CL for Binary 0xC changes. · 76eb976a
      titzer authored
      [0xC] Convert to stack machine semantics.
      [0xC] Use section codes instead of names.
      [0xC] Add elements section decoding.
      [0xC] Decoding of globals section.
      [0xC] Decoding of memory section.
      [0xC] Decoding of imports section.
      [0xC] Decoding of exports section.
      [0xC] Decoding of data section.
      [0xC] Remove CallImport bytecode.
      [0xC] Function bodies have an implicit block.
      [0xC] Remove the bottom label from loops.
      [0xC] Add signatures to blocks.
      [0xC] Remove arities from branches.
      Add tests for init expression decoding.
      Rework compilation of import wrappers and how they are patched.
      Rework function indices in debugging.
      Fix ASM->WASM builder for stack machine.
      Reorganize asm.js foreign functions due to import indices change.
      
      R=ahaas@chromium.org,rossberg@chromium.org,bradnelson@chromium.org
      BUG=chromium:575167
      LOG=Y
      
      Review-Url: https://codereview.chromium.org/2345593003
      Cr-Commit-Position: refs/heads/master@{#39678}
      76eb976a
  16. 20 Sep, 2016 1 commit
  17. 25 Jul, 2016 2 commits
  18. 29 Jun, 2016 1 commit
  19. 27 Jun, 2016 1 commit
    • ddchen's avatar
      [wasm] improve handling of malformed inputs · fd2bf837
      ddchen authored
      When reading malformed input, the length of variable-length types can be very large. Computing operand length with this and adding it to PC will overflow and screw up decode.
      
      This patch switches to unsigned int for arity and lengths, terminates loop analysis on error, adds overflow checking to BranchTableOperand, and adds a unit test.
      
      Review-Url: https://codereview.chromium.org/2052623003
      Cr-Commit-Position: refs/heads/master@{#37301}
      fd2bf837
  20. 24 Jun, 2016 1 commit
  21. 20 Jun, 2016 1 commit
  22. 17 Jun, 2016 1 commit
    • ivica.bogosavljevic's avatar
      Implement WASM big-endian support. · d3f3f6c8
      ivica.bogosavljevic authored
      Implement WASM support on big-endian platforms. WASM has
      an implicit requirement that it is running on little-endian
      machine. We achieve WASM support on BE by keeping data
      in memory in little-endian order, and changing data
      endianness before storing to memory and after loading from
      memory.
      
      BUG=
      
      Review-Url: https://codereview.chromium.org/2034093002
      Cr-Commit-Position: refs/heads/master@{#37065}
      d3f3f6c8
  23. 16 Jun, 2016 1 commit
  24. 12 Apr, 2016 1 commit
  25. 11 Apr, 2016 2 commits
  26. 08 Apr, 2016 2 commits
    • jfb's avatar
      Revert of Fix printf formats (patchset #8 id:140001 of... · 4c4fdc2d
      jfb authored
      Revert of Fix printf formats (patchset #8 id:140001 of https://codereview.chromium.org/1869433004/ )
      
      Reason for revert:
      One small issue easily fixed here: https://codereview.chromium.org/1867333003/
      
      But it looks like MSVS 2013 doesn't like some of the formats and exists with the unhelpful:
      Stderr:
      f:\dd\vctools\crt\crtw32\stdio\output.c(1125) : Assertion failed: ("Incorrect
      format specifier", 0)
      
      It's easier to revert for now, I'll dig more into the docs:
      https://msdn.microsoft.com/en-us/library/56e442dc(v=vs.120).aspx
      https://msdn.microsoft.com/en-us/library/tcxf1dw6(v=vs.120).aspx
      
      And then resubmit, making sure I run these bots.
      
      Original issue's description:
      > Fix printf formats
      >
      > The usage of __attribute__((format(x, y)) was either wrong or missing from multiple functions, leading to erroneous formats. This CL:
      >
      >  - Imports PRINTF_FORMAT macro from Chrome's src/base/compiler-specific.h.
      >  - Uses it appropriately.
      >  - Imports Chrome's base/format_macros.h mainly to fix size_t formats (further cleanup could be done).
      >  - Fixes a bunch of incorrect formats.
      >
      > R= jochen@chromium.org, bmeurer@chromium.org, yangguo@chromium.org, ahaas@chromium.org
      >
      > Committed: https://crrev.com/6ebf9fbb93d31f9be41156a3325d58704ed4933d
      > Cr-Commit-Position: refs/heads/master@{#35365}
      
      TBR=jochen@chromium.org,bmeurer@chromium.org,yangguo@chromium.org,ahaas@chromium.org
      # Skipping CQ checks because original CL landed less than 1 days ago.
      NOPRESUBMIT=true
      NOTREECHECKS=true
      NOTRY=true
      
      Review URL: https://codereview.chromium.org/1867383002
      
      Cr-Commit-Position: refs/heads/master@{#35366}
      4c4fdc2d
    • jfb's avatar
      Fix printf formats · 6ebf9fbb
      jfb authored
      The usage of __attribute__((format(x, y)) was either wrong or missing from multiple functions, leading to erroneous formats. This CL:
      
       - Imports PRINTF_FORMAT macro from Chrome's src/base/compiler-specific.h.
       - Uses it appropriately.
       - Imports Chrome's base/format_macros.h mainly to fix size_t formats (further cleanup could be done).
       - Fixes a bunch of incorrect formats.
      
      R= jochen@chromium.org, bmeurer@chromium.org, yangguo@chromium.org, ahaas@chromium.org
      
      Review URL: https://codereview.chromium.org/1869433004
      
      Cr-Commit-Position: refs/heads/master@{#35365}
      6ebf9fbb
  27. 05 Apr, 2016 1 commit
  28. 10 Mar, 2016 1 commit
  29. 09 Mar, 2016 2 commits
  30. 07 Mar, 2016 1 commit
    • titzer's avatar
      [wasm] Rework encoding of local declarations. · 835c5e6b
      titzer authored
      Local declarations were previously encoded as an optional set of
      4 uint16 values as part of the function declaration. This CL
      implements the current design of moving these declarations to
      a list of pairs of (type, count) that is part of the body.
      
      R=bradnelson@chromium.org,binji@chromium.org
      BUG=
      
      Review URL: https://codereview.chromium.org/1763433002
      
      Cr-Commit-Position: refs/heads/master@{#34564}
      835c5e6b