Permalink
Browse files

Release 0.4.3, profiling branch.

    (### see comments in profile.c)
    (Jan-2-2009: added memset calls to zero out profiling mallocs)
  • Loading branch information...
Andrew Plotkin
Andrew Plotkin committed Mar 22, 2009
1 parent a8831a6 commit c705ca6033a411904c0872cc4af42e1a987ed7b4
Showing with 793 additions and 2 deletions.
  1. +1 −1 Makefile
  2. +5 −1 README
  3. +15 −0 exec.c
  4. +3 −0 funcs.c
  5. +9 −0 glulxe.h
  6. +4 −0 main.c
  7. +464 −0 profile-analyze.py
  8. +292 −0 profile.c
View
@@ -31,7 +31,7 @@ CFLAGS = $(OPTIONS) -I$(GLKINCLUDEDIR)
LIBS = -L$(GLKLIBDIR) $(GLKLIB) $(LINKLIBS)
OBJS = main.o files.o vm.o exec.o funcs.o operand.o string.o glkop.o \
- heap.o serial.o search.o gestalt.o osdepend.o
+ heap.o serial.o search.o gestalt.o osdepend.o profile.o
all: glulxe
View
6 README
@@ -1,5 +1,5 @@
Glulxe: the Glulx VM interpreter
-Version 0.4.3
+Version 0.4.3 PROFILING
Designed by Andrew Plotkin <erkyrath@eblong.com>
http://eblong.com/zarf/glulx/index.html
@@ -32,6 +32,10 @@ Ditto for Windows, using "winstart.c".
* Version
+PROFILING:
+ (### see comments in profile.c)
+ (Jan-2-2009: added memset calls to zero out profiling mallocs)
+
0.4.3:
Verify the presence of Unicode calls in the Glk library at runtime.
(Thanks Simon Baldwin.)
View
15 exec.c
@@ -24,6 +24,7 @@ void execute_loop()
while (!done_executing) {
+ profile_tick();
/* Do OS-specific processing, if appropriate. */
glk_tick();
@@ -322,6 +323,7 @@ void execute_loop()
goto PerformJump;
break;
case op_throw:
+ profile_fail("throw");
value = inst.value[0];
stackptr = inst.value[1];
pop_callstub(value);
@@ -496,19 +498,27 @@ void execute_loop()
break;
case op_streamchar:
+ profile_in(2);
value = inst.value[0] & 0xFF;
(*stream_char_handler)(value);
+ profile_out();
break;
case op_streamunichar:
+ profile_in(2);
value = inst.value[0];
(*stream_unichar_handler)(value);
+ profile_out();
break;
case op_streamnum:
+ profile_in(2);
vals0 = inst.value[0];
stream_num(vals0, FALSE, 0);
+ profile_out();
break;
case op_streamstr:
+ profile_in(2);
stream_string(inst.value[0], 0, 0);
+ profile_out();
break;
default:
@@ -580,10 +590,12 @@ void execute_loop()
break;
case op_glk:
+ profile_in(1);
value = inst.value[1];
arglist = pop_arguments(value, 0);
val0 = perform_glk(inst.value[0], value, arglist);
store_operand(inst.desttype, inst.value[2], val0);
+ profile_out();
break;
case op_random:
@@ -606,6 +618,7 @@ void execute_loop()
break;
case op_restart:
+ profile_fail("restart");
vm_restart();
break;
@@ -627,6 +640,7 @@ void execute_loop()
break;
case op_restore:
+ profile_fail("restore");
value = perform_restore(find_stream_by_id(inst.value[0]));
if (value == 0) {
/* We've succeeded, and the stack now contains the callstub
@@ -648,6 +662,7 @@ void execute_loop()
break;
case op_restoreundo:
+ profile_fail("restoreundo");
value = perform_restoreundo();
if (value == 0) {
/* We've succeeded, and the stack now contains the callstub
View
@@ -19,6 +19,8 @@ void enter_function(glui32 addr, glui32 argc, glui32 *argv)
int functype;
glui32 modeaddr, opaddr, val;
int loctype, locnum;
+
+ profile_in(addr);
/* Check the Glulx type identifier byte. */
functype = Mem1(addr);
@@ -179,6 +181,7 @@ void enter_function(glui32 addr, glui32 argc, glui32 *argv)
void leave_function()
{
stackptr = frameptr;
+ profile_out();
}
/* push_callstub():
View
@@ -238,4 +238,13 @@ extern int init_dispatch(void);
extern glui32 perform_glk(glui32 funcnum, glui32 numargs, glui32 *arglist);
extern strid_t find_stream_by_id(glui32 objid);
+/* profile.c */
+extern glui32 profile_opcount;
+#define profile_tick() (profile_opcount++)
+extern int init_profile(void);
+extern void profile_in(glui32 addr);
+extern void profile_out(void);
+extern void profile_fail(char *reason);
+extern void profile_quit(void);
+
#endif /* _GLULXE_H */
View
4 main.c
@@ -36,11 +36,15 @@ void glk_main()
if (!init_dispatch()) {
return;
}
+ if (!init_profile()) {
+ return;
+ }
setup_vm();
execute_loop();
finalize_vm();
+ profile_quit();
glk_exit();
}
Oops, something went wrong.

0 comments on commit c705ca6

Please sign in to comment.