Bug 127269 - A few utility functions for setting/clearing the op_debug hasBreakpointFlag.
Summary: A few utility functions for setting/clearing the op_debug hasBreakpointFlag.
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords:
Depends on:
Blocks: 122836
  Show dependency treegraph
 
Reported: 2014-01-20 00:06 PST by Mark Lam
Modified: 2014-01-20 15:46 PST (History)
5 users (show)

See Also:


Attachments
the patch. (5.80 KB, patch)
2014-01-20 00:23 PST, Mark Lam
ggaren: review-
ggaren: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2014-01-20 00:06:10 PST
The bytecode level breakpoint debugger will have to set and clear breakpoints by setting/clearing the hasBreakpointFlag operand in the op_debug bytecode of a CodeBlock.  In addition, as an optimization, there’s also a need to for a utility function clear all breakpoints in a CodeBlock that may have been set.  This is useful when a debugger detaches, and breakpoints need to be cleared in bulk.  This patch will provide these utility functions in anticipation of upcoming support for bytecode level breakpoints.  These functions are not currently in use.
Comment 1 Mark Lam 2014-01-20 00:23:33 PST
Created attachment 221628 [details]
the patch.
Comment 2 Mark Lam 2014-01-20 01:59:36 PST
FYI, the efl-wk2 bot failure is due to an internal compiler error on the bot.  Hence, it is not due to the patch.
Comment 3 Geoffrey Garen 2014-01-20 09:26:56 PST
Comment on attachment 221628 [details]
the patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=221628&action=review

> Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp:406
> +void UnlinkedCodeBlock::clearAllBreakpointsIn(RefCountedArray<Instruction>& instructions)
> +{
> +    LineColumnInfoList& list = opDebugLineColumnInfoList();
> +    for (LineColumnInfoList::iterator it = list.begin(); it != list.end(); ++it) {
> +        static const int hasBreakpointFlagOffset = 2; 
> +        unsigned offset = it->instructionOffset;
> +        ASSERT(m_vm->interpreter->getOpcodeID(instructions[offset].u.opcode) == op_debug);
> +        instructions[offset + hasBreakpointFlagOffset] = false;
> +    }
> +}

This doesn't look right. The unlinked CodeBlock should never contain breakpoints, or metadata about whether they're set. The unlinked CodeBlock is cached and shared among webpages. Putting breakpoint metadata in it would cause debugging in one webpage to set breakpoints in another, and it would cause breakpoints to persist across page loads.
Comment 4 Mark Lam 2014-01-20 09:33:47 PST
(In reply to comment #3)
> (From update of attachment 221628 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=221628&action=review
> 
> > Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp:406
> > +void UnlinkedCodeBlock::clearAllBreakpointsIn(RefCountedArray<Instruction>& instructions)
> > +{
> > +    LineColumnInfoList& list = opDebugLineColumnInfoList();
> > +    for (LineColumnInfoList::iterator it = list.begin(); it != list.end(); ++it) {
> > +        static const int hasBreakpointFlagOffset = 2; 
> > +        unsigned offset = it->instructionOffset;
> > +        ASSERT(m_vm->interpreter->getOpcodeID(instructions[offset].u.opcode) == op_debug);
> > +        instructions[offset + hasBreakpointFlagOffset] = false;
> > +    }
> > +}
> 
> This doesn't look right. The unlinked CodeBlock should never contain breakpoints, or metadata about whether they're set. The unlinked CodeBlock is cached and shared among webpages. Putting breakpoint metadata in it would cause debugging in one webpage to set breakpoints in another, and it would cause breakpoints to persist across page loads.

I’m not touching the UnlinkedCodeBlock bytecode here.  The bytecode instructions array is provided by the CodeBlock and passed in.  What the UnlinkedCodeBlock has is a map of where all the op_debug bytecodes are so that we can get to them quickly.  I opted to have the UnlinkedCodeBlock provided this utility function that the CodeBlock can use to clear its breakpoints because I wanted to keep that list private.

The alternative is to make opDebugLineColumnInfoList() public and have CodeBlock walk it to do the breakpoint clearing.
Comment 5 Mark Lam 2014-01-20 15:46:01 PST
We have a change of plans.  Instead of going with bytecode level breakpoints, we're going with CodeBlock level breakpoints.  This patch is no longer relevant.