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
75b794ad
Commit
75b794ad
authored
May 26, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bjit: allocate code block using mmap
also add a option to pass MAP_32BIT to mmap
parent
b022674c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+16
-5
src/codegen/baseline_jit.h
src/codegen/baseline_jit.h
+14
-1
No files found.
src/codegen/baseline_jit.cpp
View file @
75b794ad
...
...
@@ -16,6 +16,7 @@
#include <llvm/ADT/DenseMap.h>
#include <llvm/ADT/DenseSet.h>
#include <sys/mman.h>
#include "codegen/irgen/hooks.h"
#include "codegen/memmgr.h"
...
...
@@ -59,12 +60,22 @@ static_assert(JitCodeBlock::scratch_size == 256, "have to update EH table!");
constexpr
int
code_size
=
JitCodeBlock
::
memory_size
-
sizeof
(
eh_info
);
JitCodeBlock
::
MemoryManager
::
MemoryManager
()
{
int
protection
=
PROT_READ
|
PROT_WRITE
|
PROT_EXEC
;
int
flags
=
MAP_PRIVATE
|
MAP_ANONYMOUS
;
#if ENABLE_BASELINEJIT_MAP_32BIT
flags
|=
MAP_32BIT
;
#endif
addr
=
(
uint8_t
*
)
mmap
(
NULL
,
JitCodeBlock
::
memory_size
,
protection
,
flags
,
-
1
,
0
);
}
JitCodeBlock
::
MemoryManager
::~
MemoryManager
()
{
munmap
(
addr
,
JitCodeBlock
::
memory_size
);
addr
=
NULL
;
}
JitCodeBlock
::
JitCodeBlock
(
llvm
::
StringRef
name
)
:
memory
(
new
uint8_t
[
memory_size
]),
entry_offset
(
0
),
a
(
memory
.
get
()
+
sizeof
(
eh_info
),
code_size
),
is_currently_writing
(
false
),
asm_failed
(
false
)
{
:
entry_offset
(
0
),
a
(
memory
.
get
()
+
sizeof
(
eh_info
),
code_size
),
is_currently_writing
(
false
),
asm_failed
(
false
)
{
static
StatCounter
num_jit_code_blocks
(
"num_baselinejit_code_blocks"
);
num_jit_code_blocks
.
log
();
static
StatCounter
num_jit_total_bytes
(
"num_baselinejit_total_bytes"
);
...
...
src/codegen/baseline_jit.h
View file @
75b794ad
...
...
@@ -23,6 +23,9 @@
namespace
pyston
{
// passes MAP_32BIT to mmap when allocating the memory for the bjit code.
// it's nice for inspecting the generated asm because the debugger is able to show the name of called C/C++ functions
#define ENABLE_BASELINEJIT_MAP_32BIT 0
#define ENABLE_BASELINEJIT_ICS 1
class
AST_stmt
;
...
...
@@ -147,8 +150,18 @@ public:
static
constexpr
int
sp_adjustment
=
scratch_size
+
num_stack_args
*
8
+
8
/* = alignment */
;
private:
struct
MemoryManager
{
private:
uint8_t
*
addr
;
public:
MemoryManager
();
~
MemoryManager
();
uint8_t
*
get
()
{
return
addr
;
}
};
// the memory block contains the EH frame directly followed by the generated machine code.
std
::
unique_ptr
<
uint8_t
[]
>
memory
;
MemoryManager
memory
;
int
entry_offset
;
assembler
::
Assembler
a
;
bool
is_currently_writing
;
...
...
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