Commit 182870a4 authored by Eduardo Souza's avatar Eduardo Souza

Adding test_rpython.

parent 93f19eab
Pipeline #5446 failed with stages
in 1 minute
......@@ -14,6 +14,14 @@ build:
- rustup toolchain install nightly-2019-11-04 # Needed for rustfmt
- rustup default stable # Change `stable` to whatever rust toolchain you want, it will be installed and set as the default
- rustc --version
- rm -r $CI_HOME/aot-mu/mu-client-pypy # temporarily for now, but we should check for changes instead
- if [ ! -d $CI_HOME/aot-mu/mu-client-pypy ]; then # mu-client-pypy
- git clone https://gitlab.anu.edu.au/mu/mu-client-pypy.git $CI_HOME/aot-mu/mu-client-pypy
- pushd $CI_HOME/aot-mu/mu-client-pypy
- git checkout zebu-aot-llvm
- git apply pypy.patch
- popd
- fi
- cd $MU_ZEBU
- git fetch
- git reset --hard
......@@ -102,6 +110,12 @@ test_pyt:pertarget_runnable:
- cd $MU_LLVM_ZEBU
- pytest src/tests/tests_py/test_pertarget_runnable.py -v --color=yes
test_jit:rpython:
stage: test
script:
- cd $MU_LLVM_ZEBU
- MU_LOG_LEVEL=info pytest src/tests/tests_py/test_rpython*.py -v --color=yes
rustfmt:
stage: rustfmt
script:
......
......@@ -45,9 +45,9 @@ else
export RUST_TEST_THREADS=1
export RUST_BACKTRACE=1
export PYTHONPATH=$CI_HOME/mu-client-pypy:$CI_HOME/RPySOM/src
export PYTHONPATH=$CI_HOME/aot-mu/mu-client-pypy:$CI_HOME/RPySOM/src
export RPYSOM=$CI_HOME/RPySOM
export PYPY=$CI_HOME/mu-client-pypy
export PYPY=$CI_HOME/aot-mu/mu-client-pypy
export MUC=$CI_HOME/mu-tool-compiler/muc
if [ ! -d $CI_HOME/venv2 ]; then
......
......@@ -163,9 +163,6 @@ pub fn make_boot_image_internal(
output_file: String,
is_test: bool
) {
if vm.vm_options.flag_generate_llvm == false {
panic!("Mu VM should be created with option: '--generate-llvm'")
}
info!("Making boot image...");
mu::vm::uir_output::emit_uir("", vm);
......@@ -296,7 +293,8 @@ pub fn make_boot_image_internal(
vm.link_boot_image(
whitelist_funcs,
extra_sources_to_link,
output_file
output_file,
true
);
}
}
......@@ -328,14 +326,20 @@ fn link_boot_image_for_testing(
func_names,
extra_srcs,
&output_file,
vm
vm,
true
);
} else {
if extra_srcs.len() != 0 {
panic!("trying to create an executable with linking extern sources, unimplemented");
}
// compile as executable
mu::linkutils::aot::link_test_primordial(func_names, &output_file, vm);
mu::linkutils::aot::link_test_primordial(
func_names,
&output_file,
vm,
true
);
}
trace!("Done!");
......
......@@ -2,10 +2,12 @@ use crate::aot_mu::make_boot_image_internal;
use libloading as ll;
use mu::ast::ir::MuID;
use mu::ast::types::{
HybridTagMap, StructTagMap, HYBRID_TAG_MAP_LOC, STRUCT_TAG_MAP_LOC
HybridTagMap, StructTagMap, HYBRID_TAG_MAP, HYBRID_TAG_MAP_LOC,
STRUCT_TAG_MAP, STRUCT_TAG_MAP_LOC
};
use mu::vm::api::api_c::{CMuArraySize, CMuCString, CMuVM};
use mu::vm::api::api_c::{CMuArraySize, CMuCString, CMuVM, CMuValue};
use mu::vm::api::from_CMuVM;
use mu::vm::handle::APIHandle;
use mu::vm::VM;
use std::ffi::CStr;
use std::ops::Deref;
......@@ -53,7 +55,7 @@ pub unsafe extern "C" fn compile_to_llvm_sharedlib(
}
#[no_mangle]
pub unsafe extern "C" fn compile_to_llvm_sharedlib_given_context(
pub unsafe extern "C" fn compile_to_llvm_sharedlib_using_context(
mvm: *mut CMuVM,
lib_name: CMuCString,
extra_srcs: *mut CMuCString,
......@@ -112,6 +114,68 @@ pub unsafe extern "C" fn compile_to_llvm_sharedlib_given_context(
);
}
#[no_mangle]
pub unsafe extern "C" fn compile_to_llvm_sharedlib_with_primordial(
mvm: *mut CMuVM,
lib_name: CMuCString,
extra_srcs: *mut CMuCString,
n_extra_srcs: CMuArraySize,
context: CMuCString,
primordial: CMuValue
) {
let vm = from_CMuVM(mvm);
let mut context = from_mucstring(context);
let primordial = from_handle_optional(primordial);
// loading STRUCT_TAG_MAP and HYBRID_TAG_MAP from the context
let dylib = load_from_context(context);
let lib: ll::Library = std::mem::transmute(
ll::os::unix::Library::open(
Some(dylib.as_os_str()),
libc::RTLD_NOW | libc::RTLD_GLOBAL
)
.unwrap()
);
let mut stm: ll::Symbol<StructTagMap> =
lib.get("STRUCT_TAG_MAP".as_bytes()).unwrap();
let stm_loaded = stm.load(Ordering::SeqCst);
STRUCT_TAG_MAP_LOC.swap(stm_loaded, Ordering::SeqCst);
let mut htm: ll::Symbol<HybridTagMap> =
lib.get("HYBRID_TAG_MAP".as_bytes()).unwrap();
let htm_loaded = htm.load(Ordering::SeqCst);
HYBRID_TAG_MAP_LOC.swap(htm_loaded, Ordering::SeqCst);
let vm = VM::resume_loaded_vm(vm);
let mut _arg_lib_name = from_mucstring(lib_name);
let mut _arg_extra_srcs = from_mucstring_array(extra_srcs, n_extra_srcs);
let mut funcs: Vec<MuID> = {
let funcs = vm.funcs().read().unwrap();
funcs.keys().map(|x| *x).collect()
};
funcs.sort();
make_boot_image_internal(
&vm,
funcs,
primordial,
None,
None,
vec![],
vec![],
vec![],
vec![],
_arg_extra_srcs,
_arg_lib_name,
false
);
}
#[inline(always)]
fn from_mucstring(cstring: CMuCString) -> String {
debug_assert!(!cstring.is_null());
......@@ -135,6 +199,22 @@ fn from_array_direct<'a, T>(ptr: *const T, len: usize) -> &'a [T] {
}
}
#[inline(always)]
fn from_handle_optional<'a>(cmuvalue: CMuValue) -> Option<&'a APIHandle> {
if cmuvalue.is_null() {
None
} else {
Some(from_handle(cmuvalue))
}
}
// APIHandle is immutable when used.
#[inline(always)]
fn from_handle<'a>(cmuvalue: CMuValue) -> &'a APIHandle {
debug_assert!(!cmuvalue.is_null());
unsafe { &*(cmuvalue as *const APIHandle) }
}
unsafe fn load_from_context(context: String) -> PathBuf {
let mu_aot_llvm_path = match env::var("MU_LLVM_ZEBU") {
Ok(v) => {
......@@ -147,17 +227,41 @@ unsafe fn load_from_context(context: String) -> PathBuf {
let dylib = mu_aot_llvm_path.join(PathBuf::from(context));
let dylib = compile_context(dylib);
compile_context_into_object(dylib.clone());
let dylib = compile_context_into_shared_lib(dylib);
dylib
}
fn compile_context(file: PathBuf) -> PathBuf {
fn compile_context_into_object(file: PathBuf) -> PathBuf {
let mut cc = Command::new(get_c_compiler());
// position independent code
cc.arg("-c");
cc.arg("-fPIC");
let mut out = file.clone();
let mut in_file = file.clone();
in_file.set_extension("S");
out.set_extension("o");
cc.arg(in_file.as_os_str());
cc.arg("-o");
cc.arg(out.as_os_str());
exec_cmd(cc);
out
}
fn compile_context_into_shared_lib(file: PathBuf) -> PathBuf {
let mut cc = Command::new(get_c_compiler());
// position independent code
cc.arg("-fPIC");
cc.arg("-shared");
cc.arg("-Wl");
let mut out = file.clone();
if cfg!(target_os = "linux") {
......@@ -173,6 +277,20 @@ fn compile_context(file: PathBuf) -> PathBuf {
out.set_extension("dylib");
}
cc.arg("-rdynamic");
cc.arg(format!(
"{}",
get_path_under_zebu(if cfg!(debug_assertions) {
"target/debug/deps/libmu.a"
} else {
"target/release/deps/libmu.a"
})
.to_str()
.unwrap()
));
// cc.arg("-lmu");
cc.arg(file.as_os_str());
cc.arg("-o");
cc.arg(out.as_os_str());
......@@ -182,6 +300,23 @@ fn compile_context(file: PathBuf) -> PathBuf {
out
}
fn get_path_under_zebu(str: &'static str) -> PathBuf {
use std::env;
match env::var("MU_ZEBU") {
Ok(v) => {
trace!("MU_ZEBU is set to: -{}-", v);
let mut ret = PathBuf::from(v.clone());
ret.push(str);
ret
}
Err(e) => {
trace!("MU_ZEBU error: -{}-", e);
PathBuf::from(str)
}
}
}
fn get_c_compiler() -> String {
use std::env;
......
......@@ -1337,16 +1337,28 @@ pub unsafe fn gen_instr_new_hybrid(
let llvm_var_ty = gen_llvm_type(llvm_internal_context, var_ty);
let size_of_hybrid = LLVMABISizeOfType(module_data_layout, llvm_var_ty);
let length = match &ins.ops.get(*length).unwrap().as_value().v {
Value_::Constant(c) => match c {
Constant::Int(n) => *n,
_ => unimplemented!()
},
_ => unimplemented!()
};
total_size += size_of_hybrid * length;
let llvm_length = gen_llvm_value(
llvm_internal_context,
ins.ops.get(*length).unwrap(),
store
);
let llvm_hybrid_size =
LLVMConstInt(LLVMInt64Type(), size_of_hybrid, true as i32);
let hybrid_size = LLVMBuildMul(
llvm_internal_context.builder,
llvm_length,
llvm_hybrid_size,
"hyb_size\0".as_ptr() as *const c_char
);
let total_size = LLVMConstInt(LLVMInt64Type(), total_size, true as i32);
let total_size = LLVMBuildAdd(
llvm_internal_context.builder,
hybrid_size,
total_size,
"total_size\0".as_ptr() as *const c_char
);
let mut calloc_args =
vec![LLVMConstInt(LLVMInt64Type(), 1, true as i32), total_size];
......@@ -1908,6 +1920,45 @@ pub unsafe fn gen_instr_thread_exit(
LLVMBuildUnreachable(llvm_internal_context.builder);
}
pub unsafe fn gen_instr_get_thread_local(
llvm_internal_context: &mut AOTLLVMInternalContext,
store: &mut HashMap<MuID, LLVMValueRef>,
ins: &Instruction
) {
let function_name = CString::new("muentry_get_thread_local").unwrap();
let llvm_function_name = LLVMGetNamedFunction(
llvm_internal_context.module,
function_name.as_ptr()
);
if llvm_function_name.is_null() {
panic!("Could not find function.");
}
let mut get_thread_local_args = vec![];
let thread_local = LLVMBuildCall(
llvm_internal_context.builder,
llvm_function_name,
get_thread_local_args.as_mut_ptr(),
get_thread_local_args.len() as c_uint,
"tl\0".as_ptr() as *const c_char
);
let ins_value = ins.value.clone().unwrap();
let mut name = String::from("");
let mut id = 0;
if ins_value.len() > 1 {
panic!("Unsupported operation.");
} else if ins_value.len() == 1 {
id = ins_value.get(0).unwrap().hdr.id();
name = format!("{}\0", ins_value.get(0).unwrap().hdr.name());
}
store.insert(id, thread_local);
}
pub unsafe fn gen_instr_new_thread(
llvm_internal_context: &mut AOTLLVMInternalContext,
store: &mut HashMap<MuID, LLVMValueRef>,
......@@ -2365,7 +2416,13 @@ pub unsafe fn gen_instr_convop(
ConvOp::PTRCAST => match to_ty.v {
MuType_::Int(_) => LLVMOpcode::LLVMPtrToInt,
MuType_::UPtr(_) | MuType_::IRef(_) | MuType_::Ref(_) => {
LLVMOpcode::LLVMBitCast
match _from_ty.v {
MuType_::Int(_) => LLVMOpcode::LLVMIntToPtr,
MuType_::UPtr(_) | MuType_::IRef(_) | MuType_::Ref(_) => {
LLVMOpcode::LLVMBitCast
}
_ => panic!("Type should be reference type or integer.")
}
}
_ => panic!("Type should be reference type or integer.")
}
......
......@@ -267,6 +267,21 @@ fn visit_inst_custom(
return_type
);
},
mu::ast::inst::Instruction_::CommonInst_GetThreadLocal => unsafe {
let function_name =
MuName::new(String::from("muentry_get_thread_local"));
let llvm_arg_types = vec![];
let return_type = LLVMPointerType(LLVMVoidType(), 0);
add_function_to_module(
llvm_internal_context,
function_name,
llvm_arg_types,
return_type
);
},
mu::ast::inst::Instruction_::ThreadExit => unsafe {
let function_name =
MuName::new(String::from("muentry_get_thread_local"));
......@@ -1502,6 +1517,15 @@ unsafe fn gen_llvm_instruction(
mu::ast::inst::Instruction_::NewStack(op) => {
gen_instr_new_stack(llvm_internal_context, store, ins, op);
}
mu::ast::inst::Instruction_::CommonInst_GetThreadLocal => {
gen_instr_get_thread_local(llvm_internal_context, store, ins);
}
mu::ast::inst::Instruction_::CommonInst_SetThreadLocal(op) => {
//FIXME implement set thread local
//
// gen_instr_get_thread_local(llvm_internal_context, store,
// ins);
}
// FIXME pinning and unpinning are not available without an
// appropriate GC
mu::ast::inst::Instruction_::CommonInst_Unpin(op) => {}
......
This diff is collapsed.
# Copyright 2017 The Australian National University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from rpython.rtyper.lltypesystem import rffi
from util import fncptr_from_rpy_func, fncptr_from_rpy_func_llvm, may_spawn_proc
# disabled all tests on u64 MAX boundary
# rpython int is i64
@may_spawn_proc
def test_rpython_int_cmp():
def int_cmp(a, b):
if a > b:
return 1
elif a == b:
return 0
else:
return -1
mu_int_cmp, _ = fncptr_from_rpy_func_llvm(int_cmp, [rffi.LONGLONG, rffi.LONGLONG], rffi.LONGLONG)
assert mu_int_cmp(1, 0) == 1
assert mu_int_cmp(0, 1) == -1
assert mu_int_cmp(0, 0) == 0
assert mu_int_cmp(1, 1) == 0
assert mu_int_cmp(1, -1) == 1
assert mu_int_cmp(-1, 1) == -1
assert mu_int_cmp(-1, -2) == 1
assert mu_int_cmp(-2, -1) == -1
assert mu_int_cmp(-1, -1) == 0
assert mu_int_cmp(9223372036854775807, -9223372036854775808) == 1
# assert mu_int_cmp(18446744073709551615, 9223372036854775807) == -1
# assert mu_int_cmp(18446744073709551615, -9223372036854775808) == 1
# assert mu_int_cmp(18446744073709551615, -1) == 0
@may_spawn_proc
def test_rpython_int_cmp_zero():
def int_cmp_zero(a):
if a > 0:
return 1
elif a == 0:
return 0
else:
return -1
mu_int_cmp_zero, _ = fncptr_from_rpy_func_llvm(int_cmp_zero, [rffi.LONGLONG], rffi.LONGLONG)
assert mu_int_cmp_zero(1) == 1
assert mu_int_cmp_zero(9223372036854775807) == 1
# assert mu_int_cmp_zero(18446744073709551615) == -1
assert mu_int_cmp_zero(0) == 0
assert mu_int_cmp_zero(-1) == -1
assert mu_int_cmp_zero(-9223372036854775808) == -1
@may_spawn_proc
def test_rpython_int_cmp_const_zero_eq_zero():
# these may get optimized away by Rpython compiler
def int_cmp_zero_eq_zero():
if 0 == 0:
return 1
else:
return 0
mu_int_cmp_zero_eq_zero, _ = fncptr_from_rpy_func_llvm(int_cmp_zero_eq_zero, [], rffi.LONGLONG)
assert mu_int_cmp_zero_eq_zero() == 1
@may_spawn_proc
def test_rpython_int_cmp_const_zero_ne_zero():
# these may get optimized away by Rpython compiler
def int_cmp_zero_ne_zero():
if 0 != 0:
return 0
else:
return 1
mu_int_cmp_zero_ne_zero, _ = fncptr_from_rpy_func_llvm(int_cmp_zero_ne_zero, [], rffi.LONGLONG)
assert mu_int_cmp_zero_ne_zero() == 1
@may_spawn_proc
def test_rpython_int_cmp_const_zero_eq_one():
# these may get optimized away by Rpython compiler
def int_cmp_zero_eq_one():
if 0 == 1:
return 0
else:
return 1
mu_int_cmp_zero_eq_one , _ = fncptr_from_rpy_func_llvm(int_cmp_zero_eq_one , [], rffi.LONGLONG)
assert mu_int_cmp_zero_eq_one () == 1
@may_spawn_proc
def test_rpython_int_cmp_const_zero_ne_one():
# these may get optimized away by Rpython compiler
def int_cmp_zero_ne_one():
if 0 != 1:
return 1
else:
return 0
mu_int_cmp_zero_ne_one , _ = fncptr_from_rpy_func_llvm(int_cmp_zero_ne_one , [], rffi.LONGLONG)
assert mu_int_cmp_zero_ne_one () == 1
@may_spawn_proc
def test_rpython_int_gt_value():
def int_gt_value(a, b):
ret = a > b
return ret
mu_int_gt_value, _ = fncptr_from_rpy_func_llvm(int_gt_value, [rffi.LONGLONG, rffi.LONGLONG], rffi.LONGLONG)
assert mu_int_gt_value(1, 0) == 1
assert mu_int_gt_value(0, 1) == 0
assert mu_int_gt_value(1, 1) == 0
assert mu_int_gt_value(1, -1) == 1
assert mu_int_gt_value(-1, 1) == 0
assert mu_int_gt_value(-1, -1) == 0
assert mu_int_gt_value(9223372036854775807, -9223372036854775808) == 1
assert mu_int_gt_value(-9223372036854775808, 9223372036854775807) == 0
# assert mu_int_gt_value(18446744073709551615, 9223372036854775807) == 0
# assert mu_int_gt_value(18446744073709551615, -9223372036854775808) == 1
# assert mu_int_gt_value(18446744073709551615, -1) == 0
@may_spawn_proc
def test_rpython_int_ge_value():
def int_ge_value(a, b):
ret = a >= b
return ret
mu_int_ge_value, _ = fncptr_from_rpy_func_llvm(int_ge_value, [rffi.LONGLONG, rffi.LONGLONG], rffi.LONGLONG)
assert mu_int_ge_value(1, 0) == 1
assert mu_int_ge_value(0, 1) == 0
assert mu_int_ge_value(1, 1) == 1
assert mu_int_ge_value(1, -1) == 1
assert mu_int_ge_value(-1, 1) == 0
assert mu_int_ge_value(-1, -1) == 1
assert mu_int_ge_value(9223372036854775807, -9223372036854775808) == 1
assert mu_int_ge_value(-9223372036854775808, 9223372036854775807) == 0
# assert mu_int_ge_value(18446744073709551615, 9223372036854775807) == 0
# assert mu_int_ge_value(18446744073709551615, -9223372036854775808) == 1
# assert mu_int_ge_value(18446744073709551615, -1) == 1
@may_spawn_proc
def test_rpython_int_lt_value():
def int_lt_value(a, b):
ret = a < b
return ret
mu_int_lt_value, _ = fncptr_from_rpy_func_llvm(int_lt_value, [rffi.LONGLONG, rffi.LONGLONG], rffi.LONGLONG)
assert mu_int_lt_value(1, 0) == 0
assert mu_int_lt_value(0, 1) == 1
assert mu_int_lt_value(1, 1) == 0
assert mu_int_lt_value(1, -1) == 0
assert mu_int_lt_value(-1, 1) == 1
assert mu_int_lt_value(-1, -1) == 0
assert mu_int_lt_value(9223372036854775807, -9223372036854775808) == 0
assert mu_int_lt_value(-9223372036854775808, 9223372036854775807) == 1
# assert mu_int_lt_value(18446744073709551615, 9223372036854775807) == 1
# assert mu_int_lt_value(18446744073709551615, -9223372036854775808) == 0
# assert mu_int_lt_value(18446744073709551615, -1) == 0
@may_spawn_proc
def test_rpython_int_le_value():
def int_le_value(a, b):
ret = a <= b
return ret
mu_int_le_value, _ = fncptr_from_rpy_func_llvm(int_le_value, [rffi.LONGLONG, rffi.LONGLONG], rffi.LONGLONG)
assert mu_int_le_value(1, 0) == 0
assert mu_int_le_value(0, 1) == 1
assert mu_int_le_value(1, 1) == 1
assert mu_int_le_value(1, -1) == 0
assert mu_int_le_value(-1, 1) == 1
assert mu_int_le_value(-1, -1) == 1
assert mu_int_le_value(9223372036854775807, -9223372036854775808) == 0
assert mu_int_le_value(-9223372036854775808, 9223372036854775807) == 1
# assert mu_int_le_value(18446744073709551615, 9223372036854775807) == 1
# assert mu_int_le_value(18446744073709551615, -9223372036854775808) == 0
# assert mu_int_le_value(18446744073709551615, -1) == 1
@may_spawn_proc
def test_rpython_int_eq_value():
def int_eq_value(a, b):
ret = a == b
return ret
mu_int_eq_value, _ = fncptr_from_rpy_func_llvm(int_eq_value, [rffi.LONGLONG, rffi.LONGLONG], rffi.LONGLONG)
assert mu_int_eq_value(1, 0) == 0
assert mu_int_eq_value(0, 1) == 0
assert mu_int_eq_value(1, 1) == 1
assert mu_int_eq_value(1, -1) == 0
assert mu_int_eq_value(-1, 1) == 0
assert mu_int_eq_value(-1, -1) == 1
assert mu_int_eq_value(9223372036854775807, -9223372036854775808) == 0
assert mu_int_eq_value(-9223372036854775808, 9223372036854775807) == 0
# assert mu_int_eq_value(18446744073709551615, 9223372036854775807) == 0
# assert mu_int_eq_value(18446744073709551615, -9223372036854775808) == 0
# assert mu_int_eq_value(18446744073709551615, -1) == 1
@may_spawn_proc
def test_rpython_int_ne_value():
def int_ne_value(a, b):
ret = a != b
return ret
mu_int_ne_value, _ = fncptr_from_rpy_func_llvm(int_ne_value, [rffi.LONGLONG, rffi.LONGLONG], rffi.LONGLONG)
assert mu_int_ne_value(1, 0) == 1
assert mu_int_ne_value(0, 1) == 1
assert mu_int_ne_value(1, 1) == 0
assert mu_int_ne_value(1, -1) == 1
assert mu_int_ne_value(-1, 1) == 1
assert mu_int_ne_value(-1, -1) == 0
assert mu_int_ne_value(9223372036854775807, -9223372036854775808) == 1
assert mu_int_ne_value(-9223372036854775808, 9223372036854775807) == 1
# assert mu_int_ne_value(18446744073709551615, 9223372036854775807) == 1
# assert mu_int_ne_value(18446744073709551615, -9223372036854775808) == 1
# assert mu_int_ne_value(18446744073709551615, -1) == 0
\ No newline at end of file
# Copyright 2017 The Australian National University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rlib.rmu import zebu as rmu
from rpython.translator.platform import platform
from util import fncptr_from_rpy_func, fncptr_from_rpy_func_llvm, fncptr_from_py_script, may_spawn_proc
import ctypes, py, stat
import pytest
from test_rpython import run_boot_image, check
c_exit = rffi.llexternal('exit', [rffi.INT], lltype.Void, _nowrapper=True)
@may_spawn_proc
def test_rpython_dict_new_empty():
def new_empty():
a = {}
fn, (db, bdlgen) = fncptr_from_rpy_func_llvm(new_empty, [], lltype.Void)
bdlgen.mu.current_thread_as_mu_thread(rmu.null(rmu.MuCPtr))
fn()
@may_spawn_proc
def test_rpython_dict_new_1():
def new_1():
a = {0: 42}