Support compiling JS in self-hosting mode in the shell

RESOLVED FIXED in mozilla19

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: till, Assigned: till)

Tracking

(Blocks: 1 bug)

Other Branch
mozilla19
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [js:t])

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

6 years ago
This would enable testing self-hosted code without recompiling the shell.
Whiteboard: [js:t]
(Assignee)

Comment 1

6 years ago
Created attachment 663833 [details] [diff] [review]
v1

So it occurred to me that making it possible to load an external JS file during runtime and to set that file using an environment variable is more useful than adding a special compile mode to the shell.

This patch adds the environment variable "MOZ_SELFHOSTEDJS" and changes the makefile and embedjs.py script very slightly to make creating the required JS file easier.

Usage:
1. modify any JS file that's compiled into selfhosted.js
2. invoke the shell or the browser with "MOZ_SELFHOSTEDJS=./selfhosted.js ./js" (for the shell, in the obj dir) or "MOZ_SELFHOSTEDJS=[path to js obj dir].selfhosted.js ./run-mozilla.sh ./firefox" (for the browser, in the dist/bin dir)
Assignee: general → tschneidereit
Status: NEW → ASSIGNED
Attachment #663833 - Flags: review?(luke)

Comment 2

6 years ago
Comment on attachment 663833 [details] [diff] [review]
v1

Punting to Terrence.
Attachment #663833 - Flags: review?(luke) → review?(terrence)
Comment on attachment 663833 [details] [diff] [review]
v1

Review of attachment 663833 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM
Attachment #663833 - Flags: review?(terrence) → review+
(Assignee)

Comment 5

6 years ago
Comment on attachment 663833 [details] [diff] [review]
v1

hrmpf
Attachment #663833 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/5f1d0cfe99ac
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
Comment on attachment 670367 [details] [diff] [review]
v2

Review of attachment 670367 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jscntxt.cpp
@@ +272,5 @@
> +    char *filename = getenv("MOZ_SELFHOSTEDJS");
> +    if (filename) {
> +        RootedScript script(cx, Compile(cx, shg, options, filename));
> +        if (script)
> +            ok = Execute(cx, script, *shg.get(), &rv);

So if script is null, we will return some uninitialized value?
(Assignee)

Comment 9

6 years ago
(In reply to :Ms2ger from comment #8)
> So if script is null, we will return some uninitialized value?

Thanks for noticing. Luckily, Ehsan fixed that in bug 801344.
Depends on: 801344
You need to log in before you can comment on or make changes to this bug.