Skip to content

Commit b970563

Browse files
committed
Patchwork of attempted fixes to effect system and gc system; eventually give up and disable it entirely in the runtime. Will need extensive reworking.
1 parent 7e733bf commit b970563

File tree

9 files changed

+185
-111
lines changed

9 files changed

+185
-111
lines changed

src/boot/be/abi.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ let iterator_args_elt_outer_frame_ptr = 1;;
103103
let indirect_args_elt_closure = 0;;
104104

105105
(* Current worst case is by vec grow glue *)
106-
let worst_case_glue_call_args = 7;;
106+
let worst_case_glue_call_args = 8;;
107107

108108
type abi =
109109
{

src/boot/me/trans.ml

+34-21
Original file line numberDiff line numberDiff line change
@@ -1893,34 +1893,38 @@ let trans_visitor
18931893
get_typed_mem_glue g fty inner
18941894

18951895
(*
1896-
* Vector-growth glue takes four arguments:
1896+
* Vector-growth glue takes the following arguments:
18971897
*
18981898
* 0. (Implicit) task ptr
18991899
* 1. Pointer to the typarams of the caller's frame (possibly required to
19001900
* be passed to element's copy glue).
1901-
* 2. Pointer to tydesc of the vec's stored element type, so that elements
1901+
* 2. Pointer to the tydesc of the vec, so that we can tell if it's gc
1902+
* mem, and have a tydesc to pass to malloc if we're allocating anew.
1903+
* 3. Pointer to tydesc of the vec's stored element type, so that elements
19021904
* can be copied to a newly alloc'ed vec if one must be created.
1903-
* 3. Alias to vec that needs to grow (i.e. ptr to ptr to rust_vec).
1904-
* 4. Number of bytes of growth requested
1905+
* 4. Alias to vec that needs to grow (i.e. ptr to ptr to rust_vec).
1906+
* 5. Number of bytes of growth requested
19051907
*)
19061908
and emit_vec_grow_glue
19071909
(fix:fixup)
19081910
(g:glue)
19091911
: unit =
19101912
let arg_typarams_ptr = 0 in
1911-
let arg_tydesc_ptr = 1 in
1912-
let arg_vec_alias = 2 in
1913-
let arg_nbytes = 3 in
1913+
let arg_vec_tydesc_ptr = 1 in
1914+
let arg_elt_tydesc_ptr = 2 in
1915+
let arg_vec_alias = 3 in
1916+
let arg_nbytes = 4 in
19141917

19151918
let name = glue_str cx g in
19161919
log cx "emitting glue: %s" name;
19171920

19181921
let fn_ty =
19191922
mk_simple_ty_fn
19201923
[| ty_params_covering Ast.TY_int; (* an OK lie *)
1924+
local_slot Ast.TY_type;
19211925
local_slot Ast.TY_type;
19221926
alias_slot (Ast.TY_vec Ast.TY_int); (* an OK lie *)
1923-
local_slot Ast.TY_uint; |]
1927+
local_slot Ast.TY_uint |]
19241928
in
19251929

19261930
let args_rty = call_args_referent_type cx 0 fn_ty None in
@@ -1936,7 +1940,8 @@ let trans_visitor
19361940
let vec_alias_cell = get_element_ptr args_cell arg_vec_alias in
19371941
let vec_cell = deref vec_alias_cell in
19381942
let nbytes_cell = get_element_ptr args_cell arg_nbytes in
1939-
let td_ptr_cell = get_element_ptr args_cell arg_tydesc_ptr in
1943+
let vec_td_ptr_cell = get_element_ptr args_cell arg_vec_tydesc_ptr in
1944+
let elt_td_ptr_cell = get_element_ptr args_cell arg_elt_tydesc_ptr in
19401945
let ty_params_cell =
19411946
deref (get_element_ptr args_cell arg_typarams_ptr)
19421947
in
@@ -1951,7 +1956,8 @@ let trans_visitor
19511956
new_vec_cell
19521957
[| Il.Cell vec_cell;
19531958
Il.Cell nbytes_cell;
1954-
Il.Cell need_copy_alias_cell |]
1959+
Il.Cell need_copy_alias_cell;
1960+
Il.Cell vec_td_ptr_cell; |]
19551961
end;
19561962

