Commit Graph

4316 Commits

Author SHA1 Message Date
Julian Seward
6dbd528357 Bug 1820120 - Manage Wasm{Array,Struct}Object OOL-storage-blocks using a thread-private cache. r=jonco,rhunt.
Wasm{Array,Struct}Objects may be freely nursery-allocated, hence enjoying the
benefits of generational GC.  However, those with out-of-line storage in the
C++ heap (called "trailer blocks" in the patch) have those blocks managed by
js_malloc/js_free.  This is expensive, and especially for objects which don't
get tenured, undercuts the benefit gained from generational GC.

This patch adds to js::Nursery, two new mechanisms:

* a cache of blocks, js::gc::MallocedBlockCache, which are suitable for use as
  trailers.  Allocation and freeing of trailers is done mostly from this
  cache.  A supporting type, js::PointerAndUint7, has also been added, as
  extra data (a freelist ID) is needed when returning blocks to the cache.

* a more limited version of the existing Nursery::mallocedBuffers mechanism.
  The goal is the same -- to enumerate the subtraction of sets of allocated vs
  tenured trailer blocks, at the end of minor GC.  The new version differs in
  that (1) it tracks PointerAndUint7, not void*s, (2) block resizing is not
  supported, and (3) the difference is computed via vector comparison rather
  than a hash set, for performance reasons.

An SMDOC explaining the mechanisms in detail has been added to WasmGcObject.cpp.

Differential Revision: https://phabricator.services.mozilla.com/D171551
2023-03-07 22:05:59 +00:00
Ben Visness
5c665e56a8 Bug 1814421: Prepare wasm extended-const for ship. r=rhunt
Differential Revision: https://phabricator.services.mozilla.com/D169247
2023-03-07 20:18:45 +00:00
Ryan Hunt
bb4aeeabfb Bug 1820584 - wasm: Don't disable function-references when fuzzing Ion. r=yury
Differential Revision: https://phabricator.services.mozilla.com/D171729
2023-03-07 14:00:09 +00:00
Jon Coppeard
8da9dfe9d8 Bug 1817965 - Add telemetry to monitor how quickly GC tasks run after being queued r=jandem
I initially tried to do this for all helper thread tasks but most of them don't
have any associated runtime to send the telemetry to and this resulted in a
much larger set of changes.

What do you think?

Differential Revision: https://phabricator.services.mozilla.com/D171597
2023-03-06 15:41:40 +00:00
Sandor Molnar
5efd10cbf6 Backed out changeset 3546c099a1cf (bug 1814924) for causing build bustages in js/src/vm/SharedArrayObject.cpp CLOSED TREE 2023-03-03 00:34:29 +02:00
Ben Visness
7c1f265635 Bug 1814924: Implement memory.discard for shared memories. r=rhunt
Differential Revision: https://phabricator.services.mozilla.com/D170839
2023-03-02 22:00:53 +00:00
Sean Feng
5ad9ff01bc Bug 1814478 - Add JSON parsing to JS Validator r=farre,smaug,tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D166946
2023-03-02 17:55:31 +00:00
Ms2ger
696e704767 Bug 1819129 - Add a better API to JSON.stringify; r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D171208
2023-03-01 10:36:59 +00:00
Jan de Mooij
456e577517 Bug 1483869 part 4 - Make wrappers work correctly with bound functions. r=iain,peterv
Now that bound functions use a `JSClass` that's not `JSFunction`, we need to give
them a `JSProtoKey` to make (xray) wrapper calls work. This fixes a lot of xpcshell
and browser test failures.

The old implementation used `JSProto_Function`. This patch adds `JSProto_BoundFunction`
and (as much as possible) tries to use the same code paths for it.

Differential Revision: https://phabricator.services.mozilla.com/D170568
2023-02-27 13:05:43 +00:00
Jon Coppeard
c8eda9a080 Bug 1817741 - Part 1: Add stats phases and telemetry for parallel marking r=sfink
This adds a stast phase PARALLEL_MARK which is used for total time on both main
and helper threads. Addtionally, helper threads record PARALLEL_MARK_MARK and
PARALLEL_MARK_WAIT.

The patch also adds three telemetry probes related to parallel marking:
 - GC_PARALLEL_MARK_SPEEDUP - Ratio of total helper thread time spent marking to main thread time
 - GC_PARALLEL_MARK_UTILIZATION - Ratio of helper thread time spent marking to total helper thread time
 - GC_PARALLEL_MARK_INTERRUPTIONS - Number of interruptions/donations per slice

Differential Revision: https://phabricator.services.mozilla.com/D170379
2023-02-23 17:38:42 +00:00
Cristian Tuns
80ef3aa9b7 Backed out 16 changesets (bug 1773319) for causing hazard bustages in TestingFunctions.cpp CLOSED TREE
Backed out changeset 432d50b65ee6 (bug 1773319)
Backed out changeset 55c0f82e8645 (bug 1773319)
Backed out changeset d1f138fae2c4 (bug 1773319)
Backed out changeset c4e12157c001 (bug 1773319)
Backed out changeset 50c3ae074be3 (bug 1773319)
Backed out changeset 7f773c7ee0fd (bug 1773319)
Backed out changeset 3005fd755990 (bug 1773319)
Backed out changeset c3fd0107003b (bug 1773319)
Backed out changeset 26a8fc40437f (bug 1773319)
Backed out changeset 4e7e1ec10ed2 (bug 1773319)
Backed out changeset 83d4b82795fe (bug 1773319)
Backed out changeset 8bdbbd322d34 (bug 1773319)
Backed out changeset 6c952cee28e2 (bug 1773319)
Backed out changeset 1068cb71a7bf (bug 1773319)
Backed out changeset c10a596d7395 (bug 1773319)
Backed out changeset ce294fa9953c (bug 1773319)
2023-02-22 12:10:18 -05:00
Bryan Thrall
2b6f1ba722 Bug 1773319 - Add JS::SetSupportedImportAssertions(FrontendContext*) to API r=arai
Differential Revision: https://phabricator.services.mozilla.com/D170083
2023-02-22 16:18:37 +00:00
Bryan Thrall
ed938c15b8 Bug 1773319 - Add CompileModuleScriptToStencil() and use it r=arai
Differential Revision: https://phabricator.services.mozilla.com/D169658
2023-02-22 16:18:36 +00:00
Bryan Thrall
35a812cc3b Bug 1773319 - Rename CompileGlobalScriptToStencil r=arai
Since CompileGlobalScriptToStencil(FrontendContext*...) is a thin wrapper
around CompileGlobalScriptToStencil(JSContext*...), it makes sense for the
names to match.

jsapi-test testCompileNonsyntactic's test name conflicted with
testCompileScript's, so I renamed it to more precisely match what it is
testing.

Differential Revision: https://phabricator.services.mozilla.com/D169134
2023-02-22 16:18:34 +00:00
Bryan Thrall
60bea9e473 Bug 1773319 - Add PrepareForInstantiate() to API r=arai
The only failure cases for PrepareForInstantiate() are OOM, which will be
checked in a separate commit.

Differential Revision: https://phabricator.services.mozilla.com/D168683
2023-02-22 16:18:33 +00:00
Bryan Thrall
1a92d1bd71 Bug 1773319 - Add CompilationInput parameter to ParseGlobalScript r=arai
The CompilationInput will be needed for PrepareForInstantiate().

Differential Revision: https://phabricator.services.mozilla.com/D168681
2023-02-22 16:18:32 +00:00
Bryan Thrall
2888f537f4 Bug 1773319 - Intro API to create/destroy FrontendContext, ParseScript r=arai
Need to fill out jsapi-test for more details and use cases.

ParseGlobalScript() has a stackLimit parameter because I don't expect to
know what the limit for the TaskController task is, or even that the function
is being run by TaskController.

Differential Revision: https://phabricator.services.mozilla.com/D167461
2023-02-22 16:18:31 +00:00
Ryan Hunt
c569461af6 Bug 1812132 - wasm: Allow anyref, structref, arrayref, and (ref T) in ToWasmValue/ToJSValue. r=jseward
The minimal JS-API spec for the GC proposal allows these types to be used on the
JS-Wasm boundary. So far we have not supported this. This commit updates these
methods so that the types work. This commit does not add support to our JIT
fast paths for exit/entry, so any use of these types will be stuck in the
interpreter entry/exit.

Differential Revision: https://phabricator.services.mozilla.com/D170005
2023-02-17 18:22:23 +00:00
Denis Palmeiro
054edd0fc2 Bug 1814105: part 1 - Record offsets directly instead of through a Label, and add string support for recording instructions r=iain
Differential Revision: https://phabricator.services.mozilla.com/D168583
2023-02-16 14:07:55 +00:00
Ben Visness
3bb963d741 Bug 1804310: Add wasm memory control pref. r=rhunt
Differential Revision: https://phabricator.services.mozilla.com/D168485
2023-02-14 19:27:54 +00:00
Ben Visness
a2dbc1c182 Bug 1804310: Implement memory.discard wasm instruction. r=rhunt,supply-chain-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D167324
2023-02-14 19:27:53 +00:00
Andi-Bogdan Postelnicu
d7e8a09c21 Bug 1519636 - Reformat recent changes to the Google coding style. r=glandium
Updated with clang-format version 15.0.5 (taskcluster-MKK8dHUpQkGfPLA793lizg)
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D168658
2023-02-13 15:02:07 +00:00
Ben Visness
e117e4aed8 Bug 1790873: Add js::DumpFmt as a convenient equivalent to printf_stderr. r=tcampbell
As far as I can tell, SpiderMonkey did not have a quick one-line fprintf(stderr) equivalent that would also go to the Windows debug console.

Differential Revision: https://phabricator.services.mozilla.com/D165225
2023-02-10 18:58:17 +00:00
Tooru Fujisawa
bbd6a64a49 Bug 1812540 - Part 1: Add JS::ToGetterId and JS::ToSetterId. r=sfink
Differential Revision: https://phabricator.services.mozilla.com/D168512
2023-02-07 07:36:17 +00:00
Sandor Molnar
4fcb729dc9 Backed out 11 changesets (bug 1806598, bug 1812905, bug 1812540) for causing dt failures in devtools/client/webconsole/test/browser/browser_console_evaluation_context_selector.js CLOSED TREE
Backed out changeset 3b0e28b20def (bug 1812540)
Backed out changeset 810ed5832764 (bug 1812540)
Backed out changeset 9e042da8472f (bug 1806598)
Backed out changeset ab04e3122f20 (bug 1806598)
Backed out changeset f97c01add0a5 (bug 1806598)
Backed out changeset de9d04dc5014 (bug 1806598)
Backed out changeset 3808fc5bf528 (bug 1806598)
Backed out changeset 9be2509e8540 (bug 1806598)
Backed out changeset 3fc6c5d9d620 (bug 1806598)
Backed out changeset 297a91be123b (bug 1806598)
Backed out changeset 24cc5069faf3 (bug 1812905)
2023-02-06 07:19:51 +02:00
Tooru Fujisawa
bcfe88c55b Bug 1812540 - Part 1: Add JS::ToGetterId and JS::ToSetterId. r=sfink
Differential Revision: https://phabricator.services.mozilla.com/D168512
2023-02-06 03:42:37 +00:00
Jon Coppeard
82dbe984bc Bug 1812268 - Add a GC parameter to control the number of threads used for parallel marking r=sfink
This also adds a shell option to set the parameter.

Care is taken to avoid using more threads than we start parallel GC tasks for
as otherwise we can deadlock.

Differential Revision: https://phabricator.services.mozilla.com/D167783
2023-01-25 17:20:04 +00:00
Steve Fink
73ebdf61bc Bug 1807169 - Properly hand over ownership of the transferables in a JSStructuredCloneData r=iain
Differential Revision: https://phabricator.services.mozilla.com/D165445
2023-01-10 22:23:44 +00:00
Jon Coppeard
9513c27cf4 Bug 1808927 - Use a single vector for module export entries r=arai
This uses a single vector for all export entries and stores the start positions
for indirect and star export entries separately. The export entries are
returned as spans, and other vectors changed to be returned as spans too to
ease the shell integration.

Differential Revision: https://phabricator.services.mozilla.com/D166187
2023-01-10 09:44:07 +00:00
Yoshi Cheng-Hao Huang
87d399b16d Bug 1808357: Add better error message for importmaps of invalid JSON format. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D166084
2023-01-06 13:34:17 +00:00
Jan de Mooij
23e221e237 Bug 1808744 part 1 - Combine Value unboxing mask with ChunkMask for Value barriers in JIT code. r=jonco
This gets rid of an extra or-instruction on 64-bit platforms and simplifies
loading the store buffer.

Differential Revision: https://phabricator.services.mozilla.com/D166137
2023-01-06 12:29:51 +00:00
Jon Coppeard
addd297a0f Bug 1806725 - Avoid gray unmarking when unlinking module records r=mccr8,sfink
Original patch by mccr8.

At least for the cycle collector, the purpose of calling unmark gray when
accessing a JS field of a C++ object is to avoid creating references from a
black object to a gray object. However, this particular code is writing
undefined, so that should not be a danger.

This particular code is by its nature dealing with GC things that are gray and
may be about to be GCed, so calling unmark grey can waste a tremendous amount
of time. On a profile of collecting a JS-heavy page, I was seeing 20% of the
100ms CC being spent on it.

The patch uses unbarrieredGet in ModuleScript::UnlinkModuleRecord and adds a
new API to clear a module record's private value without checking whether
associated objects are gray.

Differential Revision: https://phabricator.services.mozilla.com/D165202
2023-01-04 09:40:05 +00:00
Jan de Mooij
3729a6c96c Bug 1703508 part 1 - Remove pref for large ArrayBuffers. r=rhunt
This shipped in Firefox 89, more than a year ago.

Differential Revision: https://phabricator.services.mozilla.com/D165027
2022-12-21 09:25:23 +00:00
Jon Coppeard
50c149f6dc Bug 1806136 - Part 0: Change the API so that the supported assertions are set once on initialization r=arai
Not related to the rest of the bug. This is a simplification so that we set the
supported import assertions once rather than querying the host every time they
are needed.

Differential Revision: https://phabricator.services.mozilla.com/D164914
2022-12-19 11:56:34 +00:00
Tom Schuster
bf618bbc4a Bug 1774866 - Always allow cloning error stacks. r=nika,sfink,smaug
Differential Revision: https://phabricator.services.mozilla.com/D164577
2022-12-15 19:03:53 +00:00
Tooru Fujisawa
b6573b45ef Bug 1787528 - Part 4: Use fc as FrontendContext variable name. r=bthrall
Replace 'ec' with 'fc'.

Differential Revision: https://phabricator.services.mozilla.com/D158416
2022-12-14 07:31:10 +00:00
Tooru Fujisawa
a823123f46 Bug 1787528 - Part 3: Use FrontendContext in all consumers. r=bthrall
Differential Revision: https://phabricator.services.mozilla.com/D158415
2022-12-14 07:31:10 +00:00
Tooru Fujisawa
8dc005bc26 Bug 1787528 - Part 2: Merge ErrorContext and OffThreadErrorContext and rename to FrontendContext. r=bthrall
Differential Revision: https://phabricator.services.mozilla.com/D158414
2022-12-14 07:31:09 +00:00
Jan de Mooij
2031ad337d Bug 1804253 part 4 - Optimize checks for native objects and proxies. r=jonco
This saves two dereferences by looking at the shape instead of the class.

Differential Revision: https://phabricator.services.mozilla.com/D164214
2022-12-13 10:58:30 +00:00
Jan de Mooij
41fa7887cc Bug 1804253 part 2 - Add ProxyShape and WasmGCShape. r=jonco
Add separate `Shape` subclasses. `SharedShape` is now only used for native objects.
This will make it possible to store other data in Proxy/WasmGC shapes in the future.

Differential Revision: https://phabricator.services.mozilla.com/D164212
2022-12-13 10:58:29 +00:00
Jan de Mooij
1ff9a98f17 Bug 1803438 - Bump wasiRecursionDepthLimit to 350. r=arai
Based on some local testing, this should still be small enough to avoid hitting the
WASI runtime's stack limit.

Differential Revision: https://phabricator.services.mozilla.com/D164323
2022-12-09 15:05:51 +00:00
Ted Campbell
9c73cd619c Bug 1803495 - Support initializing SourceText from AutoStableStringChars. r=arai
These two are commonly used together in eval and testing functions so add an
overload and simplify the callers. This also allows transfering buffers in more
cases to avoid additional string copies. Currently only support the char16_t
overload, but in future should also support Utf8Unit overloads.

Differential Revision: https://phabricator.services.mozilla.com/D163552
2022-12-07 21:52:37 +00:00
Jon Coppeard
a6d8509270 Bug 1802897 - Part 5: Add methods to update the mark bitmap atomically r=sfink
The mark bitmap is represented using relaxed atomics. Currently we update this
using separate load and store operations where possible as this is more
efficient but this is only possible if there are no concurrent writes.

Parallel marking will perform concurrent writes to the marking bitmap so
requires updates to be performed atomically.

The patch adds methods that are correct in the face of multiple writes
(different threads won't stomp over each others' updates) however the
markIfUnmarkedAtomic method can return false positives. It works out faster
overall to allow this and tolerate multiple threads trying to mark the same
thing at the same time occasionally than to have the extra synchronisation
overhead of avoiding it.

Differential Revision: https://phabricator.services.mozilla.com/D163465
2022-12-07 12:58:51 +00:00
Jon Coppeard
641c66c5a4 Bug 1802897 - Part 1: Add a pref for parallel marking, disabled by default r=sfink
Differential Revision: https://phabricator.services.mozilla.com/D163461
2022-12-07 12:58:49 +00:00
Jon Coppeard
7856ea877c Bug 1804254 - Part 3: Replace RequestedModuleObject with native RequestedModule r=arai
This is more complicated because it needed a change to the public API now we're
not longer returning an array object. The new API is less error prone since
it's no longer possible for the caller to mutate the object returned.

Depends on D163948

Differential Revision: https://phabricator.services.mozilla.com/D163949
2022-12-07 11:28:28 +00:00
Cristian Tuns
58e3b12e8a Backed out 13 changesets (bug 1802897) for causing build bustages on Marking.cpp CLOSED TREE
Backed out changeset 61a336a6d2c9
Backed out changeset 5c3c2afd76af (bug 1802897)
Backed out changeset 1b2d9c4afee8 (bug 1802897)
Backed out changeset bf236f6a197c (bug 1802897)
Backed out changeset b3e82a32e13e (bug 1802897)
Backed out changeset 9fcff7ae8aac (bug 1802897)
Backed out changeset f21b54985888 (bug 1802897)
Backed out changeset d6c6eaa2508a (bug 1802897)
Backed out changeset ab00bd1ada69 (bug 1802897)
Backed out changeset f98def4568e6 (bug 1802897)
Backed out changeset 68880308ca96 (bug 1802897)
Backed out changeset 73ad67b6e4f6 (bug 1802897)
Backed out changeset 28c061eb2993 (bug 1802897)
2022-12-06 14:44:08 -05:00
Jon Coppeard
f381628593 Bug 1802897 - Part 5: Add methods to update the mark bitmap atomically r=sfink
The mark bitmap is represented using relaxed atomics. Currently we update this
using separate load and store operations where possible as this is more
efficient but this is only possible if there are no concurrent writes.

Parallel marking will perform concurrent writes to the marking bitmap so
requires updates to be performed atomically.

The patch adds methods that are correct in the face of multiple writes
(different threads won't stomp over each others' updates) however the
markIfUnmarkedAtomic method can return false positives. It works out faster
overall to allow this and tolerate multiple threads trying to mark the same
thing at the same time occasionally than to have the extra synchronisation
overhead of avoiding it.

Differential Revision: https://phabricator.services.mozilla.com/D163465
2022-12-06 18:19:29 +00:00
Jon Coppeard
0c7ec55801 Bug 1802897 - Part 1: Add a pref for parallel marking, disabled by default r=sfink
Differential Revision: https://phabricator.services.mozilla.com/D163461
2022-12-06 18:19:28 +00:00
Bryan Thrall
ad72c449bd Bug 1782573 - Verify JSContext is not used to alloc memory from helper threads r=nbp
The off-thread-inner-fcn.js test verifies that ParseContext is using
ErrorContext as AllocPolicy. It seems like a fragile test, so perhaps I should
convert it to a jsapi test.

TempAllocPolicy::assertNotJSContextOnHelperThread() needs to be defined in the
.cpp file because the header would have a circular dependency on JSContext.h if
it #included it. We do want to make sure it is inlined, though, to avoid the
extra function calls.

Differential Revision: https://phabricator.services.mozilla.com/D160697
2022-12-06 18:15:33 +00:00
Bryan Thrall
5bd8898a21 Bug 1782573 - Allow ErrorContext in TempAllocPolicy r=nbp
Reduce struct size by using a tagged pointer for the JSContext/ErrorContext
member, since they are mutually exclusive.

According to JS::PropertyKey, it is better to use XOR instead of `& ~JsContextTag`
because small immediates can be encoded more efficiently on some platorms.

Differential Revision: https://phabricator.services.mozilla.com/D160079
2022-12-06 18:15:29 +00:00