ext/ruby_prof/rp_method.h in ruby-prof-0.18.0 vs ext/ruby_prof/rp_method.h in ruby-prof-1.0.0

- old
+ new

@@ -2,74 +2,69 @@ Please see the LICENSE file for copyright and distribution information */ #ifndef __RP_METHOD_INFO__ #define __RP_METHOD_INFO__ -#include <ruby.h> +#include "ruby_prof.h" +#include "rp_measurement.h" -extern VALUE cMethodInfo; +extern VALUE cRpMethodInfo; -/* A key used to identify each method */ -typedef struct -{ - VALUE klass; /* The method's class. */ - ID mid; /* The method id. */ - st_index_t key; /* Cache calculated key */ -} prof_method_key_t; - /* Source relation bit offsets. */ enum { - kModuleIncludee = 0, /* Included module */ - kModuleSingleton, /* Singleton class of a module */ - kObjectSingleton /* Singleton class of an object */ + kModuleIncludee = 0x1, /* Included in module */ + kClassSingleton = 0x2, /* Singleton of a class */ + kModuleSingleton = 0x4, /* Singleton of a module */ + kObjectSingleton = 0x8, /* Singleton of an object */ + kOtherSingleton = 0x10 /* Singleton of unkown object */ }; /* Forward declaration, see rp_call_info.h */ struct prof_call_infos_t; /* Profiling information for each method. */ /* Excluded methods have no call_infos, source_klass, or source_file. */ typedef struct { - /* Hot */ + st_data_t key; /* Table key */ - prof_method_key_t *key; /* Table key */ - - struct prof_call_infos_t *call_infos; /* Call infos */ int visits; /* Current visits on the stack */ + bool excluded; /* Exclude from profile? */ - unsigned int excluded : 1; /* Exclude from profile? */ - unsigned int recursive : 1; /* Recursive (direct or mutual)? */ + st_table* parent_call_infos; /* Call infos that call this method */ + st_table* child_call_infos; /* Call infos that this method calls */ + st_table* allocations_table; /* Tracks object allocations */ - /* Cold */ + unsigned int klass_flags; /* Information about the type of class */ + VALUE klass; /* Resolved klass */ + VALUE klass_name; /* Resolved klass name for this method */ + VALUE method_name; /* Resolved method name for this method */ VALUE object; /* Cached ruby object */ - VALUE source_klass; /* Source class */ - const char *source_file; /* Source file */ - int line; /* Line number */ - unsigned int resolved : 1; /* Source resolved? */ - unsigned int relation : 3; /* Source relation bits */ + bool root; /* Is this a root method */ + bool recursive; + VALUE source_file; /* Source file */ + int source_line; /* Line number */ + + prof_measurement_t *measurement; } prof_method_t; void rp_init_method_info(void); -void method_key(prof_method_key_t* key, VALUE klass, ID mid); +st_data_t method_key(VALUE klass, VALUE msym); -st_table * method_table_create(); -prof_method_t * method_table_lookup(st_table *table, const prof_method_key_t* key); -size_t method_table_insert(st_table *table, const prof_method_key_t *key, prof_method_t *val); +st_table *method_table_create(void); +prof_method_t* prof_method_create_excluded(VALUE klass, VALUE msym); +prof_method_t *method_table_lookup(st_table *table, st_data_t key); +size_t method_table_insert(st_table *table, st_data_t key, prof_method_t *val); void method_table_free(st_table *table); +prof_method_t *prof_method_create(VALUE klass, VALUE msym, VALUE source_file, int source_line); +prof_method_t *prof_method_get(VALUE self); -prof_method_t* prof_method_create(VALUE klass, ID mid, const char* source_file, int line); -prof_method_t* prof_method_create_excluded(VALUE klass, ID mid); - VALUE prof_method_wrap(prof_method_t *result); -void prof_method_mark(prof_method_t *method); +void prof_method_mark(void *data); -/* Setup infrastructure to use method keys as hash comparisons */ -int method_table_cmp(prof_method_key_t *key1, prof_method_key_t *key2); -st_index_t method_table_hash(prof_method_key_t *key); +VALUE resolve_klass(VALUE klass, unsigned int *klass_flags); +VALUE resolve_klass_name(VALUE klass, unsigned int* klass_flags); -extern struct st_hash_type type_method_hash; - -#endif +#endif //__RP_METHOD_INFO__