After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 711046 - mozjs24 port
mozjs24 port
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2013-10-29 04:29 UTC by darkxst
Modified: 2013-12-05 19:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
build: switch to mozjs-24 (1.75 KB, patch)
2013-10-29 04:29 UTC, darkxst
accepted-commit_now Details | Review
update for changes in options (1.16 KB, patch)
2013-10-29 04:29 UTC, darkxst
reviewed Details | Review
update delete property in JSClass definitions to use JS_DeletePropertyStub (6.31 KB, patch)
2013-10-29 04:29 UTC, darkxst
accepted-commit_now Details | Review
Add a wrapper for JS_GetGlobalObject (2.05 KB, patch)
2013-10-29 04:29 UTC, darkxst
accepted-commit_now Details | Review
Misc js24 API changes (3.00 KB, patch)
2013-10-29 04:29 UTC, darkxst
reviewed Details | Review
update for JS_GetPrototype api change (3.12 KB, patch)
2013-10-29 04:29 UTC, darkxst
reviewed Details | Review
profiler: convert to new JSAbstractFramePtr api and update callbacks for api change (4.81 KB, patch)
2013-10-29 04:29 UTC, darkxst
none Details | Review
Adapt to utf8 changes (7.51 KB, patch)
2013-10-29 04:29 UTC, darkxst
accepted-commit_now Details | Review
context: handlify locale callbacks (3.36 KB, patch)
2013-10-29 04:29 UTC, darkxst
none Details | Review
Compartments are compulsory now (10.26 KB, patch)
2013-10-29 04:29 UTC, darkxst
none Details | Review
JS_SetVersion has been removed, JS Version is now set on the compartment instead of context. (2.84 KB, patch)
2013-10-29 04:29 UTC, darkxst
none Details | Review
disable bogus tests (1.39 KB, patch)
2013-10-29 04:29 UTC, darkxst
committed Details | Review
update for changes in options (1.19 KB, patch)
2013-10-31 20:50 UTC, darkxst
none Details | Review
Misc js24 API changes (3.01 KB, patch)
2013-10-31 20:51 UTC, darkxst
none Details | Review
build: switch to mozjs-24 (1.75 KB, patch)
2013-11-08 20:34 UTC, darkxst
none Details | Review
0001-virtualenv-Support-cases-where-host-Python-only-ship.patch (2.54 KB, patch)
2013-11-28 15:18 UTC, Colin Walters
reviewed Details | Review

Description darkxst 2013-10-29 04:29:05 UTC
This is the patchset for gjs on spidermonkey 24

libpeas and gnome-shell also need patches to make sure there is no direct access to jsapi
from C code.
Comment 1 darkxst 2013-10-29 04:29:07 UTC
Created attachment 258393 [details] [review]
build: switch to mozjs-24
Comment 2 darkxst 2013-10-29 04:29:10 UTC
Created attachment 258394 [details] [review]
update for changes in options

JSOPTION_STRICT rename JSOPTION_EXTRA_WARNINGS
JSOPTION_METHODJIT removed since JaegerMonkey is gone, use JSOPTION_BASELINE instead
Comment 3 darkxst 2013-10-29 04:29:14 UTC
Created attachment 258395 [details] [review]
update delete property in JSClass definitions to use JS_DeletePropertyStub
Comment 4 darkxst 2013-10-29 04:29:17 UTC
Created attachment 258396 [details] [review]
Add a wrapper for JS_GetGlobalObject

Context global object is only available through a private api now, create a wrapper that emulates the
old api. Context globals will be going away in the future.
Comment 5 darkxst 2013-10-29 04:29:21 UTC
Created attachment 258397 [details] [review]
Misc js24 API changes

JS_EncodeStringToBuffer takes add context as first argument,
JS_NewRuntime adds a JS_NO_HELPER_THREADS flag
Update to new JS_Call*Tracer API
Comment 6 darkxst 2013-10-29 04:29:24 UTC
Created attachment 258398 [details] [review]
update for JS_GetPrototype api change
Comment 7 darkxst 2013-10-29 04:29:28 UTC
Created attachment 258399 [details] [review]
profiler: convert to new JSAbstractFramePtr api and update callbacks for api change
Comment 8 darkxst 2013-10-29 04:29:32 UTC
Created attachment 258400 [details] [review]
Adapt to utf8 changes

