The default bug view has changed. See this FAQ.

convert more places to use the C++ compile/evaluate api

RESOLVED FIXED in mozilla17

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: Benjamin, Assigned: Benjamin)

Tracking

unspecified
mozilla17
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

5 years ago
Created attachment 649861 [details] [diff] [review]
convert
Attachment #649861 - Flags: review?(jorendorff)
Please provide a description, even if short, in all filed bugs.  It makes things much easier for people who follow all the bugs in a particular component.  Thanks!
(Assignee)

Updated

5 years ago
Depends on: 781070
(Assignee)

Comment 2

5 years ago
Created attachment 649925 [details] [diff] [review]
convert

I forgot one.
Assignee: general → bpeterson
Attachment #649861 - Attachment is obsolete: true
Attachment #649861 - Flags: review?(jorendorff)
Attachment #649925 - Flags: review?(jorendorff)
(Assignee)

Updated

5 years ago
Blocks: 781104
(Assignee)

Comment 3

5 years ago
Created attachment 650274 [details] [diff] [review]
use c++ api

Remove usage of JS::NullPtr.
Attachment #649925 - Attachment is obsolete: true
Attachment #649925 - Flags: review?(jorendorff)
Attachment #650274 - Flags: review?(jorendorff)
Comment on attachment 650274 [details] [diff] [review]
use c++ api

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

jst, this is just an API change. The new API isn't markedly better in these cases, but it's more explicit. I've reviewed it. Please request any additional reviews that are needed.

This eliminates two casts. Do we know why those were necessary in the first place? With the patch, does this still build on Windows?

::: dom/workers/WorkerPrivate.cpp
@@ +3795,5 @@
>                                                          &stringLength);
> +      if (!string) {
> +        retval = false;
> +        break;
> +      }

The original code called JS_ReportPendingException in the case where string is null.

@@ +3805,1 @@
>            !JS_ReportPendingException(aCx)) {

And here: JS_ReportPendingException is supposed to be called when Evaluate returns false.
Attachment #650274 - Flags: superreview?(jst)
Attachment #650274 - Flags: review?(jorendorff)
Attachment #650274 - Flags: review+
I should comment briefly on why this is desirable.

There are a bunch of compile-time options that affect script compilation and nothing else. Historically some of these have been stored in the JSContext, but then some JSAPI-using code just grabs a JSContext somewhat arbitrarily and starts using it, so I think historically the choice of language version, compile options, and other odds and ends has often been pretty arbitrary. This is bad. To counteract that we've been adding more and more JS_Compile* APIs, like JS_CompileUCScriptForPrincipalsVersionOrigin.

With CompileOptions, there are still a bunch of knobs (too many, I guess), but you can see all of them. They're all in one place. If you want to know exactly which options your code is going to be compiled with, just look at the CompileOptions object you've made. That's what the JS engine will use.

Compilation depends only on the CompileOptions; AFAIK it no longer depends on JSContext state in any subtle ways.

Ideally I would like to make CompileOptions itself independent of any JSContext state. This is a step in that direction without changing the semantics at all yet.
[A side note about CompileOptions:  it's now passed to JSScript::Create(), which I don't particularly like, because that function only reads some of its fields -- 5 out of 11, to be exact.]
Get your own bug!  :)

Updated

5 years ago
Attachment #650274 - Flags: superreview?(jst) → superreview+
(Assignee)

Comment 8

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/4bb09a1e8c15
https://hg.mozilla.org/mozilla-central/rev/4bb09a1e8c15
https://hg.mozilla.org/mozilla-central/rev/d985281cad13
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.