19571963
let no_copy_jmps =
@@ -1965,7 +1971,7 @@ let trans_visitor
19651971
get_element_ptr_dyn ty_params_cell src_vec Abi.vec_elt_fill
19661972
in
19671973
let elt_sz =
1968-
get_element_ptr (deref td_ptr_cell) Abi.tydesc_field_size
1974+
get_element_ptr (deref elt_td_ptr_cell) Abi.tydesc_field_size
19691975
in
19701976

19711977
let dst_buf =
@@ -1993,11 +1999,11 @@ let trans_visitor
19931999

19942000
(* Copy *)
19952001
let ty_params_ptr =
1996-
get_tydesc_params ty_params_cell td_ptr_cell
2002+
get_tydesc_params ty_params_cell elt_td_ptr_cell
19972003
in
19982004
let initflag = Il.Reg (force_to_reg one) in
19992005
trans_call_dynamic_glue
2000-
td_ptr_cell
2006+
elt_td_ptr_cell
20012007
Abi.tydesc_field_copy_glue
20022008
(Some (deref dptr))
20032009
[| ty_params_ptr; sptr; initflag |]
@@ -2971,8 +2977,8 @@ let trans_visitor
29712977
(ty:Ast.ty)
29722978
: unit =
29732979

2974-
let ty = strip_mutable_or_constrained_ty ty in
29752980
let mctrl = ty_mem_ctrl cx ty in
2981+
let ty = strip_mutable_or_constrained_ty ty in
29762982

29772983
match ty with
29782984

@@ -3173,7 +3179,7 @@ let trans_visitor
31733179
check_box_rty cell;
31743180
note_drop_step ty "in free-ty";
31753181
begin
3176-
match simplified_ty ty with
3182+
match strip_mutable_or_constrained_ty ty with
31773183
Ast.TY_port _ -> trans_del_port cell
31783184
| Ast.TY_chan _ -> trans_del_chan cell
31793185
| Ast.TY_task -> trans_kill_task cell
@@ -3183,14 +3189,13 @@ let trans_visitor
31833189
(fun _ src ty -> drop_ty ty_params src ty);
31843190
trans_free cell is_gc
31853191

3186-
| _ ->
3192+
| Ast.TY_box body_ty ->
31873193
note_drop_step ty "in free-ty, dropping structured body";
31883194
let (body_mem, _) =
31893195
need_mem_cell
31903196
(get_element_ptr_dyn ty_params (deref cell)
31913197
Abi.box_rc_field_body)
31923198
in
3193-
let body_ty = simplified_ty ty in
31943199
let vr = next_vreg_cell Il.voidptr_t in
31953200
lea vr body_mem;
31963201
trace_word cx.ctxt_sess.Session.sess_trace_drop vr;
@@ -3201,6 +3206,8 @@ let trans_visitor
32013206
None;
32023207
note_drop_step ty "in free-ty, calling free";
32033208
trans_free cell is_gc;
3209+
3210+
| t -> bug () "freeing unexpected type: %a" Ast.sprintf_ty t
32043211
end;
32053212
note_drop_step ty "free-ty done";
32063213

@@ -3268,13 +3275,17 @@ let trans_visitor
32683275
(slot:Ast.slot)
32693276
: unit =
32703277
check_and_flush_chan cell slot;
3271-
drop_slot (get_ty_params_of_current_frame()) cell slot
3278+
drop_slot (get_ty_params_of_current_frame()) cell
3279+
{ slot with
3280+
Ast.slot_ty = Some (strip_mutable_or_constrained_ty
3281+
(slot_ty slot)) }
32723282

32733283
and drop_ty_in_current_frame
32743284
(cell:Il.cell)
32753285
(ty:Ast.ty)
32763286
: unit =
3277-
drop_ty (get_ty_params_of_current_frame()) cell ty
3287+
drop_ty (get_ty_params_of_current_frame()) cell
3288+
(strip_mutable_or_constrained_ty ty)
32783289

