[svn:parrot] r47641 - in branches/gsoc_instrument: examples/library runtime/parrot/library/Instrument src/dynpmc src/pmc t/dynpmc
khairul at svn.parrot.org
khairul at svn.parrot.org
Tue Jun 15 16:38:52 UTC 2010
Author: khairul
Date: Tue Jun 15 16:38:51 2010
New Revision: 47641
URL: https://trac.parrot.org/parrot/changeset/47641
Log:
make codetest happy
Modified:
branches/gsoc_instrument/examples/library/tracer.nqp (contents, props changed)
branches/gsoc_instrument/runtime/parrot/library/Instrument/Base.nqp (props changed)
branches/gsoc_instrument/runtime/parrot/library/Instrument/Event.nqp (props changed)
branches/gsoc_instrument/runtime/parrot/library/Instrument/EventDispatcher.nqp (props changed)
branches/gsoc_instrument/runtime/parrot/library/Instrument/EventLibrary.nqp (props changed)
branches/gsoc_instrument/runtime/parrot/library/Instrument/Instrument.pir (props changed)
branches/gsoc_instrument/runtime/parrot/library/Instrument/Probe.nqp (props changed)
branches/gsoc_instrument/src/dynpmc/instrument.pmc (contents, props changed)
branches/gsoc_instrument/src/pmc/task.pmc
branches/gsoc_instrument/t/dynpmc/instrument.t (contents, props changed)
Modified: branches/gsoc_instrument/examples/library/tracer.nqp
==============================================================================
--- branches/gsoc_instrument/examples/library/tracer.nqp Tue Jun 15 12:20:35 2010 (r47640)
+++ branches/gsoc_instrument/examples/library/tracer.nqp Tue Jun 15 16:38:51 2010 (r47641)
@@ -6,16 +6,15 @@
examples/library/tracer.nqp - Implementation of the tracing runcore using the Instrument dynpmc
-=head1 SYNOPSIS
-
- % ./parrot-nqp examples/library/tracer.nqp <file>
-
=head1 DESCRIPTION
A simple example of how to use the Instrument dynpmc in nqp.
+=head1 SYNOPSIS
+
+% ./parrot-nqp examples/library/tracer.nqp <file>
+
=end
-=cut
Q:PIR {
load_bytecode 'Instrument/InstrumentLib.pbc'
@@ -41,12 +40,12 @@
my $param_cnt := pir::elements($op_code);
my $params := '';
my $cur_arg := 0;
-
+
my $arg_list := [];
while $cur_arg < $param_cnt {
my $arg_str;
my $arg_type := pir::set_i_p_ki__IPI($op_code, $cur_arg);
-
+
# Evaluate in order of:
# 1. keys
# 2. constants
@@ -60,7 +59,7 @@
# String constant key.
my $arg := $instr_obj.get_op_arg($op[$cur_arg + 1], $arg_type);
$arg_str := '["' ~ $arg ~ '"]';
-
+
} else {
# Integer constant key.
$arg_str := '[' ~ $op[$cur_arg + 1] ~ ']';
@@ -76,28 +75,28 @@
$arg_str := '[P' ~ $op[$cur_arg + 1] ~ ']';
}
}
-
+
my $prev := $arg_list.pop();
$arg_str := $prev ~ $arg_str;
-
+
} elsif pir::band__III($arg_type, 16) == 16
&& pir::band__III($arg_type, 2) != 2 {
my $arg := $instr_obj.get_op_arg($op[$cur_arg + 1], $arg_type);
-
+
if pir::band__III($arg_type, 1) == 1 {
$arg_str := '"' ~ $arg ~ '"';
-
+
} else {
$arg_str := $arg;
}
} elsif !$arg_type {
# 0 is int reg.
$arg_str := 'I' ~ $op[$cur_arg + 1];
-
+
} elsif pir::band__III($arg_type, 1) == 1{
# 1 is string reg.
$arg_str := 'S' ~ $op[$cur_arg + 1];
-
+
} elsif pir::band__III($arg_type, 2) == 2 {
# 2 is pmc.
if pir::band__III($arg_type, 16) == 16 {
@@ -107,23 +106,23 @@
# Normal reg.
$arg_str := 'P' ~ $op[$cur_arg + 1];
}
-
+
} elsif pir::band__III($arg_type, 3) == 3 {
# 3 is num reg.
$arg_str := 'N' ~ $op[$cur_arg + 1];
-
+
}
-
+
$arg_list.push($arg_str);
$cur_arg++;
}
-
+
my $prefix := ' ';
for $arg_list {
$params := $params ~ $prefix ~ $_;
$prefix := ', '
}
-
+
say($pc_hex ~ ' ' ~ $op_name ~ $params);
};
Modified: branches/gsoc_instrument/src/dynpmc/instrument.pmc
==============================================================================
--- branches/gsoc_instrument/src/dynpmc/instrument.pmc Tue Jun 15 12:20:35 2010 (r47640)
+++ branches/gsoc_instrument/src/dynpmc/instrument.pmc Tue Jun 15 16:38:51 2010 (r47641)
@@ -101,23 +101,23 @@
Parrot_Instrument_attributes * const attr = PARROT_INSTRUMENT(SELF);
PMC *evt_key1, *evt_key2, *nothing;
INTVAL evt_class_type;
-
+
/* Obtain the class type of Instrument::EventDispatcher. */
- evt_key1 = key_new_cstring(INTERP, "Instrument");
- evt_key2 = key_new_cstring(INTERP, "EventDispatcher");
- key_append(INTERP, evt_key1, evt_key2);
-
- evt_class_type = Parrot_pmc_get_type(INTERP, evt_key1);
+ evt_key1 = key_new_cstring(INTERP, "Instrument");
+ evt_key2 = key_new_cstring(INTERP, "EventDispatcher");
+ key_append(INTERP, evt_key1, evt_key2);
+
+ evt_class_type = Parrot_pmc_get_type(INTERP, evt_key1);
/* Create the child interpreter PMC */
attr->supervised = Parrot_new(INTERP);
attr->probes = Parrot_pmc_new(INTERP, enum_class_Hash);
attr->evt_dispatcher = Parrot_pmc_new(INTERP, evt_class_type);
- /* Initialise the event dispatcher */
- (PMC *nothing) = PCCINVOKE(INTERP, attr->evt_dispatcher, "_self_init");
+ /* Initialise the event dispatcher */
+ (PMC *nothing) = PCCINVOKE(INTERP, attr->evt_dispatcher, "_self_init");
- /* Initialize the runcore for the child interpreter */
+ /* Initialize the runcore for the child interpreter */
Instrument_runcore_init(attr->supervised, INTERP, SELF);
/* Initialize the scheduler for the child interpreter */
@@ -197,7 +197,7 @@
if (Parrot_str_equal(INTERP, name, item)) {
return attr->probes;
}
-
+
/* eventdispatcher: return the event dispatcher instance */
name = CONST_STRING(INTERP, "eventdispatcher");
if (Parrot_str_equal(INTERP, name, item)) {
@@ -325,10 +325,8 @@
enable_method = VTABLE_find_method(INTERP, obj, CONST_STRING(INTERP, "_on_attach"));
if (PMC_IS_NULL(enable_method)) {
/* Error! Could not find the enable method. */
- Parrot_ex_throw_from_c_args(
- INTERP, NULL, 1,
- "Could not locate the method '_on_attach'."
- );
+ Parrot_ex_throw_from_c_args(INTERP, NULL, 1,
+ "Could not locate the method '_on_attach'.");
}
/* Call the method.
@@ -350,7 +348,7 @@
=cut
*/
-
+
METHOD insert_op_hook(PMC *id, INTVAL op_num, PMC *hook) {
Parrot_Instrument_attributes * const attr = PARROT_INSTRUMENT(SELF);
Instrument_runcore_t *core = (Instrument_runcore_t *) attr->supervised->run_core;
@@ -359,7 +357,7 @@
if (index >= attr->supervised->op_count) {
/* Invalid op num */
- Parrot_ex_throw_from_c_args(INTERP, NULL, 1,"Invalid op number %d.", index);
+ Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "Invalid op number %d.", index);
}
if (list[index] == NULL) {
@@ -378,7 +376,7 @@
=cut
*/
-
+
METHOD remove_op_hook(PMC *id, INTVAL op_num, PMC *callback) {
Parrot_Instrument_attributes * const attr = PARROT_INSTRUMENT(SELF);
Instrument_runcore_t *core = (Instrument_runcore_t *) attr->supervised->run_core;
@@ -388,7 +386,7 @@
if (index >= attr->supervised->op_count) {
/* Invalid op num */
- Parrot_ex_throw_from_c_args(INTERP, NULL, 1,"Invalid op number %d.", index);
+ Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "Invalid op number %d.", index);
}
if (list[index] != NULL) {
@@ -516,7 +514,7 @@
cc = CURRENT_CONTEXT(attr->supervised);
switch (type) {
- case PARROT_ARG_IC:
+ case PARROT_ARG_IC:
/* Integer constants are stored as part of the opcode
in the packfile */
ret = Parrot_pmc_new(INTERP, enum_class_Integer);
@@ -573,7 +571,7 @@
{
PMC *key;
key = (Parrot_pcc_get_constants(attr->supervised, cc)[arg])->u.key;
-
+
VTABLE_set_string_native(INTERP, ret, VTABLE_get_string(attr->supervised, key));
}
@@ -593,7 +591,7 @@
break;
default:
Parrot_ex_throw_from_c_args(INTERP, NULL, 1,
- "Currently unhandled op arg type %d.", type );
+ "Currently unhandled op arg type %d.", type);
};
RETURN(PMC *ret);
@@ -608,11 +606,10 @@
* This is the simplified custom runops function.
* This is based on the PARROT_FAST_RUNCORE.
*/
-
+
static
opcode_t *
-Instrument_runcore_runops(PARROT_INTERP, Parrot_runcore_t *runcore, opcode_t *pc)
-{
+Instrument_runcore_runops(PARROT_INTERP, Parrot_runcore_t *runcore, opcode_t *pc) {
Instrument_runcore_t *core = (Instrument_runcore_t *) runcore;
Parrot_Interp supervisor = core->supervisor_interp;
@@ -625,9 +622,9 @@
Instrument_fire_hooks(pc, interp);
DO_OP(pc, interp);
-
+
/* Todo: Move this to a probe. This detects loadlib opcodes. */
- if(*pc_copy >= 96 && *pc_copy <= 101) {
+ if (*pc_copy >= 96 && *pc_copy <= 101) {
detect_loadlib(interp);
}
@@ -682,9 +679,9 @@
* This is the initializer for the probe tables.
* Probes are stored in the extended runcore_t.
*/
-
+
static void Instrument_init_probes(Parrot_Interp supervisor, Parrot_Interp supervised) {
- Instrument_runcore_t *core;
+ Instrument_runcore_t *core;
INTVAL op_count;
core = (Instrument_runcore_t *) supervised->run_core;
@@ -779,43 +776,43 @@
Instrument_runcore_t *core;
Parrot_Interp supervisor;
INTVAL old_count, new_count;
-
+
core = (Instrument_runcore_t *) interp->run_core;
supervisor = core->supervisor_interp;
super_dynlibs = supervisor->iglobals;
old_dynlibs = core->old_dynlibs;
dynlibs = VTABLE_get_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_DYN_LIBS);
-
+
/* Check if any libraries were loaded. */
old_count = VTABLE_get_integer(supervisor, old_dynlibs);
new_count = VTABLE_get_integer(interp, dynlibs);
-
+
if (old_count != new_count) {
PMC *iter;
-
+
/* Normalise the vtables of both interps due to singletons. */
normalise_vtables(interp, supervisor);
-
+
/* Before we normalise the op tables, we need to update the hooks table. */
Instrument_init_probes(supervisor, interp);
normalise_op_tables(interp, supervisor);
-
+
/* Look for the new dynlibs and raise an event about them. */
iter = VTABLE_get_iter(interp, dynlibs);
while (VTABLE_get_bool(interp, iter)) {
PMC *key;
-
+
key = VTABLE_shift_pmc(interp, iter);
-
+
if (!VTABLE_exists_keyed(supervisor, old_dynlibs, key)) {
/* New lib detected. */
PMC *lib, *task, *task_hash, *task_data;
-
+
lib = VTABLE_get_pmc_keyed(interp, dynlibs, key);
-
+
task_data = Parrot_pmc_new(supervisor, enum_class_ResizablePMCArray);
VTABLE_push_string(supervisor, task_data, VTABLE_get_string(interp, lib));
-
+
task_hash = Parrot_pmc_new(supervisor, enum_class_Hash);
VTABLE_set_string_keyed_str(supervisor, task_hash,
CONST_STRING(supervisor, "type"),
@@ -827,16 +824,16 @@
VTABLE_set_pmc_keyed_str(supervisor, task_hash,
CONST_STRING(supervisor, "data"),
task_data);
-
+
task = Parrot_pmc_new_init(supervisor, enum_class_Task, task_hash);
Parrot_cx_schedule_task(supervisor, task);
-
+
/* Add lib to the old dynlib hash */
VTABLE_set_pmc_keyed(supervisor, old_dynlibs, key, lib);
}
}
}
-
+
/* Force handling of any pending tasks in super. */
Parrot_cx_handle_tasks(supervisor, supervisor->scheduler);
}
@@ -863,7 +860,7 @@
for (i = dest->n_vtable_max; i < src->n_vtable_max; i++) {
dest->vtables[i] = src->vtables[i];
}
-
+
dest->n_vtable_max = src->n_vtable_max;
}
Modified: branches/gsoc_instrument/src/pmc/task.pmc
==============================================================================
--- branches/gsoc_instrument/src/pmc/task.pmc Tue Jun 15 12:20:35 2010 (r47640)
+++ branches/gsoc_instrument/src/pmc/task.pmc Tue Jun 15 16:38:51 2010 (r47641)
@@ -110,8 +110,6 @@
An interpreter in which to execute this task.
-=back
-
=item C<data>
Additional data for the task.
@@ -175,7 +173,7 @@
core_struct->codeblock = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "code"));
core_struct->data = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "data"));
-
+
core_struct->interp = (Parrot_Interp)VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "interp"));
}
Modified: branches/gsoc_instrument/t/dynpmc/instrument.t
==============================================================================
--- branches/gsoc_instrument/t/dynpmc/instrument.t Tue Jun 15 12:20:35 2010 (r47640)
+++ branches/gsoc_instrument/t/dynpmc/instrument.t Tue Jun 15 16:38:51 2010 (r47641)
@@ -40,7 +40,7 @@
ok($I0, 'Instrument dynpmc loaded')
.return()
-
+
.end
.sub 'test_instantiate'
@@ -52,7 +52,7 @@
.end
-.sub 'test_attach'
+.sub 'test_attach'
.local pmc mock_probe, instr
mock_probe = new ['MockProbe']
More information about the parrot-commits
mailing list