Bug 1531479 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

## 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`](https://searchfox.org/mozilla-central/source/js/src/vm/BytecodeLocation.h) and [`BytecodeIterator`](https://searchfox.org/mozilla-central/source/js/src/vm/BytecodeIterator.h), we'd like to replace uses of `jsbytecode*` and `pcOffset` inside [`GetThisValueForDebuggerMaybeOptimizedOut`](https://searchfox.org/mozilla-central/rev/00f3836a87b844b5e4bc82f698c559b9966e4be2/js/src/vm/EnvironmentObject.cpp#3291-3302). 

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 `pcOffset`s. 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](https://phabricator.services.mozilla.com/D8920) used these interfaces to modify `JSScript::assertValidJumpTargets`. You can use that patch as inspiration for what we're looking for. 


## Prerequisites

Before getting started, you'll want to

* You Have a checkout of the Firefox source code 
* Make sure you can build [SpiderMonkey](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation) 


## 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!
## 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`](https://searchfox.org/mozilla-central/source/js/src/vm/BytecodeLocation.h) and [`BytecodeIterator`](https://searchfox.org/mozilla-central/source/js/src/vm/BytecodeIterator.h), we'd like to replace uses of `jsbytecode*` and `pcOffset` inside [`GetThisValueForDebuggerMaybeOptimizedOut`](https://searchfox.org/mozilla-central/rev/00f3836a87b844b5e4bc82f698c559b9966e4be2/js/src/vm/EnvironmentObject.cpp#3291-3302). 

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 `pcOffset`s. 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](https://phabricator.services.mozilla.com/D8920) used these interfaces to modify `JSScript::assertValidJumpTargets`. You can use that patch as inspiration for what we're looking for. 


## Prerequisites

Before getting started, you'll want to

* You Have a checkout of the Firefox source code 
* Make sure you can build [SpiderMonkey](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation) 
* Read [this walkthrough](https://moz-conduit.readthedocs.io/en/latest/walkthrough.html) about how development works in Firefox

## 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!

Back to Bug 1531479 Comment 0