Closed Bug 1702487 Opened 3 years ago Closed 3 years ago

jitsrc could be useful for tracing bytecode generation, but needs more patterns

Categories

(Core :: JavaScript Engine, enhancement, P5)

enhancement

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: mgaudet, Assigned: iain)

Details

Attachments

(1 file)

The jitsrc.py gdb script could be perfect for finding the original emission point of bytecode, but it does need additional patterns to support this.

In the interpreter I ran

(rr) print script->code() // Turns out this suffices, as I'm interested in where the first op came from! 
$53 = 0x7f89bdee9d61 (JSOp::Uninitialized)
(rr) jitsrc 0x7f89bdee9d61
Thread 1 hit Hardware watchpoint -580: *0x7f89bdee9d61
Old value = 43946
New value = -469718102
0x000055e490a71132 in std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m<mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false> > (__first=..., __last=..., __result=...) at /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_algobase.h:324
324                   *__result = *__first;
(rr) bt
#0  0x000055e490a71132 in std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m<mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false> >(mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false>) (__first=..., __last=..., __result=...) at /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_algobase.h:324
#1  0x000055e490a70ff1 in std::__copy_move_a<false, mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false> >(mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false>) (__first=..., __last=..., __result=...) at /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_algobase.h:385
#2  0x000055e490a70eaa in std::__copy_move_a2<false, mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false> >(mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false>) (__first=..., __last=..., __result=...) at /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_algobase.h:422
#3  0x000055e490a70c64 in std::copy<mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false> >(mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char const, 18446744073709551615ul>, true>, mozilla::span_details::span_iterator<mozilla::Span<unsigned char, 18446744073709551615ul>, false>) (__first=..., __last=..., __result=...) at /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_algobase.h:454
#4  0x000055e490a1ee62 in CopySpan<mozilla::Span<unsigned char const, 18446744073709551615ul>, mozilla::Span<unsigned char, 18446744073709551615ul> >(mozilla::Span<unsigned char const, 18446744073709551615ul> const&, mozilla::Span<unsigned char, 18446744073709551615ul>) (source=..., target=...) at /home/matthew/unified/js/src/vm/JSScript.cpp:4520
#5  0x000055e4909e4318 in js::ImmutableScriptData::new_(JSContext*, unsigned int, unsigned int, unsigned int, js::GCThingIndex, unsigned int, bool, unsigned short, mozilla::Span<unsigned char const, 18446744073709551615ul>, mozilla::Span<js::SrcNote const, 18446744073709551615ul>, mozilla::Span<unsigned int const, 18446744073709551615ul>, mozilla::Span<js::ScopeNote const, 18446744073709551615ul>, mozilla::Span<js::TryNote const, 18446744073709551615ul>) (cx=0x7f89bde50000, mainOffset=0, nfixed=1, nslots=9, bodyScopeIndex=..., numICEntries=26, isFunction=false, funLength=0, code=..., notes=..., resumeOffsets=..., scopeNotes=..., tryNotes=...) at /home/matthew/unified/js/src/vm/JSScript.cpp:4563
#6  0x000055e49104389c in js::frontend::BytecodeEmitter::createImmutableScriptData(JSContext*) (this=0x7ffc2e731558, cx=0x7f89bde50000) at /home/matthew/unified/js/src/frontend/BytecodeEmitter.cpp:2694
#7  0x000055e491043165 in js::frontend::BytecodeEmitter::intoScriptStencil(js::frontend::TypedIndex<js::frontend::ScriptStencil>) (this=0x7ffc2e731558, scriptIndex=...) at /home/matthew/unified/js/src/frontend/BytecodeEmitter.cpp:11666

So we get lost inside Span copying

Here's my fifteen minute attempt at support. Test it out and let me know if anything breaks / is missing.

EndianUtils::copyAndSwapTo is used for self-hosted code. The 0,0 checks for Little->Little, which is just a memcpy.

Assignee: nobody → iireland
Status: NEW → ASSIGNED
Pushed by iireland@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/947bf0db49d3
Support bytecode generation in jitsrc r=mgaudet
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: