Skip to content

Commit 8bd019b

Browse files
committed
rt: Remember the number of captured type descriptors for objects in the type descriptor crate cache
1 parent 608f7cc commit 8bd019b

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/comp/middle/trans.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,13 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: ty::t, escapes: bool,
958958

959959
// If the tydesc escapes in this context, the cached derived
960960
// tydesc also has to be one that was marked as escaping.
961-
if !(escapes && !info.escapes) { ret rslt(cx, info.lltydesc); }
961+
if !(escapes && !info.escapes) && storage == tps_normal {
962+
ret rslt(cx, info.lltydesc);
963+
}
962964
}
963965
none. {/* fall through */ }
964966
}
967+
965968
bcx_ccx(cx).stats.n_derived_tydescs += 1u;
966969
let bcx = new_raw_block_ctxt(cx.fcx, cx.fcx.llderivedtydescs);
967970
let tys = linearize_ty_params(bcx, t);

src/rt/rust_crate_cache.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#include "rust_internal.h"
3+
#include <algorithm>
34

45
type_desc *
56
rust_crate_cache::get_type_desc(size_t size,
@@ -14,6 +15,10 @@ rust_crate_cache::get_type_desc(size_t size,
1415
HASH_FIND(hh, this->type_descs, descs, keysz, td);
1516
if (td) {
1617
DLOG(sched, cache, "rust_crate_cache::get_type_desc hit");
18+
19+
// FIXME: This is a gross hack.
20+
td->n_obj_params = std::max(td->n_obj_params, n_obj_params);
21+
1722
return td;
1823
}
1924
DLOG(sched, cache, "rust_crate_cache::get_type_desc miss");

src/rt/rust_shape.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ class type_param {
259259
// Creates type parameters from a type descriptor.
260260
static inline type_param *from_tydesc(const type_desc *tydesc,
261261
arena &arena) {
262+
if (tydesc->n_obj_params) {
263+
// TODO
264+
}
262265
return make(tydesc->first_param, tydesc->n_params, arena);
263266
}
264267
};

0 commit comments

Comments
 (0)