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
4f2ec866
Commit
4f2ec866
authored
Jul 19, 2019
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix comparator bug
parent
1e3f6211
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
24 deletions
+29
-24
OperandSwappingWatermarker.cpp
src/kyut/watermarker/OperandSwappingWatermarker.cpp
+29
-24
No files found.
src/kyut/watermarker/OperandSwappingWatermarker.cpp
View file @
4f2ec866
...
...
@@ -439,7 +439,7 @@ namespace kyut::watermarker {
return
(
std
::
max
)(
loEffect
,
hiEffect
);
}
f
(
*
expr
);
f
(
*
expr
,
*
lo
,
*
hi
);
return
(
std
::
max
)(
loEffect
,
hiEffect
);
}
...
...
@@ -587,10 +587,10 @@ namespace kyut::watermarker {
// Embed watermarks
const
auto
posStart
=
stream
.
tell
();
OperandSwappingVisitor
visitor
{[
&
stream
](
wasm
::
Binary
&
expr
)
{
OperandSwappingVisitor
visitor
{
[
&
](
wasm
::
Binary
&
expr
,
wasm
::
Expression
&
lo
,
[[
maybe_unused
]]
wasm
::
Expression
&
hi
)
{
// Embed watermarks by swapping operands
const
bool
bit
=
stream
.
readBit
();
const
auto
&
lo
=
(
std
::
min
)(
*
expr
.
left
,
*
expr
.
right
);
if
(
bit
==
(
expr
.
left
==
&
lo
))
{
swapOperands
(
expr
);
...
...
@@ -620,10 +620,9 @@ namespace kyut::watermarker {
// Extract watermarks
const
auto
posStart
=
stream
.
tell
();
OperandSwappingVisitor
visitor
{[
&
stream
](
wasm
::
Binary
&
expr
)
{
OperandSwappingVisitor
visitor
{
[
&
](
wasm
::
Binary
&
expr
,
wasm
::
Expression
&
lo
,
[[
maybe_unused
]]
wasm
::
Expression
&
hi
)
{
// Extract watermarks from the order of operands
const
auto
&
lo
=
(
std
::
min
)(
*
expr
.
left
,
*
expr
.
right
);
stream
.
writeBit
(
expr
.
left
!=
&
lo
);
}};
...
...
@@ -728,17 +727,23 @@ namespace wasm {
return
std
::
tie
(
a
.
op
,
*
a
.
value
)
<
std
::
tie
(
b
.
op
,
*
b
.
value
);
}
bool
operator
<
(
const
wasm
::
Binary
&
a
,
const
wasm
::
Binary
&
b
)
{
if
(
a
.
op
!=
b
.
op
)
{
return
a
.
op
<
b
.
op
;
}
if
(
!
kyut
::
watermarker
::
isCommutative
(
a
.
op
))
{
// Normalize expression
constexpr
auto
normalize
=
[](
const
wasm
::
Binary
&
x
)
->
std
::
tuple
<
wasm
::
BinaryOp
,
wasm
::
Expression
&
,
wasm
::
Expression
&>
{
if
(
!
kyut
::
watermarker
::
isCommutative
(
x
.
op
))
{
// Noncommutative
return
std
::
tie
(
*
a
.
left
,
*
a
.
right
)
<
std
::
tie
(
*
b
.
left
,
*
b
.
right
)
;
return
{
x
.
op
,
*
x
.
left
,
*
x
.
right
}
;
}
// Commutative
return
std
::
minmax
(
*
a
.
left
,
*
a
.
right
)
<
std
::
minmax
(
*
b
.
left
,
*
b
.
right
);
if
(
*
x
.
right
<
*
x
.
left
)
{
return
{
*
kyut
::
watermarker
::
getSwappedPredicate
(
x
.
op
),
*
x
.
right
,
*
x
.
left
};
}
else
{
return
{
x
.
op
,
*
x
.
left
,
*
x
.
right
};
}
};
return
normalize
(
a
)
<
normalize
(
b
);
}
bool
operator
<
(
const
wasm
::
Select
&
a
,
const
wasm
::
Select
&
b
)
{
return
std
::
tie
(
*
a
.
condition
,
*
a
.
ifTrue
,
*
a
.
ifFalse
)
<
std
::
tie
(
*
b
.
condition
,
*
b
.
ifTrue
,
*
b
.
ifFalse
);
...
...
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