JS_SetCStringsAreUTF8 has been removed and internally spidermonkey no longer handles
utf8 strings. There is a compiletime option setUTF8 that needs to be set, this change
requires using JS::Evaluate. Additionally we need to handle utf8 encoding in the
gjs_string functions. Finally JS_BufferIsCompilableUnit no longer has a utf8 argument
Comment 9 darkxst 2013-10-29 04:29:36 UTC
Created attachment 258401 [details] [review]
context: handlify locale callbacks
Comment 10 darkxst 2013-10-29 04:29:40 UTC
Created attachment 258402 [details] [review]
Compartments are compulsory now

We need to add AutoCompartment calls at all entry points
Comment 11 darkxst 2013-10-29 04:29:44 UTC
Created attachment 258403 [details] [review]
JS_SetVersion has been removed, JS Version is now set on the compartment instead of context.
Comment 12 darkxst 2013-10-29 04:29:48 UTC
Created attachment 258404 [details] [review]
disable bogus tests

note mozjs24 must be built with --disable-intl-api right now for the locale callbacks to work.
In theory the locale callbacks are no longer needed since this is handled by ICU, however it
looks like js24 will ship with an in-tree ICU, which many distros might disable
Comment 13 Colin Walters 2013-10-30 20:41:34 UTC
Review of attachment 258397 [details] [review]:

One comment.

::: gjs/context.cpp
@@ +567,3 @@
     js_context = GJS_CONTEXT(object);
 
+    js_context->runtime = JS_NewRuntime(32*1024*1024 /* max bytes */, JS_NO_HELPER_THREADS);

Why don't we want helper threads?  The default "js" shell appears to use them...

Or is this part of avoiding having e.g. destroy notifications run out of the GC thread which *is* important for gjs?
Comment 14 Colin Walters 2013-10-30 20:53:47 UTC
Review of attachment 258400 [details] [review]:

Looks good.
Comment 15 Colin Walters 2013-10-30 20:54:07 UTC
Review of attachment 258393 [details] [review]:

Right.
Comment 16 Colin Walters 2013-10-30 20:54:36 UTC
Er, to be clear I'm marking these patches accepted-commit-now but let's only push them all once we're ready?
Comment 17 Colin Walters 2013-10-30 20:56:47 UTC
Review of attachment 258394 [details] [review]:

::: gjs/context.cpp
@@ +592,3 @@
     if (!g_getenv("GJS_DISABLE_JIT")) {
         gjs_debug(GJS_DEBUG_CONTEXT, "Enabling JIT");
+        options_flags |= JSOPTION_BASELINE | JSOPTION_TYPE_INFERENCE;

By default, I'd prefer to do exactly what the upstream "js" shell does.  Which in this case, is:

JSOPTION_TYPE_INFERENCE | JSOPTION_ION | JSOPTION_BASELINE | JSOPTION_ASMJS
Comment 18 Colin Walters 2013-10-30 20:59:08 UTC
Review of attachment 258395 [details] [review]:

Right, just a mechanical change.
Comment 19 Colin Walters 2013-10-30 20:59:33 UTC
Review of attachment 258396 [details] [review]:

Ok.
Comment 20 Colin Walters 2013-10-30 21:04:39 UTC
Review of attachment 258398 [details] [review]:

Yes, but JS_GetPrototype also now returns JSBool, maybe it can theoretically throw an exception now?  Dunno, gjs code is not the best when it comes to handling errors...but if you're feeling charitable, maybe instead do:

if (!JS_GetPrototype(...))
  goto out;

?

But you can also ignore this.
Comment 21 darkxst 2013-10-31 20:12:08 UTC
Review of attachment 258394 [details] [review]:

We don't actually have any use for asm.js do we?
Comment 22 Jasper St. Pierre (not reading bugmail) 2013-10-31 20:21:12 UTC
I don't see any reason to not add it.
Comment 23 darkxst 2013-10-31 20:29:48 UTC
Review of attachment 258397 [details] [review]:

right, actually we probably do want to use helper threads as that will match the previous js17 behaviour, seems the option was added to avoid having multiple gc threads when you have multiple run-times (which we don't).
Comment 24 darkxst 2013-10-31 20:50:25 UTC
Created attachment 258688 [details] [review]
update for changes in options

JSOPTION_STRICT rename JSOPTION_EXTRA_WARNINGS
JSOPTION_METHODJIT removed since JaegerMonkey is gone, use JSOPTION_BASELINE instead

use the same options as upstream js shell

I will re-attch all patches in order, once the other patches are reviewed
Comment 25 darkxst 2013-10-31 20:51:10 UTC
Created attachment 258689 [details] [review]
Misc js24 API changes

JS_EncodeStringToBuffer takes add context as first argument,
JS_NewRuntime adds a JS_USE_HELPER_THREADS flag
Update to new JS_Call*Tracer API

use helper threads
Comment 26 Colin Walters 2013-11-08 14:36:15 UTC
Review of attachment 258404 [details] [review]:

Ok, yeah we don't really need to test the core JS API here.
Comment 27 Colin Walters 2013-11-08 14:45:20 UTC
Tim: Can you push these patches to a wip/mozjs24 git branch of gjs?

I think we're at the point where we should just try to land this and iterate on improving it from there.

What's the status of the upstream release?
Comment 28 darkxst 2013-11-08 20:34:08 UTC
Created attachment 259300 [details] [review]
build: switch to mozjs-24

upstream version was bumped to 24.1 for RC tarball
Comment 29 darkxst 2013-11-08 20:50:20 UTC
updated wip/js24 branch.

Release should happen in the next couple of weeks.
Comment 30 Colin Walters 2013-11-08 20:56:21 UTC
(In reply to comment #29)
> updated wip/js24 branch.
> 
> Release should happen in the next couple of weeks.

Thanks.  Can you link here in this bug to the current mozjs24 snapshot tarballs you're using for this?
Comment 32 Colin Walters 2013-11-13 00:51:32 UTC
(In reply to comment #31)
> https://people.mozilla.org/~sstangl/mozjs-24.1.0.rc1.tar.bz2

Hmm...this falls over for me messily inside configure with some virtualenv/"mach" stuff.  Can you link me to the Debian packaging you're using?
Comment 33 darkxst 2013-11-13 01:13:16 UTC
Ubuntu packaging can be found here:
https://launchpad.net/~ricotz/+archive/staging/+packages

I'm also running it in jhbuild without any issues.
Comment 34 Colin Walters 2013-11-13 14:55:39 UTC
I'm running into issues with the embedded virtualenv, failure looks like this:

Creating Python environment
    ImportError: Bad magic number in /ostbuild/source/js24/_build/js/src/_virtualenv/lib/python2.7/site.pyo
    New python executable in /ostbuild/source/js24/_build/js/src/_virtualenv/bin/python2.7
    Also creating executable in /ostbuild/source/js24/_build/js/src/_virtualenv/bin/python
    ERROR: The executable /ostbuild/source/js24/_build/js/src/_virtualenv/bin/python2.7 is not functioning
    ERROR: It thinks sys.prefix is u'/ostbuild/source/js24/_build/js/src' (should be u'/ostbuild/source/js24/_build/js/src/_virtualenv')
    ERROR: virtualenv is not compatible with this system or executable
    Traceback (most recent call last):
  • File "/ostbuild/source/js24/_build/js/src/build/virtualenv/populate_virtualenv.py", line 384 in <module>
    manager.ensure()
  • File "/ostbuild/source/js24/_build/js/src/build/virtualenv/populate_virtualenv.py", line 103 in ensure
    return self.build()
  • File "/ostbuild/source/js24/_build/js/src/build/virtualenv/populate_virtualenv.py", line 315 in build
    self.create()
  • File "/ostbuild/source/js24/_build/js/src/build/virtualenv/populate_virtualenv.py", line 122 in create
    raise Exception('Error creating virtualenv.')     Exception: Error creating virtualenv.



Do you have a system package of virtualenv in your buildroot?
Comment 35 Colin Walters 2013-11-13 14:59:20 UTC
Have you seen this issue before?  Do you have a system copy of virtualenv maybe in your buildroot, i.e. is "python-virtualenv" pulled in for you?
Comment 36 Colin Walters 2013-11-28 15:18:46 UTC
Created attachment 263031 [details] [review]
0001-virtualenv-Support-cases-where-host-Python-only-ship.patch
Comment 37 Colin Walters 2013-11-28 15:19:54 UTC
Ok, sorry it took me a while to debug this.  I'll do a bit more testing now that js24 builds for me, and let's try to land this soon!
Comment 38 Jasper St. Pierre (not reading bugmail) 2013-11-28 17:24:21 UTC
Review of attachment 263031 [details] [review]:

::: js/src/python/virtualenv/virtualenv.py
@@ +915,3 @@
             env['VIRTUALENV_INTERPRETER_RUNNING'] = 'true'
             file = __file__
+            if file.endswith('.pyc') or site_filename.endswith('.pyo'):

file.endswith(('.pyc', '.pyo'))
Comment 40 Colin Walters 2013-12-05 19:10:31 UTC
Now pushed to master.  Everyone: please send any issues/patches as new bugs.