Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
60644abd
Commit
60644abd
authored
Nov 30, 2015
by
Dean Moldovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix shift-negative-value warnings
parent
3205005f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
11 deletions
+17
-11
src/asm_writing/assembler.cpp
src/asm_writing/assembler.cpp
+7
-7
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+1
-1
src/asm_writing/types.h
src/asm_writing/types.h
+1
-3
src/core/common.h
src/core/common.h
+8
-0
No files found.
src/asm_writing/assembler.cpp
View file @
60644abd
...
...
@@ -80,7 +80,7 @@ void Assembler::emitArith(Immediate imm, Register r, int opcode) {
// assert(r != RSP && "This breaks unwinding, please don't use.");
int64_t
amount
=
imm
.
val
;
RELEASE_ASSERT
(
(
-
1L
<<
31
)
<=
amount
&&
amount
<
(
1L
<<
31
)
-
1
,
""
);
RELEASE_ASSERT
(
fitsInto
<
int32_t
>
(
amount
)
,
""
);
assert
(
0
<=
opcode
&&
opcode
<
8
);
int
rex
=
REX_W
;
...
...
@@ -183,7 +183,7 @@ void Assembler::mov(Immediate val, Register dest, bool force_64bit_load) {
void
Assembler
::
movq
(
Immediate
src
,
Indirect
dest
)
{
int64_t
src_val
=
src
.
val
;
assert
(
(
-
1L
<<
31
)
<=
src_val
&&
src_val
<
(
1L
<<
31
)
-
1
);
assert
(
fitsInto
<
int32_t
>
(
src_val
)
);
int
rex
=
REX_W
;
...
...
@@ -739,7 +739,7 @@ void Assembler::cmp(Register reg, Immediate imm) {
void
Assembler
::
cmp
(
Indirect
mem
,
Immediate
imm
)
{
int64_t
val
=
imm
.
val
;
assert
(
(
-
1L
<<
31
)
<=
val
&&
val
<
(
1L
<<
31
)
-
1
);
assert
(
fitsInto
<
int32_t
>
(
val
)
);
int
src_idx
=
mem
.
base
.
regnum
;
...
...
@@ -760,7 +760,7 @@ void Assembler::cmp(Indirect mem, Immediate imm) {
emitModRM
(
0b01
,
7
,
src_idx
);
emitByte
(
mem
.
offset
);
}
else
{
assert
(
(
-
1L
<<
31
)
<=
mem
.
offset
&&
mem
.
offset
<
(
1L
<<
31
)
-
1
);
assert
(
fitsInto
<
int32_t
>
(
mem
.
offset
)
);
emitModRM
(
0b10
,
7
,
src_idx
);
emitInt
(
mem
.
offset
,
4
);
}
...
...
@@ -794,7 +794,7 @@ void Assembler::cmp(Indirect mem, Register reg) {
emitModRM
(
0b01
,
reg_idx
,
mem_idx
);
emitByte
(
mem
.
offset
);
}
else
{
assert
(
(
-
1L
<<
31
)
<=
mem
.
offset
&&
mem
.
offset
<
(
1L
<<
31
)
-
1
);
assert
(
fitsInto
<
int32_t
>
(
mem
.
offset
)
);
emitModRM
(
0b10
,
reg_idx
,
mem_idx
);
emitInt
(
mem
.
offset
,
4
);
}
...
...
@@ -830,7 +830,7 @@ void Assembler::lea(Indirect mem, Register reg) {
if
(
mode
==
0b01
)
{
emitByte
(
mem
.
offset
);
}
else
if
(
mode
==
0b10
)
{
assert
(
(
-
1L
<<
31
)
<=
mem
.
offset
&&
mem
.
offset
<
(
1L
<<
31
)
-
1
);
assert
(
fitsInto
<
int32_t
>
(
mem
.
offset
)
);
emitInt
(
mem
.
offset
,
4
);
}
}
...
...
@@ -910,7 +910,7 @@ void Assembler::jmp(Indirect dest) {
emitModRM
(
0b01
,
0b100
,
reg_idx
);
emitByte
(
dest
.
offset
);
}
else
{
assert
(
(
-
1L
<<
31
)
<=
dest
.
offset
&&
dest
.
offset
<
(
1L
<<
31
)
-
1
);
assert
(
fitsInto
<
int32_t
>
(
dest
.
offset
)
);
emitModRM
(
0b10
,
0b100
,
reg_idx
);
emitInt
(
dest
.
offset
,
4
);
}
...
...
src/asm_writing/rewriter.h
View file @
60644abd
...
...
@@ -600,7 +600,7 @@ public:
static
Rewriter
*
createRewriter
(
void
*
rtn_addr
,
int
num_args
,
const
char
*
debug_name
);
static
bool
isLargeConstant
(
int64_t
val
)
{
return
(
val
<
(
-
1L
<<
31
)
||
val
>=
(
1L
<<
31
)
-
1
);
}
static
bool
isLargeConstant
(
int64_t
val
)
{
return
!
fitsInto
<
int32_t
>
(
val
);
}
// The "aggressiveness" with which we should try to do this rewrite. It starts high, and decreases over time.
// The values are nominally in the range 0-100, with 0 being no aggressiveness and 100 being fully aggressive,
...
...
src/asm_writing/types.h
View file @
60644abd
...
...
@@ -172,9 +172,7 @@ struct JumpDestination {
int
offset
;
JumpDestination
(
OffsetType
type
,
int64_t
offset
)
:
type
(
type
),
offset
(
offset
)
{
assert
((
-
1L
<<
31
)
<=
offset
&&
offset
<
(
1L
<<
31
)
-
1
);
}
JumpDestination
(
OffsetType
type
,
int64_t
offset
)
:
type
(
type
),
offset
(
offset
)
{
assert
(
fitsInto
<
int32_t
>
(
offset
));
}
static
JumpDestination
fromStart
(
int
offset
)
{
return
JumpDestination
(
FROM_START
,
offset
);
}
};
}
...
...
src/core/common.h
View file @
60644abd
...
...
@@ -19,6 +19,7 @@
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <stdint.h>
#include <string>
#include <unordered_map>
...
...
@@ -82,4 +83,11 @@ template <typename T1, typename T2, typename T3> struct hash<tuple<T1, T2, T3>>
};
}
namespace
pyston
{
template
<
typename
T
>
constexpr
bool
fitsInto
(
int64_t
x
)
{
return
std
::
numeric_limits
<
T
>::
min
()
<=
x
&&
x
<
std
::
numeric_limits
<
T
>::
max
();
}
}
#endif
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