Closed Bug 781035 Opened 12 years ago Closed 12 years ago

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

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: Benjamin, Assigned: Benjamin)

References

Details

Attachments

(1 file, 2 obsolete files)

Attached patch convert (obsolete) — Splinter Review
      No description provided.
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!
Depends on: 781070
Attached patch convert (obsolete) — Splinter Review
I forgot one.
Assignee: general → bpeterson
Attachment #649861 - Attachment is obsolete: true
Attachment #649861 - Flags: review?(jorendorff)
Attachment #649925 - Flags: review?(jorendorff)
Blocks: 781104
Attached patch use c++ apiSplinter Review
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!  :)
Attachment #650274 - Flags: superreview?(jst) → superreview+
https://hg.mozilla.org/mozilla-central/rev/4bb09a1e8c15
https://hg.mozilla.org/mozilla-central/rev/d985281cad13
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: