Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wasm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
wasm-watermarker
Commits
39ff4a29
Commit
39ff4a29
authored
Nov 07, 2019
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Binaryen
1.38.32 -> 1.39.1
parent
3b144f8b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
28 deletions
+123
-28
binaryen.cmake
cmake/binaryen.cmake
+1
-1
Commutativity.hpp
src/kyut/Commutativity.hpp
+1
-1
Comparator.inl.hpp
src/kyut/Comparator.inl.hpp
+67
-18
OperandSwappingWatermarker.cpp
src/kyut/watermarker/OperandSwappingWatermarker.cpp
+54
-8
No files found.
cmake/binaryen.cmake
View file @
39ff4a29
ExternalProject_Add
(
binaryen
URL https://github.com/WebAssembly/binaryen/archive/1.3
8.32
.tar.gz
URL https://github.com/WebAssembly/binaryen/archive/1.3
9.1
.tar.gz
PREFIX binaryen
INSTALL_COMMAND
""
TEST_COMMAND
""
...
...
src/kyut/Commutativity.hpp
View file @
39ff4a29
...
...
@@ -9,7 +9,7 @@
namespace
kyut
{
[[
nodiscard
]]
inline
boost
::
optional
<
wasm
::
BinaryOp
>
getSwappedPredicate
(
wasm
::
BinaryOp
op
)
{
static_assert
(
wasm
::
InvalidBinary
==
15
2
);
static_assert
(
wasm
::
InvalidBinary
==
15
8
);
switch
(
op
)
{
// Commutative instructions
...
...
src/kyut/Comparator.inl.hpp
View file @
39ff4a29
...
...
@@ -24,7 +24,8 @@ namespace wasm {
return
a
.
getf64
()
<
b
.
getf64
();
case
v128
:
return
a
.
getv128
()
<
b
.
getv128
();
case
except_ref
:
case
anyref
:
case
exnref
:
return
false
;
case
unreachable
:
return
false
;
...
...
@@ -34,7 +35,7 @@ namespace wasm {
}
[[
nodiscard
]]
inline
bool
operator
<
(
const
Expression
&
a
,
const
Expression
&
b
)
{
static_assert
(
Expression
::
NumExpressionIds
==
36
);
static_assert
(
Expression
::
NumExpressionIds
==
44
);
constexpr
auto
opt
=
[](
const
Expression
*
p
)
->
boost
::
optional
<
const
Expression
&>
{
if
(
p
==
nullptr
)
{
...
...
@@ -94,27 +95,27 @@ namespace wasm {
return
std
::
forward_as_tuple
(
x
.
operands
,
*
x
.
target
)
<
std
::
forward_as_tuple
(
y
.
operands
,
*
y
.
target
);
}
case
Expression
:
:
GetLocal
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
GetLocal
>
();
const
auto
&
y
=
*
b
.
cast
<
GetLocal
>
();
case
Expression
:
:
LocalGet
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
LocalGet
>
();
const
auto
&
y
=
*
b
.
cast
<
LocalGet
>
();
return
x
.
index
<
y
.
index
;
}
case
Expression
:
:
SetLocal
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
SetLocal
>
();
const
auto
&
y
=
*
b
.
cast
<
SetLocal
>
();
case
Expression
:
:
LocalSet
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
LocalSet
>
();
const
auto
&
y
=
*
b
.
cast
<
LocalSet
>
();
return
std
::
tie
(
x
.
index
,
*
x
.
value
)
<
std
::
tie
(
y
.
index
,
*
y
.
value
);
}
case
Expression
:
:
G
etGlobal
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
G
etGlobal
>
();
const
auto
&
y
=
*
b
.
cast
<
G
etGlobal
>
();
case
Expression
:
:
G
lobalGet
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
G
lobalGet
>
();
const
auto
&
y
=
*
b
.
cast
<
G
lobalGet
>
();
return
x
.
name
<
y
.
name
;
}
case
Expression
:
:
SetGlobal
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
SetGlobal
>
();
const
auto
&
y
=
*
b
.
cast
<
SetGlobal
>
();
case
Expression
:
:
GlobalSet
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
GlobalSet
>
();
const
auto
&
y
=
*
b
.
cast
<
GlobalSet
>
();
return
std
::
tie
(
*
x
.
value
,
x
.
name
)
<
std
::
tie
(
*
y
.
value
,
y
.
name
);
}
...
...
@@ -221,6 +222,12 @@ namespace wasm {
return
std
::
tie
(
x
.
offset
.
addr
,
*
x
.
ptr
,
*
x
.
notifyCount
)
<
std
::
tie
(
y
.
offset
.
addr
,
*
y
.
ptr
,
*
y
.
notifyCount
);
}
case
Expression
:
:
AtomicFenceId
:
{
[[
maybe_unused
]]
const
auto
&
x
=
*
a
.
cast
<
AtomicFence
>
();
[[
maybe_unused
]]
const
auto
&
y
=
*
b
.
cast
<
AtomicFence
>
();
return
false
;
}
case
Expression
:
:
SIMDExtractId
:
{
const
auto
&
x
=
*
a
.
cast
<
SIMDExtract
>
();
const
auto
&
y
=
*
b
.
cast
<
SIMDExtract
>
();
...
...
@@ -239,11 +246,11 @@ namespace wasm {
return
std
::
tie
(
*
x
.
left
,
*
x
.
right
,
x
.
mask
)
<
std
::
tie
(
*
y
.
left
,
*
y
.
right
,
y
.
mask
);
}
case
Expression
:
:
SIMD
Bitselect
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
SIMD
Bitselect
>
();
const
auto
&
y
=
*
b
.
cast
<
SIMD
Bitselect
>
();
case
Expression
:
:
SIMD
Ternary
Id
:
{
const
auto
&
x
=
*
a
.
cast
<
SIMD
Ternary
>
();
const
auto
&
y
=
*
b
.
cast
<
SIMD
Ternary
>
();
return
std
::
tie
(
*
x
.
left
,
*
x
.
right
,
*
x
.
cond
)
<
std
::
tie
(
*
y
.
left
,
*
y
.
right
,
*
y
.
cond
);
return
std
::
tie
(
*
x
.
a
,
*
x
.
b
,
*
x
.
c
)
<
std
::
tie
(
*
y
.
a
,
*
y
.
b
,
*
y
.
c
);
}
case
Expression
:
:
SIMDShiftId
:
{
const
auto
&
x
=
*
a
.
cast
<
SIMDShift
>
();
...
...
@@ -251,6 +258,12 @@ namespace wasm {
return
std
::
tie
(
x
.
op
,
*
x
.
vec
,
*
x
.
shift
)
<
std
::
tie
(
y
.
op
,
*
y
.
vec
,
*
y
.
shift
);
}
case
Expression
:
:
SIMDLoadId
:
{
const
auto
&
x
=
*
a
.
cast
<
SIMDLoad
>
();
const
auto
&
y
=
*
b
.
cast
<
SIMDLoad
>
();
return
std
::
tie
(
x
.
op
,
x
.
offset
,
x
.
align
,
*
x
.
ptr
)
<
std
::
tie
(
y
.
op
,
y
.
offset
,
y
.
align
,
*
y
.
ptr
)
;
}
case
Expression
:
:
MemoryInitId
:
{
const
auto
&
x
=
*
a
.
cast
<
MemoryInit
>
();
const
auto
&
y
=
*
b
.
cast
<
MemoryInit
>
();
...
...
@@ -275,6 +288,42 @@ namespace wasm {
return
std
::
tie
(
*
x
.
dest
,
*
x
.
value
,
*
x
.
size
)
<
std
::
tie
(
*
y
.
dest
,
*
y
.
value
,
*
y
.
size
);
}
case
Expression
:
:
PushId
:
{
const
auto
&
x
=
*
a
.
cast
<
Push
>
();
const
auto
&
y
=
*
b
.
cast
<
Push
>
();
return
std
::
tie
(
*
x
.
value
)
<
std
::
tie
(
*
y
.
value
);
}
case
Expression
:
:
PopId
:
{
[[
maybe_unused
]]
const
auto
&
x
=
*
a
.
cast
<
Pop
>
();
[[
maybe_unused
]]
const
auto
&
y
=
*
b
.
cast
<
Pop
>
();
return
false
;
}
case
Expression
:
:
TryId
:
{
const
auto
&
x
=
*
a
.
cast
<
Try
>
();
const
auto
&
y
=
*
b
.
cast
<
Try
>
();
return
std
::
forward_as_tuple
(
opt
(
x
.
body
),
opt
(
x
.
catchBody
))
<
std
::
forward_as_tuple
(
opt
(
y
.
body
),
opt
(
y
.
catchBody
));
}
case
Expression
:
:
ThrowId
:
{
const
auto
&
x
=
*
a
.
cast
<
Throw
>
();
const
auto
&
y
=
*
b
.
cast
<
Throw
>
();
return
std
::
tie
(
x
.
operands
)
<
std
::
tie
(
y
.
operands
);
}
case
Expression
:
:
RethrowId
:
{
const
auto
&
x
=
*
a
.
cast
<
Rethrow
>
();
const
auto
&
y
=
*
b
.
cast
<
Rethrow
>
();
return
std
::
forward_as_tuple
(
opt
(
x
.
exnref
))
<
std
::
forward_as_tuple
(
opt
(
y
.
exnref
));
}
case
Expression
:
:
BrOnExnId
:
{
const
auto
&
x
=
*
a
.
cast
<
BrOnExn
>
();
const
auto
&
y
=
*
b
.
cast
<
BrOnExn
>
();
return
std
::
forward_as_tuple
(
opt
(
x
.
exnref
))
<
std
::
forward_as_tuple
(
opt
(
y
.
exnref
));
}
default
:
WASM_UNREACHABLE
();
}
...
...
src/kyut/watermarker/OperandSwappingWatermarker.cpp
View file @
39ff4a29
...
...
@@ -88,21 +88,21 @@ namespace kyut::watermarker {
return
SideEffect
::
write
;
}
SideEffect
visit
GetLocal
([[
maybe_unused
]]
wasm
::
GetLocal
*
expr
)
{
SideEffect
visit
LocalGet
([[
maybe_unused
]]
wasm
::
LocalGet
*
expr
)
{
return
SideEffect
::
readOnly
;
}
SideEffect
visit
SetLocal
(
wasm
::
SetLocal
*
expr
)
{
SideEffect
visit
LocalSet
(
wasm
::
LocalSet
*
expr
)
{
visit
(
expr
->
value
);
return
SideEffect
::
write
;
}
SideEffect
visitG
etGlobal
([[
maybe_unused
]]
wasm
::
GetGlobal
*
expr
)
{
SideEffect
visitG
lobalGet
([[
maybe_unused
]]
wasm
::
GlobalGet
*
expr
)
{
return
SideEffect
::
readOnly
;
}
SideEffect
visit
SetGlobal
(
wasm
::
SetGlobal
*
expr
)
{
SideEffect
visit
GlobalSet
(
wasm
::
GlobalSet
*
expr
)
{
visit
(
expr
->
value
);
return
SideEffect
::
write
;
...
...
@@ -216,6 +216,10 @@ namespace kyut::watermarker {
return
SideEffect
::
write
;
}
SideEffect
visitAtomicFence
([[
maybe_unused
]]
wasm
::
AtomicFence
*
expr
)
{
return
SideEffect
::
write
;
}
SideEffect
visitSIMDExtract
(
wasm
::
SIMDExtract
*
expr
)
{
return
visit
(
expr
->
vec
);
}
...
...
@@ -228,11 +232,11 @@ namespace kyut::watermarker {
return
(
std
::
max
)(
visit
(
expr
->
left
),
visit
(
expr
->
right
));
}
SideEffect
visitSIMD
Bitselect
(
wasm
::
SIMDBitselect
*
expr
)
{
SideEffect
visitSIMD
Ternary
(
wasm
::
SIMDTernary
*
expr
)
{
return
(
std
::
max
)({
visit
(
expr
->
cond
),
visit
(
expr
->
left
),
visit
(
expr
->
right
),
visit
(
expr
->
a
),
visit
(
expr
->
b
),
visit
(
expr
->
c
),
});
}
...
...
@@ -240,6 +244,13 @@ namespace kyut::watermarker {
return
(
std
::
max
)(
visit
(
expr
->
vec
),
visit
(
expr
->
shift
));
}
SideEffect
visitSIMDLoad
(
wasm
::
SIMDLoad
*
expr
)
{
return
(
std
::
max
)({
visit
(
expr
->
ptr
),
SideEffect
::
readOnly
,
});
}
SideEffect
visitMemoryInit
(
wasm
::
MemoryInit
*
expr
)
{
visit
(
expr
->
dest
);
visit
(
expr
->
offset
);
...
...
@@ -268,6 +279,41 @@ namespace kyut::watermarker {
return
SideEffect
::
write
;
}
SideEffect
visitPush
([[
maybe_unused
]]
wasm
::
Push
*
expr
)
{
visit
(
expr
->
value
);
return
SideEffect
::
write
;
}
SideEffect
visitPop
([[
maybe_unused
]]
wasm
::
Pop
*
expr
)
{
return
SideEffect
::
write
;
}
SideEffect
visitTry
(
wasm
::
Try
*
expr
)
{
return
(
std
::
max
)({
visit
(
expr
->
body
),
visit
(
expr
->
catchBody
),
});
}
SideEffect
visitThrow
(
wasm
::
Throw
*
expr
)
{
visitExpressionList
(
expr
->
operands
);
return
SideEffect
::
write
;
}
SideEffect
visitRethrow
(
wasm
::
Rethrow
*
expr
)
{
visit
(
expr
->
exnref
);
return
SideEffect
::
write
;
}
SideEffect
visitBrOnExn
(
wasm
::
BrOnExn
*
expr
)
{
visit
(
expr
->
exnref
);
return
SideEffect
::
write
;
}
SideEffect
visit
(
wasm
::
Expression
*
expr
)
{
if
(
expr
==
nullptr
)
{
return
SideEffect
::
none
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment