Skip to content

Refactor stack IR / binary writer (NFC)#2250

Merged
aheejin merged 7 commits intoWebAssembly:masterfrom
aheejin:stack_ir_refactor
Jul 23, 2019
Merged

Refactor stack IR / binary writer (NFC)#2250
aheejin merged 7 commits intoWebAssembly:masterfrom
aheejin:stack_ir_refactor

Conversation

@aheejin
Copy link
Copy Markdown
Member

@aheejin aheejin commented Jul 22, 2019

Previously StackWriter and its subclasses had routines for all three
modes (Binaryen2Binary, Binaryen2Stack, and Stack2Binary) within a
single class. This splits routines for each in a separate class and
also factors out binary writing into a separate class
(BinaryInstWriter) so other classes can make use of it.

The new classes are:

  • BinaryInstWriter:
    Binary instruction writer. Only responsible for emitting binary
    contents and no other logic
  • BinaryenIRWriter: Converts binaryen IR into something else
    • BinaryenIRToBinaryWriter: Writes binaryen IR to binary
    • StackIRGenerator: Converts binaryen IR to stack IR
  • StackIRToBinaryWriter: Writes stack IR to binary

I didn't use the existing ***StackWriter names because I couldn't
exactly understand their meanings, but I can rename classes to resemble
previous names if people suggest it.

Previously `StackWriter` and its subclasses had routines for all three
modes (`Binaryen2Binary`, `Binaryen2Stack`, and `Stack2Binary`) within a
single class. This splits routines for each in a separate class and
also factors out binary writing into a separate class
(`BinaryInstWriter`) so other classes can make use of it.

The new classes are:
- `BinaryInstWriter`:
   Binary instruction writer. Only responsible for emitting binary
   contents and no other logic
- `BinaryenIRWriter`: Converts binaryen IR into something else
  - `BinaryenIRToBinaryWriter`: Writes binaryen IR to binary
  - `StackIRGenerator`: Converts binaryen IR to stack IR
- `StackIRToBinaryWriter`: Writes stack IR to binary

I didn't use the existing `***StackWriter` names because I couldn't
exactly understand their meanings, but I can rename classes to resemble
previous names if people suggest it.
@aheejin aheejin changed the title Refactor stack IR / binary writer Refactor stack IR / binary writer (NFC) Jul 22, 2019
Copy link
Copy Markdown
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Very nice! Much better than before.

New names look good too.

Comment thread src/wasm-stack.h Outdated
Comment thread src/wasm/wasm-binary.cpp Outdated
@kripken
Copy link
Copy Markdown
Member

kripken commented Jul 23, 2019

Looks like this CI problem is unrelated to your PR, I just saw it after I merged another green PR to master. It was green 2 days ago, but was red when it landed, so some CI infra change over the last day or so seems to be at fault,

https://travis-ci.org/WebAssembly/binaryen/jobs/562365712

Copy link
Copy Markdown
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

I think this organization looks much more robust 👍

Comment thread src/wasm-stack.h Outdated
Comment thread src/wasm/wasm-stack.cpp Outdated
@aheejin aheejin merged commit 00d02f7 into WebAssembly:master Jul 23, 2019
@aheejin aheejin deleted the stack_ir_refactor branch July 23, 2019 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants