runtime_analysis 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +115 -0
- data/LICENSE.txt +96 -0
- data/README.md +164 -0
- data/editor/nvim/README.md +278 -0
- data/editor/nvim/lua/runtime_analysis/connected.lua +565 -0
- data/editor/nvim/lua/runtime_analysis/go_to_class.lua +63 -0
- data/editor/nvim/lua/runtime_analysis/inline.lua +138 -0
- data/editor/nvim/lua/runtime_analysis/lens.lua +50 -0
- data/editor/nvim/lua/runtime_analysis/lsp.lua +92 -0
- data/editor/nvim/lua/runtime_analysis/menu.lua +98 -0
- data/editor/nvim/lua/runtime_analysis/preview.lua +70 -0
- data/editor/nvim/lua/runtime_analysis/project.lua +28 -0
- data/editor/nvim/lua/runtime_analysis/rerun.lua +39 -0
- data/editor/nvim/lua/runtime_analysis/text.lua +23 -0
- data/editor/nvim/lua/runtime_analysis/value_popup.lua +45 -0
- data/editor/nvim/plugin/runtime_analysis.lua +71 -0
- data/examples/trackers/PROMPT.md +86 -0
- data/examples/trackers/honeybadger.rb +19 -0
- data/examples/trackers/sentry.rb +16 -0
- data/ext/runtime_analysis/extconf.rb +68 -0
- data/ext/runtime_analysis/fast.c +775 -0
- data/ext/runtime_analysis/fast.h +59 -0
- data/ext/runtime_analysis/hold.c +560 -0
- data/ext/runtime_analysis/init.c +36 -0
- data/ext/runtime_analysis/names.c +78 -0
- data/ext/runtime_analysis/names.h +28 -0
- data/ext/runtime_analysis/novelty.c +139 -0
- data/ext/runtime_analysis/novelty.h +22 -0
- data/ext/runtime_analysis/os.c +73 -0
- data/ext/runtime_analysis/os.h +32 -0
- data/ext/runtime_analysis/ring.c +445 -0
- data/ext/runtime_analysis/rows.c +304 -0
- data/ext/runtime_analysis/sink.c +485 -0
- data/ext/runtime_analysis/sink.h +240 -0
- data/ext/runtime_analysis/state.c +254 -0
- data/ext/runtime_analysis/state.h +57 -0
- data/ext/runtime_analysis/wrapper.c +278 -0
- data/ext/runtime_analysis/wrapper.h +24 -0
- data/lib/runtime_analysis/errors.rb +34 -0
- data/lib/runtime_analysis/failsafe.rb +123 -0
- data/lib/runtime_analysis/host/controller_entry_point.rb +18 -0
- data/lib/runtime_analysis/host/declared.rb +152 -0
- data/lib/runtime_analysis/host/inject.rb +90 -0
- data/lib/runtime_analysis/host/job_runners.rb +27 -0
- data/lib/runtime_analysis/host/middleware.rb +23 -0
- data/lib/runtime_analysis/host/minitest_integration.rb +22 -0
- data/lib/runtime_analysis/host/railtie.rb +42 -0
- data/lib/runtime_analysis/host/reports.rb +54 -0
- data/lib/runtime_analysis/host/rspec_integration.rb +17 -0
- data/lib/runtime_analysis/host/web.rb +22 -0
- data/lib/runtime_analysis/host.rb +34 -0
- data/lib/runtime_analysis/inject.rb +5 -0
- data/lib/runtime_analysis/minitest.rb +9 -0
- data/lib/runtime_analysis/native/build.rb +17 -0
- data/lib/runtime_analysis/native/byte_size.rb +27 -0
- data/lib/runtime_analysis/native/call_site_logger/definitions.rb +51 -0
- data/lib/runtime_analysis/native/call_site_logger/held.rb +35 -0
- data/lib/runtime_analysis/native/call_site_logger/rows.rb +110 -0
- data/lib/runtime_analysis/native/call_site_logger/segments.rb +100 -0
- data/lib/runtime_analysis/native/call_site_logger/streams.rb +110 -0
- data/lib/runtime_analysis/native/call_site_logger.rb +80 -0
- data/lib/runtime_analysis/native/rotation_policy.rb +28 -0
- data/lib/runtime_analysis/native/sanitizer_runtime.rb +50 -0
- data/lib/runtime_analysis/native/sink.rb +12 -0
- data/lib/runtime_analysis/native.rb +74 -0
- data/lib/runtime_analysis/platform.rb +30 -0
- data/lib/runtime_analysis/query/index/anonymise.rb +98 -0
- data/lib/runtime_analysis/query/index/graph.rb +107 -0
- data/lib/runtime_analysis/query/index/graph_cache.rb +32 -0
- data/lib/runtime_analysis/query/index/reading/declared.rb +42 -0
- data/lib/runtime_analysis/query/index/reading/dict.rb +43 -0
- data/lib/runtime_analysis/query/index/reading/frame.rb +27 -0
- data/lib/runtime_analysis/query/index/reading/node.rb +45 -0
- data/lib/runtime_analysis/query/index/reading/path.rb +21 -0
- data/lib/runtime_analysis/query/index/reading/reruns.rb +30 -0
- data/lib/runtime_analysis/query/index/reading/rows.rb +128 -0
- data/lib/runtime_analysis/query/index/reading/stream.rb +82 -0
- data/lib/runtime_analysis/query/index/reading/tree.rb +66 -0
- data/lib/runtime_analysis/query/index/reading/tree_builder.rb +135 -0
- data/lib/runtime_analysis/query/index/reading/values.rb +49 -0
- data/lib/runtime_analysis/query/index/reading.rb +80 -0
- data/lib/runtime_analysis/query/index/shapes.rb +142 -0
- data/lib/runtime_analysis/query/index/signatures/active_support.rb +31 -0
- data/lib/runtime_analysis/query/index/signatures/core.json +1 -0
- data/lib/runtime_analysis/query/index/signatures/layers.rb +29 -0
- data/lib/runtime_analysis/query/index/signatures/lineage.rb +57 -0
- data/lib/runtime_analysis/query/index/signatures/overloads.rb +32 -0
- data/lib/runtime_analysis/query/index/signatures/rbs/entry.rb +95 -0
- data/lib/runtime_analysis/query/index/signatures/rbs/export.rb +76 -0
- data/lib/runtime_analysis/query/index/signatures/rbs/library.rb +43 -0
- data/lib/runtime_analysis/query/index/signatures/rbs/overload.rb +66 -0
- data/lib/runtime_analysis/query/index/signatures/rbs/project.rb +69 -0
- data/lib/runtime_analysis/query/index/signatures/rbs/types.rb +79 -0
- data/lib/runtime_analysis/query/index/signatures/rbs.rb +57 -0
- data/lib/runtime_analysis/query/index/signatures/sorbet/sig.rb +48 -0
- data/lib/runtime_analysis/query/index/signatures/sorbet/signed.rb +69 -0
- data/lib/runtime_analysis/query/index/signatures/sorbet/table.rb +43 -0
- data/lib/runtime_analysis/query/index/signatures/sorbet/types.rb +96 -0
- data/lib/runtime_analysis/query/index/signatures/sorbet.rb +150 -0
- data/lib/runtime_analysis/query/index/signatures/sources.rb +80 -0
- data/lib/runtime_analysis/query/index/signatures/written.rb +45 -0
- data/lib/runtime_analysis/query/index/signatures.rb +93 -0
- data/lib/runtime_analysis/query/index/source_named_graph.rb +84 -0
- data/lib/runtime_analysis/query/index/static/change_set.rb +20 -0
- data/lib/runtime_analysis/query/index/static/changes.rb +80 -0
- data/lib/runtime_analysis/query/index/static/code_visitor.rb +144 -0
- data/lib/runtime_analysis/query/index/static/klass.rb +13 -0
- data/lib/runtime_analysis/query/index/static/method.rb +19 -0
- data/lib/runtime_analysis/query/index/static/params.rb +52 -0
- data/lib/runtime_analysis/query/index/static/source.rb +69 -0
- data/lib/runtime_analysis/query/index/static/stub.rb +14 -0
- data/lib/runtime_analysis/query/index/static/stub_visitor.rb +133 -0
- data/lib/runtime_analysis/query/index/static/value.rb +17 -0
- data/lib/runtime_analysis/query/index/static/values.rb +71 -0
- data/lib/runtime_analysis/query/index/static/visibility.rb +40 -0
- data/lib/runtime_analysis/query/index/static.rb +85 -0
- data/lib/runtime_analysis/query/index.rb +32 -0
- data/lib/runtime_analysis/query/nodes.rb +60 -0
- data/lib/runtime_analysis/query/project/config.rb +108 -0
- data/lib/runtime_analysis/query/project.rb +40 -0
- data/lib/runtime_analysis/query/report/document.rb +84 -0
- data/lib/runtime_analysis/query/report/finding.rb +15 -0
- data/lib/runtime_analysis/query/report/json_renderer.rb +51 -0
- data/lib/runtime_analysis/query/report/list.rb +15 -0
- data/lib/runtime_analysis/query/report/location.rb +14 -0
- data/lib/runtime_analysis/query/report/one_row.rb +14 -0
- data/lib/runtime_analysis/query/report/outline.rb +15 -0
- data/lib/runtime_analysis/query/report/paint.rb +34 -0
- data/lib/runtime_analysis/query/report/related.rb +11 -0
- data/lib/runtime_analysis/query/report/table.rb +15 -0
- data/lib/runtime_analysis/query/report/text.rb +13 -0
- data/lib/runtime_analysis/query/report/text_renderer.rb +102 -0
- data/lib/runtime_analysis/query/report.rb +35 -0
- data/lib/runtime_analysis/query/surfaces/class_value.rb +17 -0
- data/lib/runtime_analysis/query/surfaces/cli/answer.rb +32 -0
- data/lib/runtime_analysis/query/surfaces/cli/command_line.rb +77 -0
- data/lib/runtime_analysis/query/surfaces/cli/usage.rb +32 -0
- data/lib/runtime_analysis/query/surfaces/cli.rb +101 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/lexical.rb +44 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/notation.rb +33 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/observed.rb +102 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/outline.rb +111 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/rbs_file.rb +100 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/rbs_member.rb +50 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/rbs_notation.rb +44 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/seen.rb +74 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/sig_text.rb +49 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/sorbet_edit.rb +106 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/sorbet_notation.rb +48 -0
- data/lib/runtime_analysis/query/surfaces/crystallise/subject.rb +55 -0
- data/lib/runtime_analysis/query/surfaces/crystallise.rb +94 -0
- data/lib/runtime_analysis/query/surfaces/mcp.rb +89 -0
- data/lib/runtime_analysis/query/surfaces/record/commands.rb +45 -0
- data/lib/runtime_analysis/query/surfaces/record/environment.rb +48 -0
- data/lib/runtime_analysis/query/surfaces/record/ignore.rb +62 -0
- data/lib/runtime_analysis/query/surfaces/record/question.rb +55 -0
- data/lib/runtime_analysis/query/surfaces/record/run.rb +30 -0
- data/lib/runtime_analysis/query/surfaces/record.rb +122 -0
- data/lib/runtime_analysis/query/surfaces/rerun.rb +87 -0
- data/lib/runtime_analysis/query/surfaces/setup/agents.rb +76 -0
- data/lib/runtime_analysis/query/surfaces/setup/changes.rb +107 -0
- data/lib/runtime_analysis/query/surfaces/setup/project.rb +80 -0
- data/lib/runtime_analysis/query/surfaces/setup/steps.md +205 -0
- data/lib/runtime_analysis/query/surfaces/setup.rb +98 -0
- data/lib/runtime_analysis/query/surfaces.rb +14 -0
- data/lib/runtime_analysis/query/tools/base.rb +86 -0
- data/lib/runtime_analysis/query/tools/method_lookup.rb +37 -0
- data/lib/runtime_analysis/query/tools/namespaces.rb +36 -0
- data/lib/runtime_analysis/query/tools/origins.rb +47 -0
- data/lib/runtime_analysis/query/tools/stubs.rb +53 -0
- data/lib/runtime_analysis/query/tools/unknown_method.rb +11 -0
- data/lib/runtime_analysis/query/tools/verify_mock.rb +145 -0
- data/lib/runtime_analysis/query/tools/what_calls.rb +67 -0
- data/lib/runtime_analysis/query/tools/what_it_receives.rb +142 -0
- data/lib/runtime_analysis/query/tools/where_nil_comes_from.rb +105 -0
- data/lib/runtime_analysis/query/tools/who_actually_answered.rb +82 -0
- data/lib/runtime_analysis/query/tools.rb +34 -0
- data/lib/runtime_analysis/query.rb +33 -0
- data/lib/runtime_analysis/recording/blob.rb +13 -0
- data/lib/runtime_analysis/recording/format.rb +32 -0
- data/lib/runtime_analysis/recording/opcodes.rb +30 -0
- data/lib/runtime_analysis/recording/raise_ids.rb +15 -0
- data/lib/runtime_analysis/recording/ruby_sink.rb +176 -0
- data/lib/runtime_analysis/recording/run_manifest.rb +110 -0
- data/lib/runtime_analysis/recording/seen/nothing.rb +15 -0
- data/lib/runtime_analysis/recording/seen/tally.rb +48 -0
- data/lib/runtime_analysis/recording/seen.rb +63 -0
- data/lib/runtime_analysis/recording/sink.rb +19 -0
- data/lib/runtime_analysis/recording/source_blob.rb +20 -0
- data/lib/runtime_analysis/recording.rb +52 -0
- data/lib/runtime_analysis/rspec.rb +8 -0
- data/lib/runtime_analysis/ruby_parsing/packages.rb +17 -0
- data/lib/runtime_analysis/ruby_parsing.rb +98 -0
- data/lib/runtime_analysis/trace/configuration/capturing.rb +32 -0
- data/lib/runtime_analysis/trace/configuration/per_run.rb +31 -0
- data/lib/runtime_analysis/trace/configuration/tier.rb +27 -0
- data/lib/runtime_analysis/trace/configuration.rb +115 -0
- data/lib/runtime_analysis/trace/entries.rb +47 -0
- data/lib/runtime_analysis/trace/hold/raises.rb +28 -0
- data/lib/runtime_analysis/trace/hold/requests.rb +47 -0
- data/lib/runtime_analysis/trace/hold/telling.rb +45 -0
- data/lib/runtime_analysis/trace/hold/unwound.rb +30 -0
- data/lib/runtime_analysis/trace/hold.rb +142 -0
- data/lib/runtime_analysis/trace/inclusion.rb +46 -0
- data/lib/runtime_analysis/trace/installer/alias_repair.rb +68 -0
- data/lib/runtime_analysis/trace/installer/answers.rb +24 -0
- data/lib/runtime_analysis/trace/installer/body_sync.rb +25 -0
- data/lib/runtime_analysis/trace/installer/built_classes.rb +43 -0
- data/lib/runtime_analysis/trace/installer/called_names.rb +33 -0
- data/lib/runtime_analysis/trace/installer/class_builders.rb +50 -0
- data/lib/runtime_analysis/trace/installer/deferral.rb +42 -0
- data/lib/runtime_analysis/trace/installer/hook.rb +170 -0
- data/lib/runtime_analysis/trace/installer/included_gems.rb +53 -0
- data/lib/runtime_analysis/trace/installer/probe.rb +28 -0
- data/lib/runtime_analysis/trace/installer/reflection.rb +50 -0
- data/lib/runtime_analysis/trace/installer/registry.rb +78 -0
- data/lib/runtime_analysis/trace/installer/sorbet.rb +29 -0
- data/lib/runtime_analysis/trace/installer/wrapping/ivar_writes.rb +62 -0
- data/lib/runtime_analysis/trace/installer/wrapping.rb +66 -0
- data/lib/runtime_analysis/trace/installer.rb +149 -0
- data/lib/runtime_analysis/trace/mechanism/block_entries.rb +29 -0
- data/lib/runtime_analysis/trace/mechanism/frame_readers.rb +61 -0
- data/lib/runtime_analysis/trace/mechanism/native_asks.rb +36 -0
- data/lib/runtime_analysis/trace/mechanism/native_sync.rb +28 -0
- data/lib/runtime_analysis/trace/mechanism/pure_wrapper.rb +41 -0
- data/lib/runtime_analysis/trace/mechanism/ruby_wrapper.rb +141 -0
- data/lib/runtime_analysis/trace/mechanism/wrapper.rb +79 -0
- data/lib/runtime_analysis/trace/mechanism/wrapper_shape.rb +40 -0
- data/lib/runtime_analysis/trace/mechanism.rb +28 -0
- data/lib/runtime_analysis/trace/nil_origin/answers.rb +24 -0
- data/lib/runtime_analysis/trace/nil_origin/beyond.rb +182 -0
- data/lib/runtime_analysis/trace/nil_origin/index.rb +164 -0
- data/lib/runtime_analysis/trace/nil_origin/lifetime.rb +29 -0
- data/lib/runtime_analysis/trace/nil_origin/named.rb +48 -0
- data/lib/runtime_analysis/trace/nil_origin/objects.rb +78 -0
- data/lib/runtime_analysis/trace/nil_origin/provenance.rb +136 -0
- data/lib/runtime_analysis/trace/nil_origin/receiver.rb +121 -0
- data/lib/runtime_analysis/trace/nil_origin/rows.rb +43 -0
- data/lib/runtime_analysis/trace/nil_origin/source.rb +315 -0
- data/lib/runtime_analysis/trace/nil_origin/stored.rb +159 -0
- data/lib/runtime_analysis/trace/nil_origin/told.rb +152 -0
- data/lib/runtime_analysis/trace/nil_origin/values.rb +47 -0
- data/lib/runtime_analysis/trace/nil_origin/weighed.rb +70 -0
- data/lib/runtime_analysis/trace/nil_origin/writers.rb +79 -0
- data/lib/runtime_analysis/trace/nil_origin.rb +278 -0
- data/lib/runtime_analysis/trace/novelty.rb +17 -0
- data/lib/runtime_analysis/trace/pure/novelty.rb +43 -0
- data/lib/runtime_analysis/trace/pure/state.rb +94 -0
- data/lib/runtime_analysis/trace/pure.rb +15 -0
- data/lib/runtime_analysis/trace/recorder/class_name.rb +63 -0
- data/lib/runtime_analysis/trace/recorder/fingerprint.rb +39 -0
- data/lib/runtime_analysis/trace/recorder/frame_key.rb +27 -0
- data/lib/runtime_analysis/trace/recorder/paths.rb +89 -0
- data/lib/runtime_analysis/trace/recorder/raise_site.rb +36 -0
- data/lib/runtime_analysis/trace/recorder/reachability.rb +46 -0
- data/lib/runtime_analysis/trace/recorder/row_emission.rb +137 -0
- data/lib/runtime_analysis/trace/recorder/safe_steps.rb +84 -0
- data/lib/runtime_analysis/trace/recorder/tree_steps.rb +42 -0
- data/lib/runtime_analysis/trace/recorder/unwinding.rb +23 -0
- data/lib/runtime_analysis/trace/recorder.rb +149 -0
- data/lib/runtime_analysis/trace/state.rb +16 -0
- data/lib/runtime_analysis/trace.rb +142 -0
- data/lib/runtime_analysis/version.rb +6 -0
- data/lib/runtime_analysis/web.rb +6 -0
- data/lib/runtime_analysis.rb +125 -0
- metadata +330 -0
|
@@ -0,0 +1,775 @@
|
|
|
1
|
+
#include "fast.h"
|
|
2
|
+
#include "wrapper.h"
|
|
3
|
+
#include "novelty.h"
|
|
4
|
+
#include <ruby/debug.h>
|
|
5
|
+
#include <errno.h>
|
|
6
|
+
#include <poll.h>
|
|
7
|
+
#include <sched.h>
|
|
8
|
+
#include <stddef.h>
|
|
9
|
+
#include <stdlib.h>
|
|
10
|
+
#include <string.h>
|
|
11
|
+
#include <time.h>
|
|
12
|
+
#include <unistd.h>
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* A call the recorder has seen before, on a route and from a line it has seen before, needs nothing
|
|
16
|
+
* worked out: its row is the tree, the next step, and two numbers the Ruby side already found. So
|
|
17
|
+
* each sink remembers what the Ruby path wrote for each (route, call site), and the wrapper writes
|
|
18
|
+
* the row for a repeat itself, without going into Ruby.
|
|
19
|
+
*
|
|
20
|
+
* It only ever repeats what Ruby did. Anything new goes through Ruby: a route or a call site not
|
|
21
|
+
* seen in this segment, the first call of a tree, a method of an included gem, a method_missing.
|
|
22
|
+
* And so does one call in every RA_FAST_BURST, so that the checks Ruby makes as it writes, for a
|
|
23
|
+
* file grown large enough to rotate, still happen.
|
|
24
|
+
*
|
|
25
|
+
* What is remembered is good for one segment of one stream. A new segment spells out its paths and
|
|
26
|
+
* its strings again, so a roll forgets them. Anything that could leave a fiber holding a handle to
|
|
27
|
+
* a sink that is gone, a close, a fork, a fresh start, moves the epoch on, and a fiber whose epoch
|
|
28
|
+
* is old goes through Ruby until it is told its sink again. */
|
|
29
|
+
/* The table starts small and doubles as it fills, so a stream pays for the calls it makes. A test
|
|
30
|
+
* suite the size of Redmine's takes hundreds of thousands of routes in one segment, and a table of a
|
|
31
|
+
* thousand entries sent 3 million of its 20 million calls through Ruby. Both sizes are powers of
|
|
32
|
+
* two, since the table is indexed by masking. At its largest the table is 48 MB and holds 1.5
|
|
33
|
+
* million calls. */
|
|
34
|
+
#define RA_FAST_START 1024
|
|
35
|
+
#define RA_FAST_MOST (1 << 21)
|
|
36
|
+
#define RA_FAST_BURST 512
|
|
37
|
+
|
|
38
|
+
/* 24 bytes: a suite with 270,000 routes has that many entries on each stream. */
|
|
39
|
+
struct fast_entry {
|
|
40
|
+
uint64_t path_hash;
|
|
41
|
+
uint64_t site; /* the call site as one word, see site_of */
|
|
42
|
+
uint32_t path_id; /* 0 marks an empty entry: paths are numbered from 1 */
|
|
43
|
+
int32_t file_id;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
int ra_fast = 0;
|
|
47
|
+
ra_method *ra_methods = NULL;
|
|
48
|
+
size_t ra_methods_cap = 0;
|
|
49
|
+
ra_ivars *ra_ivar_names = NULL;
|
|
50
|
+
int64_t ra_fast_rows = 0;
|
|
51
|
+
int64_t ra_slow_calls = 0;
|
|
52
|
+
static ra_novelty *g_novelty = NULL; /* adaptive mode's gate, or NULL when every call is kept */
|
|
53
|
+
static VALUE g_novelty_object = Qnil;
|
|
54
|
+
static size_t g_fast_most = RA_FAST_MOST; /* a spec lowers it, to fill a table */
|
|
55
|
+
static ID id_class_id; /* Trace.class_id */
|
|
56
|
+
static ID id_keyword_id; /* Trace.keyword_id */
|
|
57
|
+
static ID id_outcome; /* Trace.record_outcome */
|
|
58
|
+
static ID id_before; /* Trace.record_before_native */
|
|
59
|
+
static ID id_tree_ended; /* Trace.tree_ended */
|
|
60
|
+
|
|
61
|
+
/* A new segment spells out its paths and its strings again, so nothing remembered of the old holds. */
|
|
62
|
+
void ra_fast_forget(sink *s) {
|
|
63
|
+
if (s->fast) memset(s->fast, 0, s->fast_cap * sizeof(struct fast_entry));
|
|
64
|
+
s->fast_count = 0;
|
|
65
|
+
if (s->names) memset(s->names, 0, RA_NAME_SLOTS * sizeof(ra_name));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* What tells one method's frame from another's on a route: the method, where it is defined, and the
|
|
69
|
+
* class of the object that received the call. The Ruby path asks for the same key through
|
|
70
|
+
* Native::Wrapper.frame_key, so both fold a call into the route alike. It is kept to 62 bits so that Ruby
|
|
71
|
+
* hands it back as the same machine integer. */
|
|
72
|
+
uint64_t ra_frame_key(long id, VALUE receiver) {
|
|
73
|
+
VALUE klass = (RB_TYPE_P(receiver, T_CLASS) || RB_TYPE_P(receiver, T_MODULE)) ? receiver : rb_obj_class(receiver);
|
|
74
|
+
uint64_t salt = ((size_t)id < ra_methods_cap) ? ra_methods[id].salt : 0;
|
|
75
|
+
uint64_t key = ((uint64_t)id * 0x9E3779B97F4A7C15ULL) ^ salt ^ (NUM2ULL(rb_obj_id(klass)) * 0xC2B2AE3D27D4EB4FULL);
|
|
76
|
+
return key & RA_HASH_MASK;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static VALUE wrapper_frame_key(VALUE self, VALUE id, VALUE receiver) {
|
|
80
|
+
return ULL2NUM(ra_frame_key(NUM2LONG(id), receiver));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* Told by the installer as it wraps a method: whether the method may go the fast way, and a number
|
|
84
|
+
* that changes when the method is defined somewhere else, so that a redefinition is a new frame. */
|
|
85
|
+
/* register(id, fast, salt, hash_kw, probe): what the wrapper is to know of the method with this id. */
|
|
86
|
+
static VALUE wrapper_register(VALUE self, VALUE id, VALUE fast, VALUE salt, VALUE hash_kw, VALUE probe) {
|
|
87
|
+
size_t at = (size_t)NUM2LONG(id);
|
|
88
|
+
if (at >= ra_methods_cap) {
|
|
89
|
+
size_t cap = ra_methods_cap ? ra_methods_cap : 256;
|
|
90
|
+
while (cap <= at) cap *= 2;
|
|
91
|
+
ra_ivars *names = ra_realloc(ra_ivar_names, cap * sizeof(ra_ivars));
|
|
92
|
+
if (!names) return Qnil;
|
|
93
|
+
ra_ivar_names = names;
|
|
94
|
+
ra_method *grown = ra_realloc(ra_methods, cap * sizeof(ra_method));
|
|
95
|
+
if (!grown) return Qnil; /* out of memory: the method goes through Ruby, which is always right */
|
|
96
|
+
memset(grown + ra_methods_cap, 0, (cap - ra_methods_cap) * sizeof(ra_method));
|
|
97
|
+
ra_methods = grown;
|
|
98
|
+
ra_methods_cap = cap;
|
|
99
|
+
}
|
|
100
|
+
ra_methods[at].fast = RTEST(fast) ? 1 : 0;
|
|
101
|
+
ra_methods[at].hash_kw = RTEST(hash_kw) ? 1 : 0;
|
|
102
|
+
ra_methods[at].probe = RTEST(probe) ? 1 : 0;
|
|
103
|
+
ra_methods[at].salt = (uint64_t)NUM2LONG(salt);
|
|
104
|
+
ra_methods[at].ivarc = 0;
|
|
105
|
+
return Qnil;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* watch_ivars(id, names): the ivars the method with this id writes, read back each time a call of it
|
|
109
|
+
* returns, at tiers 3 and 4. Only the first RA_IVARS_MAX are kept. Asked for after register. */
|
|
110
|
+
static VALUE wrapper_watch_ivars(VALUE self, VALUE id, VALUE names) {
|
|
111
|
+
size_t at = (size_t)NUM2LONG(id);
|
|
112
|
+
Check_Type(names, T_ARRAY);
|
|
113
|
+
if (at >= ra_methods_cap) return Qnil;
|
|
114
|
+
|
|
115
|
+
long count = RARRAY_LEN(names) < RA_IVARS_MAX ? RARRAY_LEN(names) : RA_IVARS_MAX;
|
|
116
|
+
for (long i = 0; i < count; i++) ra_ivar_names[at].names[i] = rb_to_id(RARRAY_AREF(names, i));
|
|
117
|
+
ra_methods[at].ivarc = (uint8_t)count;
|
|
118
|
+
return Qnil;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* A recording is starting. It numbers its methods on from where the one before it stopped, and what
|
|
122
|
+
* was known of the old ones goes: a call through an earlier recording's wrapper is sent to Ruby,
|
|
123
|
+
* which finds its number in no file and records nothing. `gate` is adaptive mode's, which the wrapper asks before it does anything else for a
|
|
124
|
+
* call, or nil when every call is kept. `fast` says whether the wrapper may record a call itself. */
|
|
125
|
+
void ra_fast_start(VALUE gate, int fast) {
|
|
126
|
+
if (ra_methods) memset(ra_methods, 0, ra_methods_cap * sizeof(ra_method));
|
|
127
|
+
for (size_t i = 0; i < ra_sinks_cap; i++) {
|
|
128
|
+
if (ra_sinks[i] && ra_sinks[i]->names) memset(ra_sinks[i]->names, 0, RA_NAME_SLOTS * sizeof(ra_name));
|
|
129
|
+
}
|
|
130
|
+
ra_keep_none();
|
|
131
|
+
ra_epoch++;
|
|
132
|
+
g_novelty = NIL_P(gate) ? NULL : ra_novelty_of(gate);
|
|
133
|
+
g_novelty_object = gate;
|
|
134
|
+
ra_fast = fast;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* Where a call was made from, as one word: the address of the caller's file name, which is only
|
|
138
|
+
* ever compared, and the line. An address is a multiple of 8 and under 2^48, so the two fit side by
|
|
139
|
+
* side when the line is under half a million. A call from further down a file than that, or from an
|
|
140
|
+
* address that does not fit, is not remembered. */
|
|
141
|
+
#define RA_SITE_LINE_BITS 19
|
|
142
|
+
|
|
143
|
+
static int site_of(const char *file, int line, uint64_t *site) {
|
|
144
|
+
uintptr_t address = (uintptr_t)file;
|
|
145
|
+
if (line < 0 || line >= (1 << RA_SITE_LINE_BITS) || (uint64_t)address >> 48) return 0;
|
|
146
|
+
*site = ((uint64_t)address >> 3 << RA_SITE_LINE_BITS) | (uint64_t)line;
|
|
147
|
+
return 1;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static size_t fast_home(const sink *s, uint64_t path_hash, uint64_t site) {
|
|
151
|
+
uint64_t mixed = (path_hash ^ (site * 0x9E3779B97F4A7C15ULL)) * 0xC2B2AE3D27D4EB4FULL;
|
|
152
|
+
return (size_t)(mixed >> 32) & (s->fast_cap - 1);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* An entry sits in its own slot or the next free one after it. The table is never more than three
|
|
156
|
+
* quarters full and entries are only ever cleared all together, so a search ends at the first
|
|
157
|
+
* empty slot. */
|
|
158
|
+
static struct fast_entry *fast_find(sink *s, uint64_t path_hash, uint64_t site) {
|
|
159
|
+
size_t at = fast_home(s, path_hash, site);
|
|
160
|
+
for (;; at = (at + 1) & (s->fast_cap - 1)) {
|
|
161
|
+
struct fast_entry *e = &s->fast[at];
|
|
162
|
+
if (e->path_id == 0) return NULL;
|
|
163
|
+
if (e->path_hash == path_hash && e->site == site) return e;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static int fast_full(const sink *s) {
|
|
168
|
+
return s->fast_count * 4 >= s->fast_cap * 3;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Remembers a call: over its own entry if it has one, else in the first empty slot from its own.
|
|
172
|
+
* A table that is full and cannot grow takes no more: the call goes over whatever is in its own
|
|
173
|
+
* slot, and that one is forgotten. */
|
|
174
|
+
static void fast_store(sink *s, const struct fast_entry *call) {
|
|
175
|
+
size_t home = fast_home(s, call->path_hash, call->site), at = home;
|
|
176
|
+
while (s->fast[at].path_id != 0 && !(s->fast[at].path_hash == call->path_hash && s->fast[at].site == call->site)) {
|
|
177
|
+
at = (at + 1) & (s->fast_cap - 1);
|
|
178
|
+
}
|
|
179
|
+
if (s->fast[at].path_id == 0) {
|
|
180
|
+
if (!fast_full(s)) s->fast_count++;
|
|
181
|
+
else if (s->fast[home].path_id != 0) at = home;
|
|
182
|
+
else return;
|
|
183
|
+
}
|
|
184
|
+
s->fast[at] = *call;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* Twice the room, with every call remembered again. Without the memory for it the table stays as
|
|
188
|
+
* it is, and the calls it has no room for go through Ruby. */
|
|
189
|
+
static void fast_grow(sink *s) {
|
|
190
|
+
size_t cap = s->fast_cap ? s->fast_cap * 2 : RA_FAST_START;
|
|
191
|
+
struct fast_entry *grown = ra_calloc(cap, sizeof(struct fast_entry));
|
|
192
|
+
if (!grown) return;
|
|
193
|
+
|
|
194
|
+
struct fast_entry *was = s->fast;
|
|
195
|
+
size_t was_cap = s->fast_cap;
|
|
196
|
+
s->fast = grown;
|
|
197
|
+
s->fast_cap = cap;
|
|
198
|
+
s->fast_count = 0;
|
|
199
|
+
for (size_t i = 0; i < was_cap; i++) {
|
|
200
|
+
if (was[i].path_id) fast_store(s, &was[i]);
|
|
201
|
+
}
|
|
202
|
+
free(was);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* The table is kept under three quarters full, so that a search is short and always meets an empty
|
|
206
|
+
* slot. */
|
|
207
|
+
static int fast_room(sink *s) {
|
|
208
|
+
if (!s->fast || (fast_full(s) && s->fast_cap < g_fast_most)) fast_grow(s);
|
|
209
|
+
return s->fast != NULL;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* A call the wrapper may handle by itself is inside a tree and outside the recorder's own capture. */
|
|
213
|
+
static int in_tree(const ra_state *st) {
|
|
214
|
+
return !st->capturing && st->depth > 0 && st->uuid != 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* The sink a fiber writes to, when the fiber has been told of one that is still there. */
|
|
218
|
+
static sink *fast_sink(const ra_state *st) {
|
|
219
|
+
if (st->epoch != ra_epoch) return NULL;
|
|
220
|
+
if (st->handle < 0 || (size_t)st->handle >= ra_sinks_cap) return NULL;
|
|
221
|
+
sink *s = ra_sinks[st->handle];
|
|
222
|
+
return (s && s->fast && !s->disabled && s->fast_since_slow < RA_FAST_BURST) ? s : NULL;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* After Ruby has recorded a call: if it handed a row to a sink for this very call, remember the row
|
|
226
|
+
* under the route and the call site, and that this fiber writes to that sink. */
|
|
227
|
+
void ra_fast_remember(ra_state *st, const char *file, int line) {
|
|
228
|
+
if (st->last_path_id == 0 || st->last_step != st->step) return;
|
|
229
|
+
if (st->last_handle < 0 || (size_t)st->last_handle >= ra_sinks_cap) return;
|
|
230
|
+
sink *s = ra_sinks[st->last_handle];
|
|
231
|
+
if (!s || !fast_room(s)) return;
|
|
232
|
+
|
|
233
|
+
struct fast_entry call = { st->path_hash, 0, (uint32_t)st->last_path_id, (int32_t)st->last_file_id };
|
|
234
|
+
int fits = st->last_path_id <= UINT32_MAX && st->last_file_id <= INT32_MAX;
|
|
235
|
+
if (fits && site_of(file, line, &call.site)) fast_store(s, &call);
|
|
236
|
+
s->fast_since_slow = 0;
|
|
237
|
+
st->handle = st->last_handle;
|
|
238
|
+
st->epoch = ra_epoch;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* What gathers a call's values into rows: the stream, the fiber, and whether object ids are wanted. */
|
|
242
|
+
struct capture { sink *s; ra_state *st; int oids; };
|
|
243
|
+
|
|
244
|
+
/* The id a name has in the segment the stream is writing. The first time an object's name is wanted
|
|
245
|
+
* there Ruby is asked, which defines it, and from then on it is read from the stream's table. -1 when
|
|
246
|
+
* it cannot be had here, and the call then goes through Ruby.
|
|
247
|
+
*
|
|
248
|
+
* Asking Ruby lets other threads run, and one of them may end the recording and free the stream. A
|
|
249
|
+
* stream that is closed moves the epoch on, so the stream is not touched again unless the epoch held. */
|
|
250
|
+
static int64_t name_id(struct capture *c, VALUE key, VALUE subject, VALUE kept, ID ask) {
|
|
251
|
+
sink *s = c->s;
|
|
252
|
+
if (!s->names && !(s->names = ra_calloc(RA_NAME_SLOTS, sizeof(ra_name)))) return -1;
|
|
253
|
+
|
|
254
|
+
int64_t id = ra_names_find(s->names, key);
|
|
255
|
+
if (id >= 0) return id;
|
|
256
|
+
|
|
257
|
+
VALUE answer = rb_funcall(ra_trace, ask, 2, LONG2NUM(c->st->handle), subject);
|
|
258
|
+
if (!FIXNUM_P(answer) || c->st->epoch != ra_epoch) return -1;
|
|
259
|
+
if (kept != Qundef && ra_keep(kept)) ra_names_store(s->names, key, FIX2LONG(answer));
|
|
260
|
+
return FIX2LONG(answer);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* A value is recorded under its class's name. A class or module passed as a value is recorded under
|
|
264
|
+
* the name Ruby gives its singleton class, and is keyed apart from its instances by the low bit, which
|
|
265
|
+
* an object's address never has. A class with no name of its own is named after an ancestor, and
|
|
266
|
+
* there may be any number of those, so its name is asked for each time. */
|
|
267
|
+
static int64_t value_class_id(struct capture *c, VALUE value) {
|
|
268
|
+
int module = RB_TYPE_P(value, T_CLASS) || RB_TYPE_P(value, T_MODULE);
|
|
269
|
+
VALUE klass = module ? value : rb_obj_class(value);
|
|
270
|
+
VALUE kept = NIL_P(rb_mod_name(klass)) ? Qundef : klass;
|
|
271
|
+
return name_id(c, module ? (klass | 1) : klass, value, kept, id_class_id);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/* Ruby makes the id of a number or a Symbol from its value, so 2500's is 5001, and a recording
|
|
275
|
+
* holds no values. Those are written as 0, the id a value has when none was kept. */
|
|
276
|
+
static int64_t oid_of(VALUE value) {
|
|
277
|
+
if (RB_INTEGER_TYPE_P(value) || RB_FLOAT_TYPE_P(value) || RB_SYMBOL_P(value)) return 0;
|
|
278
|
+
return NUM2LL(rb_obj_id(value));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* Adds a value to a row: its class and, when ids are wanted, its object id. A row stores MAX_ARGS
|
|
282
|
+
* values, and the caller's count says how many there were. */
|
|
283
|
+
static int put_value(struct capture *c, slot *sl, VALUE value) {
|
|
284
|
+
if (sl->argn >= MAX_ARGS) return 1;
|
|
285
|
+
|
|
286
|
+
int64_t klass = value_class_id(c, value);
|
|
287
|
+
if (klass < 0) return 0;
|
|
288
|
+
if (c->oids) sl->arg_oids[sl->argn] = oid_of(value);
|
|
289
|
+
sl->args[sl->argn++] = klass;
|
|
290
|
+
return 1;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
static void begin_slot(slot *sl, uint8_t kind, long uuid, long step) {
|
|
294
|
+
memset(sl, 0, offsetof(slot, args));
|
|
295
|
+
sl->recv_oid = 0;
|
|
296
|
+
sl->kind = kind;
|
|
297
|
+
sl->rec[0] = uuid;
|
|
298
|
+
sl->rec[1] = step;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* The tail of a call row. Tier 2 has one only when there are arguments. From tier 3 there is always
|
|
302
|
+
* one, since the receiver's id is in it. `as_arg` is the keywords of a call to a method that takes
|
|
303
|
+
* them as one more argument, or Qundef. */
|
|
304
|
+
static int call_tail(struct capture *c, slot *sl, int posc, const VALUE *argv, VALUE as_arg, VALUE self) {
|
|
305
|
+
int count = posc + (as_arg != Qundef);
|
|
306
|
+
if (!c->oids && count == 0) return 1;
|
|
307
|
+
|
|
308
|
+
sl->tier = c->oids ? 3 : 2;
|
|
309
|
+
sl->argc = count;
|
|
310
|
+
if (c->oids) sl->recv_oid = oid_of(self);
|
|
311
|
+
for (int i = 0; i < posc; i++) {
|
|
312
|
+
if (!put_value(c, sl, argv[i])) return 0;
|
|
313
|
+
}
|
|
314
|
+
return as_arg == Qundef || put_value(c, sl, as_arg);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
struct keyword_ctx { struct capture *c; slot *sl; int ok; };
|
|
318
|
+
|
|
319
|
+
static int put_keyword(VALUE key, VALUE value, VALUE p) {
|
|
320
|
+
struct keyword_ctx *k = (struct keyword_ctx *)p;
|
|
321
|
+
slot *sl = k->sl;
|
|
322
|
+
if (sl->argn >= MAX_ARGS) return ST_STOP;
|
|
323
|
+
|
|
324
|
+
int64_t name = SYMBOL_P(key) ? name_id(k->c, key, key, key, id_keyword_id) : -1;
|
|
325
|
+
if (name < 0 || !put_value(k->c, sl, value)) {
|
|
326
|
+
k->ok = 0;
|
|
327
|
+
return ST_STOP;
|
|
328
|
+
}
|
|
329
|
+
sl->kw_names[sl->argn - 1] = name;
|
|
330
|
+
return ST_CONTINUE;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/* The keywords row: each keyword's name, its value's class and, from tier 3, the value's id. A
|
|
334
|
+
* keyword that is not a Symbol is left to Ruby. */
|
|
335
|
+
static int keywords_row(struct capture *c, slot *sl, VALUE kwargs) {
|
|
336
|
+
struct keyword_ctx k = { c, sl, 1 };
|
|
337
|
+
sl->tier = c->oids ? 3 : 2;
|
|
338
|
+
sl->argc = (int64_t)RHASH_SIZE(kwargs);
|
|
339
|
+
rb_hash_foreach(kwargs, put_keyword, (VALUE)&k);
|
|
340
|
+
return k.ok;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/* The return row: the result's class and id, and for an Array the same of its first elements. */
|
|
344
|
+
static int return_row(struct capture *c, slot *sl, VALUE result) {
|
|
345
|
+
int64_t klass = value_class_id(c, result);
|
|
346
|
+
if (klass < 0) return 0;
|
|
347
|
+
sl->rec[2] = klass;
|
|
348
|
+
sl->rec[3] = oid_of(result);
|
|
349
|
+
if (!RB_TYPE_P(result, T_ARRAY)) return 1;
|
|
350
|
+
|
|
351
|
+
sl->tier = 1;
|
|
352
|
+
sl->argc = RARRAY_LEN(result);
|
|
353
|
+
for (long i = 0; i < RARRAY_LEN(result) && i < MAX_ARGS; i++) {
|
|
354
|
+
if (!put_value(c, sl, RARRAY_AREF(result, i))) return 0;
|
|
355
|
+
}
|
|
356
|
+
return 1;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
struct fast_ctx { int argc; VALUE *argv; ra_state *st; long uuid, step; int done; long id; VALUE self; };
|
|
360
|
+
|
|
361
|
+
static VALUE fast_super(VALUE p) {
|
|
362
|
+
struct fast_ctx *c = (struct fast_ctx *)p;
|
|
363
|
+
return rb_call_super_kw(c->argc, c->argv, RB_PASS_CALLED_KEYWORDS);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/* Runs however the call ends: a return, a raise, a block's return or a throw. */
|
|
367
|
+
static VALUE fast_leave(VALUE p) {
|
|
368
|
+
struct fast_ctx *c = (struct fast_ctx *)p;
|
|
369
|
+
if (!c->done) ra_state_pop(c->st);
|
|
370
|
+
return Qnil;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/* The stream a fiber writes to, if it is still the one the fiber was told of. */
|
|
374
|
+
static sink *sink_now(const ra_state *st) {
|
|
375
|
+
if (st->epoch != ra_epoch || st->handle < 0 || (size_t)st->handle >= ra_sinks_cap) return NULL;
|
|
376
|
+
sink *s = ra_sinks[st->handle];
|
|
377
|
+
return (s && !s->disabled) ? s : NULL;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/* What Ruby is handed when it writes the row that closes a call: the tree and the step. */
|
|
381
|
+
static VALUE outcome_key(const struct fast_ctx *c) {
|
|
382
|
+
return rb_assoc_new(LONG2NUM(c->uuid), LONG2NUM(c->step));
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* The ivars the method writes, as they are now the call has returned: each one's name, class and
|
|
386
|
+
* object id, laid out as a keywords row is. An ivar the call did not set reads as nil. The call is
|
|
387
|
+
* recorded whether or not this row can be, so a name only Ruby could give drops the row alone. */
|
|
388
|
+
static void ivars_row(struct capture *cap, const struct fast_ctx *c) {
|
|
389
|
+
const ra_ivars *watched = &ra_ivar_names[c->id];
|
|
390
|
+
int count = ra_methods[c->id].ivarc;
|
|
391
|
+
slot sl;
|
|
392
|
+
begin_slot(&sl, SLOT_IVARS, c->uuid, c->step);
|
|
393
|
+
sl.tier = 3;
|
|
394
|
+
sl.argc = count;
|
|
395
|
+
for (int i = 0; i < count; i++) {
|
|
396
|
+
VALUE name = ID2SYM(watched->names[i]);
|
|
397
|
+
int64_t named = name_id(cap, name, name, name, id_keyword_id);
|
|
398
|
+
if (named < 0 || !put_value(cap, &sl, rb_ivar_get(c->self, watched->names[i]))) return;
|
|
399
|
+
sl.kw_names[sl.argn - 1] = named;
|
|
400
|
+
}
|
|
401
|
+
if (cap->st->epoch == ra_epoch) ra_push_slot(cap->s, &sl);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/* The call has returned. It leaves the tree, and its return row is written here when the stream is
|
|
405
|
+
* still there to write to, and by Ruby when it is not: after a fork, say, or the end of a recording. */
|
|
406
|
+
static VALUE fast_super_returning(VALUE p) {
|
|
407
|
+
struct fast_ctx *c = (struct fast_ctx *)p;
|
|
408
|
+
VALUE result = rb_call_super_kw(c->argc, c->argv, RB_PASS_CALLED_KEYWORDS);
|
|
409
|
+
c->done = 1;
|
|
410
|
+
ra_state_pop(c->st);
|
|
411
|
+
|
|
412
|
+
slot sl;
|
|
413
|
+
struct capture cap = { sink_now(c->st), c->st, 1 };
|
|
414
|
+
begin_slot(&sl, SLOT_RETURN, c->uuid, c->step);
|
|
415
|
+
if (cap.s && return_row(&cap, &sl, result)) {
|
|
416
|
+
ra_push_slot(cap.s, &sl);
|
|
417
|
+
if (ra_methods[c->id].ivarc) ivars_row(&cap, c);
|
|
418
|
+
} else {
|
|
419
|
+
rb_funcall(ra_trace, id_outcome, 3, outcome_key(c), Qnil, result);
|
|
420
|
+
}
|
|
421
|
+
return result;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/* A raise is rare, and its row names where it was raised, which Ruby works out. */
|
|
425
|
+
static void fast_raised(void *p, VALUE err) {
|
|
426
|
+
struct fast_ctx *c = (struct fast_ctx *)p;
|
|
427
|
+
if (c->done) return;
|
|
428
|
+
c->done = 1;
|
|
429
|
+
ra_state_pop(c->st);
|
|
430
|
+
rb_funcall(ra_trace, id_outcome, 3, outcome_key(c), err, Qnil);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
static VALUE fast_super_guarded(VALUE p) {
|
|
434
|
+
int state = 0;
|
|
435
|
+
VALUE result = rb_protect(fast_super_returning, p, &state);
|
|
436
|
+
if (state) ra_carry_on(state, fast_raised, (void *)p);
|
|
437
|
+
return result;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/* Tier 3 writes a row when the call returns, and tier 4 one when it raises as well. */
|
|
441
|
+
static VALUE fast_run(struct fast_ctx *c) {
|
|
442
|
+
if (ra_tier >= 4) return rb_ensure(fast_super_guarded, (VALUE)c, fast_leave, (VALUE)c);
|
|
443
|
+
if (ra_tier == 3) return rb_ensure(fast_super_returning, (VALUE)c, fast_leave, (VALUE)c);
|
|
444
|
+
return rb_ensure(fast_super, (VALUE)c, fast_leave, (VALUE)c);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/* Gathers what a call carried into its call row and, when it has keywords of its own, a keywords
|
|
448
|
+
* row. `given` is the call's keywords as a Hash, or Qundef when none were passed. Returns 0 for a
|
|
449
|
+
* call that has to go through Ruby, with nothing written and the tree as it was. */
|
|
450
|
+
static int carried(struct capture *c, long id, int posc, const VALUE *argv, VALUE given, VALUE self,
|
|
451
|
+
slot *call, slot *keywords) {
|
|
452
|
+
VALUE kwargs = Qundef, as_arg = Qundef;
|
|
453
|
+
if (given != Qundef && RB_TYPE_P(given, T_HASH) && RHASH_SIZE(given) > 0) {
|
|
454
|
+
if (ra_methods[id].hash_kw) as_arg = given; else kwargs = given;
|
|
455
|
+
}
|
|
456
|
+
if (!call_tail(c, call, posc, argv, as_arg, self)) return 0;
|
|
457
|
+
if (kwargs != Qundef && !keywords_row(c, keywords, kwargs)) return 0;
|
|
458
|
+
return kwargs == Qundef ? 1 : 2;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/* Whether the gate keeps the call on this route. A kept call may still have to go through Ruby,
|
|
462
|
+
* which asks the gate too, so the answer is left on the fiber for it. */
|
|
463
|
+
static int gate_keeps(ra_state *st, uint64_t path_hash) {
|
|
464
|
+
if (!ra_novelty_keep(g_novelty, path_hash)) return 0;
|
|
465
|
+
st->kept = 1;
|
|
466
|
+
st->kept_hash = path_hash;
|
|
467
|
+
return 1;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/* What becomes of a call on this fiber before anything is written: it is outside a tree and Ruby's
|
|
471
|
+
* to record, adaptive mode skips it, or it is kept. `key` and `path_hash` are the call's frame key
|
|
472
|
+
* and the route it would take, filled in whenever the call is in a tree. */
|
|
473
|
+
enum verdict { OUTSIDE_TREE, SKIPPED, KEPT };
|
|
474
|
+
|
|
475
|
+
static enum verdict verdict_on(ra_state *st, long id, VALUE self, uint64_t *key, uint64_t *path_hash) {
|
|
476
|
+
if (!in_tree(st)) return OUTSIDE_TREE;
|
|
477
|
+
*key = ra_frame_key(id, self);
|
|
478
|
+
*path_hash = ra_state_fold(st->path_hash, *key);
|
|
479
|
+
return (g_novelty && !gate_keeps(st, *path_hash)) ? SKIPPED : KEPT;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/* What the fast path made of a call before it is made: Ruby's to record, with nothing written and
|
|
483
|
+
* the tree as it was; skipped by adaptive mode, in its place in the tree; or kept, with its rows
|
|
484
|
+
* written and its step now the state's. */
|
|
485
|
+
enum fast_outcome { FAST_RUBY, FAST_SKIPPED, FAST_KEPT };
|
|
486
|
+
|
|
487
|
+
/* `posc` and `argv` are the call's positional arguments and `given` its keywords as a Hash, or
|
|
488
|
+
* Qundef when none were passed. */
|
|
489
|
+
static enum fast_outcome fast_enter(ra_state *st, long id, ra_site *from, int posc, const VALUE *argv, VALUE given,
|
|
490
|
+
VALUE self) {
|
|
491
|
+
uint64_t key, path_hash;
|
|
492
|
+
if (!ra_state_room(st)) return FAST_RUBY; /* Ruby is refused the same, and counts it */
|
|
493
|
+
switch (verdict_on(st, id, self, &key, &path_hash)) {
|
|
494
|
+
case OUTSIDE_TREE: return FAST_RUBY;
|
|
495
|
+
case SKIPPED:
|
|
496
|
+
st->step++;
|
|
497
|
+
ra_state_push(st, key, 0);
|
|
498
|
+
return FAST_SKIPPED;
|
|
499
|
+
case KEPT: break;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
uint64_t site;
|
|
503
|
+
sink *s = fast_sink(st);
|
|
504
|
+
int placed = s && ra_site_known(from) && site_of(from->file, from->line, &site);
|
|
505
|
+
struct fast_entry *e = placed ? fast_find(s, path_hash, site) : NULL;
|
|
506
|
+
if (!e) return FAST_RUBY;
|
|
507
|
+
|
|
508
|
+
slot call, keywords;
|
|
509
|
+
int rows = 1;
|
|
510
|
+
begin_slot(&call, SLOT_CALL, st->uuid, st->step + 1);
|
|
511
|
+
call.rec[2] = e->path_id;
|
|
512
|
+
call.rec[3] = e->file_id;
|
|
513
|
+
call.rec[4] = from->line;
|
|
514
|
+
if (ra_tier >= 2) {
|
|
515
|
+
struct capture cap = { s, st, ra_tier >= 3 };
|
|
516
|
+
begin_slot(&keywords, SLOT_KWARGS, st->uuid, st->step + 1);
|
|
517
|
+
if (!(rows = carried(&cap, id, posc, argv, given, self, &call, &keywords))) return FAST_RUBY;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
st->step++;
|
|
521
|
+
st->kept = 0;
|
|
522
|
+
ra_state_push(st, key, 0);
|
|
523
|
+
ra_push_slot(s, &call);
|
|
524
|
+
if (rows == 2) ra_push_slot(s, &keywords);
|
|
525
|
+
s->fast_since_slow++;
|
|
526
|
+
ra_fast_rows++;
|
|
527
|
+
return FAST_KEPT;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/* Writes the rows for a call seen before and makes the call, or returns Qundef for Ruby to record it. */
|
|
531
|
+
VALUE ra_fast_call(ra_state *st, long id, ra_site *from, int argc, VALUE *argv, VALUE self) {
|
|
532
|
+
int posc = argc;
|
|
533
|
+
VALUE given = Qundef;
|
|
534
|
+
if (argc > 0 && rb_keyword_given_p()) given = argv[--posc];
|
|
535
|
+
|
|
536
|
+
struct fast_ctx c = { argc, argv, st, 0, 0, 0, id, self };
|
|
537
|
+
switch (fast_enter(st, id, from, posc, argv, given, self)) {
|
|
538
|
+
case FAST_RUBY: break;
|
|
539
|
+
case FAST_SKIPPED: return rb_ensure(fast_super, (VALUE)&c, fast_leave, (VALUE)&c);
|
|
540
|
+
case FAST_KEPT:
|
|
541
|
+
c.uuid = st->uuid;
|
|
542
|
+
c.step = st->step;
|
|
543
|
+
return fast_run(&c);
|
|
544
|
+
}
|
|
545
|
+
return Qundef;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/* Where a wrapper written in Ruby was called from: the nearest Ruby frame above the wrapper's own,
|
|
549
|
+
* which is two frames above the C function the wrapper asks from. A C method between them, `send`
|
|
550
|
+
* or `Array#map`, has no file and is passed over, as rb_sourcefile passes over it for the C wrapper. */
|
|
551
|
+
#define RA_SITE_FRAMES 8
|
|
552
|
+
|
|
553
|
+
int ra_site_above(ra_site *site) {
|
|
554
|
+
VALUE frames[RA_SITE_FRAMES];
|
|
555
|
+
int lines[RA_SITE_FRAMES];
|
|
556
|
+
int count = rb_profile_frames(0, RA_SITE_FRAMES, frames, lines);
|
|
557
|
+
for (int i = 2; i < count; i++) {
|
|
558
|
+
VALUE path = rb_profile_frame_path(frames[i]);
|
|
559
|
+
if (NIL_P(path)) continue;
|
|
560
|
+
site->file = RSTRING_PTR(path);
|
|
561
|
+
site->line = lines[i];
|
|
562
|
+
return 1;
|
|
563
|
+
}
|
|
564
|
+
return 0;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/* The frames between the Ruby recorder and the call site when a Ruby wrapper asks it to record a
|
|
568
|
+
* call: this function's and the wrapper's own, one more than the C wrapper puts there. */
|
|
569
|
+
#define RA_RUBY_WRAPPER_DEPTH 3
|
|
570
|
+
|
|
571
|
+
/* The tree and the step of a kept call that has a row to write when it ends, as one Integer while
|
|
572
|
+
* both fit, so that a recorded call allocates nothing on its way in. Ruby's own token for such a
|
|
573
|
+
* call is the pair [uuid, step], and leave takes either. */
|
|
574
|
+
#define RA_TOKEN_BITS 30
|
|
575
|
+
|
|
576
|
+
static VALUE outcome_token(long uuid, long step) {
|
|
577
|
+
if (uuid < 0 || uuid >> RA_TOKEN_BITS || step < 0 || step >> RA_TOKEN_BITS) {
|
|
578
|
+
return rb_assoc_new(LONG2NUM(uuid), LONG2NUM(step));
|
|
579
|
+
}
|
|
580
|
+
return LONG2FIX((uuid << RA_TOKEN_BITS) | step);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
static int token_parts(VALUE token, long *uuid, long *step) {
|
|
584
|
+
if (FIXNUM_P(token)) {
|
|
585
|
+
long packed = FIX2LONG(token);
|
|
586
|
+
*uuid = packed >> RA_TOKEN_BITS;
|
|
587
|
+
*step = packed & ((1L << RA_TOKEN_BITS) - 1);
|
|
588
|
+
return 1;
|
|
589
|
+
}
|
|
590
|
+
if (RB_TYPE_P(token, T_ARRAY) && RARRAY_LEN(token) == 2) {
|
|
591
|
+
*uuid = NUM2LONG(rb_ary_entry(token, 0));
|
|
592
|
+
*step = NUM2LONG(rb_ary_entry(token, 1));
|
|
593
|
+
return 1;
|
|
594
|
+
}
|
|
595
|
+
return 0;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/* The token as Ruby's recorder knows it, for the rows it writes. */
|
|
599
|
+
static VALUE token_pair(VALUE token, long uuid, long step) {
|
|
600
|
+
return FIXNUM_P(token) ? rb_assoc_new(LONG2NUM(uuid), LONG2NUM(step)) : token;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/* enter(id, receiver, *args, **kwargs): a wrapper written in Ruby stands in front of the method
|
|
604
|
+
* with this registry id and has been called. Everything the C wrapper does before it calls super
|
|
605
|
+
* happens here, and the wrapper is handed what to give leave once the call is done: nil when there
|
|
606
|
+
* is nothing to close, the fiber's State for a call that only took its place in the tree, or the
|
|
607
|
+
* recorder's token for a call with a row to write when it ends. The arguments are the method's own,
|
|
608
|
+
* passed on as they are from tier 2 up and for a method_missing, and gathered into an Array only
|
|
609
|
+
* for a call Ruby records. */
|
|
610
|
+
static VALUE wrapper_enter(int argc, VALUE *argv, VALUE self) {
|
|
611
|
+
rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS);
|
|
612
|
+
VALUE id = argv[0], receiver = argv[1];
|
|
613
|
+
if (!ra_enabled || !FIXNUM_P(id)) return Qnil;
|
|
614
|
+
|
|
615
|
+
int posc = argc - 2;
|
|
616
|
+
const VALUE *values = argv + 2;
|
|
617
|
+
VALUE given = Qundef;
|
|
618
|
+
if (posc > 0 && rb_keyword_given_p()) given = values[--posc];
|
|
619
|
+
|
|
620
|
+
long method = FIX2LONG(id);
|
|
621
|
+
VALUE state = ra_state_current_object();
|
|
622
|
+
ra_state *st = NIL_P(state) ? NULL : ra_state_of(state);
|
|
623
|
+
ra_site from = { NULL, 0, 0, 1 };
|
|
624
|
+
|
|
625
|
+
if (st && ra_fast_method(method)) {
|
|
626
|
+
switch (fast_enter(st, method, &from, posc, values, given, receiver)) {
|
|
627
|
+
case FAST_SKIPPED: return state;
|
|
628
|
+
case FAST_KEPT: return ra_tier >= 3 ? outcome_token(st->uuid, st->step) : state;
|
|
629
|
+
case FAST_RUBY: st->last_path_id = 0; break;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
ra_slow_calls++;
|
|
634
|
+
VALUE args = (ra_tier >= 2 || posc > 0 || given != Qundef) ? rb_ary_new_from_values(posc, values) : Qnil;
|
|
635
|
+
VALUE kwargs = given == Qundef ? Qnil : given;
|
|
636
|
+
VALUE token = rb_funcall(ra_trace, id_before, 5, id, receiver, args, kwargs, INT2FIX(RA_RUBY_WRAPPER_DEPTH));
|
|
637
|
+
if (st) st->kept = 0;
|
|
638
|
+
if (NIL_P(token)) return Qnil;
|
|
639
|
+
if (st && ra_site_known(&from)) ra_fast_remember(st, from.file, from.line);
|
|
640
|
+
RB_GC_GUARD(args);
|
|
641
|
+
return token;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/* Ruby's token for a probed call: [uuid, step, true]. Its values are Ruby's to write, at any tier. */
|
|
645
|
+
static int probe_token(VALUE token) {
|
|
646
|
+
return RB_TYPE_P(token, T_ARRAY) && RARRAY_LEN(token) == 3;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/* The row that closes a call recorded with one to write when it ends: its return at tier 3, or at
|
|
650
|
+
* tier 4 the raise that ended it. */
|
|
651
|
+
static void close_row(ra_state *st, VALUE token, VALUE result, VALUE error) {
|
|
652
|
+
long uuid, step;
|
|
653
|
+
if (probe_token(token)) {
|
|
654
|
+
rb_funcall(ra_trace, id_outcome, 3, token, error, result);
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (!token_parts(token, &uuid, &step)) return;
|
|
658
|
+
if (!NIL_P(error)) {
|
|
659
|
+
if (ra_tier >= 4) rb_funcall(ra_trace, id_outcome, 3, token_pair(token, uuid, step), error, Qnil);
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
slot sl;
|
|
664
|
+
struct capture cap = { st ? sink_now(st) : NULL, st, 1 };
|
|
665
|
+
begin_slot(&sl, SLOT_RETURN, uuid, step);
|
|
666
|
+
if (cap.s && return_row(&cap, &sl, result)) {
|
|
667
|
+
ra_push_slot(cap.s, &sl);
|
|
668
|
+
} else {
|
|
669
|
+
rb_funcall(ra_trace, id_outcome, 3, token_pair(token, uuid, step), Qnil, result);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/* leave(token, result = nil, error = nil, finished = false): the call a Ruby wrapper entered has
|
|
674
|
+
* ended. It leaves the tree, and a call that was recorded with a row to write when it ends gets it.
|
|
675
|
+
* `finished` is false for a call that ended without returning or raising, a block's return or a
|
|
676
|
+
* throw through it, which has no row. In errors-only recording Ruby is told when the call was its
|
|
677
|
+
* tree's root, after the row that closes it is written. */
|
|
678
|
+
static VALUE wrapper_leave(int argc, VALUE *argv, VALUE self) {
|
|
679
|
+
VALUE token, result, error, finished;
|
|
680
|
+
rb_scan_args(argc, argv, "13", &token, &result, &error, &finished);
|
|
681
|
+
if (ra_state_p(token)) {
|
|
682
|
+
ra_state_pop(ra_state_of(token));
|
|
683
|
+
return Qnil;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
ra_state *st = ra_state_current();
|
|
687
|
+
if (st) ra_state_pop(st);
|
|
688
|
+
if (RTEST(finished)) close_row(st, token, result, error);
|
|
689
|
+
if (ra_hold && st && st->depth == 0) rb_funcall(ra_trace, id_tree_ended, 1, error);
|
|
690
|
+
return Qnil;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/* pass_on(error): a wrapper written in Ruby has rescued the exception its call raised, to hand it
|
|
694
|
+
* to leave, and sends it on its way here. A `raise` there would send the exception `exception` and
|
|
695
|
+
* `backtrace` again, see RA_TAG_RAISE. Anything but an exception is refused, as `raise` refuses
|
|
696
|
+
* it: the jump would take the VM down with nothing to raise. */
|
|
697
|
+
static VALUE wrapper_pass_on(VALUE self, VALUE error) {
|
|
698
|
+
if (!rb_obj_is_kind_of(error, rb_eException)) rb_raise(rb_eTypeError, "exception object expected");
|
|
699
|
+
rb_set_errinfo(error);
|
|
700
|
+
rb_jump_tag(RA_TAG_RAISE);
|
|
701
|
+
/* coverage:off -- return after a call that does not return */
|
|
702
|
+
return Qnil;
|
|
703
|
+
/* coverage:on */
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/* The same pair for a hook written into the method's own body, which keeps no local between the two
|
|
707
|
+
* calls: a call inside a tree is pushed whether the gate keeps or skips it, and the leave finds the
|
|
708
|
+
* fiber's state again and pops. The kept call is still not recorded. */
|
|
709
|
+
static VALUE wrapper_skip_enter_current(VALUE self, VALUE id, VALUE receiver) {
|
|
710
|
+
ra_state *st = ra_state_current();
|
|
711
|
+
if (!st) return Qnil;
|
|
712
|
+
|
|
713
|
+
uint64_t key, path_hash;
|
|
714
|
+
if (!ra_state_room(st)) rb_syserr_fail(ENOMEM, "runtime_analysis native: no memory for a deeper tree");
|
|
715
|
+
if (verdict_on(st, NUM2LONG(id), receiver, &key, &path_hash) == OUTSIDE_TREE) return Qnil;
|
|
716
|
+
st->kept = 0;
|
|
717
|
+
st->step++;
|
|
718
|
+
ra_state_push(st, key, 0);
|
|
719
|
+
return Qnil;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
static VALUE wrapper_skip_leave_current(VALUE self) {
|
|
723
|
+
ra_state *st = ra_state_current();
|
|
724
|
+
if (st && st->depth > 0) ra_state_pop(st);
|
|
725
|
+
return Qnil;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
#ifdef RA_TESTING
|
|
729
|
+
/* The line the running method was called from, found the way a profiler finds it: by walking the
|
|
730
|
+
* frames above the method's own. A hook inside a method's body has to look two frames up for its
|
|
731
|
+
* call site, where a wrapper reads the frame it runs in. For the benchmark and its spec. */
|
|
732
|
+
static VALUE testing_caller_line(VALUE self) {
|
|
733
|
+
VALUE frames[3];
|
|
734
|
+
int lines[3];
|
|
735
|
+
if (rb_profile_frames(0, 3, frames, lines) < 3) return Qnil;
|
|
736
|
+
rb_profile_frame_path(frames[2]);
|
|
737
|
+
return INT2FIX(lines[2]);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/* For specs: the most entries a stream's table may grow to, or nil for the usual limit. */
|
|
741
|
+
static VALUE testing_set_fast_most(VALUE self, VALUE entries) {
|
|
742
|
+
g_fast_most = NIL_P(entries) ? RA_FAST_MOST : NUM2SIZET(entries);
|
|
743
|
+
return entries;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/* For specs: sends every call through Ruby, to compare what the two paths write. */
|
|
747
|
+
static VALUE testing_set_fast_path(VALUE self, VALUE on) {
|
|
748
|
+
ra_fast = RTEST(on) ? 1 : 0;
|
|
749
|
+
return on;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
void Init_ra_fast_testing(VALUE mTesting) {
|
|
753
|
+
rb_define_singleton_method(mTesting, "caller_line", testing_caller_line, 0);
|
|
754
|
+
rb_define_singleton_method(mTesting, "fast_most=", testing_set_fast_most, 1);
|
|
755
|
+
rb_define_singleton_method(mTesting, "fast_path=", testing_set_fast_path, 1);
|
|
756
|
+
}
|
|
757
|
+
#endif
|
|
758
|
+
|
|
759
|
+
void Init_ra_fast(VALUE mWrapper) {
|
|
760
|
+
id_class_id = rb_intern("class_id");
|
|
761
|
+
id_keyword_id = rb_intern("keyword_id");
|
|
762
|
+
id_outcome = rb_intern("record_outcome");
|
|
763
|
+
id_before = rb_intern("record_before_native");
|
|
764
|
+
id_tree_ended = rb_intern("tree_ended");
|
|
765
|
+
rb_gc_register_address(&g_novelty_object);
|
|
766
|
+
|
|
767
|
+
rb_define_singleton_method(mWrapper, "frame_key", wrapper_frame_key, 2);
|
|
768
|
+
rb_define_singleton_method(mWrapper, "register", wrapper_register, 5);
|
|
769
|
+
rb_define_singleton_method(mWrapper, "watch_ivars", wrapper_watch_ivars, 2);
|
|
770
|
+
rb_define_singleton_method(mWrapper, "enter", wrapper_enter, -1);
|
|
771
|
+
rb_define_singleton_method(mWrapper, "leave", wrapper_leave, -1);
|
|
772
|
+
rb_define_singleton_method(mWrapper, "pass_on", wrapper_pass_on, 1);
|
|
773
|
+
rb_define_singleton_method(mWrapper, "skip_enter_current", wrapper_skip_enter_current, 2);
|
|
774
|
+
rb_define_singleton_method(mWrapper, "skip_leave_current", wrapper_skip_leave_current, 0);
|
|
775
|
+
}
|