aboutsummaryrefslogtreecommitdiffstats
path: root/vm_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_dump.c')
-rw-r--r--vm_dump.c139
1 files changed, 0 insertions, 139 deletions
diff --git a/vm_dump.c b/vm_dump.c
index 10061020ce..8e005bd14e 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -395,145 +395,6 @@ rb_vmdebug_debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp
#endif
}
-#ifdef COLLECT_USAGE_ANALYSIS
-/* uh = {
- * insn(Fixnum) => ihash(Hash)
- * }
- * ihash = {
- * -1(Fixnum) => count, # insn usage
- * 0(Fixnum) => ophash, # operand usage
- * }
- * ophash = {
- * val(interned string) => count(Fixnum)
- * }
- */
-void
-vm_analysis_insn(int insn)
-{
- ID usage_hash;
- ID bigram_hash;
- static int prev_insn = -1;
-
- VALUE uh;
- VALUE ihash;
- VALUE cv;
-
- CONST_ID(usage_hash, "USAGE_ANALYSIS_INSN");
- CONST_ID(bigram_hash, "USAGE_ANALYSIS_INSN_BIGRAM");
- uh = rb_const_get(rb_cRubyVM, usage_hash);
- if ((ihash = rb_hash_aref(uh, INT2FIX(insn))) == Qnil) {
- ihash = rb_hash_new();
- rb_hash_aset(uh, INT2FIX(insn), ihash);
- }
- if ((cv = rb_hash_aref(ihash, INT2FIX(-1))) == Qnil) {
- cv = INT2FIX(0);
- }
- rb_hash_aset(ihash, INT2FIX(-1), INT2FIX(FIX2INT(cv) + 1));
-
- /* calc bigram */
- if (prev_insn != -1) {
- VALUE bi;
- VALUE ary[2];
- VALUE cv;
-
- ary[0] = INT2FIX(prev_insn);
- ary[1] = INT2FIX(insn);
- bi = rb_ary_new4(2, &ary[0]);
-
- uh = rb_const_get(rb_cRubyVM, bigram_hash);
- if ((cv = rb_hash_aref(uh, bi)) == Qnil) {
- cv = INT2FIX(0);
- }
- rb_hash_aset(uh, bi, INT2FIX(FIX2INT(cv) + 1));
- }
- prev_insn = insn;
-}
-
-/* from disasm.c */
-extern VALUE insn_operand_intern(int insn, int op_no, VALUE op,
- int len, int pos, VALUE child);
-
-void
-vm_analysis_operand(int insn, int n, VALUE op)
-{
- ID usage_hash;
-
- VALUE uh;
- VALUE ihash;
- VALUE ophash;
- VALUE valstr;
- VALUE cv;
-
- CONST_ID(usage_hash, "USAGE_ANALYSIS_INSN");
-
- uh = rb_const_get(rb_cRubyVM, usage_hash);
- if ((ihash = rb_hash_aref(uh, INT2FIX(insn))) == Qnil) {
- ihash = rb_hash_new();
- rb_hash_aset(uh, INT2FIX(insn), ihash);
- }
- if ((ophash = rb_hash_aref(ihash, INT2FIX(n))) == Qnil) {
- ophash = rb_hash_new();
- rb_hash_aset(ihash, INT2FIX(n), ophash);
- }
- /* intern */
- valstr = insn_operand_intern(insn, n, op, 0, 0, 0);
-
- /* set count */
- if ((cv = rb_hash_aref(ophash, valstr)) == Qnil) {
- cv = INT2FIX(0);
- }
- rb_hash_aset(ophash, valstr, INT2FIX(FIX2INT(cv) + 1));
-}
-
-void
-vm_analysis_register(int reg, int isset)
-{
- ID usage_hash;
- VALUE uh;
- VALUE rhash;
- VALUE valstr;
- static const char regstrs[][5] = {
- "pc", /* 0 */
- "sp", /* 1 */
- "ep", /* 2 */
- "cfp", /* 3 */
- "self", /* 4 */
- "iseq", /* 5 */
- };
- static const char getsetstr[][4] = {
- "get",
- "set",
- };
- static VALUE syms[sizeof(regstrs) / sizeof(regstrs[0])][2];
-
- VALUE cv;
-
- CONST_ID(usage_hash, "USAGE_ANALYSIS_REGS");
- if (syms[0] == 0) {
- char buff[0x10];
- int i;
-
- for (i = 0; i < sizeof(regstrs) / sizeof(regstrs[0]); i++) {
- int j;
- for (j = 0; j < 2; j++) {
- snfprintf(stderr, buff, 0x10, "%d %s %-4s", i, getsetstr[j],
- regstrs[i]);
- syms[i][j] = ID2SYM(rb_intern(buff));
- }
- }
- }
- valstr = syms[reg][isset];
-
- uh = rb_const_get(rb_cRubyVM, usage_hash);
- if ((cv = rb_hash_aref(uh, valstr)) == Qnil) {
- cv = INT2FIX(0);
- }
- rb_hash_aset(uh, valstr, INT2FIX(FIX2INT(cv) + 1));
-}
-
-
-#endif
-
VALUE
rb_vmdebug_thread_dump_state(VALUE self)
{