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
8b368114
Verified
Commit
8b368114
authored
Dec 12, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add operator<(Function,Function)
parent
16ed4772
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
FunctionReordering.hpp
lib/kyut/methods/FunctionReordering.hpp
+2
-2
Compare-inl.hpp
lib/kyut/wasm-ext/Compare-inl.hpp
+10
-0
Compare.hpp
lib/kyut/wasm-ext/Compare.hpp
+1
-0
test_Reordering.cpp
test/test_Reordering.cpp
+6
-0
No files found.
lib/kyut/methods/FunctionReordering.hpp
View file @
8b368114
...
@@ -24,7 +24,7 @@ namespace kyut::methods::function_reordering {
...
@@ -24,7 +24,7 @@ namespace kyut::methods::function_reordering {
start
,
start
,
end
,
end
,
[](
const
auto
&
a
,
const
auto
&
b
)
{
[](
const
auto
&
a
,
const
auto
&
b
)
{
return
*
a
->
body
<
*
b
->
body
;
return
*
a
<
*
b
;
});
});
return
size_bits
;
return
size_bits
;
...
@@ -44,7 +44,7 @@ namespace kyut::methods::function_reordering {
...
@@ -44,7 +44,7 @@ namespace kyut::methods::function_reordering {
start
,
start
,
end
,
end
,
[](
const
auto
&
a
,
const
auto
&
b
)
{
[](
const
auto
&
a
,
const
auto
&
b
)
{
return
*
a
->
body
<
*
b
->
body
;
return
*
a
<
*
b
;
});
});
return
size_bits
;
return
size_bits
;
...
...
lib/kyut/wasm-ext/Compare-inl.hpp
View file @
8b368114
...
@@ -347,6 +347,10 @@ namespace wasm {
...
@@ -347,6 +347,10 @@ namespace wasm {
}
}
inline
bool
operator
<
(
const
ExpressionList
&
a
,
const
ExpressionList
&
b
)
{
inline
bool
operator
<
(
const
ExpressionList
&
a
,
const
ExpressionList
&
b
)
{
if
(
a
.
size
()
!=
b
.
size
())
{
return
a
.
size
()
<
b
.
size
();
}
return
std
::
lexicographical_compare
(
return
std
::
lexicographical_compare
(
std
::
begin
(
a
),
std
::
begin
(
a
),
std
::
end
(
a
),
std
::
end
(
a
),
...
@@ -356,6 +360,12 @@ namespace wasm {
...
@@ -356,6 +360,12 @@ namespace wasm {
return
*
a
<
*
b
;
return
*
a
<
*
b
;
});
});
}
}
inline
bool
operator
<
(
const
Function
&
a
,
const
Function
&
b
)
{
// wasm::Function::getNumVars() does not modify states
return
std
::
forward_as_tuple
(
a
.
sig
,
const_cast
<
Function
&>
(
a
).
getNumVars
(),
*
a
.
body
)
<
std
::
forward_as_tuple
(
b
.
sig
,
const_cast
<
Function
&>
(
b
).
getNumVars
(),
*
b
.
body
);
}
}
// namespace wasm
}
// namespace wasm
#endif // INCLUDE_kyut_wasm_ext_Compare_inl_hpp
#endif // INCLUDE_kyut_wasm_ext_Compare_inl_hpp
lib/kyut/wasm-ext/Compare.hpp
View file @
8b368114
...
@@ -7,6 +7,7 @@ namespace wasm {
...
@@ -7,6 +7,7 @@ namespace wasm {
bool
operator
<
(
const
Literal
&
a
,
const
Literal
&
b
);
bool
operator
<
(
const
Literal
&
a
,
const
Literal
&
b
);
bool
operator
<
(
const
Expression
&
a
,
const
Expression
&
b
);
bool
operator
<
(
const
Expression
&
a
,
const
Expression
&
b
);
bool
operator
<
(
const
ExpressionList
&
a
,
const
ExpressionList
&
b
);
bool
operator
<
(
const
ExpressionList
&
a
,
const
ExpressionList
&
b
);
bool
operator
<
(
const
Function
&
a
,
const
Function
&
b
);
}
// namespace wasm
}
// namespace wasm
#include "Compare-inl.hpp"
#include "Compare-inl.hpp"
...
...
test/test_Reordering.cpp
View file @
8b368114
...
@@ -37,6 +37,9 @@ TEST(kyut_Reordering, embed_by_reordering) {
...
@@ -37,6 +37,9 @@ TEST(kyut_Reordering, embed_by_reordering) {
check_embed
(
"2314"
,
"
\x50
"
sv
,
20
,
4
,
"2314"
);
check_embed
(
"2314"
,
"
\x50
"
sv
,
20
,
4
,
"2314"
);
check_embed
(
"2314"
,
"
\x00
"
sv
,
20
,
4
,
"1234"
);
check_embed
(
"2314"
,
"
\x00
"
sv
,
20
,
4
,
"1234"
);
// check_embed("1223", "\x00"sv, 20, 2, "1232");
// check_embed("1223", "\x40"sv, 20, 2, "2132");
}
}
namespace
{
namespace
{
...
@@ -69,6 +72,9 @@ TEST(kyut_Reordering, extract_by_reordering) {
...
@@ -69,6 +72,9 @@ TEST(kyut_Reordering, extract_by_reordering) {
check_extract
(
"4231"
,
20
,
4
,
"
\x30
"
sv
);
check_extract
(
"4231"
,
20
,
4
,
"
\x30
"
sv
);
check_extract
(
"1324"
,
20
,
4
,
"
\x40
"
sv
);
check_extract
(
"1324"
,
20
,
4
,
"
\x40
"
sv
);
check_extract
(
"2314"
,
20
,
4
,
"
\x50
"
sv
);
check_extract
(
"2314"
,
20
,
4
,
"
\x50
"
sv
);
// check_extract("1232", 20, 2, "\x00"sv);
// check_extract("2132", 20, 2, "\x40"sv);
}
}
namespace
{
namespace
{
...
...
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