Skip to content

Commit b722dc3

Browse files
committed
rt: Fix logging of type-parametric resources
1 parent 05d96f1 commit b722dc3

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

src/comp/middle/shape.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,7 @@ fn shape_of(ccx: &@crate_ctxt, t: ty::t) -> [u8] {
395395
s += [shape_res];
396396
add_u16(s, id as u16);
397397
add_u16(s, vec::len(tps) as u16);
398-
399-
let sub = [];
400-
for tp: ty::t in tps { add_substr(s, sub); }
401-
add_substr(s, sub);
402-
398+
for tp: ty::t in tps { add_substr(s, shape_of(ccx, tp)); }
403399
add_substr(s, shape_of(ccx, subt));
404400

405401
}

src/rt/rust_shape.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,22 @@ print::walk_struct(bool align, const uint8_t *end_sp) {
110110
}
111111

112112
void
113-
print::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
114-
const uint8_t *ty_params_sp, const uint8_t *end_sp) {
113+
print::walk_res(bool align, const rust_fn *dtor, unsigned n_params,
114+
const type_param *params, const uint8_t *end_sp) {
115115
DPRINT("res@%p", dtor);
116116

117117
// Print type parameters.
118-
if (n_ty_params) {
118+
if (n_params) {
119119
DPRINT("<");
120120

121121
bool first = true;
122-
for (uint16_t i = 0; i < n_ty_params; i++) {
122+
for (uint16_t i = 0; i < n_params; i++) {
123123
if (!first)
124124
DPRINT(",");
125125
first = false;
126-
get_u16_bump(sp); // Skip over the size.
127-
walk(align);
126+
127+
ctxt<print> sub(*this, params[i].shape);
128+
sub.walk(align);
128129
}
129130

130131
DPRINT(">");
@@ -347,7 +348,7 @@ class cmp : public data<cmp,ptr_pair> {
347348
const data_pair<uint32_t> &tag_variants);
348349
void walk_struct(bool align, const uint8_t *end_sp);
349350
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
350-
const uint8_t *ty_params_sp, const uint8_t *end_sp,
351+
const type_param *ty_params_sp, const uint8_t *end_sp,
351352
const data_pair<uintptr_t> &live);
352353
void walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
353354
const std::pair<const uint8_t *,const uint8_t *>
@@ -400,7 +401,7 @@ cmp::walk_struct(bool align, const uint8_t *end_sp) {
400401

401402
void
402403
cmp::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
403-
const uint8_t *ty_params_sp, const uint8_t *end_sp,
404+
const type_param *ty_params_sp, const uint8_t *end_sp,
404405
const data_pair<uintptr_t> &live) {
405406
abort(); // TODO
406407
}
@@ -502,9 +503,8 @@ log::walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
502503
}
503504

504505
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) {
506+
log::walk_res(bool align, const rust_fn *dtor, unsigned n_params,
507+
const type_param *params, const uint8_t *end_sp, bool live) {
508508
out << "res";
509509

510510
if (this->sp == end_sp)

src/rt/rust_shape.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,19 @@ ctxt<T>::walk_res(bool align) {
446446

447447
uint16_t n_ty_params = get_u16_bump(sp);
448448

449-
uint16_t ty_params_size = get_u16_bump(sp);
450-
const uint8_t *ty_params_sp = sp;
451-
sp += ty_params_size;
449+
// Read in the tag type parameters.
450+
type_param params[n_ty_params];
451+
for (uint16_t i = 0; i < n_ty_params; i++) {
452+
uint16_t ty_param_len = get_u16_bump(sp);
453+
const uint8_t *next_sp = sp + ty_param_len;
454+
params[i].set(this);
455+
sp = next_sp;
456+
}
452457

453458
uint16_t sp_size = get_u16_bump(sp);
454459
const uint8_t *end_sp = sp + sp_size;
455460

456-
static_cast<T *>(this)->walk_res(align, dtor, n_ty_params, ty_params_sp,
461+
static_cast<T *>(this)->walk_res(align, dtor, n_ty_params, params,
457462
end_sp);
458463

459464
sp = end_sp;
@@ -479,8 +484,8 @@ class print : public ctxt<print> {
479484

480485
void walk_tag(bool align, tag_info &tinfo);
481486
void walk_struct(bool align, const uint8_t *end_sp);
482-
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
483-
const uint8_t *ty_params_sp, const uint8_t *end_sp);
487+
void walk_res(bool align, const rust_fn *dtor, unsigned n_params,
488+
const type_param *params, const uint8_t *end_sp);
484489
void walk_var(bool align, uint8_t param);
485490

486491
void walk_evec(bool align, bool is_pod, uint16_t sp_size) {
@@ -559,8 +564,8 @@ class size_of : public ctxt<size_of> {
559564
sa = sub.sa;
560565
}
561566

562-
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
563-
const uint8_t *ty_params_sp, const uint8_t *end_sp) {
567+
void walk_res(bool align, const rust_fn *dtor, unsigned n_params,
568+
const type_param *params, const uint8_t *end_sp) {
564569
abort(); // TODO
565570
}
566571

@@ -788,12 +793,12 @@ class data : public ctxt< data<T,U> > {
788793
dp = next_dp;
789794
}
790795

791-
void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params,
792-
const uint8_t *ty_params_sp, const uint8_t *end_sp) {
796+
void walk_res(bool align, const rust_fn *dtor, unsigned n_params,
797+
const type_param *params, const uint8_t *end_sp) {
793798
typename U::template data<uintptr_t>::t live = bump_dp<uintptr_t>(dp);
794799
// Delegate to the implementation.
795-
static_cast<T *>(this)->walk_res(align, dtor, n_ty_params,
796-
ty_params_sp, end_sp, live);
800+
static_cast<T *>(this)->walk_res(align, dtor, n_params, params,
801+
end_sp, live);
797802
}
798803

799804
void walk_var(bool align, uint8_t param_index) {
@@ -1006,9 +1011,8 @@ class log : public data<log,ptr> {
10061011
const std::pair<const uint8_t *,const uint8_t *>
10071012
variant_ptr_and_end);
10081013
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);
1014+
void walk_res(bool align, const rust_fn *dtor, unsigned n_params,
1015+
const type_param *params, const uint8_t *end_sp, bool live);
10121016

10131017
template<typename T>
10141018
void walk_number() { out << get_dp<T>(dp); }

0 commit comments

Comments
 (0)