ruby-prof 1.6.1-x64-mingw-ucrt → 1.6.3-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,44 +1,47 @@
1
- /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
- Please see the LICENSE file for copyright and distribution information */
3
-
4
- #ifndef __RP_CALL_TREE_H__
5
- #define __RP_CALL_TREE_H__
6
-
7
- #include "ruby_prof.h"
8
- #include "rp_measurement.h"
9
- #include "rp_method.h"
10
-
11
- extern VALUE cRpCallTree;
12
-
13
- /* Callers and callee information for a method. */
14
- typedef struct prof_call_tree_t
15
- {
16
- prof_owner_t owner;
17
- prof_method_t* method;
18
- struct prof_call_tree_t* parent;
19
- st_table* children; /* Call infos that this call info calls */
20
- prof_measurement_t* measurement;
21
- VALUE object;
22
-
23
- int visits; /* Current visits on the stack */
24
-
25
- unsigned int source_line;
26
- VALUE source_file;
27
- } prof_call_tree_t;
28
-
29
- prof_call_tree_t* prof_call_tree_create(prof_method_t* method, prof_call_tree_t* parent, VALUE source_file, int source_line);
30
- prof_call_tree_t* prof_call_tree_copy(prof_call_tree_t* other);
31
- void prof_call_tree_merge_internal(prof_call_tree_t* destination, prof_call_tree_t* other);
32
- void prof_call_tree_mark(void* data);
33
- prof_call_tree_t* call_tree_table_lookup(st_table* table, st_data_t key);
34
-
35
- void prof_call_tree_add_parent(prof_call_tree_t* self, prof_call_tree_t* parent);
36
- void prof_call_tree_add_child(prof_call_tree_t* self, prof_call_tree_t* child);
37
-
38
- uint32_t prof_call_figure_depth(prof_call_tree_t* call_tree_data);
39
- prof_call_tree_t* prof_get_call_tree(VALUE self);
40
- VALUE prof_call_tree_wrap(prof_call_tree_t* call_tree);
41
- void prof_call_tree_free(prof_call_tree_t* call_tree);
42
- void rp_init_call_tree();
43
-
44
- #endif //__RP_CALL_TREE_H__
1
+ /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ #ifndef __RP_CALL_TREE_H__
5
+ #define __RP_CALL_TREE_H__
6
+
7
+ #include "ruby_prof.h"
8
+ #include "rp_measurement.h"
9
+ #include "rp_method.h"
10
+
11
+ extern VALUE cRpCallTree;
12
+
13
+ /* Callers and callee information for a method. */
14
+ typedef struct prof_call_tree_t
15
+ {
16
+ prof_owner_t owner;
17
+ prof_method_t* method;
18
+ struct prof_call_tree_t* parent;
19
+ st_table* children; /* Call infos that this call info calls */
20
+ prof_measurement_t* measurement;
21
+ VALUE object;
22
+
23
+ int visits; /* Current visits on the stack */
24
+
25
+ unsigned int source_line;
26
+ VALUE source_file;
27
+ } prof_call_tree_t;
28
+
29
+ prof_call_tree_t* prof_call_tree_create(prof_method_t* method, prof_call_tree_t* parent, VALUE source_file, int source_line);
30
+ prof_call_tree_t* prof_call_tree_copy(prof_call_tree_t* other);
31
+ void prof_call_tree_merge_internal(prof_call_tree_t* destination, prof_call_tree_t* other, st_table* method_table);
32
+ void prof_call_tree_mark(void* data);
33
+ prof_call_tree_t* call_tree_table_lookup(st_table* table, st_data_t key);
34
+
35
+ void prof_call_tree_add_parent(prof_call_tree_t* self, prof_call_tree_t* parent);
36
+ void prof_call_tree_add_child(prof_call_tree_t* self, prof_call_tree_t* child);
37
+
38
+ uint32_t prof_call_tree_figure_depth(prof_call_tree_t* call_tree);
39
+ VALUE prof_call_tree_methods(prof_call_tree_t* call_tree);
40
+
41
+ prof_call_tree_t* prof_get_call_tree(VALUE self);
42
+ VALUE prof_call_tree_wrap(prof_call_tree_t* call_tree);
43
+ void prof_call_tree_free(prof_call_tree_t* call_tree);
44
+
45
+ void rp_init_call_tree();
46
+
47
+ #endif //__RP_CALL_TREE_H__
@@ -170,7 +170,7 @@ VALUE prof_call_trees_min_depth(VALUE self)
170
170
  prof_call_trees_t* call_trees = prof_get_call_trees(self);
