Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Last active December 30, 2021 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasterDuke17/1daf47f370201f0f2c4afedfa41e42ee to your computer and use it in GitHub Desktop.
Save MasterDuke17/1daf47f370201f0f2c4afedfa41e42ee to your computer and use it in GitHub Desktop.
[dan@alexandria perl6]$ raku --profile -e 'use nqp; say nqp::dispatch("boot-syscall", "instrumented-profile-data", nqp::hash("kind", "instrumented", "path", "foo.sqlite3"));'
(((94513945208328 {managed_size => 72, repr => MVMCode, type => The 'ForeignCode' class is a Rakudo-specific implementation detail and has no serviceable parts inside}) (94513945208256 {has_unmanaged_data => 1, managed_size => 56, repr => VMArray, type => (List)}) (94513945208280 {has_unmanaged_data => 1, managed_size => 32, repr => VMHash, type => (Hash)})) {call_graph => {callees => ({callees => ({allocations => ({count => 1, id => 94513945208328} {count => 1, id => 94513945208256}), callees => ({allocations => ({count => 1, id => 94513945208280}), entries => 1, exclusive_time => 3399, file => -e, first_entry_time => 35, id => 94513979820464, inclusive_time => 3399, line => 1, mono => 1, name => <unit>}), entries => 1, exclusive_time => 14, file => -e, first_entry_time => 21, id => 94513979820208, inclusive_time => 3414, line => 1, mono => 1, name => <unit-outer>}), entries => 1, exclusive_time => 6, file => gen/moar/stage2/NQPHLL.nqp, first_entry_time => 15, id => 94513947134832, inclusive_time => 3420, line => 1942, mono => 1, name => }), entries => 1, exclusive_time => 15, file => , first_entry_time => 0, id => 94513979821488, inclusive_time => 3436, line => -1, name => }, gcs => (), parent => 0, spesh_time => 0, start_time => 0, thread => 1, total_time => 3426})
at -e:1 (<ephemeral file>:<unit>)
from -e:1 (<ephemeral file>:<unit-outer>)
from gen/moar/stage2/NQPHLL.nqp:1942 (/home/dan/Source/perl6/install/share/nqp/lib/NQPHLL.moarvm:)
from gen/moar/stage2/NQPHLL.nqp:168 (/home/dan/Source/perl6/install/share/nqp/lib/NQPHLL.moarvm:run_profiled)
from gen/moar/stage2/NQPHLL.nqp:1941 (/home/dan/Source/perl6/install/share/nqp/lib/NQPHLL.moarvm:eval)
from gen/moar/stage2/NQPHLL.nqp:2059 (/home/dan/Source/perl6/install/share/nqp/lib/NQPHLL.moarvm:)
from gen/moar/stage2/NQPHLL.nqp:2058 (/home/dan/Source/perl6/install/share/nqp/lib/NQPHLL.moarvm:command_eval)
from gen/moar/Compiler.nqp:111 (/home/dan/Source/perl6/install/share/perl6/lib/Perl6/Compiler.moarvm:command_eval)
from gen/moar/stage2/NQPHLL.nqp:2039 (/home/dan/Source/perl6/install/share/nqp/lib/NQPHLL.moarvm:command_line)
from gen/moar/rakudo.nqp:140 (/home/dan/Source/perl6/install/share/perl6/runtime/perl6.moarvm:MAIN)
from gen/moar/rakudo.nqp:1 (/home/dan/Source/perl6/install/share/perl6/runtime/perl6.moarvm:<mainline>)
from <unknown>:1 (/home/dan/Source/perl6/install/share/perl6/runtime/perl6.moarvm:<main>)
from <unknown>:1 (/home/dan/Source/perl6/install/share/perl6/runtime/perl6.moarvm:<entry>)
MoarVM panic: Profiler lost sequence
diff --git src/disp/syscall.c src/disp/syscall.c
index 0a1f3e76b..72857beec 100644
--- src/disp/syscall.c
+++ src/disp/syscall.c
@@ -1171,6 +1171,25 @@ static MVMDispSysCall code_is_stub = {
.expected_concrete = { 1 },
};
+/* instrumented-profile-data */
+static void instrumented_profile_data_impl(MVMThreadContext *tc, MVMArgs arg_info) {
+ MVMObject *config = get_obj_arg(arg_info, 0);
+ MVMObject *prof_data = MVM_profile_end(tc);
+ MVM_free_null(tc->prof_data->collected_data);
+ MVM_profile_instrumented_free_data(tc);
+ MVM_profile_start(tc, config);
+ MVM_args_set_result_obj(tc, prof_data, MVM_RETURN_CURRENT_FRAME);
+}
+static MVMDispSysCall instrumented_profile_data = {
+ .c_name = "instrumented-profile-data",
+ .implementation = instrumented_profile_data_impl,
+ .min_args = 1,
+ .max_args = 1,
+ .expected_kinds = { MVM_CALLSITE_ARG_OBJ },
+ .expected_reprs = { 0 },
+ .expected_concrete = { 0 },
+};
+
/* Add all of the syscalls into the hash. */
MVM_STATIC_INLINE void add_to_hash(MVMThreadContext *tc, MVMDispSysCall *syscall) {
MVMString *name = MVM_string_ascii_decode_nt(tc, tc->instance->VMString, syscall->c_name);
@@ -1254,6 +1273,7 @@ void MVM_disp_syscall_setup(MVMThreadContext *tc) {
add_to_hash(tc, &type_check_mode_flags);
add_to_hash(tc, &has_type_check_cache);
add_to_hash(tc, &code_is_stub);
+ add_to_hash(tc, &instrumented_profile_data);
MVM_gc_allocate_gen2_default_clear(tc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment