Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace unneeded QRPA with ResizablePMCArray
  • Loading branch information
Reini Urban committed Jan 12, 2015
1 parent c528f06 commit f6d965a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 2,017 deletions.
5 changes: 0 additions & 5 deletions src/vm/parrot/6model/serialization.c
Expand Up @@ -61,7 +61,6 @@ static INTVAL perl6_lexpad_id = 0;
static INTVAL ctmthunk_id = 0;
static INTVAL ownedhash_id = 0;
static INTVAL ownedrpa_id = 0;
static INTVAL qrpa_id = 0;

/* Endian translation (file format is little endian, so on big endian we need
* to twiddle. */
Expand Down Expand Up @@ -494,9 +493,6 @@ void write_ref_func(PARROT_INTERP, SerializationWriter *writer, PMC *ref) {
else if (ref->vtable->base_type == ownedrpa_id) {
discrim = REFVAR_VM_ARR_VAR;
}
else if (ref->vtable->base_type == qrpa_id) {
discrim = REFVAR_VM_ARR_VAR;
}
else if (ref->vtable->base_type == enum_class_ResizableIntegerArray) {
discrim = REFVAR_VM_ARR_INT;
}
Expand Down Expand Up @@ -1041,7 +1037,6 @@ STRING * Serialization_serialize(PARROT_INTERP, PMC *sc, PMC *empty_string_heap)
ctmthunk_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "CTMThunk", 0));
ownedhash_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedHash", 0));
ownedrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedResizablePMCArray", 0));
qrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "QRPA", 0));

/* Initialize string heap so first entry is the NULL string. */
VTABLE_push_string(interp, empty_string_heap, STRINGNULL);
Expand Down
8 changes: 2 additions & 6 deletions src/vm/parrot/6model/sixmodelobject.c
Expand Up @@ -11,7 +11,6 @@ static INTVAL stable_id = 0;
static INTVAL smo_id = 0;
static INTVAL sc_id = 0;
static INTVAL ownedrpa_id = 0;
static INTVAL qrpa_id = 0;
static INTVAL ownedhash_id = 0;

/* Cached strings. */
Expand Down Expand Up @@ -309,8 +308,6 @@ PMC * hllize(PARROT_INTERP, PMC *obj, INTVAL hll_id) {
/* Otherwise, it's a Parrot type. */
if (ownedrpa_id == 0)
ownedrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedResizablePMCArray", 0));
if (qrpa_id == 0)
qrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "QRPA", 0));
if (ownedhash_id == 0)
ownedhash_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedHash", 0));
if (obj->vtable->base_type == enum_class_String) {
Expand Down Expand Up @@ -368,9 +365,8 @@ PMC * hllize(PARROT_INTERP, PMC *obj, INTVAL hll_id) {
return obj;
}
}
else if (obj->vtable->base_type == enum_class_ResizablePMCArray
|| obj->vtable->base_type == ownedrpa_id
|| obj->vtable->base_type == qrpa_id) {
else if (obj->vtable->base_type == enum_class_ResizablePMCArray /* XXX ResizableStringArray? */
|| obj->vtable->base_type == ownedrpa_id) {
if (VTABLE_exists_keyed_str(interp, config, Parrot_str_new_constant(interp, "foreign_transform_array"))) {
PMC *result;
PMC *code = VTABLE_get_pmc_keyed_str(interp, config, Parrot_str_new_constant(interp, "foreign_transform_array"));
Expand Down
2 changes: 1 addition & 1 deletion src/vm/parrot/QAST/Operations.nqp
Expand Up @@ -271,7 +271,7 @@ QAST::Operations.add_core_op('list', :inlinable(1), -> $qastcomp, $op {
# Create register for the resulting list and make an empty one.
my $list_reg := $*REGALLOC.fresh_p();
my $ops := PIRT::Ops.new(:result($list_reg));
$ops.push_pirop('new', $list_reg, "'QRPA'");
$ops.push_pirop('new', $list_reg, "'ResizablePMCArray'");
if +$op.list > 1 {
$ops.push_pirop('assign', $list_reg, +$op.list);
$ops.push_pirop('assign', $list_reg, 0);
Expand Down
28 changes: 13 additions & 15 deletions src/vm/parrot/ops/nqp.ops
Expand Up @@ -34,7 +34,6 @@ static INTVAL initialized = 0;
static INTVAL stable_id = 0;
static INTVAL smo_id = 0;
static INTVAL disp_id = 0;
static INTVAL qrpa_id = 0;
static INTVAL ohash_id = 0;

/* Built-in meta-objects. */
Expand All @@ -60,7 +59,7 @@ static PMC *empty_hash = NULL;
/* SC write barrier for objects. */
static void SC_write_barrier_obj(PARROT_INTERP, PMC *obj) {
if (!sc_write_barrier_off_depth && VTABLE_get_bool(interp, compiling_scs)) {
PMC *comp_sc = VTABLE_get_pmc_keyed_int(interp, compiling_scs, 0);
const PMC *comp_sc = VTABLE_get_pmc_keyed_int(interp, compiling_scs, 0);
if (SC_PMC(obj) != comp_sc) {
SC_repossess_object(interp, comp_sc, SC_PMC(obj), obj);
SC_PMC(obj) = comp_sc;
Expand All @@ -73,7 +72,7 @@ static void SC_write_barrier_obj(PARROT_INTERP, PMC *obj) {
/* SC write barrier for STables. */
static void SC_write_barrier_st(PARROT_INTERP, STable *st) {
if (!sc_write_barrier_off_depth && VTABLE_get_bool(interp, compiling_scs)) {
PMC *comp_sc = VTABLE_get_pmc_keyed_int(interp, compiling_scs, 0);
const PMC *comp_sc = VTABLE_get_pmc_keyed_int(interp, compiling_scs, 0);
if (st->sc != comp_sc) {
SC_repossess_stable(interp, comp_sc, st->sc, st->stable_pmc);
st->sc = comp_sc;
Expand All @@ -83,18 +82,18 @@ static void SC_write_barrier_st(PARROT_INTERP, STable *st) {
}
}

/* Test for something being a list (RPA or QRPA). */
/* Test for something being a list (ResizablePMCArray or ResizableStringArray). */
static INTVAL
nqp_islist(PMC *pmc) {
INTVAL type = pmc->vtable->base_type;
return (INTVAL)(type == qrpa_id || type == enum_class_ResizablePMCArray
|| type == enum_class_ResizableStringArray);
const INTVAL type = pmc->vtable->base_type;
return (INTVAL)(type == enum_class_ResizablePMCArray
|| type == enum_class_ResizableStringArray);
}

/* Test for something being a hash. */
static INTVAL
nqp_ishash(PMC *pmc) {
INTVAL type = pmc->vtable->base_type;
const INTVAL type = pmc->vtable->base_type;
return (INTVAL)(type == enum_class_Hash || type == ohash_id);
}

Expand Down Expand Up @@ -136,14 +135,14 @@ revquicksort(INTVAL *arr, INTVAL elements) {

/* Does a run of the NFA. Produces a list of integers indicating the
* chosen ordering. */
static INTVAL * nqp_nfa_run(PARROT_INTERP, NFABody *nfa, STRING *target, INTVAL offset, INTVAL *total_fates_out) {
INTVAL eos = Parrot_str_length(interp, target);
static const INTVAL * nqp_nfa_run(PARROT_INTERP, NFABody *nfa, STRING *target, INTVAL offset, INTVAL *total_fates_out) {
const INTVAL eos = Parrot_str_length(interp, target);
INTVAL gen = 1;
INTVAL numcur = 0;
INTVAL numnext = 0;
INTVAL *done, *fates, *curst, *nextst, *longlit;
INTVAL i, fate_arr_len, num_states, total_fates, prev_fates, usedlonglit;
INTVAL orig_offset = offset;
const INTVAL orig_offset = offset;

/* Allocate "done states", "current states" and "next states" arrays. */
num_states = nfa->num_states;
Expand Down Expand Up @@ -978,7 +977,6 @@ inline op nqp_dynop_setup() :base_core {
/* Look up and cache some type IDs. */
stable_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "STable", 0));
smo_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "SixModelObject", 0));
qrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "QRPA", 0));
ohash_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "OwnedHash", 0));

/* Initialize the object model. */
Expand Down Expand Up @@ -2878,7 +2876,7 @@ inline op repr_hint_for(out INT, invar PMC, in STR) :base_core {

=item nqp_islist

Checks if the type of thing in $2 is a nqp list (either QRPA or RPA).
Checks if the type of thing in $2 is a nqp list (either ResizablePMCArray or ResizableStringArray).

=cut

Expand Down Expand Up @@ -3278,7 +3276,7 @@ inline op nqp_push_label(invar PMC, in LABEL) :base_core {
inline op nqp_nfa_run_proto(out PMC, invar PMC, in STR, in INT) :base_core {
/* Run the NFA. */
INTVAL total_fates, i;
INTVAL *fates = nqp_nfa_run(interp, OBJECT_BODY($2), $3, $4, &total_fates);
const INTVAL *fates = nqp_nfa_run(interp, (NFABody *)OBJECT_BODY($2), $3, $4, &total_fates);

/* Copy results into an RIA. */
PMC *fatepmc = Parrot_pmc_new(interp, enum_class_ResizableIntegerArray);
Expand All @@ -3299,7 +3297,7 @@ inline op nqp_nfa_run_alt(invar PMC, in STR, in INT, invar PMC, invar PMC, invar

/* Run the NFA. */
INTVAL total_fates, i;
INTVAL *fates = nqp_nfa_run(interp, OBJECT_BODY(nfa), target, offset, &total_fates);
const INTVAL *fates = nqp_nfa_run(interp, (NFABody *)OBJECT_BODY(nfa), target, offset, &total_fates);

/* Push the results onto the bstack. */
INTVAL caps = VTABLE_defined(interp, cstack) ? VTABLE_elements(interp, cstack) : 0;
Expand Down

0 comments on commit f6d965a

Please sign in to comment.