171
171
  for (prof_call_tree_t** p_call_tree = call_trees->start; p_call_tree < call_trees->ptr; p_call_tree++)
172
172
  {
173
- unsigned int call_tree_depth = prof_call_figure_depth(*p_call_tree);
173
+ unsigned int call_tree_depth = prof_call_tree_figure_depth(*p_call_tree);
174
174
  if (call_tree_depth < depth)
175
175
  depth = call_tree_depth;
176
176
  }
@@ -154,6 +154,14 @@ prof_method_t* prof_method_create(VALUE profile, VALUE klass, VALUE msym, VALUE
154
154
  return result;
155
155
  }
156
156
 
157
+ prof_method_t* prof_method_copy(prof_method_t* other)
158
+ {
159
+ prof_method_t* result = prof_method_create(other->profile, other->klass, other->method_name, other->source_file, other->source_line);
160
+ result->measurement = prof_measurement_copy(other->measurement);
161
+
162
+ return result;
163
+ }
164
+
157
165
  /* The underlying c structures are freed when the parent profile is freed.
158
166
  However, on shutdown the Ruby GC frees objects in any will-nilly order.
159
167
  That means the ruby thread object wrapping the c thread struct may
@@ -274,6 +282,30 @@ size_t method_table_insert(st_table* table, st_data_t key, prof_method_t* val)
274
282
  return rb_st_insert(table, (st_data_t)key, (st_data_t)val);
275
283
  }
276
284
 
285
+ static int prof_method_table_merge_internal(st_data_t key, st_data_t value, st_data_t data)
286
+ {
287
+ st_table* self_table = (st_table*)data;
288
+ prof_method_t* other_child = (prof_method_t*)value;
289
+
290
+ prof_method_t* self_child = method_table_lookup(self_table, other_child->key);
291
+ if (self_child)
292
+ {
293
+ prof_measurement_merge_internal(self_child->measurement, other_child->measurement);
294
+ }
295
+ else
296
+ {
297
+ prof_method_t* copy = prof_method_copy(other_child);
298
+ method_table_insert(self_table, copy->key, copy);
299
+ }
300
+
301
+ return ST_CONTINUE;
302
+ }
303
+
304
+ void prof_method_table_merge(st_table* self, st_table* other)
305
+ {
306
+ rb_st_foreach(other, prof_method_table_merge_internal, (st_data_t)self);
307
+ }
308
+
277
309
  prof_method_t* method_table_lookup(st_table* table, st_data_t key)
278
310
  {
279
311
  st_data_t val;
@@ -378,7 +410,7 @@ static VALUE prof_method_line(VALUE self)
378
410
  }
379
411
 
380
412
  /* call-seq:
381
- klass_name -> string
413
+ klass_name -> String
382
414
 
383
415
  Returns the name of this method's class. Singleton classes
384
416
  will have the form <Object::Object>. */
@@ -404,9 +436,9 @@ static VALUE prof_method_klass_flags(VALUE self)
404
436
  }
405
437
 
406
438
  /* call-seq:
407
- method_name -> string
439
+ method_name -> Symbol
408
440
 
409
- Returns the name of this method in the format Object#method. Singletons
441
+ Returns the name of this method in the format Object#method. Singletons
410
442
  methods will be returned in the format <Object::Object>#method.*/
411
443
 
412
444
  static VALUE prof_method_name(VALUE self)
