mirror of
https://github.com/servo/servo
synced 2026-04-28 10:27:40 +02:00
Auto merge of #13406 - Mylainos:issue-13377, r=jdm
Extract panic-catching for JS engine callbacks into a separate function
All of our generated code for script contains inline code like this:
```
let result = panic::catch_unwind(AssertUnwindSafe(|| {
...
};
match result {
Ok(result) => result,
Err(error) => {
store_panic_result(error);
return false;
}
}
```
This PR change it to something like this:
```
wrap_panic(|| { ... }, false)
```
---
- [X] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [X] These changes fix #13377
- [ ] There are tests for these changes
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13406)
<!-- Reviewable:end -->
This commit is contained in:
@@ -2383,16 +2383,8 @@ class CGAbstractMethod(CGThing):
|
||||
|
||||
if self.catchPanic:
|
||||
body = CGWrapper(CGIndenter(body),
|
||||
pre="let result = panic::catch_unwind(AssertUnwindSafe(|| {\n",
|
||||
post=("""}));
|
||||
match result {
|
||||
Ok(result) => result,
|
||||
Err(error) => {
|
||||
store_panic_result(error);
|
||||
return%s;
|
||||
}
|
||||
}
|
||||
""" % ("" if self.returnType == "void" else " false")))
|
||||
pre="return wrap_panic(|| {\n",
|
||||
post=("""}, %s);""" % ("()" if self.returnType == "void" else "false")))
|
||||
|
||||
return CGWrapper(CGIndenter(body),
|
||||
pre=self.definition_prologue(),
|
||||
@@ -5566,6 +5558,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
||||
'dom::bindings::utils::resolve_global',
|
||||
'dom::bindings::utils::set_dictionary_property',
|
||||
'dom::bindings::utils::trace_global',
|
||||
'dom::bindings::utils::wrap_panic',
|
||||
'dom::bindings::trace::JSTraceable',
|
||||
'dom::bindings::trace::RootedTraceable',
|
||||
'dom::bindings::callback::CallSetup',
|
||||
@@ -5617,14 +5610,12 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
||||
'libc',
|
||||
'util::prefs::PREFS',
|
||||
'script_runtime::maybe_take_panic_result',
|
||||
'script_runtime::store_panic_result',
|
||||
'std::borrow::ToOwned',
|
||||
'std::cmp',
|
||||
'std::mem',
|
||||
'std::num',
|
||||
'std::os',
|
||||
'std::panic',
|
||||
'std::panic::AssertUnwindSafe',
|
||||
'std::ptr',
|
||||
'std::str',
|
||||
'std::rc',
|
||||
|
||||
Reference in New Issue
Block a user