Closed
Bug 557247
Opened 15 years ago
Closed 15 years ago
TM: In debug builds, expose whether we're on trace or not (tracemonkey.onTrace)
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jorendorff, Assigned: jorendorff)
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file)
|
871 bytes,
patch
|
gal
:
review+
|
Details | Diff | Splinter Review |
The problem with such a feature, of course, is that people are tempted to use the boolean value as a branching condition:
for (var x = 0; x < 20; x++) {
if (tracemonkey.onTrace) // d'oh
print("on trace");
}
This could end up being really misleading if you don't recognize what's going on. When onTrace is true, you'll end up taking a different path through the loop--which forces you off trace.
On the other hand, suppose you have a large test case and you want to know whether a particular loop is staying on trace or not. You could just add:
print("onTrace: " + tracemonkey.onTrace);
and that will tell you the answer without shunting you onto the wrong track. Or similarly, you could add this:
for (...) {
...
wasOnTrace = tracemonkey.onTrace; // sample without branching
...
}
print("last loop was on trace?: " + wasOnTrace);
You have to be careful, but I think the pros outweigh the cons.
Comment 1•15 years ago
|
||
Would tracemonkey.storeOnTrace("nameOfGlobal") be less hazardous?
| Assignee | ||
Comment 2•15 years ago
|
||
Assignee: general → jorendorff
Attachment #437061 -
Flags: review?(gal)
Updated•15 years ago
|
Attachment #437061 -
Flags: review?(gal) → review+
| Assignee | ||
Comment 3•15 years ago
|
||
(In reply to comment #1)
> Would tracemonkey.storeOnTrace("nameOfGlobal") be less hazardous?
Sounds like a trigger lock. Theoretically, yeah, it becomes harder to get the footgun to fire. But there's nothing preventing the user from thinking "man, this api sucks--oh well" and then going straight on and doing whatever dumb thing they were going to do.
I also thought about taking the "usability through obscurity" approach and calling it tracemonkey.bananas or something.
Both remedies seem kind of out of proportion to the risk of confusion here--as I estimate it, anyway.
Comment 4•15 years ago
|
||
You could also make it an outparam-like thing, that set a property on a passed-in object. I too think the risk of confusion's small enough to not worry about the problem, tho.
| Assignee | ||
Comment 5•15 years ago
|
||
Whiteboard: fixed-in-tracemonkey
Comment 6•15 years ago
|
||
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•