Skip to content

Commit 4629130

Browse files
committed
---
yaml --- r: 5042 b: refs/heads/master c: 05d96f1 h: refs/heads/master v: v3
1 parent e2518ff commit 4629130

File tree

3 files changed

+63
-21
lines changed

3 files changed

+63
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 7bbe8d2e8c61165d539a9e4d916566a57f59d708
2+
refs/heads/master: 05d96f155f8bc6eec0e9f3485b47698fb858aa72

trunk/src/rt/rust_shape.cpp

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,42 @@ print::walk_struct(bool align, const uint8_t *end_sp) {
111111

112112
void
113113
print::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
114-
const uint8_t *ty_params_sp) {
114+
const uint8_t *ty_params_sp, const uint8_t *end_sp) {
115115
DPRINT("res@%p", dtor);
116-
if (!n_ty_params)
116+
117+
// Print type parameters.
118+
if (n_ty_params) {
119+
DPRINT("<");
120+
121+
bool first = true;
122+
for (uint16_t i = 0; i < n_ty_params; i++) {
123+
if (!first)
124+
DPRINT(",");
125+
first = false;
126+
get_u16_bump(sp); // Skip over the size.
127+
walk(align);
128+
}
129+
130+
DPRINT(">");
131+
}
132+
133+
// Print arguments.
134+
135+
if (sp == end_sp)
117136
return;
118137

119-
DPRINT("<");
138+
DPRINT("(");
120139

121140
bool first = true;
122-
for (uint16_t i = 0; i < n_ty_params; i++) {
141+
while (sp != end_sp) {
123142
if (!first)
124143
DPRINT(",");
125144
first = false;
126-
get_u16_bump(sp); // Skip over the size.
145+
127146
walk(align);
128147
}
129148

130-
DPRINT(">");
149+
DPRINT(")");
131150
}
132151

133152
void
@@ -328,7 +347,8 @@ class cmp : public data<cmp,ptr_pair> {
328347
const data_pair<uint32_t> &tag_variants);
329348
void walk_struct(bool align, const uint8_t *end_sp);
330349
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
331-
const uint8_t *ty_params_sp);
350+
const uint8_t *ty_params_sp, const uint8_t *end_sp,
351+
const data_pair<uintptr_t> &live);
332352
void walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
333353
const std::pair<const uint8_t *,const uint8_t *>
334354
variant_ptr_and_end);
@@ -380,7 +400,8 @@ cmp::walk_struct(bool align, const uint8_t *end_sp) {
380400

381401
void
382402
cmp::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
383-
const uint8_t *ty_params_sp) {
403+
const uint8_t *ty_params_sp, const uint8_t *end_sp,
404+
const data_pair<uintptr_t> &live) {
384405
abort(); // TODO
385406
}
386407

@@ -480,6 +501,28 @@ log::walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
480501
out << ")";
481502
}
482503

504+
void
505+
log::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
506+
const uint8_t *ty_params_sp, const uint8_t *end_sp,
507+
bool live) {
508+
out << "res";
509+
510+
if (this->sp == end_sp)
511+
return;
512+
513+
out << "(";
514+
515+
bool first = true;
516+
while (sp != end_sp) {
517+
if (!first)
518+
out << ", ";
519+
walk(align);
520+
align = true, first = false;
521+
}
522+
523+
out << ")";
524+
}
525+
483526
} // end namespace shape
484527

485528
extern "C" void

trunk/src/rt/rust_shape.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ ctxt<T>::walk_res(bool align) {
453453
uint16_t sp_size = get_u16_bump(sp);
454454
const uint8_t *end_sp = sp + sp_size;
455455

456-
static_cast<T *>(this)->walk_res(align, dtor, n_ty_params, ty_params_sp);
456+
static_cast<T *>(this)->walk_res(align, dtor, n_ty_params, ty_params_sp,
457+
end_sp);
457458

458459
sp = end_sp;
459460
}
@@ -479,7 +480,7 @@ class print : public ctxt<print> {
479480
void walk_tag(bool align, tag_info &tinfo);
480481
void walk_struct(bool align, const uint8_t *end_sp);
481482
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
482-
const uint8_t *ty_params_sp);
483+
const uint8_t *ty_params_sp, const uint8_t *end_sp);
483484
void walk_var(bool align, uint8_t param);
484485

485486
void walk_evec(bool align, bool is_pod, uint16_t sp_size) {
@@ -559,7 +560,7 @@ class size_of : public ctxt<size_of> {
559560
}
560561

561562
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
562-
const uint8_t *ty_params_sp) {
563+
const uint8_t *ty_params_sp, const uint8_t *end_sp) {
563564
abort(); // TODO
564565
}
565566

@@ -788,10 +789,11 @@ class data : public ctxt< data<T,U> > {
788789
}
789790

790791
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
791-
const uint8_t *ty_params_sp) {
792+
const uint8_t *ty_params_sp, const uint8_t *end_sp) {
793+
typename U::template data<uintptr_t>::t live = bump_dp<uintptr_t>(dp);
792794
// Delegate to the implementation.
793795
static_cast<T *>(this)->walk_res(align, dtor, n_ty_params,
794-
ty_params_sp);
796+
ty_params_sp, end_sp, live);
795797
}
796798

797799
void walk_var(bool align, uint8_t param_index) {
@@ -957,8 +959,6 @@ class log : public data<log,ptr> {
957959
: data<log,ptr>(other.task, other.sp, other.params, other.tables, in_dp),
958960
out(other.out) {}
959961

960-
void walk_string(const std::pair<ptr,ptr> &data);
961-
962962
void walk_evec(bool align, bool is_pod, uint16_t sp_size) {
963963
walk_vec(align, is_pod, get_evec_data_range(dp));
964964
}
@@ -991,11 +991,6 @@ class log : public data<log,ptr> {
991991
void walk_chan(bool align) { out << "chan"; }
992992
void walk_task(bool align) { out << "task"; }
993993

994-
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
995-
const uint8_t *ty_params_sp) {
996-
out << "res"; // TODO
997-
}
998-
999994
void walk_subcontext(bool align, log &sub) { sub.walk(align); }
1000995

1001996
void walk_box_contents(bool align, log &sub, ptr &ref_count_dp) {
@@ -1010,6 +1005,10 @@ class log : public data<log,ptr> {
10101005
void walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
10111006
const std::pair<const uint8_t *,const uint8_t *>
10121007
variant_ptr_and_end);
1008+
void walk_string(const std::pair<ptr,ptr> &data);
1009+
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
1010+
const uint8_t *ty_params_sp, const uint8_t *end_sp,
1011+
bool live);
10131012

10141013
template<typename T>
10151014
void walk_number() { out << get_dp<T>(dp); }

0 commit comments

Comments
 (0)