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
61c870c6
Verified
Commit
61c870c6
authored
Jan 05, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change output of watermarked wasm binary
parent
43e4b627
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
80 deletions
+103
-80
.gitignore
example/ammo.js/.gitignore
+1
-1
Makefile
example/ammo.js/Makefile
+29
-23
benchmark.js
example/ammo.js/benchmark.js
+12
-12
.gitignore
example/zlib-wasm/.gitignore
+1
-4
Makefile
example/zlib-wasm/Makefile
+26
-19
benchmark.js
example/zlib-wasm/benchmark.js
+34
-21
No files found.
example/ammo.js/.gitignore
View file @
61c870c6
ammo-*
dist/
example/ammo.js/Makefile
View file @
61c870c6
...
...
@@ -7,48 +7,54 @@ W3 := 0d97880d
W4
:=
fe8191b3
all
:
\
ammo-1-${W1} ammo-2-${W1}
ammo-3-${W1}
\
ammo-1-${W2} ammo-2-${W2}
ammo-3-${W2}
\
ammo-1-${W3} ammo-2-${W3}
ammo-3-${W3}
\
ammo-1-${W4} ammo-2-${W4}
ammo-3-${W4}
\
dist/ammo-1-${W1} dist/ammo-2-${W1} dist/
ammo-3-${W1}
\
dist/ammo-1-${W2} dist/ammo-2-${W2} dist/
ammo-3-${W2}
\
dist/ammo-1-${W3} dist/ammo-2-${W3} dist/
ammo-3-${W3}
\
dist/ammo-1-${W4} dist/ammo-2-${W4} dist/
ammo-3-${W4}
\
#
ammo-1-${W1}
:
ammo-1-${W1}/ammo.wasm.js ammo-1-${W1}/ammo.wasm.wasm
ammo-1-${W2}
:
ammo-1-${W2}/ammo.wasm.js ammo-1-${W2}/ammo.wasm.wasm
ammo-1-${W3}
:
ammo-1-${W3}/ammo.wasm.js ammo-1-${W3}/ammo.wasm.wasm
ammo-1-${W4}
:
ammo-1-${W4}/ammo.wasm.js ammo-1-${W4}/ammo.wasm.wasm
ammo-2-${W1}
:
ammo-2-${W1}/ammo.wasm.js ammo-2-${W1}/ammo.wasm.wasm
ammo-2-${W2}
:
ammo-2-${W2}/ammo.wasm.js ammo-2-${W2}/ammo.wasm.wasm
ammo-2-${W3}
:
ammo-2-${W3}/ammo.wasm.js ammo-2-${W3}/ammo.wasm.wasm
ammo-2-${W4}
:
ammo-2-${W4}/ammo.wasm.js ammo-2-${W4}/ammo.wasm.wasm
ammo-3-${W1}
:
ammo-3-${W1}/ammo.wasm.js ammo-3-${W1}/ammo.wasm.wasm
ammo-3-${W2}
:
ammo-3-${W2}/ammo.wasm.js ammo-3-${W2}/ammo.wasm.wasm
ammo-3-${W3}
:
ammo-3-${W3}/ammo.wasm.js ammo-3-${W3}/ammo.wasm.wasm
ammo-3-${W4}
:
ammo-3-${W4}/ammo.wasm.js ammo-3-${W4}/ammo.wasm.wasm
ammo-%/ammo.wasm.js
:
ammo.js/builds/ammo.wasm.js
test
:
all
node test.js
bench
:
all
node benchmark.js
dist/ammo-1-${W1}
:
dist/ammo-1-${W1}/ammo.wasm.js dist/ammo-1-${W1}/ammo.wasm.wasm
dist/ammo-1-${W2}
:
dist/ammo-1-${W2}/ammo.wasm.js dist/ammo-1-${W2}/ammo.wasm.wasm
dist/ammo-1-${W3}
:
dist/ammo-1-${W3}/ammo.wasm.js dist/ammo-1-${W3}/ammo.wasm.wasm
dist/ammo-1-${W4}
:
dist/ammo-1-${W4}/ammo.wasm.js dist/ammo-1-${W4}/ammo.wasm.wasm
dist/ammo-2-${W1}
:
dist/ammo-2-${W1}/ammo.wasm.js dist/ammo-2-${W1}/ammo.wasm.wasm
dist/ammo-2-${W2}
:
dist/ammo-2-${W2}/ammo.wasm.js dist/ammo-2-${W2}/ammo.wasm.wasm
dist/ammo-2-${W3}
:
dist/ammo-2-${W3}/ammo.wasm.js dist/ammo-2-${W3}/ammo.wasm.wasm
dist/ammo-2-${W4}
:
dist/ammo-2-${W4}/ammo.wasm.js dist/ammo-2-${W4}/ammo.wasm.wasm
dist/ammo-3-${W1}
:
dist/ammo-3-${W1}/ammo.wasm.js dist/ammo-3-${W1}/ammo.wasm.wasm
dist/ammo-3-${W2}
:
dist/ammo-3-${W2}/ammo.wasm.js dist/ammo-3-${W2}/ammo.wasm.wasm
dist/ammo-3-${W3}
:
dist/ammo-3-${W3}/ammo.wasm.js dist/ammo-3-${W3}/ammo.wasm.wasm
dist/ammo-3-${W4}
:
dist/ammo-3-${W4}/ammo.wasm.js dist/ammo-3-${W4}/ammo.wasm.wasm
dist/ammo-%/ammo.wasm.js
:
ammo.js/builds/ammo.wasm.js
@
mkdir
-p
${
@D
}
cp
$<
$@
ammo-1-%/ammo.wasm.wasm
:
ammo.js/builds/ammo.wasm.wasm
dist/
ammo-1-%/ammo.wasm.wasm
:
ammo.js/builds/ammo.wasm.wasm
@
mkdir
-p
${
@D
}
${
SNPI
}
$<
funcord
${
@
:zlib-1-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
${
AS
}
${
@
:%.wasm
=%.wast
}
-o
$@
${
RM
}
${
@
:%.wasm
=%.wast
}
ammo-2-%/ammo.wasm.wasm
:
ammo.js/builds/ammo.wasm.wasm
dist/
ammo-2-%/ammo.wasm.wasm
:
ammo.js/builds/ammo.wasm.wasm
@
mkdir
-p
${
@D
}
${
SNPI
}
$<
opswap
${
@
:zlib-2-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
${
AS
}
${
@
:%.wasm
=%.wast
}
-o
$@
${
RM
}
${
@
:%.wasm
=%.wast
}
ammo-3-%/ammo.wasm.wasm
:
ammo-1-%/ammo.wasm.wasm
dist/ammo-3-%/ammo.wasm.wasm
:
dist/
ammo-1-%/ammo.wasm.wasm
@
mkdir
-p
${
@D
}
${
SNPI
}
$<
opswap
${
@
:zlib-3-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
${
AS
}
${
@
:%.wasm
=%.wast
}
-o
$@
${
RM
}
${
@
:%.wasm
=%.wast
}
clean
:
${
RM
}
-rf
ammo-
*
${
RM
}
-rf
dist
.PHONY
:
all clean
.PHONY
:
all
test bench
clean
example/ammo.js/benchmark.js
View file @
61c870c6
...
...
@@ -19,18 +19,18 @@ const stress = require("./stress");
const
wasms
=
[
"ammo.js/builds"
,
"ammo-1-0c9c85c7"
,
"ammo-1-0d97880d"
,
"ammo-1-60b725f1"
,
"ammo-1-fe8191b3"
,
"ammo-2-0c9c85c7"
,
"ammo-2-0d97880d"
,
"ammo-2-60b725f1"
,
"ammo-2-fe8191b3"
,
"ammo-3-0c9c85c7"
,
"ammo-3-0d97880d"
,
"ammo-3-60b725f1"
,
"ammo-3-fe8191b3"
"
dist/
ammo-1-0c9c85c7"
,
"
dist/
ammo-1-0d97880d"
,
"
dist/
ammo-1-60b725f1"
,
"
dist/
ammo-1-fe8191b3"
,
"
dist/
ammo-2-0c9c85c7"
,
"
dist/
ammo-2-0d97880d"
,
"
dist/
ammo-2-60b725f1"
,
"
dist/
ammo-2-fe8191b3"
,
"
dist/
ammo-3-0c9c85c7"
,
"
dist/
ammo-3-0d97880d"
,
"
dist/
ammo-3-60b725f1"
,
"
dist/
ammo-3-fe8191b3"
];
for
(
wasm
of
wasms
)
{
...
...
example/zlib-wasm/.gitignore
View file @
61c870c6
zlib-1-*.wasm
zlib-2-*.wasm
zlib-3-*.wasm
*.wast
dist/
example/zlib-wasm/Makefile
View file @
61c870c6
...
...
@@ -9,36 +9,43 @@ W4 := fe8191b3
SRC
:=
zlib-sample.wasm
TARGETS
:=
\
zlib-1-
${
W1
}
.wasm
\
zlib-2-
${
W1
}
.wasm
\
zlib-3-
${
W1
}
.wasm
\
zlib-1-
${
W2
}
.wasm
\
zlib-2-
${
W2
}
.wasm
\
zlib-3-
${
W2
}
.wasm
\
zlib-1-
${
W3
}
.wasm
\
zlib-2-
${
W3
}
.wasm
\
zlib-3-
${
W3
}
.wasm
\
zlib-1-
${
W4
}
.wasm
\
zlib-2-
${
W4
}
.wasm
\
zlib-3-
${
W4
}
.wasm
dist/
zlib-1-
${
W1
}
.wasm
\
dist/
zlib-2-
${
W1
}
.wasm
\
dist/
zlib-3-
${
W1
}
.wasm
\
dist/
zlib-1-
${
W2
}
.wasm
\
dist/
zlib-2-
${
W2
}
.wasm
\
dist/
zlib-3-
${
W2
}
.wasm
\
dist/
zlib-1-
${
W3
}
.wasm
\
dist/
zlib-2-
${
W3
}
.wasm
\
dist/
zlib-3-
${
W3
}
.wasm
\
dist/
zlib-1-
${
W4
}
.wasm
\
dist/
zlib-2-
${
W4
}
.wasm
\
dist/
zlib-3-
${
W4
}
.wasm
all
:
${TARGETS}
bench
:
all
node benchmark.js
zlib-1-%.wasm
:
zlib-sample.wasm
${
SNPI
}
$<
funcord
${
@
:zlib-1-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
dist/zlib-1-%.wasm
:
zlib-sample.wasm
@
mkdir
-p
${
@D
}
${
SNPI
}
$<
funcord
${
@
:dist/zlib-1-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
${
AS
}
${
@
:%.wasm
=%.wast
}
-o
$@
${
RM
}
${
@
:%.wasm
=%.wast
}
zlib-2-%.wasm
:
zlib-sample.wasm
${
SNPI
}
$<
opswap
${
@
:zlib-2-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
dist/zlib-2-%.wasm
:
zlib-sample.wasm
@
mkdir
-p
${
@D
}
${
SNPI
}
$<
opswap
${
@
:dist/zlib-2-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
${
AS
}
${
@
:%.wasm
=%.wast
}
-o
$@
${
RM
}
${
@
:%.wasm
=%.wast
}
zlib-3-%.wasm
:
zlib-1-%.wasm
${
SNPI
}
$<
opswap
${
@
:zlib-3-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
dist/zlib-3-%.wasm
:
dist/zlib-1-%.wasm
@
mkdir
-p
${
@D
}
${
SNPI
}
$<
opswap
${
@
:dist/zlib-3-%.wasm
=%
}
>
${
@
:%.wasm
=%.wast
}
${
AS
}
${
@
:%.wasm
=%.wast
}
-o
$@
${
RM
}
${
@
:%.wasm
=%.wast
}
clean
:
${
RM
}
zlib-1-
*
.wasm zlib-2-
*
.wasm zlib-3-
*
.wasm
*
.wast
${
RM
}
dist
.PHONY
:
all bench clean
example/zlib-wasm/benchmark.js
View file @
61c870c6
const
Crypto
=
require
(
'crypto'
);
const
assert
=
require
(
'assert'
);
const
Crypto
=
require
(
"crypto"
);
const
assert
=
require
(
"assert"
);
const
size
=
1
_000_000
;
const
rawData
=
Crypto
.
randomBytes
(
size
);
(
async
function
()
{
(
async
function
()
{
const
libPaths
=
[
`zlib-sample.wasm`
,
'zlib-1-0c9c85c7.wasm'
,
'zlib-1-0d97880d.wasm'
,
'zlib-1-60b725f1.wasm'
,
'zlib-1-fe8191b3.wasm'
,
'zlib-2-0c9c85c7.wasm'
,
'zlib-2-0d97880d.wasm'
,
'zlib-2-60b725f1.wasm'
,
'zlib-2-fe8191b3.wasm'
,
'zlib-3-0c9c85c7.wasm'
,
'zlib-3-0d97880d.wasm'
,
'zlib-3-60b725f1.wasm'
,
'zlib-3-fe8191b3.wasm'
,
"dist/zlib-1-0c9c85c7.wasm"
,
"dist/zlib-1-0d97880d.wasm"
,
"dist/zlib-1-60b725f1.wasm"
,
"dist/zlib-1-fe8191b3.wasm"
,
"dist/zlib-2-0c9c85c7.wasm"
,
"dist/zlib-2-0d97880d.wasm"
,
"dist/zlib-2-60b725f1.wasm"
,
"dist/zlib-2-fe8191b3.wasm"
,
"dist/zlib-3-0c9c85c7.wasm"
,
"dist/zlib-3-0d97880d.wasm"
,
"dist/zlib-3-60b725f1.wasm"
,
"dist/zlib-3-fe8191b3.wasm"
];
const
libs
=
await
Promise
.
all
(
libPaths
.
map
(
async
path
=>
await
require
(
'./zlib'
).
initialize
(
`
${
__dirname
}
/
${
path
}
`
)));
const
libs
=
await
Promise
.
all
(
libPaths
.
map
(
async
path
=>
await
require
(
"./zlib"
).
initialize
(
`
${
__dirname
}
/
${
path
}
`
)
)
);
const
compressed
=
libs
[
0
].
deflate
(
rawData
);
// Validation
libs
.
forEach
((
Zlib
,
i
)
=>
{
assert
.
deepEqual
(
Zlib
.
deflate
(
rawData
),
compressed
,
`
${
libPaths
[
i
]}
- .deflate()`
);
assert
.
deepEqual
(
Zlib
.
inflate
(
compressed
),
rawData
,
`
${
libPaths
[
i
]}
- .inflate()`
);
assert
.
deepEqual
(
Zlib
.
deflate
(
rawData
),
compressed
,
`
${
libPaths
[
i
]}
- .deflate()`
);
assert
.
deepEqual
(
Zlib
.
inflate
(
compressed
),
rawData
,
`
${
libPaths
[
i
]}
- .inflate()`
);
});
const
compressionRate
=
compressed
.
length
/
rawData
.
length
;
console
.
log
(
`raw size:
${
rawData
.
length
}
bytes`
);
console
.
log
(
`deflated size:
${
compressed
.
length
}
bytes`
);
console
.
log
(
`compression rate:
${(
compress
ed
.
length
/
rawData
.
length
*
100
).
toFixed
(
1
)}
%`
)
console
.
log
(
`compression rate:
${(
compress
ionRate
*
100
).
toFixed
(
1
)}
%`
);
libs
.
forEach
((
Zlib
,
i
)
=>
{
// Warming up
...
...
@@ -50,5 +64,4 @@ const rawData = Crypto.randomBytes(size);
}
console
.
timeEnd
(
`Benchmark -
${
libPaths
[
i
]}
`
);
});
}());
})();
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