Closed Bug 1586441 Opened 5 years ago Closed 4 years ago

Use BytecodeLocation and BytecodeIterator in DebugScript::clearBreakpointsIn

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: asorholm, Assigned: yozaam)

References

(Blocks 1 open bug)

Details

(Whiteboard: [lang=c++])

Attachments

(1 file)

Background

Historically access to bytecode in SpiderMonkey has been fairly freeform and common. This means that common idioms are repeated without encapsulation, and it's difficult to audit the codebase for patterns which makes changes around bytecode much more fragile than we'd like.

We'd like to encapsulate manipulation of bytecode within the engine to a set of accessor classes where possible.

This Bug

By using the BytecodeLocation and BytecodeIterator, we'd like to replace uses of jsbytecode* and pcOffset inside DebugScript::clearBreakpointsIn.

This bug is only for changing the implementation of this function: It's OK that when values escape this function the return to jsbytecode* and pcOffsets. We can't change everything at once!

Note: It is expected that you may have to expand the interface of BytecodeLocation or BytecodeIterator. The interfaces as they exist now are driven by clients, and are comparatively thin.

Prior Art

  • In Bug 1499544, Part 2 used these interfaces to modify JSScript::assertValidJumpTargets. You can use that patch as inspiration for what we're looking for.

  • Dependencies of Bug 1478034 that have been marked RESOLVED FIXED can also be used as inspiration for what we're looking for.

Prerequisites

Before getting started, you'll want to

This patch is done when

  • Direct access to the bytecode in DebugScript::clearBreakpointsIn is abstracted through the use of the classes BytecodeLocation and BytecodeIterator. In other words, jsbytecode* and offsetToPC uses in DebugScript::clearBreakpointsIn are replaced with methods and members of the classes BytecodeLocation and BytecodeIterator.

  • Your patch passes the test suites described here.

Getting Help

Feel free to leave comments on this bug for questions, or, if you have more synchronous questions about this bug, feel free to drop into #jsapi on irc.mozilla.org.

Tips:

  • Not sure if the code you've been editing is getting run? Insert a call to MOZ_CRASH, a macro which will crash when executed, and run the entire test suite with an optimized build (for speed). If you see crashes, you can then use a debug build to make sure it's crashing in your code!
Priority: -- → P3
Assignee: nobody → yozaam
Status: NEW → ASSIGNED
Pushed by mgaudet@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/820fa7359a58
Using iterator and BytecodeIterable in for loop instead of jsbytecode* pc r=mgaudet
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: