Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Last active May 14, 2020 13:42
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/c505c33b11a31eddb4d3a153c47f048c to your computer and use it in GitHub Desktop.
Save MasterDuke17/c505c33b11a31eddb4d3a153c47f048c to your computer and use it in GitHub Desktop.
[dan@alexandria nqp]$ gdb --args '/home/dan/Source/perl6/install/bin/moar' --libpath=src/vm/moar/stage0 src/vm/moar/stage0/nqp.moarvm --bootstrap --no-regex-lib --target=mbc --setting=NULL --stable-sc=stage1 --output=gen/moar/stage1/nqpmo.moarvm gen/moar/stage1/nqpmo.nqp '/usr/bin/perl' '/home/dan/Source/perl6/nqp/Configure.pl' --backends=moar --prefix='/home/dan/Source/perl6/install' --expand /home/dan/Source/perl6/nqp/tools/templates/unix/nqp-m-build.c --out nqp-m.c --set-var=MOAR='/home/dan/Source/perl6/install/bin/moar' --set-var=base_dir='/home/dan/Source/perl6/nqp' --set-var=exec_name='/home/dan/Source/perl6/nqp/nqp-m' --set-var=mbc=nqp.moarvm
GNU gdb (GDB) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/dan/Source/perl6/install/bin/moar...
MoarVM string pretty printer registered
moar-heap registered
diff-moar-heap registered
(gdb) r
Starting program: /home/dan/Source/perl6/install/bin/moar --libpath=src/vm/moar/stage0 src/vm/moar/stage0/nqp.moarvm --bootstrap --no-regex-lib --target=mbc --setting=NULL --stable-sc=stage1 --output=gen/moar/stage1/nqpmo.moarvm gen/moar/stage1/nqpmo.nqp /usr/bin/perl /home/dan/Source/perl6/nqp/Configure.pl --backends=moar --prefix=/home/dan/Source/perl6/install --expand /home/dan/Source/perl6/nqp/tools/templates/unix/nqp-m-build.c --out nqp-m.c --set-var=MOAR=/home/dan/Source/perl6/install/bin/moar --set-var=base_dir=/home/dan/Source/perl6/nqp --set-var=exec_name=/home/dan/Source/perl6/nqp/nqp-m --set-var=mbc=nqp.moarvm
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff6db1700 (LWP 86344)]
Thread 2 "moar" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6db1700 (LWP 86344)]
0x00007ffff79c2c29 in MVM_jit_emit_primitive (tc=0x5555555ed550, compiler=0x7ffff6daefb0, jg=0x7ffff11c13d0, prim=0x7ffff1311c18) at src/jit/x64/emit.dasc:2104
warning: Source file is more recent than executable.
2104 }
(gdb) x/i $rip
=> 0x7ffff79c2c29 <MVM_jit_emit_primitive+22008>: mov (%rax),%rdx
(gdb) bt
#0 0x00007ffff79c2c29 in MVM_jit_emit_primitive (tc=0x5555555ed550, compiler=0x7ffff6daefb0, jg=0x7ffff11c13d0, prim=0x7ffff1311c18) at src/jit/x64/emit.dasc:2104
#1 0x00007ffff79aafe6 in MVM_jit_compile_graph (tc=0x5555555ed550, jg=0x7ffff11c13d0) at src/jit/compile.c:86
#2 0x00007ffff790e4c8 in MVM_spesh_candidate_add (tc=0x5555555ed550, p=0x7ffff00c9840) at src/spesh/candidate.c:128
#3 0x00007ffff792dea9 in worker (tc=0x5555555ed550, arg_info=...) at src/spesh/worker.c:20
#4 0x00007ffff78b2f7b in invoke_handler (tc=0x5555555ed550, invokee=0x5555555db0c0, callsite=0x7ffff7f65de0 <null_args_callsite>, args=0x0) at src/6model/reprs/MVMCFunction.c:40
#5 0x00007ffff78532a4 in thread_initial_invoke (tc=0x5555555ed550, data=0x5555555ee8e0) at src/core/threads.c:59
#6 0x00007ffff780e369 in MVM_interp_run (tc=0x5555555ed550, initial_invoke=0x7ffff7853219 <thread_initial_invoke>, invoke_data=0x5555555ee8e0, outer_runloop=0x0) at src/core/interp.c:164
#7 0x00007ffff7853369 in start_thread (data=0x5555555ee8e0) at src/core/threads.c:87
#8 0x00007ffff729d422 in start_thread () from /usr/lib/libpthread.so.0
#9 0x00007ffff74fab83 in clone () from /usr/lib/libc.so.6
(gdb)
[dan@alexandria nqp]$ gdb --args '/home/dan/Source/perl6/install/bin/moar' --libpath=src/vm/moar/stage0 src/vm/moar/stage0/nqp.moarvm --bootstrap --setting-path=gen/moar/stage1 --module-path=gen/moar/stage1 --no-regex-lib --target=mbc --setting=NQPCORE --stable-sc=stage1 --output=gen/moar/stage1/QRegex.moarvm gen/moar/stage1/QRegex.nqp
GNU gdb (GDB) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/dan/Source/perl6/install/bin/moar...
MoarVM string pretty printer registered
moar-heap registered
diff-moar-heap registered
(gdb) set disassembly-flavor intel
(gdb) r
Starting program: /home/dan/Source/perl6/install/bin/moar --libpath=src/vm/moar/stage0 src/vm/moar/stage0/nqp.moarvm --bootstrap --setting-path=gen/moar/stage1 --module-path=gen/moar/stage1 --no-regex-lib --target=mbc --setting=NQPCORE --stable-sc=stage1 --output=gen/moar/stage1/QRegex.moarvm gen/moar/stage1/QRegex.nqp
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff6db1700 (LWP 87819)]
Thread 1 "moar" received signal SIGSEGV, Segmentation fault.
0x00007ffff5f76147 in ?? ()
(gdb) bt
#0 0x00007ffff5f76147 in ?? ()
#1 0x0000000000000008 in ?? ()
#2 0x000055555555adf0 in ?? ()
#3 0x000055555555bcb0 in ?? ()
#4 0x00005555555e8ba0 in ?? ()
#5 0x00007fffffffc6e0 in ?? ()
#6 0x00007ffff786a731 in MVM_fixed_size_free (tc=0x5555555e8bc8, al=0x7fffffffc7c0, bytes=93825025966832, to_free=0x7ffff7df4620 <inv_arg_callsite>) at src/core/fixedsizealloc.c:304
#7 0x00007ffff79bb156 in MVM_jit_code_enter (tc=0x55555555adf0, code=0x7ffff012cef0, cu=0x5555558342f8) at src/jit/interface.c:24
#8 0x00007ffff783f9f2 in MVM_interp_run (tc=0x55555555adf0, initial_invoke=0x7ffff799788e <toplevel_initial_invoke>, invoke_data=0x55555561a3c0, outer_runloop=0x0) at src/core/interp.c:6509
#9 0x00007ffff7997a08 in MVM_vm_run_file (instance=0x55555555a2a0, filename=0x7fffffffe73e "src/vm/moar/stage0/nqp.moarvm") at src/moar.c:467
#10 0x0000555555555c52 in main (argc=12, argv=0x7fffffffe328) at src/main.c:305
(gdb) info registers
rax 0x55555757fbc0 93825025964992
rbx 0x55555757f740 93825025963840
rcx 0x5555558cac58 93824995863640
rdx 0x5555559b3aa0 93824996817568
rsi 0x5555573275ee 93825023505902
rdi 0x55555555adf0 93824992259568
rbp 0x7fffffffc780 0x7fffffffc780
rsp 0x7fffffffc680 0x7fffffffc680
r8 0x555557327500 93825023505664
r9 0x0 0
r10 0x0 0
r11 0x55555744f870 93825024718960
r12 0xa 10
r13 0x5555558342f8 93824995246840
r14 0x55555555adf0 93824992259568
r15 0x0 0
rip 0x7ffff5f76147 0x7ffff5f76147
eflags 0x10206 [ PF IF RF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
(gdb)
/* Look up the inline cache entry at a precalculated slot (for specialized code). */
MVMDispInlineCacheEntry ** MVM_disp_inline_cache_get_spesh(MVMStaticFrame *sf, MVMuint32 slot) {
MVMDispInlineCache *cache = &(sf->body.inline_cache);
return &(cache->entries[slot]);
}
OP(sp_getlexstatic_o): {
MVMStaticFrame *sf = (MVMStaticFrame *)tc->cur_frame
->effective_spesh_slots[GET_UI16(cur_op, 4)];
MVMDispInlineCacheEntry **ice_ptr = MVM_disp_inline_cache_get_spesh(sf,
GET_UI32(cur_op, 6));
MVMObject *found = (*ice_ptr)->run_getlexstatic(tc, ice_ptr,
GET_REG(cur_op, 2).s);
GET_REG(cur_op, 0).o = found;
cur_op += 10;
goto NEXT;
}
diff --git src/jit/graph.c src/jit/graph.c
index 564b60b77..e0d82bc9b 100644
--- src/jit/graph.c
+++ src/jit/graph.c
@@ -1909,6 +1909,7 @@ start:
case MVM_OP_getcodename:
case MVM_OP_setcodeobj:
case MVM_OP_hllbool:
+ case MVM_OP_sp_getlexstatic_o:
/* Profiling */
case MVM_OP_prof_enterspesh:
case MVM_OP_prof_enterinline:
diff --git src/jit/x64/emit.dasc src/jit/x64/emit.dasc
index eb6e96e8a..fe37c3873 100644
--- src/jit/x64/emit.dasc
+++ src/jit/x64/emit.dasc
@@ -117,6 +117,8 @@
|.type U32, MVMuint32
|.type U64, MVMuint64
|.type MPINT, mp_int
+|.type MVMDISPINLINECACHEENTRY, MVMDispInlineCacheEntry
+|.type MVMDISPINLINECACHE, MVMDispInlineCache
/* Static allocation of relevant types to registers. I pick
@@ -2084,6 +2086,22 @@ void MVM_jit_emit_primitive(MVMThreadContext *tc, MVMJitCompiler *compiler, MVMJ
| call FUNCTION;
break;
}
+ case MVM_OP_sp_getlexstatic_o: {
+ MVMint16 dst = ins->operands[0].reg.orig;
+ MVMint16 name = ins->operands[1].reg.orig;
+ MVMint16 spesh_idx = ins->operands[2].lit_i16;
+ MVMuint32 slot = ins->operands[3].lit_ui32;
+ | mov ARG1, TC;
+ | get_spesh_slot TMP1, spesh_idx;
+ | lea TMP2, STATICFRAME:TMP1->body.inline_cache;
+ | lea ARG2, MVMDISPINLINECACHE:TMP2->entries[slot];
+ | mov ARG3, aword WORK[name];
+ | mov FUNCTION, [ARG2];
+ | mov FUNCTION, MVMDISPINLINECACHEENTRY:FUNCTION->run_getlexstatic;
+ | call FUNCTION;
+ | mov WORK[dst], RV;
+ break;
+ }
case MVM_OP_getlexperinvtype_o: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMint16 name = ins->operands[1].reg.orig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment