| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
Otherwise we might still have some `JS::Heap`s lingering after
`JS_DestroyContext`, which will fail to destruct (crash) when their
destructors are called later in `~GjsContextPrivate()`.
Fixes: https://gitlab.gnome.org/GNOME/gjs/-/issues/472
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the gjs process is logging to the systemd journal directly via the
glib logging functions, the stack trace would get logged indirectly via
stderr. This however is not guaranteed to get added to the journal at
the same time as the error messages logged via glib. This is especially
noticeable when triggered from an endless loop or an idle callback. In
some cases it even can result in the stack trace not getting logged at
all.
There is currently no public API in mozjs to dump a stack trace directly
to a string from arbitrary threads, only to files, so this uses
open_memstream() as a workaround.
Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1868
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the promise job dispatcher is reset, its GCancellable is replaced
with a different instance. However, the original GCancellable instance was
passed to GjsContextPrivate::runJobs(), which aborts the job queue if the
GCancellable is cancelled.
This wasn't normally a problem, because the GCancellable isn't usually
cancelled. However, running JS with code coverage instrumentation starts
and stops the job dispatcher after every job, in order for the debugger
code to do its thing. So the GCancellable was getting cancelled and
immediately replaced with a fresh one, but the job queue was still getting
aborted.
This still didn't seem to have any noticeable effect until we merged the
runAsync() feature recently. From that point, async module evaluate
operations started getting dropped on the floor when code coverage was
active, which is very bad news.
The fix is to not hold on to the GCancellable across jobs. Instead of
checking whether the GCancellable is cancelled, instead check whether the
promise job dispatcher is running.
|
|
|
|
|
| |
This adds a new debug topic, JS MAINLOOP, and adds debug log statements to
the promise job queue, GSource, dispatcher, and main loop machinery.
|
| |
|
|
|
|
|
|
| |
For debugging, make sure the module identifier is part of the promise
reaction function's debug tag, so that when we break on it we can tell
which module was being evaluated.
|
|
|
|
|
|
|
| |
The reaction functions of the module evaluation promise accidentally had
their function IDs switched, leading to potential confusion when
debugging: a function called "async reject" would be called when the
module evaluation promise resolved, and vice versa.
|
|
|
|
|
| |
The runtime cast is defined anyway by the GObject macros, and allows
turning runtime checking on or off at build time as desired.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All modules are promises. If Gtk.Application.run() or
GLib.MainLoop.run() is called within a module it will block all other
promises as run() is a synchronous, blocking function. To work around
this there is now a setMainLoopHook function exposed which runs a
callback after module resolution is complete. This allows APIs to
"install" a mainloop asynchronously.
For Gio.Application and GLib.MainLoop there are now runAsync() versions
of their run() functions. runAsync() returns a Promise which will
resolve once the mainloop has exited.
Fixes #468
|
|
|
|
| |
They only use constexpr operations, so indeed they can be too.
|
| |
|
| |
|
| |
|
|
|
|
| |
It makes access to members using constexpr definitions
|
|
|
|
|
| |
We can avoid storing the destructor in this way, together with all the
constexpr operations.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Return will implies also calling the auto-cleanups functions we have, so
it's just nicer.
|
| |
|
|
|
|
| |
We can use a simpler version here.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is basically a revert of commit 7140cac8, although so much has
changed in the meantime that none of the revert applied cleanly, so it's
more of an "un-rewrite". This fixes a regression that has been present for
almost exactly 4 years.
Storing a JSFunction* pointer in closures did not take into account the
fact that not all callable JSObjects have an associated JSFunction. They
could be exotic objects with a [[Call]] method. In particular,
introspected functions are this, so this prevented g-i function objects
from being used as signal handlers.
(Less importantly, the same probably applied to callable Proxy objects.)
Also adds a regression test so that this doesn't happen again.
Closes: #518
|
|
|
|
|
|
|
|
|
|
| |
In newer Clang the stack allocation of the array produces the odd
-Walign-mismatch message:
error: passing 1-byte aligned argument to 8-byte aligned parameter
'this' of '' may result in an unaligned pointer access
Using std::array seems to solve the problem.
|
|
|
|
|
|
|
| |
No difference between these two, except that JS_InitWithFailureDiagnostic
returns a descriptive message if it fails, which JS_Init ignores. So, in
the rare case that it fails, we abort while printing the descriptive
message instead of just "Could not initialize JavaScript".
|
|
|
|
|
| |
Instead of recommending to call ByteArray.toString(), we should
recommend using TextDecoder to convert Uint8Array to a string.
|
|
|
|
|
| |
Since more functions will move out of jsapi.h in the future, it'll be
useful to know why exactly we are including it.
|
|
|
|
|
|
| |
This function was necessary in SpiderMonkey 91, but now the same
functionality is part of the SpiderMonkey API. There is no longer any need
to define our own.
|
|
|
|
| |
In particular, in finalize operations.
|
|
|
|
|
| |
This has some cascade effects on the signatures of other methods, since
we now need to pass the JSTracer in.
|
|
|
|
| |
See: https://hg.mozilla.org/mozilla-central/rev/551bd2292b5c9722f77f4501191a32a605a9f89b
|
|
|
|
| |
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1754405
|
|
|
|
| |
All of these options are always enabled in mozjs102.
|
|
|
|
|
|
|
|
|
|
|
| |
- js/CallAndConstruct.h: Now contains JS::Call, JS::Construct, and
related
- js/Debug.h: Already existed, but now contains JS_DefineDebuggerObject
- js/GlobalObject.h: Now contains JS::CurrentGlobalOrNull
- js/PropertyAndElement.h: Now contains APIs for getting, setting, and
defining properties, as well as array elements
- js/ScriptPrivate.h: Now contains JS::GetScriptPrivate/SetScriptPrivate
- js/Stack.h: Now contains APIs that have to do with the call stack
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
JS::GetPrivate() and JS::SetPrivate() are going away in SpiderMonkey
102. The replacement is to stuff the pointer into a JS::PrivateValue and
store it in an object's reserved slot. This is a change we can make prior
to the switch.
With SpiderMonkey 102, we are intended to use
JS::GetMaybePtrFromReservedSlot() to retrieve the pointer. This function
doesn't exist in SpiderMonkey 91, but it is a small inline function that
we can open-code in jsapi-util.h.
In most of the cases, we can encapsulate this access into three methods
of CWrapperPointerOps: has_private(), init_private(), and unset_private().
(Retrieving the pointer was already encapsulated by the various for_js()
methods.) This provides better safety anyway, because in init_private()
we can enforce that there was no pointer already set. We define that
reserved slot 0 is always the private pointer.
BoxedInstance already used slot 0 for something else, so that moves to
slot 1.
Based on Evan's commit from the mozjs102 branch.
Co-authored-by: Evan Welsh <contact@evanwelsh.com>
|
|
|
|
|
|
|
| |
I think the compilation and execution were previously split because the
API for doing both with UTF-8 source didn't work. However, it works now.
This is a good time to fix this workaround because
JS::CloneAndExecuteScript() is disappearing in mozjs102.
|
|
|
|
|
|
|
| |
JSID_VOID is going away in mozjs102. The replacement is the isVoid()
method of JS::PropertyKey.
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1754405
|
|
|
|
|
|
|
| |
internal.cpp and text-encoding.cpp hadn't been added to IWYU (it's
really annoying that globs won't work there, we should really find a way
around that) so they were never checked by IWYU. Add them and update
their headers.
|
|
|
|
|
|
| |
As with every release, IWYU's algorithms have slightly changed, and some
bugs have been fixed meaning we can remove some workarounds from the
postprocessing script; unfortunately other bugs have appeared as well.
|
|\
| |
| |
| |
| |
| |
| | |
object: Use std::vector to hold Objects GClosure's
Closes #485
See merge request GNOME/gjs!758
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We used a std::forward list to hold closure pointers in Object's to
avoid adding a vector when not needed, but these structures are terribly
slow as already pointed out in [1], and demonstrated even way poorer
performances when testing signal connections (see [2], #485 and !758), so get
rid of them and just use vectors everywhere which can boost performances
up to 95% in our tests.
This implies some more memory usage for each object, as we can't use a
std::vector without the size member since C++11, but I think it's still
better, given that size of std::forward_list is still bigger when with
only two closures/vfuncs added (as each element requires two pointers).
Fixes: #485
[1] https://github.com/3v1n0/stl-containers-benchmarks
[2] https://gitlab.gnome.org/3v1n0/gjs/-/snippets/3608
|
|/
|
|
|
|
|
|
|
|
|
|
| |
Due to the bug fixed by the previous commit, many files' includes had
gotten out of sync. This fixes all of the IWYU complaints.
We need to add some lines to the mapping file, either due to an IWYU
upgrade or changes in the header files; I'm not sure. It's annoying that
we have to list all the glib/*.h files separately, but that is for two
reasons: there is no glob for glib/* that can leave out <glib/gstdio.h>
and other public GLib headers; and glib/galloca.h should redirect to the
system alloca.h.
|
|
|
|
|
|
|
|
|
|
|
|
| |
We used to compute camel-case name of properties using toupper(),
however this is locale-dependent, while in this case we want to be sure
that we're only using ASCII values.
This is particularly problematic in Turkish (and maybe other locales)
because there 'i'.toLocaleUpperCase() is 'İ', that is definitely not an
ASCII char, causing problems to with our generated properties.
See: https://github.com/micheleg/dash-to-dock/issues/1687
|
|
|
|
|
| |
Same gint64/int64_t type mismatch on Darwin (long vs long long) as the
previous commit.
|
|\
| |
| |
| |
| |
| |
| | |
Verbose object print output
Closes #107
See merge request GNOME/gjs!587
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
It makes sense for the prettyPrint() function to be written in JS, but it
does need to be called internally in Console.interact() which is written
in C++. Therefore, create a slot on the global object in which to store
the prettyPrint() function, which can be retrieved when needing to call
the function from internal code.
Console.interact() no longer needs to use gjs_value_debug_string(), so
that code and its dependencies can be removed.
Also pass the arguments of log() and logError() through prettyPrint().
This enables the work from #107.
|
|\ \
| | |
| | |
| | |
| | | |
March maintenance
See merge request GNOME/gjs!736
|
| | | |
|
| |/ |
|
|/
|
|
|
|
|
| |
Bizarrely, if we construct ostringstream with a string already in it, the
default behaviour is to start overwriting characters at the start when
later inserting more text into the stream. If we don't want that, we have
to construct it with the 'advance to end' flag.
|