@@ -1,62 +1,63 @@
1
- /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
- Please see the LICENSE file for copyright and distribution information */
3
-
4
- #ifndef __RP_METHOD_INFO__
5
- #define __RP_METHOD_INFO__
6
-
7
- #include "ruby_prof.h"
8
- #include "rp_measurement.h"
9
-
10
- extern VALUE cRpMethodInfo;
11
-
12
- // Source relation bit offsets.
13
- enum {
14
- kModuleIncludee = 0x1, // Included in module
15
- kClassSingleton = 0x2, // Singleton of a class
16
- kModuleSingleton = 0x4, // Singleton of a module
17
- kObjectSingleton = 0x8, // Singleton of an object
18
- kOtherSingleton = 0x10 // Singleton of unknown object
19
- };
20
-
21
- // Profiling information for each method.
22
- // Excluded methods have no call_trees, source_klass, or source_file.
23
- typedef struct prof_method_t
24
- {
25
- VALUE profile; // Profile this method is associated with - needed for mark phase
26
- struct prof_call_trees_t* call_trees; // Call infos that call this method
27
- st_table* allocations_table; // Tracks object allocations
28
-
29
- st_data_t key; // Table key
30
- unsigned int klass_flags; // Information about the type of class
31
- VALUE klass; // Resolved klass
32
- VALUE klass_name; // Resolved klass name for this method
33
- VALUE method_name; // Resolved method name for this method
34
-
35
- VALUE object; // Cached ruby object
36
-
37
- bool recursive;
38
- int visits; // Current visits on the stack
39
- VALUE source_file; // Source file
40
- int source_line; // Line number
41
-
42
- prof_measurement_t* measurement; // Stores measurement data for this method
43
- } prof_method_t;
44
-
45
- void rp_init_method_info(void);
46
-
47
- st_data_t method_key(VALUE klass, VALUE msym);
48
-
49
- st_table* method_table_create(void);
50
- prof_method_t* method_table_lookup(st_table* table, st_data_t key);
51
- size_t method_table_insert(st_table* table, st_data_t key, prof_method_t* val);
52
- void method_table_free(st_table* table);
53
- prof_method_t* prof_method_create(VALUE profile, VALUE klass, VALUE msym, VALUE source_file, int source_line);
54
- prof_method_t* prof_get_method(VALUE self);
55
-
56
- VALUE prof_method_wrap(prof_method_t* result);
57
- void prof_method_mark(void* data);
58
-
59
- VALUE resolve_klass(VALUE klass, unsigned int* klass_flags);
60
- VALUE resolve_klass_name(VALUE klass, unsigned int* klass_flags);
61
-
62
- #endif //__RP_METHOD_INFO__
1
+ /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ #ifndef __RP_METHOD_INFO__
5
+ #define __RP_METHOD_INFO__
6
+
7
+ #include "ruby_prof.h"
8
+ #include "rp_measurement.h"
9
+
10
+ extern VALUE cRpMethodInfo;
11
+
12
+ // Source relation bit offsets.
13
+ enum {
14
+ kModuleIncludee = 0x1, // Included in module
15
+ kClassSingleton = 0x2, // Singleton of a class
16
+ kModuleSingleton = 0x4, // Singleton of a module
17
+ kObjectSingleton = 0x8, // Singleton of an object
18
+ kOtherSingleton = 0x10 // Singleton of unknown object
19
+ };
20
+
21
+ // Profiling information for each method.
22
+ // Excluded methods have no call_trees, source_klass, or source_file.
23
+ typedef struct prof_method_t
24
+ {
25
+ VALUE profile; // Profile this method is associated with - needed for mark phase
26
+ struct prof_call_trees_t* call_trees; // Call infos that call this method
27
+ st_table* allocations_table; // Tracks object allocations
28
+
29
+ st_data_t key; // Table key
30
+ unsigned int klass_flags; // Information about the type of class
31
+ VALUE klass; // Resolved klass
32
+ VALUE klass_name; // Resolved klass name for this method
33
+ VALUE method_name; // Resolved method name for this method
34
+
35
+ VALUE object; // Cached ruby object
36
+
37
+ bool recursive;
38
+ int visits; // Current visits on the stack
39
+ VALUE source_file; // Source file
40
+ int source_line; // Line number
41
+
42
+ prof_measurement_t* measurement; // Stores measurement data for this method
43
+ } prof_method_t;
44
+
45
+ void rp_init_method_info(void);
46
+
47
+ st_data_t method_key(VALUE klass, VALUE msym);
48
+
49
+ st_table* method_table_create(void);
50
+ prof_method_t* method_table_lookup(st_table* table, st_data_t key);
51
+ size_t method_table_insert(st_table* table, st_data_t key, prof_method_t* val);
52
+ void method_table_free(st_table* table);
53
+ void prof_method_table_merge(st_table* self, st_table* other);
54
+ prof_method_t* prof_method_create(VALUE profile, VALUE klass, VALUE msym, VALUE source_file, int source_line);
55
+ prof_method_t* prof_get_method(VALUE self);
56
+
57
+ VALUE prof_method_wrap(prof_method_t* result);
58
+ void prof_method_mark(void* data);
59
+
60
+ VALUE resolve_klass(VALUE klass, unsigned int* klass_flags);
61
+ VALUE resolve_klass_name(VALUE klass, unsigned int* klass_flags);
62
+
63
+ #endif //__RP_METHOD_INFO__