Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-fast
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
40
Issues
40
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
mu
mu-impl-fast
Commits
81b9bfe4
Commit
81b9bfe4
authored
Feb 07, 2017
by
qinsoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[wip] keep debugging
parent
0ddfce69
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
135 additions
and
22 deletions
+135
-22
src/compiler/backend/arch/x86_64/asm_backend.rs
src/compiler/backend/arch/x86_64/asm_backend.rs
+27
-4
src/compiler/backend/arch/x86_64/inst_sel.rs
src/compiler/backend/arch/x86_64/inst_sel.rs
+4
-2
src/runtime/mm.rs
src/runtime/mm.rs
+3
-1
src/testutil/aot.rs
src/testutil/aot.rs
+1
-1
src/vm/vm.rs
src/vm/vm.rs
+41
-13
tests/test_jit/test_rpython.py
tests/test_jit/test_rpython.py
+59
-1
No files found.
src/compiler/backend/arch/x86_64/asm_backend.rs
View file @
81b9bfe4
...
...
@@ -2917,16 +2917,37 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
}
// min alignment as 16 byte (written as 4 (2^4) on macos)
const
MIN_ALIGN
:
ByteSize
=
16
;
fn
check_min_align
(
align
:
ByteSize
)
->
ByteSize
{
if
align
>
MIN_ALIGN
{
MIN_ALIGN
}
else
{
align
}
}
#[cfg(target_os
=
"linux"
)]
fn
write_const_min_align
(
f
:
&
mut
File
)
{
write_align
(
f
,
MIN_ALIGN
);
}
#[cfg(target_os
=
"linux"
)]
fn
write_align
(
f
:
&
mut
File
,
align
:
ByteSize
)
{
use
std
::
io
::
Write
;
f
.write
(
"
\t
.align 16
\n
"
.as_bytes
(
))
.unwrap
();
f
.write
_fmt
(
format_args!
(
"
\t
.align {}
\n
"
,
check_min_align
(
align
)
))
.unwrap
();
}
#[cfg(target_os
=
"macos"
)]
fn
write_
const_min_align
(
f
:
&
mut
Fil
e
)
{
fn
write_
align
(
f
:
&
mut
File
,
align
:
ByteSiz
e
)
{
use
std
::
io
::
Write
;
f
.write
(
"
\t
.align 4
\n
"
.as_bytes
())
.unwrap
();
let
align
=
check_min_align
(
align
);
let
mut
n
=
0
;
while
2u
size
.pow
(
n
)
<
align
{
n
+=
1
;
}
assert
!
(
2u
size
.pow
(
n
)
==
align
,
"alignment needs to be power of 2, alignment is {}"
,
align
);
f
.write_fmt
(
format_args!
(
"
\t
.align {}
\n
"
,
n
))
.unwrap
();
}
fn
write_const
(
f
:
&
mut
File
,
constant
:
P
<
Value
>
,
loc
:
P
<
Value
>
)
{
...
...
@@ -3048,6 +3069,8 @@ pub fn emit_context_with_reloc(vm: &VM,
}
for
obj_dump
in
objects
.values
()
{
write_align
(
&
mut
file
,
8
);
// .bytes xx,xx,xx,xx (between mem_start to reference_addr)
write_data_bytes
(
&
mut
file
,
obj_dump
.mem_start
,
obj_dump
.reference_addr
);
...
...
src/compiler/backend/arch/x86_64/inst_sel.rs
View file @
81b9bfe4
...
...
@@ -1613,8 +1613,10 @@ impl <'a> InstructionSelection {
match
is_power_of_two
(
var_ty_size
)
{
Some
(
shift
)
=>
{
// a shift-left will get the total size of var part
self
.backend
.emit_shl_r_imm8
(
&
tmp_var_len
,
shift
);
if
shift
!=
0
{
// a shift-left will get the total size of var part
self
.backend
.emit_shl_r_imm8
(
&
tmp_var_len
,
shift
);
}
// add with fix-part size
self
.backend
.emit_add_r_imm
(
&
tmp_var_len
,
fix_part_size
as
i32
);
...
...
src/runtime/mm.rs
View file @
81b9bfe4
...
...
@@ -61,7 +61,7 @@ pub fn allocate_hybrid(ty: P<MuType>, len: u64, backendtype: Box<BackendTypeInfo
let
gctype
=
backendtype
.gc_type
.clone
();
let
encode
=
get_gc_type_encode
(
gctype
.id
);
trace!
(
"API: allocate
fixe
d ty: {}"
,
ty
);
trace!
(
"API: allocate
hybr
d ty: {}"
,
ty
);
trace!
(
"API: gc ty : {:?}"
,
gctype
);
trace!
(
"API: encode : {:b}"
,
encode
);
...
...
@@ -74,6 +74,8 @@ pub fn allocate_global(iref_global: P<Value>, backendtype: Box<BackendTypeInfo>)
None
=>
panic!
(
"expected global to be an iref type, found {}"
,
iref_global
.ty
)
};
assert
!
(
!
referenced_type
.is_hybrid
(),
"global cell cannot be hybrid type"
);
let
addr
=
allocate_fixed
(
referenced_type
,
backendtype
);
ValueLocation
::
Direct
(
RegGroup
::
GPR
,
addr
)
}
src/testutil/aot.rs
View file @
81b9bfe4
...
...
@@ -12,7 +12,7 @@ fn link_executable_internal (files: Vec<PathBuf>, lib: &Vec<String>, libpath: &V
let
mut
cc
=
Command
::
new
(
get_test_clang_path
());
for
file
in
files
{
println
!
(
"link with {:?}"
,
file
.as_path
());
trace
!
(
"link with {:?}"
,
file
.as_path
());
cc
.arg
(
file
.as_path
());
}
...
...
src/vm/vm.rs
View file @
81b9bfe4
...
...
@@ -1091,6 +1091,7 @@ impl <'a> VM {
pub
fn
new_fixed
(
&
self
,
tyid
:
MuID
)
->
APIHandleResult
{
let
ty
=
self
.get_type
(
tyid
);
assert
!
(
!
ty
.is_hybrid
());
let
backend_ty
=
self
.get_backend_type_info
(
tyid
);
let
addr
=
gc
::
allocate_fixed
(
ty
.clone
(),
backend_ty
);
...
...
@@ -1104,6 +1105,8 @@ impl <'a> VM {
pub
fn
new_hybrid
(
&
self
,
tyid
:
MuID
,
length
:
APIHandleArg
)
->
APIHandleResult
{
let
ty
=
self
.get_type
(
tyid
);
assert
!
(
ty
.is_hybrid
());
let
len
=
self
.handle_to_uint64
(
length
);
let
backend_ty
=
self
.get_backend_type_info
(
tyid
);
...
...
@@ -1152,14 +1155,12 @@ impl <'a> VM {
/// FIXME: iref/ref share the same address - this actually depends on GC
// iref has the same address as ref
trace!
(
"API: get iref from {:?}"
,
handle_ref
);
let
ret
=
self
.new_handle
(
APIHandle
{
id
:
self
.next_id
(),
v
:
APIHandleValue
::
IRef
(
ty
,
addr
)
});
trace!
(
"API: get iref from {:?}"
,
handle_ref
);
trace!
(
"API: result {:?}"
,
ret
);
ret
...
...
@@ -1174,10 +1175,15 @@ impl <'a> VM {
addr
.plus
(
backend_ty
.size
*
(
offset
as
usize
))
};
self
.new_handle
(
APIHandle
{
let
ret
=
self
.new_handle
(
APIHandle
{
id
:
self
.next_id
(),
v
:
APIHandleValue
::
IRef
(
ty
,
offset_addr
)
})
});
trace!
(
"API: shift iref from {:?}"
,
handle_iref
);
trace!
(
"API: result {:?}"
,
ret
);
ret
}
pub
fn
handle_get_elem_iref
(
&
self
,
handle_iref
:
APIHandleArg
,
index
:
APIHandleArg
)
->
APIHandleResult
{
...
...
@@ -1193,10 +1199,15 @@ impl <'a> VM {
addr
.plus
(
backend_ty
.size
*
(
index
as
usize
))
};
self
.new_handle
(
APIHandle
{
let
ret
=
self
.new_handle
(
APIHandle
{
id
:
self
.next_id
(),
v
:
APIHandleValue
::
IRef
(
ele_ty
,
elem_addr
)
})
});
trace!
(
"API: get element iref from {:?} at index {:?}"
,
handle_iref
,
index
);
trace!
(
"API: result {:?}"
,
ret
);
ret
}
pub
fn
handle_get_var_part_iref
(
&
self
,
handle_iref
:
APIHandleArg
)
->
APIHandleResult
{
...
...
@@ -1212,10 +1223,15 @@ impl <'a> VM {
None
=>
panic!
(
"cannot get varpart ty from {}"
,
ty
)
};
self
.new_handle
(
APIHandle
{
let
ret
=
self
.new_handle
(
APIHandle
{
id
:
self
.next_id
(),
v
:
APIHandleValue
::
IRef
(
varpart_ty
,
varpart_addr
)
})
});
trace!
(
"API: get var part iref from {:?}"
,
handle_iref
);
trace!
(
"API: result {:?}"
,
ret
);
ret
}
pub
fn
handle_get_field_iref
(
&
self
,
handle_iref
:
APIHandleArg
,
field
:
usize
)
->
APIHandleResult
{
...
...
@@ -1234,10 +1250,15 @@ impl <'a> VM {
addr
.plus
(
field_offset
)
};
self
.new_handle
(
APIHandle
{
let
ret
=
self
.new_handle
(
APIHandle
{
id
:
self
.next_id
(),
v
:
APIHandleValue
::
IRef
(
field_ty
,
field_addr
)
})
});
trace!
(
"API: get field iref from {:?}, field: {}"
,
handle_iref
,
field
);
trace!
(
"API: result {:?}"
,
ret
);
ret
}
pub
fn
handle_load
(
&
self
,
ord
:
MemoryOrder
,
loc
:
APIHandleArg
)
->
APIHandleResult
{
...
...
@@ -1257,10 +1278,15 @@ impl <'a> VM {
}
};
self
.new_handle
(
APIHandle
{
let
ret
=
self
.new_handle
(
APIHandle
{
id
:
handle_id
,
v
:
handle_value
})
});
trace!
(
"API: load from {:?}"
,
loc
);
trace!
(
"API: result {:?}"
,
ret
);
ret
}
pub
fn
handle_store
(
&
self
,
ord
:
MemoryOrder
,
loc
:
APIHandleArg
,
val
:
APIHandleArg
)
{
...
...
@@ -1297,6 +1323,8 @@ impl <'a> VM {
_
=>
unimplemented!
()
}
}
trace!
(
"API: store value {:?} to location {:?}"
,
val
,
loc
);
}
// this function and the following two make assumption that GC will not move object
...
...
tests/test_jit/test_rpython.py
View file @
81b9bfe4
...
...
@@ -25,6 +25,21 @@ def test_add():
assert
fn
(
1
,
2
)
==
3
@
may_spawn_proc
def
test_list_append
():
def
list_append
(
n
):
l
=
[]
for
i
in
range
(
0
,
n
):
l
.
append
(
i
)
sum
=
0
for
i
in
l
:
sum
+=
i
return
sum
fn
,
_
=
fncptr_from_rpy_func
(
list_append
,
[
rffi
.
LONGLONG
],
rffi
.
LONGLONG
)
assert
fn
(
10
)
==
45
@
may_spawn_proc
def
test_vec3prod
():
...
...
@@ -1042,7 +1057,7 @@ def test_rpytarget_print_argv():
assert
res
.
returncode
==
0
,
res
.
err
assert
res
.
out
==
'[%s, abc, 123]
\n
'
%
exe
@
pytest
.
mark
.
xfail
(
reason
=
"
probably need to align frame size to 16 bytes
"
)
@
pytest
.
mark
.
xfail
(
reason
=
"
no idea
"
)
@
may_spawn_proc
def
test_rpython_helloworld
():
from
rpython.translator.interactive
import
Translation
...
...
@@ -1064,6 +1079,49 @@ def test_rpython_helloworld():
assert
res
.
returncode
==
0
,
res
.
err
assert
res
.
out
==
'hello world
\n
'
@
pytest
.
mark
.
xfail
(
reason
=
"new test"
)
@
may_spawn_proc
def
test_rpython_print_number
():
from
rpython.translator.interactive
import
Translation
def
main
(
argv
):
print
255
return
0
t
=
Translation
(
main
,
None
,
backend
=
'mu'
,
muimpl
=
'fast'
,
mucodegen
=
'api'
)
t
.
driver
.
exe_name
=
'/tmp/test_print_number'
t
.
compile_mu
()
exe
=
py
.
path
.
local
(
'/tmp/test_print_number.mu'
)
# zebu
import
os
from
rpython.translator.mu
import
dir_mu
exe
.
chmod
(
stat
.
S_IRWXU
)
res
=
platform
.
execute
(
str
(
exe
),
[],
env
=
{
'DYLD_LIBRARY_PATH'
:
os
.
path
.
join
(
dir_mu
,
'rpyc'
)})
assert
res
.
returncode
==
0
,
res
.
err
assert
res
.
out
==
'1
\n
'
@
may_spawn_proc
def
test_rpython_main
():
from
rpython.translator.interactive
import
Translation
def
main
(
argv
):
return
0
t
=
Translation
(
main
,
None
,
backend
=
'mu'
,
muimpl
=
'fast'
,
mucodegen
=
'api'
)
t
.
driver
.
exe_name
=
'/tmp/test_main'
t
.
compile_mu
()
exe
=
py
.
path
.
local
(
'/tmp/test_main.mu'
)
# zebu
import
os
from
rpython.translator.mu
import
dir_mu
exe
.
chmod
(
stat
.
S_IRWXU
)
res
=
platform
.
execute
(
str
(
exe
),
[],
env
=
{
'DYLD_LIBRARY_PATH'
:
os
.
path
.
join
(
dir_mu
,
'rpyc'
)})
assert
res
.
returncode
==
0
,
res
.
err
@
pytest
.
mark
.
skipif
(
"True"
)
@
may_spawn_proc
def
test_rpytarget_sha1sum
():
...
...
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