Skip to content

Commit

Permalink
Initial attempt to instrument gc.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/branches/gsoc_instrument@47862 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
khairul committed Jun 26, 2010
1 parent a1c0f86 commit 2232faf
Show file tree
Hide file tree
Showing 8 changed files with 562 additions and 8 deletions.
2 changes: 2 additions & 0 deletions MANIFEST
Expand Up @@ -1277,7 +1277,9 @@ src/dynpmc/foo.pmc []
src/dynpmc/foo2.pmc []
src/dynpmc/gziphandle.pmc []
src/dynpmc/instrument.pmc []
src/dynpmc/instrumentgc.pmc []
src/dynpmc/instrumentop.pmc []
src/dynpmc/instrumentpmc.pmc []
src/dynpmc/main.pasm []
src/dynpmc/os.pmc []
src/dynpmc/pccmethod_test.pmc []
Expand Down
14 changes: 13 additions & 1 deletion runtime/parrot/library/Instrument/EventLibrary.nqp
Expand Up @@ -5,7 +5,7 @@
=begin

=head1 NAME
runtime/parrot/library/Instrument/EventLibrary.nqp

Library for the many classes that provide handlers for Events.
Expand Down Expand Up @@ -125,4 +125,16 @@ class Instrument::Event::Class::callmethod is Instrument::Event {
};
};

class Instrument::Event::GC::allocate is Instrument::Event {
method _self_init() {
$!event_type := 'Instrument::Event::GC::allocate';
};
};

class Instrument::Event::GC::reallocate is Instrument::Event {
method _self_init() {
$!event_type := 'Instrument::Event::GC::reallocate';
};
};

# vim: ft=perl6 expandtab shiftwidth=4:
8 changes: 6 additions & 2 deletions src/dynpmc/Defines.in
Expand Up @@ -23,11 +23,15 @@ DYNPMC_FOO_OBJS = \

DYNPMC_INSTRUMENT = \
src/dynpmc/instrument.pmc \
src/dynpmc/instrumentop.pmc
src/dynpmc/instrumentgc.pmc \
src/dynpmc/instrumentop.pmc \
src/dynpmc/instrumentpmc.pmc

DYNPMC_INSTRUMENT_OBJS = \
src/dynpmc/instrument$(O) \
src/dynpmc/instrumentop$(O)
src/dynpmc/instrumentgc$(O) \
src/dynpmc/instrumentop$(O) \
src/dynpmc/instrumentpmc$(O)

DYNPMC_H_FILES = \
include/parrot/caches.h \
Expand Down
25 changes: 24 additions & 1 deletion src/dynpmc/Rules.in
Expand Up @@ -183,7 +183,8 @@ $(DYNEXT_DIR)/instrument_group$(LOAD_EXT): $(DYNPMC_INSTRUMENT_OBJS) src/dynpmc/
#IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
#IF(cygwin or hpux): $(CHMOD) 0775 $@

src/dynpmc/instrument_group$(O): src/dynpmc/instrument.c src/dynpmc/instrumentop.c $(DYNPMC_H_FILES)
src/dynpmc/instrument_group$(O): src/dynpmc/instrument.c src/dynpmc/instrumentop.c \
src/dynpmc/instrumentpmc.c src/dynpmc/instrumentgc.c $(DYNPMC_H_FILES)

src/dynpmc/instrument_group.c: $(DYNPMC_INSTRUMENT_OBJS)
$(PMC2C) --library instrument_group --c $(DYNPMC_INSTRUMENT)
Expand All @@ -201,6 +202,17 @@ src/dynpmc/instrument.c: src/dynpmc/instrument.dump
src/dynpmc/instrument.dump: src/dynpmc/instrument.pmc vtable.dump $(CLASS_O_FILES)
$(PMC2CD) src/dynpmc/instrument.pmc

src/dynpmc/pmc_instrumentgc.h : src/dynpmc/instrumentgc.c

src/dynpmc/instrumentgc$(O): src/dynpmc/instrumentgc.c $(DYNPMC_H_FILES) \
src/gc/gc_private.h src/dynpmc/pmc_instrumentgc.h

src/dynpmc/instrumentgc.c: src/dynpmc/instrumentgc.dump
$(PMC2CC) src/dynpmc/instrumentgc.pmc

src/dynpmc/instrumentgc.dump: src/dynpmc/instrumentgc.pmc vtable.dump $(CLASS_O_FILES)
$(PMC2CD) src/dynpmc/instrumentgc.pmc

src/dynpmc/pmc_instrumentop.h : src/dynpmc/instrumentop.c

src/dynpmc/instrumentop$(O): src/dynpmc/instrumentop.c $(DYNPMC_H_FILES) \
Expand All @@ -211,3 +223,14 @@ src/dynpmc/instrumentop.c: src/dynpmc/instrumentop.dump

src/dynpmc/instrumentop.dump: src/dynpmc/instrumentop.pmc vtable.dump $(CLASS_O_FILES)
$(PMC2CD) src/dynpmc/instrumentop.pmc

src/dynpmc/pmc_instrumentpmc.h : src/dynpmc/instrumentpmc.c

src/dynpmc/instrumentpmc$(O): src/dynpmc/instrumentpmc.c $(DYNPMC_H_FILES) \
src/dynpmc/pmc_instrumentpmc.h

src/dynpmc/instrumentpmc.c: src/dynpmc/instrumentpmc.dump
$(PMC2CC) src/dynpmc/instrumentpmc.pmc

src/dynpmc/instrumentpmc.dump: src/dynpmc/instrumentpmc.pmc vtable.dump $(CLASS_O_FILES)
$(PMC2CD) src/dynpmc/instrumentpmc.pmc
18 changes: 15 additions & 3 deletions src/dynpmc/instrument.pmc
Expand Up @@ -90,6 +90,7 @@ pmclass Instrument auto_attrs dynpmc provides hash group instrument_group {
ATTR Parrot_Interp supervised; /* The interpreter running the code */
ATTR PMC *probes; /* A list of probes registered. */
ATTR PMC *evt_dispatcher;
ATTR PMC *instrument_gc;

/*

Expand All @@ -103,8 +104,8 @@ Initializes the pmc and creates a child interpreter.

VTABLE void init() {
Parrot_Instrument_attributes * const attr = PARROT_INSTRUMENT(SELF);
PMC *evt_key1, *evt_key2, *nothing;
INTVAL evt_class_type;
PMC *evt_key1, *evt_key2, *nothing, *supervised_pmc;
INTVAL evt_class_type, gc_class_type;

/* Obtain the class type of Instrument::EventDispatcher. */
evt_key1 = key_new_cstring(INTERP, "Instrument");
Expand All @@ -113,7 +114,10 @@ Initializes the pmc and creates a child interpreter.

evt_class_type = Parrot_pmc_get_type(INTERP, evt_key1);

/* Create the child interpreter PMC */
/* Obtain the class type of InstrumentGC. */
gc_class_type = Parrot_pmc_get_type_str(INTERP, CONST_STRING(INTERP, "InstrumentGC"));

/* Initialise the attributes. */
attr->supervised = Parrot_new(INTERP);
attr->probes = Parrot_pmc_new(INTERP, enum_class_Hash);
attr->evt_dispatcher = Parrot_pmc_new(INTERP, evt_class_type);
Expand All @@ -131,6 +135,12 @@ Initializes the pmc and creates a child interpreter.
/* Prepare the child interpreter's op table for instrumentation */
Instrument_init_probes(INTERP, attr->supervised);

/* Prepare for GC instrumentation. */
supervised_pmc = VTABLE_get_pmc_keyed_int(attr->supervised,
attr->supervised->iglobals,
IGLOBALS_INTERPRETER);
attr->instrument_gc = Parrot_pmc_new_init(INTERP, gc_class_type, supervised_pmc);

/* Set self to destroy manually */
PObj_custom_mark_destroy_SETALL(SELF);
}
Expand Down Expand Up @@ -185,6 +195,7 @@ Marks internal data structures as live to the gc.
/* Mark attributes as alive */
Parrot_gc_mark_PMC_alive_fun(INTERP, attr->probes);
Parrot_gc_mark_PMC_alive_fun(INTERP, attr->evt_dispatcher);
Parrot_gc_mark_PMC_alive_fun(INTERP, attr->instrument_gc);
Parrot_gc_mark_PMC_alive_fun(INTERP, core->old_dynlibs);
Parrot_gc_mark_PMC_alive_fun(INTERP, core->instr_op);
}
Expand Down Expand Up @@ -588,6 +599,7 @@ Instrument_runcore_runops(PARROT_INTERP, Parrot_runcore_t *runcore, opcode_t *pc

/* Force events */
Parrot_cx_handle_tasks(interp, interp->scheduler);
Parrot_cx_handle_tasks(supervisor, supervisor->scheduler);
}

return pc;
Expand Down

0 comments on commit 2232faf

Please sign in to comment.