32793290
(* Returns a mark for a jmp that must be patched to the continuation of
32803291
* the null case (i.e. fall-through means not null).
@@ -4755,7 +4766,8 @@ let trans_visitor
47554766
trans_call_simple_static_glue
47564767
(get_vec_grow_glue ())
47574768
(get_ty_params_of_current_frame ())
4758-
[| get_tydesc None elt_ty;
4769+
[| get_tydesc None dst_ty;
4770+
get_tydesc None elt_ty;
47594771
dst_vec_alias;
47604772
src_fill; |]
47614773
None
@@ -4827,7 +4839,8 @@ let trans_visitor
48274839
trans_call_simple_static_glue
48284840
(get_vec_grow_glue ())
48294841
(get_ty_params_of_current_frame ())
4830-
[| get_tydesc None elt_ty;
4842+
[| get_tydesc None dst_ty;
4843+
get_tydesc None elt_ty;
48314844
dst_vec_alias;
48324845
elt_sz_cell; |]
48334846
None

src/comp/driver/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import front.parser;
44
import front.token;
55
import middle.trans;
66

7-
fn main(vec[str] args) {
7+
io fn main(vec[str] args) {
88

99
log "This is the rust 'self-hosted' compiler.";
1010
log "The one written in rust.";

src/comp/front/lexer.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ state type reader = state obj {
99
fn is_eof() -> bool;
1010
fn curr() -> char;
1111
fn next() -> char;
12-
state fn bump();
13-
state fn mark();
12+
io fn bump();
13+
fn mark();
1414
fn get_filename() -> str;
1515
fn get_mark_pos() -> common.pos;
1616
fn get_curr_pos() -> common.pos;
@@ -55,7 +55,7 @@ fn new_reader(stdio_reader rdr, str filename) -> reader
5555
ret n;
5656
}
5757

58-
state fn bump() {
58+
io fn bump() {
5959
c = n;
6060

6161
if (c == (-1) as char) {
@@ -72,7 +72,7 @@ fn new_reader(stdio_reader rdr, str filename) -> reader
7272
n = rdr.getc() as char;
7373
}
7474

75-
state fn mark() {
75+
fn mark() {
7676
mark_line = line;
7777
mark_col = col;
7878
}
@@ -243,14 +243,14 @@ fn is_whitespace(char c) -> bool {
243243
ret c == ' ' || c == '\t' || c == '\r' || c == '\n';
244244
}
245245

246-
state fn consume_any_whitespace(reader rdr) {
246+
io fn consume_any_whitespace(reader rdr) {
247247
while (is_whitespace(rdr.curr())) {
248248
rdr.bump();
249249
}
250250
be consume_any_line_comment(rdr);
251251
}
252252

253-
state fn consume_any_line_comment(reader rdr) {
253+
io fn consume_any_line_comment(reader rdr) {
254254
if (rdr.curr() == '/') {
255255
alt (rdr.next()) {
256256
case ('/') {
@@ -273,7 +273,7 @@ state fn consume_any_line_comment(reader rdr) {
273273
}
274274

275275

276-
state fn consume_block_comment(reader rdr) {
276+
io fn consume_block_comment(reader rdr) {
277277
let int level = 1;
278278
while (level > 0) {
279279
if (rdr.curr() == '/' && rdr.next() == '*') {
@@ -294,7 +294,7 @@ state fn consume_block_comment(reader rdr) {
294294
be consume_any_whitespace(rdr);
295295
}
296296

297-
state fn next_token(reader rdr) -> token.token {
297+
io fn next_token(reader rdr) -> token.token {
298298
auto accum_str = "";
299299
auto accum_int = 0;
300300

@@ -355,7 +355,7 @@ state fn next_token(reader rdr) -> token.token {
355355
ret token.LIT_INT(accum_int);
356356
}
357357

358-
state fn binop(reader rdr, token.binop op) -> token.token {
358+
io fn binop(reader rdr, token.binop op) -> token.token {
359359
rdr.bump();
360360
if (rdr.next() == '=') {
361361
rdr.bump();

0 commit comments

Comments
 (0)