Commit Graph

15 Commits

Author SHA1 Message Date
Martin Robinson
99daf8c644 script: Wrap remaining unsafe code and enable unsafe_op_in_unsafe_fn (#40499)
This is last step toward enabling the default rustc
`unsafe_op_in_unsafe_fn` warning for the script crate. It wraps the
remaining unsafe code in `unsafe {}` and removes the line disabling this
warning from `script`'s `Cargo.toml`. In addition, two variables are
renamed from `v` to something slightly more descriptive.

Testing: This should not change behavior so is covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 14:27:35 +00:00
WaterWhisperer
241bff962d Change some #[allow]s to #[expect]s (#40458)
Removes some unneeded lints.

Testing: Refactor
Part of: #40383

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-06 12:31:48 +00:00
Jonathan Schwender
889ffc9880 ohos: Fix JIT detection (#40130)
On recent versions of HarmonyOS the previous JIT detection does not
appear to work anymore, since the second `mmap` succeeds. This moves the
failure in spidermonkey to a later point, when SM remaps memory to be
writable. On recent versions of HOS I observed that the `PROT_WRITE`
permission was silently ignored by mprotect, which lead to a crash later
on the first attempt to write to the memory region.
It's not exactly easy to determine if one can write to a memory location
(if mprotect lies to you), but we can use `read` to check if the memory
region is writable (without triggering a segfault), since `read` will
return an error for invalid addresses (which is possible since the
writing is handled in the kernel).

Since this solution does add more unsafe code than before, we only use
this detection on OpenHarmony, although we could use it on more
platforms later if there are other platforms which also may have JIT
forbidden.

Testing: Removing the explicit `--pref js_disable_jit=true` means the
detection is tested in CI.
Fixes: #40029

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
Co-authored-by: Sam <16504129+sagudev@users.noreply.github.com>
2025-10-24 18:03:29 +00:00
Jonathan Schwender
9e8744eca0 Linux: Detect JIT support (#40071)
On some systems (specifically ohos / HarmonyOS) JIT may be forbidden,
which would cause spidermonkey to crash.
To avoid this, we test if JIT would work on startup, by remapping a page
to be executable and disabling JIT if it not allowed.
The runtime check is currently only implemented for linux, but similar
checks could easily be added for other platforms which also may have
similar restrictions.

Testing: TBD
Fixes: #40029

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-10-22 19:35:47 +00:00
Josh Matthews
d5d7b0d34f Make generated bindings generic over DOM types (#35169)
* bindings: Start making generated bindings methods generic over DOM trait.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* bindings: Make binding initialization generic over the DOM types trait.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* bindings: Start making proxyhandler code generic over DOM types.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-01-25 05:08:49 +00:00
Martin Robinson
0e616e0c5d api: Flatten and simplify Servo preferences (#34966)
Flatten and simplify Servo's preferences code. In addition, have both
preferences and options passed in as arguments to `Servo::new()` and
make sure not to use the globally set preferences in `servoshell` (as
much as possible now).

Instead of a complex procedural macro to generate preferences, just
expose a very simple derive macro that adds string based getters and
setters.

- All command-line parsing is moved to servoshell.
- There is no longer the concept of a missing preference.
- Preferences no longer have to be part of the resources bundle because
  they now have reasonable default values.
- servoshell specific preferences are no longer part of the preferences
  exposed by the Servo API.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-14 13:54:06 +00:00
Josh Matthews
3515b83a95 Create two-phase initialization for generated JS engine bindings (#34366)
* script: Generate a runtime initialization for static JS binding information.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Replace dummy static initializers with OnceLock.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Fix clippy warnings.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Only initialize statics for DOM interfaces with interface objects.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Remove one unnecessary Box::leak usage.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Tidy.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Hide thread-unsafe OnceLock usage inside of a wrapper type.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Mark ThreadUnsafeOnceLock::get unsafe.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Simplify ThreadUnsafeOnceLock internals.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-12-06 07:34:24 +00:00
Samson
873e82a532 Add js.disable_jit pref (#34231)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2024-11-13 06:50:30 +00:00
komuhangi
df457c43c8 Fixed some clippy warning by adding default implementations (#31989)
* Fixed some clippy warning by adding default implementations

* Updated PR that adds default implementation of structs

* Clean up and extend `Default` implementations

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-04-04 09:33:30 +00:00
Samson
aad2dccc9c Strict import formatting (grouping and granularity) (#30325)
* strict imports formatting

* Reformat all imports
2023-09-11 19:16:54 +00:00
Sean Joseph
9e22804983 Added is_platform_object_static check to is_dom_object 2020-11-26 18:40:41 -05:00
Sean Joseph
3c8680f273 Add back code to identify JSObjects that should be counted in memory profiling 2020-11-26 10:43:30 -05:00
Gregory Terzian
db217d5575 allow for a service worker manager per origin 2020-04-05 22:43:40 +08:00
Josh Matthews
7944d9548c script: Ensure JS engine is initialized and deinitialized on the same thread. 2019-11-26 21:54:33 -05:00
Simon Sapin
642b8b0415 Move items at the root of the script crate to a module 2019-10-26 12:59:17 +02:00