aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-10-06 08:52:32 +0200
committerBjörn Gustavsson <[email protected]>2017-10-09 19:20:55 +0200
commit4fe3f3b8be4825726fab6d4ea7515adf5b5df1ac (patch)
tree6b417bc151f9cb71e7ab1c9ebedbe17cfc358966 /erts/emulator/beam
parente38c688d3961bedcd85f842fd052836cb345a902 (diff)
downloadotp-4fe3f3b8be4825726fab6d4ea7515adf5b5df1ac.tar.gz
otp-4fe3f3b8be4825726fab6d4ea7515adf5b5df1ac.tar.bz2
otp-4fe3f3b8be4825726fab6d4ea7515adf5b5df1ac.zip
Slightly speed up try/catch
The try_end and try_case instructions are implemented the same way (try_case is translated to try_end by the loader). We can do better than that. We know that try_case will only be executed when an exception has been caught. Therefore, we know that x(0) is the non-value and that x(1) through x(3) need to be shifted down to x(0) through x(2). There is no need to test x(0) before shifting down. try_end does not need the register shifting code at all.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/instrs.tab18
-rw-r--r--erts/emulator/beam/ops.tab3
2 files changed, 12 insertions, 9 deletions
diff --git a/erts/emulator/beam/instrs.tab b/erts/emulator/beam/instrs.tab
index 07cc4bd527..20d356a81d 100644
--- a/erts/emulator/beam/instrs.tab
+++ b/erts/emulator/beam/instrs.tab
@@ -857,8 +857,7 @@ catch(Y, Fail) {
}
catch_end(Y) {
- c_p->catches--;
- make_blank($Y);
+ $try_end($Y);
if (is_non_value(r(0))) {
c_p->fvalue = NIL;
if (x(1) == am_throw) {
@@ -888,12 +887,15 @@ catch_end(Y) {
try_end(Y) {
c_p->catches--;
make_blank($Y);
- if (is_non_value(r(0))) {
- c_p->fvalue = NIL;
- r(0) = x(1);
- x(1) = x(2);
- x(2) = x(3);
- }
+}
+
+try_case(Y) {
+ $try_end($Y);
+ ASSERT(is_non_value(r(0)));
+ c_p->fvalue = NIL;
+ r(0) = x(1);
+ x(1) = x(2);
+ x(2) = x(3);
}
try_case_end(Src) {
diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab
index 4a915c7762..7a2c39b3a8 100644
--- a/erts/emulator/beam/ops.tab
+++ b/erts/emulator/beam/ops.tab
@@ -188,7 +188,8 @@ catch_end y
# Try/catch.
try Y F => catch Y F
-try_case Y => try_end Y
+
+try_case y
try_end y
%cold