rt: Remember the number of captured type descriptors for objects in the type descriptor crate cache

This commit is contained in:
Patrick Walton 2011-08-25 14:20:21 -07:00
parent 608f7ccded
commit 8bd019bdc8
3 changed files with 12 additions and 1 deletions

View file

@ -958,10 +958,13 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: ty::t, escapes: bool,
// If the tydesc escapes in this context, the cached derived
// tydesc also has to be one that was marked as escaping.
if !(escapes && !info.escapes) { ret rslt(cx, info.lltydesc); }
if !(escapes && !info.escapes) && storage == tps_normal {
ret rslt(cx, info.lltydesc);
}
}
none. {/* fall through */ }
}
bcx_ccx(cx).stats.n_derived_tydescs += 1u;
let bcx = new_raw_block_ctxt(cx.fcx, cx.fcx.llderivedtydescs);
let tys = linearize_ty_params(bcx, t);

View file

@ -1,5 +1,6 @@
#include "rust_internal.h"
#include <algorithm>
type_desc *
rust_crate_cache::get_type_desc(size_t size,
@ -14,6 +15,10 @@ rust_crate_cache::get_type_desc(size_t size,
HASH_FIND(hh, this->type_descs, descs, keysz, td);
if (td) {
DLOG(sched, cache, "rust_crate_cache::get_type_desc hit");
// FIXME: This is a gross hack.
td->n_obj_params = std::max(td->n_obj_params, n_obj_params);
return td;
}
DLOG(sched, cache, "rust_crate_cache::get_type_desc miss");

View file

@ -259,6 +259,9 @@ public:
// Creates type parameters from a type descriptor.
static inline type_param *from_tydesc(const type_desc *tydesc,
arena &arena) {
if (tydesc->n_obj_params) {
// TODO
}
return make(tydesc->first_param, tydesc->n_params, arena);
}
};