Skip to content

Commit

Permalink
Optimize catch handling (#10519)
Browse files Browse the repository at this point in the history
* don't auto-wrap with ValueException if platform can throw anything

* fixed lua & js

* oops

* fix catching ValueException for optimized targets
  • Loading branch information
RealyUniqueName committed Dec 2, 2021
1 parent 2810be1 commit fb52486
Show file tree
Hide file tree
Showing 2 changed files with 273 additions and 135 deletions.
21 changes: 12 additions & 9 deletions src/context/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ type exceptions_config = {
ec_native_throws : path list;
(* Base types which may be caught from Haxe code without wrapping. *)
ec_native_catches : path list;
(*
Hint exceptions filter to avoid wrapping for targets, which can throw/catch any type
Ignored on targets with a specific native base type for exceptions.
*)
ec_avoid_wrapping : bool;
(* Path of a native class or interface, which can be used for wildcard catches. *)
ec_wildcard_catch : path;
(*
Expand Down Expand Up @@ -467,6 +472,7 @@ let default_config =
ec_native_catches = [];
ec_wildcard_catch = (["StdTypes"],"Dynamic");
ec_base_throw = (["StdTypes"],"Dynamic");
ec_avoid_wrapping = true;
ec_special_throw = fun _ -> false;
};
pf_scoping = {
Expand Down Expand Up @@ -495,6 +501,8 @@ let get_config com =
["js";"lib"],"Error";
["haxe"],"Exception";
];
ec_native_catches = [];
ec_avoid_wrapping = false;
};
pf_scoping = {
vs_scope = if es6 then BlockScope else FunctionScope;
Expand All @@ -510,6 +518,9 @@ let get_config com =
pf_capture_policy = CPLoopVars;
pf_uses_utf16 = false;
pf_supports_rest_args = true;
pf_exceptions = { default_config.pf_exceptions with
ec_avoid_wrapping = false;
}
}
| Neko ->
{
Expand Down Expand Up @@ -590,7 +601,7 @@ let get_config com =
pf_supports_threads = true;
pf_supports_rest_args = true;
pf_this_before_super = false;
pf_exceptions = {
pf_exceptions = { default_config.pf_exceptions with
ec_native_throws = [
["cs";"system"],"Exception";
["haxe"],"Exception";
Expand Down Expand Up @@ -667,14 +678,6 @@ let get_config com =
pf_capture_policy = CPWrapRef;
pf_pad_nulls = true;
pf_supports_threads = true;
pf_exceptions = { default_config.pf_exceptions with
ec_native_throws = [
["haxe"],"Exception";
];
ec_native_catches = [
["haxe"],"Exception";
];
}
}
| Eval ->
{
Expand Down

0 comments on commit fb52486

Please sign in to comment.