Firefox should tell SpiderMonkey what sort of code each bit of JavaScript is

ASSIGNED
Assigned to

Status

()

Core
DOM: Core & HTML
ASSIGNED
4 years ago
4 years ago

People

(Reporter: jimb, Assigned: jimb)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
Firefox should tell SpiderMonkey whether the JavaScript it has asked it to evaluate is an event handler, a script element, and so on. One bug 332176 has landed, Firefox can do so by setting CompileOptions::introductionType to the appropriate string.

There's a draft spec for introductionType, below; naturally, SpiderMonkey itself takes care of "eval" and "Function".


introductionType *(not yet implemented)*

A string indicating how this source code was introduced into the system.
This accessor returns one of the following values:

-   `"eval"`, for code passed to `eval`.
-   `"Function"`, for code passed to the `Function` constructor.
-   `"Worker"`, for code loaded by calling the Web worker
    constructor—the worker's main script.
-   `"importScripts"`, for code by calling `importScripts` in a web
    worker.
-   `"handler"`, for code assigned to DOM elements' event handler IDL
    attributes.
-   `"scriptElement"`, for code belonging to `<script>` elements.
-   `undefined`, if the implementation doesn't know how the code was
    introduced.
(Assignee)

Comment 1

4 years ago
Okay, bug 332176 has landed, so this is ready to implement. (It's one of the last remaining pieces needed for removing JSD...)
(Assignee)

Comment 2

4 years ago
Actually, we should land bug 968580, too, before working on this.
Depends on: 968580
(Assignee)

Comment 3

4 years ago
Panos, since you've been working on bug 961325, which is in the same neighborhood as this, would you be interested in preparing a patch for this? This one should be really simple --- just passing a const char * in at each site that passes JS source to SpiderMonkey (whether it's run immediately or not) --- and I've been promising it to the Firebug people for months, as it's one of their final blockers.

The two prerequisites I mentioned above are quick patches, so hopefully they won't take long to review...
OK, I'll give it a shot.
Assignee: nobody → past
Status: NEW → ASSIGNED
(Assignee)

Updated

4 years ago
Blocks: 935203
(Assignee)

Comment 5

4 years ago
Created attachment 8375222 [details] [diff] [review]
Provide introductionType information at every place in Firefox that evaluates JavaScript code.

WIP; doesn't compile
Assignee: past → jimb
(In reply to Jim Blandy :jimb from comment #5)
> Created attachment 8375222 [details] [diff] [review]
> Provide introductionType information at every place in Firefox that
> evaluates JavaScript code.
> 
> WIP; doesn't compile
Yeah, I am seeing:

4:40.26 c:\src\github.com\mozilla\gecko-dev\dom\src\jsurl\nsJSProtocolHandler.c
pp(296) : error C2660: 'nsIXPConnect::EvalInSandboxObject' : function does not t
ake 7 arguments

Is it easy to fix?
Honza
(Assignee)

Comment 7

4 years ago
I'll trim this down and re-post.
You need to log in before you can comment on or make changes to this bug.