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)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file)

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.
Would tracemonkey.storeOnTrace("nameOfGlobal") be less hazardous?
Attached patch v1Splinter Review
Assignee: general → jorendorff
Attachment #437061 - Flags: review?(gal)
Attachment #437061 - Flags: review?(gal) → review+
(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.
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.
Whiteboard: fixed-in-tracemonkey
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.

Attachment

General

Created:
Updated:
Size: