Skip to content

opcodes for known sections#1460

Merged
chakrabot merged 2 commits intochakra-core:WebAssemblyfrom
Krovatkin:known_sections
Sep 28, 2016
Merged

opcodes for known sections#1460
chakrabot merged 2 commits intochakra-core:WebAssemblyfrom
Krovatkin:known_sections

Conversation

@Krovatkin
Copy link
Collaborator

@Krovatkin Krovatkin commented Aug 17, 2016

Per WebAssembly/design#740
this adds a few bits to support opcodes for known sections
fyi @commonlisp @arunetm

@cellulle @MikeHolman homeless PR looks for a nice review and branch to be adopted into


This change is Reviewable

// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

const blob = WScript.LoadBinaryFile('f32_known_sections.wasm');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a simpler test case for this?

@commonlisp
Copy link
Collaborator

Looks like we have to rebase this one.

@Krovatkin Krovatkin force-pushed the known_sections branch 2 times, most recently from 42fba25 to 6d9b004 Compare September 20, 2016 00:01
@commonlisp
Copy link
Collaborator

@Cellule Just want to put this on your radar since other changes (globals and table/elements) will depend on it.

@Cellule
Copy link
Contributor

Cellule commented Sep 22, 2016

Reviewed 1 of 4 files at r1, 9 of 11 files at r2.
Review status: all files reviewed at latest revision, 5 unresolved discussions.


lib/WasmReader/WasmBinaryReader.cpp, line 177 at r2 (raw file):

    else
    {
        sectionName = (char*)(m_pc); //including "name" section

You are capturing the pointer too soon, you must read the length first then do sectionName = m_pc.
Right now, the name string will include the leb128 encoded length


lib/WasmReader/WasmBinaryReader.cpp, line 179 at r2 (raw file):

        sectionName = (char*)(m_pc); //including "name" section
        nameLength = LEB128(len);
        m_pc += nameLength; //skip section name for now

Should add a check here CheckBytesLeft(nameLength); before moving the pointer.


lib/WasmReader/WasmBinaryReader.cpp, line 182 at r2 (raw file):

    }

    sectionSize = LEB128(len);

According to Section Header
The sectionSize comes before the name and after the id.
Also, the end is calculated with payload_len - sizeof(name) - sizeof(name_len)


lib/WasmReader/WasmBinaryReader.cpp, line 187 at r2 (raw file):

#if ENABLE_DEBUG_CONFIG_OPTIONS
    Assert(nameLength < 64);

While your at it, instead of an assert, could you make this a check and just print Unknown section name if the length is greater than 64.


test/rlexedirs.xml, line 376 at r2 (raw file):

<dir>
  <default>
    <files>WasmSpec</files>

This is going to conflict with George's change.
I suggest to wait until he merges it than resolve this file using his version since I prefer to comment out these tests for the time being rather than deleting it.


Comments from Reviewable

@Krovatkin
Copy link
Collaborator Author

@Cellule that's amazing how much I managed to mess up in like 10 lines of code :-)))))) Regarding removing the tests George and I weren't quite sure which change goes first. Apparently his does :-) I'll back out that part and fix the rest.

@Krovatkin
Copy link
Collaborator Author

@Cellule updated the PR.

@Cellule
Copy link
Contributor

Cellule commented Sep 27, 2016

Reviewed 9 of 10 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


lib/WasmReader/WasmBinaryReader.cpp, line 178 at r3 (raw file):

    }
    else
    {

What happens to header.code in this scenario ?
I assume it keeps it default value, should we have a value that means user section ?


Comments from Reviewable

@Krovatkin
Copy link
Collaborator Author

lib/WasmReader/WasmBinaryReader.cpp, line 178 at r3 (raw file):

Previously, Cellule (Michael Ferris) wrote…

What happens to header.code in this scenario ?
I assume it keeps it default value, should we have a value that means user section ?

hhmmm, it is unlikely that it gets a default value, since its parent structure starts out as an uninitialized struct :-( I think adding an explicit user section is a really great idea. I updated the PR

Comments from Reviewable

@Cellule
Copy link
Contributor

Cellule commented Sep 28, 2016

:lgtm:


Reviewed 2 of 2 files at r4.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@Krovatkin
Copy link
Collaborator Author

@arunetm Could you please merge this when you have a mnt?

@chakrabot chakrabot merged commit f1cd176 into chakra-core:WebAssembly Sep 28, 2016
chakrabot pushed a commit that referenced this pull request Sep 28, 2016
Merge pull request #1460 from Krovatkin:known_sections

Per WebAssembly/design#740
this adds a few bits to support opcodes for known sections
fyi @commonlisp  @arunetm

@cellulle @MikeHolman homeless PR looks for a nice review and branch to be adopted into

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/microsoft/chakracore/1460)
<!-- Reviewable:end -->
@arunetm-zz
Copy link
Contributor

Merged to WebAssembly branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants