Commit graph

47 commits

Author SHA1 Message Date
Samson
450f8193a5
Use mozjs tracing infrastructure (#29918)
* Update mozjs

64711ec2e6 also fixes https://github.com/servo/servo/issues/30043

* Move to mozjs Traceable and introduce CustomTraceable
2023-08-10 21:46:06 +00:00
Samson
9514f670d1
No tracing of nop traceable fields (#29926)
* Add `no_trace` option to JSTraceable derive

* NoTrace wrapper

* Port some types to no_trace schematics

* Fixing my unsafe mistakes (not tracing traceables)

* Add docs & safety guards for no_trace

Safety guards (trait shenanigans) guarantees safety usage of `no_trace`

* Port canvas_traits to no_trace

* Port servo_media to no_trace

* Port net_traits to no_trace

* Port style to no_trace

* Port webgpu to no_trace

* Port script_traits to no_trace

* Port canvas_traits, devtools_traits, embedder_traits, profile_traits to no_trace

* unrooted_must_root lint in seperate file

* Add trace_in_no_trace_lint as script_plugin

* Composable types in must_not_have_traceable

* Introduced HashMapTracedValues wrapper

* `HashMap<NoTrace<K>,V>`->`HashMapTracedValues<K,V>`

* Port rest of servo's types to no_trace

* Port html5ever, euclid, mime and http to no_trace

* Port remaining externals to no_trace

* Port webxr and Arc<Mutex<_>>

* Fix spelling in notrace doc
2023-08-04 10:17:43 +00:00
Josh Matthews
9ea1399c30 Fix formatting. 2023-05-20 11:05:10 -04:00
Josh Matthews
fca5833e21 Remove global argument from Promise::new_in_current_realm. 2023-05-20 11:05:09 -04:00
Josh Matthews
f79e1e327d Make GlobalScope.get_cx a static method. 2023-05-20 11:05:09 -04:00
Josh Matthews
f76bb20c2e Format. 2022-11-23 10:04:53 -05:00
Josh Matthews
76edfce6a7 Trigger new module error reporting behaviour. 2022-11-23 10:04:52 -05:00
Josh Matthews
bd77a4043c Changes for spidermomkey upgrade. 2022-11-23 10:04:50 -05:00
Josh Matthews
7439401ff8
Don't hardcode string types. 2021-05-14 17:13:17 -04:00
sagudev
d8c398c457 fmt 2021-03-13 13:00:50 +01:00
sagudev
d424eaae91 Fix ModuleEvaluate 2021-03-13 12:56:41 +01:00
sagudev
a265a2a7e6 Formating 2021-03-12 18:30:13 +01:00
sagudev
425057c432 Fix errors 2021-03-12 16:26:27 +01:00
Josh Matthews
5c4939599e Update mozjs. 2021-02-18 09:35:45 -05:00
Sudarsan
4afe49d776 ran mach tidy 2020-08-28 21:01:09 +08:00
Sudarsan
f8c9ee4eff Update mozjs to 0.14.1
This update pulls in improvements on mozjs that now removes the need to
pass pointers to CompileOptionsWraper::new(), allows NewProxyObject to
now accept a Singleton bool and JSClass and removes an unsafe
Handle::new usage.
2020-08-28 20:54:18 +08:00
Arjun Ramachandrula
6014710538 Removed unnecessary conversion from UTF-8 to UTF-16 2020-07-27 21:45:20 -04:00
bors-servo
086556e706
Auto merge of #27026 - CYBAI:dynamic-module, r=jdm
Introduce dynamic module

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25439
- [x] There are tests for these changes
2020-07-19 09:29:50 -04:00
bors-servo
b63ce282aa
Auto merge of #27303 - camelid:async-to-asynch, r=jdm
Use `asynch` instead of `r#async`

<!-- Please describe your changes on the following line: -->
This is a vestige of the transition from 2015 to 2018 edition Rust.
`async` was added as a keyword in 2018 edition Rust, so `cargo fix`
changed the variable name here to `r#async`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because this is just an internal name change

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2020-07-17 22:51:12 -04:00
CYBAI
08723b0e37 Handle script private reference hooks properly 2020-07-18 00:43:35 +09:00
CYBAI
d1715918f0 Set private reference for classic script
Web developers can use `Dynamic Import` in a classic script; thus, we
need to save the script's private reference so that we can reuse it when
we're going to fetch a dynamic import module for a classic script.

Besides, because it's possible to use different executing context for a
dynamic import module (like `dynamic-import/string-compilation-other-document.html` WPT test),
we can't initialize a module owner at the timing of `SetScriptPrivate`;
thus, if the private module script doesn't hold an owner, we'll use a
DynamicImport owner for it.
2020-07-18 00:43:34 +09:00
Josh Matthews
1aef31bb2f checkpoint - dynamic load inside of a module and classic script works. 2020-07-18 00:43:34 +09:00
Camelid
a62a30ef83 Use asynch instead of r#async
This is a vestige of the transition from 2015 to 2018 edition Rust.
`async` was added as a keyword in 2018 edition Rust, so `cargo fix`
changed the variable name here to `r#async`.
2020-07-16 20:52:19 -07:00
Camelid
69881e8b06 Use Rc instead of cloning the DOMString
Specifically, I changed the `text` field of `ScriptOrigin` from a
`DOMString` to an `Rc<DOMString>`. Then I updated all the related code
to work with an `Rc`.

This is just a first pass to get the code to compile. There are probably
more things I can do that will improve the code and further reduce
cloning.
2020-07-14 20:34:01 -07:00
CYBAI
a7221fd74c Rollback to recursively check dependency status
In https://github.com/servo/servo/pull/26395/files#diff-3fe97584f564214ec8e7ebbf91747e03L253-R318,
we moved from `recursive checking` of dependency status to check only the
_current module_'s dependency status and its descendant dependency status and
also circular dependency status.

However, it will cause an issue.

For example, if the module dependency is like following

```
a -> b -> c -> d -> e
f -> g -> h -> c -> d -> e
```

In this example, if the d module is still under fetching but g is trying
to advance to finish. Then, it will cause a panic because module d is
g's grand-grand-grand-descendant which means it's still under fetching
and we can't instantiate module g.

Ideally, we should get rid of the checking in #26903 so, before #26903
fixed, we can just move back to the recursive checking way which will
ensure all descendants are not fetching.
2020-06-23 10:01:46 +09:00
Matthias Deiml
25080e3fa5 Use global.get_referrer() when appropiate 2020-06-17 22:08:06 +02:00
Matthias Deiml
fa18cf620f Make url for "client" referrer mandatory 2020-06-17 19:07:14 +02:00
CYBAI
dc2c2c8dfb Move away from Promise.all way and check if we need to finish manually
In the previous Promise.all way, we registered a promise for every
module script which means we will need to do many complex checkings like
"is this top level?" and it will make us much more difficult to understand
how the module script algorithm works.

In the new manual checking way, we will only register promises for top
level modules to notify its owner (e.g. the script element) to finish
the load. So, we can understand it much more easily and would be more
spec-aligned.

Also, I think the `Ready` and `FetchFailed` status are quite confusing
and we actually don't need them so they're removed in this patch. Then,
we will always go to `Finished` instead.

It would basically be following steps:

                                          +-----------------+
                                          | Failed to fetch | ----------+
+--------------+       +----------+     / +-----------------+           |
| Fetch module | ----> | Fetching | ---+                                v
+--------------+       +----------+     \ +---------+        +---------------------+
                                          | Fetched |        | Advance to Finished |
                                          +---------+        +---------------------+
                                               |                        ^
                                               v                        |
                                      +-------------------+             |
                                      | Fetch descendants | ----- if no descendants
                                      +-------------------+
                                               |
                                               V
                                     +----------------------+
                                     | Fetching Descendants |
                                     +----------------------+

In `Advance to Finished`, it means that module script is about to finished so it will

1. Notify all of its `ready` and `not finished` parents to finish
2. Link (instantiate) the module
3. Resolve its promise to notify owner(s) to finish
2020-06-13 11:11:25 +09:00
Gregory Terzian
48d4aec5b6 require entered realm, use aes, to append native promise handler 2020-06-04 11:38:37 +08:00
Gregory Terzian
bd5796c90b integrate readablestream with fetch and blob 2020-06-04 11:38:35 +08:00
CYBAI
6bc624001b Introduce import.meta hook for module script 2020-05-17 11:34:35 +09:00
Tipowol
8a3bf880e9 Add InRealm argument to Callback trait 2020-04-05 19:54:30 +02:00
CYBAI
018b23d43b Use mozjs exposed function to generate SourceText 2020-03-31 22:29:53 +09:00
Anthony Ramine
5a4f8cf93f Update SpiderMonkey 2020-03-06 11:13:28 +01:00
CYBAI
5245921c5c Use essence algorithm from mime crate 2020-03-02 11:05:10 +09:00
CYBAI
403ffcf1eb Always pass InRealm to GlobalScope::from_context to avoid getting null global 2020-02-16 09:55:10 +09:00
Kunal Mohan
5a3e1b8e69
rename compartment to realm 2020-01-24 20:52:36 +05:30
bors-servo
0b79fe377d
Auto merge of #25552 - CYBAI:fix-25436, r=jdm
Return the highest priority error from the descendant instead of return the very first one

The test failed because we didn't return the highest priority error (which is network error in this case).

As Manish mentioned in https://github.com/servo/servo/issues/25436#issuecomment-571065323, that's because we're using the Promise.all trick to signal loads.

If we can avoid relying on Promise.all, maybe we don't need to do a complex logic like this; instead, ideally, we should always finish the module load immediately when we hit network failure so that we don't even need to do the `max()` comparison.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25436
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2020-01-20 08:09:20 -05:00
CYBAI
33988cd8aa Return the highest priority error from the descendant instead of return the very first one 2020-01-20 19:18:12 +09:00
Kunal Mohan
f7db4b7f80
Modify script to prevent further violations of snake_case 2020-01-18 14:22:15 +05:30
Manish Goregaokar
508bfbd0da Fix module script MIME check to not include params
Also makes it error when there is no MIME type available.
2020-01-06 15:47:07 +05:30
Manish Goregaokar
be917ae9ef Upgrade module fail warning log to error 2020-01-06 15:46:59 +05:30
CYBAI
b8c6b55c98 Remove redundant checking of promise resolve and clone of URLs 2020-01-06 15:29:01 +08:00
Manish Goregaokar
9460b43f90 Use IndexSet for storing descendants
Fixes intermittent failures in `/html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html`
2020-01-06 12:24:58 +05:30
CYBAI
5c9536acdc Support module script credentials mode 2020-01-03 13:04:19 +09:00
CYBAI
cfad32cffd Support integrity for module script 2020-01-03 13:03:18 +09:00
CYBAI
f2007751dd Scaffold module script 2020-01-03 13:02:31 +09:00