started changing ralloc/ealloc return type to ref instead of uptr

parent 276d513c
......@@ -2371,21 +2371,22 @@ impl<'a> InstructionSelection {
let tmp_region =
self.emit_ireg(region, f_content, f_context, vm);
if ty.contains_iref() {
let ty_id: MuID = ty.id();
let tmp_id =
self.make_int64_const(ty_id as u64, vm);
self.emit_runtime_entry(
&entrypoints::RALLOC_TRACED,
vec![tmp_region, tmp_id],
Some(vec![tmp_res]),
Some(node),
f_content,
f_context,
vm
);
} else {
// if ty.contains_iref() {
// let ty_id: MuID = ty.id();
// let tmp_id =
// self.make_int64_const(ty_id as u64, vm);
//
// self.emit_runtime_entry(
// &entrypoints::RALLOC_TRACED,
// vec![tmp_region, tmp_id],
// Some(vec![tmp_res]),
// Some(node),
// f_content,
// f_context,
// vm
// );
// } else
{
let ty_info = vm.get_backend_type_info(ty.id());
let size = ty_info.size;
let tmp_size =
......@@ -2431,35 +2432,36 @@ impl<'a> InstructionSelection {
self.emit_ireg(region, f_content, f_context, vm);
// if the type contains iref to heap objects
if ty.contains_iref() {
let ty_id: MuID = ty.id();
let tmp_id =
self.make_int64_const(ty_id as u64, vm);
let tmp_var_len = if self
.match_iconst_any(op_var_len)
{
let const_var_len = op_var_len
.as_value()
.extract_int_const()
.unwrap();
self.make_int64_const(const_var_len as u64, vm)
} else {
debug_assert!(self.match_ireg(op_var_len));
op_var_len.as_value().clone()
};
self.emit_runtime_entry(
&entrypoints::RALLOC_HYBRID_TRACED,
vec![tmp_region, tmp_id, tmp_var_len],
Some(vec![tmp_res]),
Some(node),
f_content,
f_context,
vm
);
} else {
// if ty.contains_iref() {
// let ty_id: MuID = ty.id();
// let tmp_id =
// self.make_int64_const(ty_id as u64, vm);
//
// let tmp_var_len = if self
// .match_iconst_any(op_var_len)
// {
// let const_var_len = op_var_len
// .as_value()
// .extract_int_const()
// .unwrap();
//
// self.make_int64_const(const_var_len as u64, vm)
// } else {
// debug_assert!(self.match_ireg(op_var_len));
// op_var_len.as_value().clone()
// };
//
// self.emit_runtime_entry(
// &entrypoints::RALLOC_HYBRID_TRACED,
// vec![tmp_region, tmp_id, tmp_var_len],
// Some(vec![tmp_res]),
// Some(node),
// f_content,
// f_context,
// vm
// );
// } else
{
let tmp_fixed_size =
self.make_int64_const(fix_part_size as u64, vm);
......@@ -2506,21 +2508,22 @@ impl<'a> InstructionSelection {
// let ty_info = vm.get_backend_type_info(ty.id());
let tmp_res = self.get_result_value(node);
if ty.contains_iref() {
let ty_id: MuID = ty.id();
let tmp_id =
self.make_int64_const(ty_id as u64, vm);
self.emit_runtime_entry(
&entrypoints::EALLOC_TRACED,
vec![tmp_id],
Some(vec![tmp_res]),
Some(node),
f_content,
f_context,
vm
);
} else {
// if ty.contains_iref() {
// let ty_id: MuID = ty.id();
// let tmp_id =
// self.make_int64_const(ty_id as u64, vm);
//
// self.emit_runtime_entry(
// &entrypoints::EALLOC_TRACED,
// vec![tmp_id],
// Some(vec![tmp_res]),
// Some(node),
// f_content,
// f_context,
// vm
// );
// } else
{
let ty_info = vm.get_backend_type_info(ty.id());
let size = ty_info.size;
let tmp_size =
......@@ -2561,35 +2564,36 @@ impl<'a> InstructionSelection {
let tmp_res = self.get_result_value(node);
// if the type contains iref to heap objects
if ty.contains_iref() {
let ty_id: MuID = ty.id();
let tmp_id =
self.make_int64_const(ty_id as u64, vm);
let tmp_var_len = if self
.match_iconst_any(op_var_len)
{
let const_var_len = op_var_len
.as_value()
.extract_int_const()
.unwrap();
self.make_int64_const(const_var_len as u64, vm)
} else {
debug_assert!(self.match_ireg(op_var_len));
op_var_len.as_value().clone()
};
self.emit_runtime_entry(
&entrypoints::EALLOC_HYBRID_TRACED,
vec![tmp_id, tmp_var_len],
Some(vec![tmp_res]),
Some(node),
f_content,
f_context,
vm
);
} else {
// if ty.contains_iref() {
// let ty_id: MuID = ty.id();
// let tmp_id =
// self.make_int64_const(ty_id as u64, vm);
//
// let tmp_var_len = if self
// .match_iconst_any(op_var_len)
// {
// let const_var_len = op_var_len
// .as_value()
// .extract_int_const()
// .unwrap();
//
// self.make_int64_const(const_var_len as u64, vm)
// } else {
// debug_assert!(self.match_ireg(op_var_len));
// op_var_len.as_value().clone()
// };
//
// self.emit_runtime_entry(
// &entrypoints::EALLOC_HYBRID_TRACED,
// vec![tmp_id, tmp_var_len],
// Some(vec![tmp_res]),
// Some(node),
// f_content,
// f_context,
// vm
// );
// } else
{
let tmp_fixed_size =
self.make_int64_const(fix_part_size as u64, vm);
......
// 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.
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>
uintptr_t immmix_get_stack_ptr() {
uintptr_t rsp;
// get current rsp, rbp (this C func frame)
__asm__(
"mov %%rsp, %0 \n"
: "=rm" (rsp)
);
return rsp;
}
int get_registers_count() {
return 16;
}
uintptr_t* get_registers () {
uintptr_t rax, rbx, rcx, rdx, rbp, rsp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15;
__asm__(
"mov %%rax, %0 \n"
"mov %%rbx, %1 \n"
"mov %%rcx, %2 \n"
"mov %%rdx, %3 \n"
"mov %%rbp, %4 \n"
"mov %%rsp, %5 \n"
"mov %%rsi, %5 \n"
"mov %%rdi, %6 \n"
"mov %%r8, %7 \n"
"mov %%r9, %8 \n"
"mov %%r10, %10\n"
"mov %%r11, %11\n"
"mov %%r12, %12\n"
"mov %%r13, %13\n"
"mov %%r14, %14\n"
"mov %%r15, %15\n"
: "=m" (rax),
"=m" (rbx),
"=m" (rcx),
"=m" (rdx),
"=m" (rbp),
"=m" (rsp),
"=m" (rsi),
"=m" (rdi),
"=m" (r8),
"=m" (r9),
"=m" (r10),
"=m" (r11),
"=m" (r12),
"=m" (r13),
"=m" (r14),
"=m" (r15)
:
:
);
uintptr_t* ret = (uintptr_t*) malloc(sizeof(uintptr_t) * 16);
ret[0] = rax;
ret[1] = rbx;
ret[2] = rcx;
ret[3] = rdx;
ret[4] = rbp;
ret[5] = rsp;
ret[6] = rsi;
ret[7] = rdi;
ret[8] = r8;
ret[9] = r9;
ret[10] = r10;
ret[11] = r11;
ret[12] = r12;
ret[13] = r13;
ret[14] = r14;
ret[15] = r15;
return ret;
}
// __thread uintptr_t low_water_mark;
int lwm_initialized = 0;
static pthread_key_t low_water_mark;
void set_low_water_mark () {
uintptr_t rsp;
if(lwm_initialized == 0){
lwm_initialized = 1;
int result = pthread_key_create(&low_water_mark, NULL);
if(result != 0){
printf("set_low_water_mark(): PThread key create failed with error code = %d\n", result);
assert(0);
}
}
// get current rsp, rbp (this C func frame)
__asm__(
"mov %%rsp, %0 \n"
: "=rm" (rsp)
);
int result = pthread_setspecific(low_water_mark, (const void *) rsp);
if(result != 0){
printf("set_low_water_mark(): PThread set specific failed with error code = %d\n", result);
assert(0);
}
}
uintptr_t get_low_water_mark() {
if(lwm_initialized == 0){
printf("get_low_water_mark(): PThread key MUST be initialized before first use!!\n");
}
void * result = pthread_getspecific(low_water_mark);
if(result == NULL){
printf("get_low_water_mark(): NO pthread key found for current thread!!\n");
assert(0);
}
return (uintptr_t) result;
}
......@@ -4928,7 +4928,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
// }
let my_index = ops.len();
let op = self.add_opnd(fcb, ops, *vid);
assert_ir!(op.ty() == arg.ty);
assert_ir!(op.ty() == arg.ty, "op.ty() is -{:#?}- but arg.ty is -{:#?}", op.ty(), arg.ty);
DestArg::Normal(my_index)
})
.collect::<Vec<_>>();
......
============================= test session starts ==============================
platform linux2 -- Python 2.7.15rc1, pytest-2.9.2, py-1.4.29, pluggy-0.3.1 -- /usr/bin/python2
cachedir: .cache
rootdir: /home/javadamiri/myFiles/Src/mu-impl-fast/tests/test_jit, inifile:
collecting ... collected 30 items
test_rpython.py::test_throw <- util.py PASSED
test_rpython.py::test_find_min <- util.py PASSED
test_rpython.py::test_exception_stack_unwind <- util.py PASSED
test_rpython.py::test_partition_in_quicksort <- util.py PASSED
test_rpython.py::test_dtoa <- util.py PASSED
test_rpython.py::test_rpytarget_print_argv <- util.py PASSED
test_rpython.py::test_rpytarget_richards_measure_time <- util.py PASSED
test_rpython.py::test_float <- util.py PASSED
test_rpython.py::test_add <- util.py PASSED
test_rpython.py::test_linkedlist_reversal <- util.py PASSED
test_rpython.py::test_quicksort <- util.py PASSED
test_rpython.py::test_open_file_as_stream <- util.py PASSED
test_rpython.py::test_rpython_main <- util.py PASSED
test_rpython.py::test_nbody <- util.py PASSED
test_rpython.py::test_rpython_time_diff <- util.py PASSED
test_rpython.py::test_new_cmpeq <- util.py PASSED
test_rpython.py::test_rpython_print_number <- util.py PASSED
test_rpython.py::test_rpytarget_richards0 <- util.py PASSED
test_rpython.py::test_rpytarget_sha1sum <- util.py PASSED
test_rpython.py::test_new <- util.py PASSED
test_rpython.py::test_vec3prod <- util.py PASSED
test_rpython.py::test_make_boot_image_simple <- util.py PASSED
test_rpython.py::test_threadtran_fib <- util.py PASSED
test_rpython.py::test_rpython_rethrow <- util.py PASSED
test_rpython.py::test_rpython_helloworld <- util.py PASSED
test_rpython.py::test_arraysum <- util.py PASSED
test_rpython.py::test_rpython_print_time <- util.py PASSED
test_rpython.py::test_rpytarget_testdicts <- util.py PASSED
test_rpython.py::test_rpython_print_fmt <- util.py PASSED
test_rpython.py::test_linked_list <- util.py PASSED
========================= 30 passed in 190.17 seconds ==========================
......@@ -256,11 +256,42 @@ logger = AnsiLogger('rt_rpython_tests')
#
# assert False
# @may_spawn_proc
# def test_simple_timer():
# from rpython.dev.dev_timer import test_simple_timer
# logger.info('going to build the test function')
# exec_path = executable_from_rpy_func(test_simple_timer, [], rffi.SIGNED)
#
# logger.info('going to run the test function')
#
# # import subprocess
# # subprocess.call([fn()])
# # subprocess.check_output([fn()])
#
# import subprocess
# import os
#
# start = time.time()
#
# res = subprocess.call(
# 'sudo LD_LIBRARY_PATH=$PWD/emit:$LD_LIBRARY_PATH MU_LOG_LEVEL=debug %s' % exec_path, shell=True)
#
# end = time.time()
#
# logger.info("Test took: ")
# logger.info(end-start)
#
# logger.info('returned res = %d' % res)
#
# # assert False
# assert 0 <= res <= 50
@may_spawn_proc
def test_simple_timer():
from rpython.dev.dev_timer import test_simple_timer
def test_collision_detection():
from rpython.dev.dev_CD import dev_cd
logger.info('going to build the test function')
exec_path = executable_from_rpy_func(test_simple_timer, [], rffi.SIGNED)
exec_path = executable_from_rpy_func(dev_cd.main_region, [], rffi.SIGNED)
logger.info('going to run the test function')
......@@ -283,5 +314,6 @@ def test_simple_timer():
logger.info('returned res = %d' % res)
# assert False
assert 0 <= res <= 50
assert False
# assert 0 <= res <= 50
......@@ -165,7 +165,7 @@ fn ralloc_untraced() -> VM {
typedef!((vm) int64 = mu_int(64));
typedef!((vm) array_int64_100 = mu_array(int64, 10));
typedef!((vm) array_i100_ptr = mu_uptr(array_int64_100));
typedef!((vm) array_i100_ptr = mu_ref(array_int64_100));
typedef!((vm) regionref_t = mu_regionref);
funcsig!((vm) sig = (int64) -> (array_i100_ptr));
......@@ -239,7 +239,7 @@ fn ralloc_hybrid_untraced() -> VM {
typedef! ((vm) int64 = mu_int(64));
typedef! ((vm) hybrid_int64 = mu_hybrid(int64, int64)(int64));
typedef! ((vm) hybrid_int64_ptr = mu_uptr(hybrid_int64));
typedef! ((vm) hybrid_int64_ptr = mu_ref(hybrid_int64));
typedef! ((vm) regionref_t = mu_regionref);
constdef! ((vm) <int64> reg_size = Constant::Int(80));
......@@ -317,7 +317,7 @@ fn ralloc_traced_array() -> VM {
typedef!((vm) int64 = mu_int(64));
typedef!((vm) i64_iref = mu_iref(int64));
typedef!((vm) array_iref_100 = mu_array(i64_iref, 10));
typedef!((vm) array_i100_ptr = mu_uptr(array_iref_100));
typedef!((vm) array_i100_ptr = mu_ref(array_iref_100));
typedef!((vm) regionref_t = mu_regionref);
funcsig!((vm) sig = (int64) -> (array_i100_ptr));
......@@ -392,7 +392,7 @@ fn ralloc_traced_nested_struct() -> VM {
typedef!((vm) i64_iref = mu_iref(int64));
typedef!((vm) inner_struct = mu_struct(int64, i64_iref, int64));
typedef!((vm) outer_struct = mu_struct(int64, inner_struct, int64, i64_iref));
typedef!((vm) outer_struct_ptr = mu_uptr(outer_struct));
typedef!((vm) outer_struct_ptr = mu_ref(outer_struct));
typedef!((vm) regionref_t = mu_regionref);
funcsig!((vm) sig = (int64) -> (outer_struct_ptr));
......@@ -469,7 +469,7 @@ fn ralloc_hybrid_fix_traced() -> VM {
typedef! ((vm) int64 = mu_int(64));
typedef! ((vm) i64_iref = mu_iref(int64));
typedef! ((vm) hybrid_int64 = mu_hybrid(int64, i64_iref)(int64));
typedef! ((vm) hybrid_int64_ptr = mu_uptr(hybrid_int64));
typedef! ((vm) hybrid_int64_ptr = mu_ref(hybrid_int64));
typedef! ((vm) regionref_t = mu_regionref);
constdef! ((vm) <int64> reg_size = Constant::Int(80));
......@@ -541,7 +541,7 @@ fn ralloc_hybrid_var_traced() -> VM {
typedef! ((vm) int64 = mu_int(64));
typedef! ((vm) i64_iref = mu_iref(int64));
typedef! ((vm) hybrid_int64 = mu_hybrid(int64, int64)(i64_iref));
typedef! ((vm) hybrid_int64_ptr = mu_uptr(hybrid_int64));
typedef! ((vm) hybrid_int64_ptr = mu_ref(hybrid_int64));
typedef! ((vm) regionref_t = mu_regionref);
constdef! ((vm) <int64> reg_size = Constant::Int(80));
......@@ -617,7 +617,7 @@ fn e_alloc_untraced() -> VM {
typedef!((vm) int64 = mu_int(64));
typedef!((vm) array_i64_100 = mu_array(int64, 10));
typedef!((vm) array_i100_ptr = mu_uptr(array_i64_100));
typedef!((vm) array_i100_ptr = mu_ref(array_i64_100));
funcsig!((vm) sig = () -> (array_i100_ptr));
funcdecl!((vm) <sig> func);
......@@ -670,7 +670,7 @@ fn ealloc_hybrid_untraced() -> VM {
typedef! ((vm) int64 = mu_int(64));
typedef! ((vm) hybrid_int64 = mu_hybrid(int64, int64)(int64));
typedef! ((vm) hybrid_int64_ptr = mu_uptr(hybrid_int64));
typedef! ((vm) hybrid_int64_ptr = mu_ref(hybrid_int64));
funcsig! ((vm) sig = (int64) -> (hybrid_int64_ptr));
funcdecl! ((vm) <sig> func);
......@@ -731,7 +731,7 @@ fn e_delete_untraced() -> VM {
typedef!((vm) int64 = mu_int(64));
typedef!((vm) array_i64_100 = mu_array(int64, 10));
typedef!((vm) array_i100_ptr = mu_uptr(array_i64_100));
typedef!((vm) array_i100_ptr = mu_ref(array_i64_100));
funcsig!((vm) sig = () -> ());
funcdecl!((vm) <sig> func);
......@@ -788,7 +788,7 @@ fn e_alloc_traced() -> VM {
typedef!((vm) int64 = mu_int(64));
typedef!((vm) i64_iref = mu_iref(int64));
typedef!((vm) array_iref_100 = mu_array(i64_iref, 10));
typedef!((vm) array_i100_ptr = mu_uptr(array_iref_100));
typedef!((vm) array_i100_ptr = mu_ref(array_iref_100));
funcsig!((vm) sig = () -> (array_i100_ptr));
funcdecl!((vm) <sig> func);
......@@ -844,7 +844,7 @@ fn ealloc_hybrid_fixed_traced() -> VM {
typedef! ((vm) int64 = mu_int(64));
typedef! ((vm) i64_iref = mu_iref(int64));
typedef! ((vm) hybrid_int64 = mu_hybrid(int64, i64_iref)(int64));
typedef! ((vm) hybrid_int64_ptr = mu_uptr(hybrid_int64));
typedef! ((vm) hybrid_int64_ptr = mu_ref(hybrid_int64));
funcsig! ((vm) sig = (int64) -> (hybrid_int64_ptr));
funcdecl! ((vm) <sig> func);
......@@ -901,7 +901,7 @@ fn ealloc_hybrid_var_traced() -> VM {
typedef! ((vm) int64 = mu_int(64));
typedef! ((vm) i64_iref = mu_iref(int64));
typedef! ((vm) hybrid_int64 = mu_hybrid(i64_iref, int64)(i64_iref));
typedef! ((vm) hybrid_int64_ptr = mu_uptr(hybrid_int64));
typedef! ((vm) hybrid_int64_ptr = mu_ref(hybrid_int64));
funcsig! ((vm) sig = (int64) -> (hybrid_int64_ptr));
funcdecl! ((vm) <sig> func);
......@@ -963,7 +963,7 @@ fn e_delete_traced() -> VM {
typedef!((vm) int64 = mu_int(64));
typedef!((vm) i64_iref = mu_iref(int64));
typedef!((vm) array_iref_100 = mu_array(i64_iref, 10));
typedef!((vm) array_i100_ptr = mu_uptr(array_iref_100));
typedef!((vm) array_i100_ptr = mu_ref(array_iref_100));
funcsig!((vm) sig = () -> ());
funcdecl!((vm) <sig> func);
......@@ -1021,7 +1021,7 @@ fn edelete_hybrid_traced() -> VM {
typedef! ((vm) int64 = mu_int(64));
typedef! ((vm) i64_iref = mu_iref(int64));
typedef! ((vm) hybrid_int64 = mu_hybrid(i64_iref, int64)(i64_iref));
typedef! ((vm) hybrid_int64_ptr = mu_uptr(hybrid_int64));
typedef! ((vm) hybrid_int64_ptr = mu_ref(hybrid_int64));
funcsig! ((vm) sig = (int64) -> ());
funcdecl! ((vm) <sig> func);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment