aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/genop.tab
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-11-28 07:28:25 +0100
committerBjörn Gustavsson <[email protected]>2018-01-22 14:23:52 +0100
commit9b0122b65bdcafbae2a3cfd3299903da0948acab (patch)
tree59405671dad4d8240978faaf4ea8e3dcdff289b5 /lib/compiler/src/genop.tab
parentb7ff9c0d76372f16d14ecaac04c6fbbbadaf9435 (diff)
downloadotp-9b0122b65bdcafbae2a3cfd3299903da0948acab.tar.gz
otp-9b0122b65bdcafbae2a3cfd3299903da0948acab.tar.bz2
otp-9b0122b65bdcafbae2a3cfd3299903da0948acab.zip
Don't build a stacktrace if it's only passed to erlang:raise/3
Consider the following function: function({function,Name,Arity,CLabel,Is0}, Lc0) -> try %% Optimize the code for the function. catch Class:Error:Stack -> io:format("Function: ~w/~w\n", [Name,Arity]), erlang:raise(Class, Error, Stack) end. The stacktrace is retrieved, but it is only used in the call to erlang:raise/3. There is no need to build a stacktrace in this function. We can avoid the building if we introduce an instruction called raw_raise/3 that works exactly like the erlang:raise/3 BIF except that its third argument must be a raw stacktrace.
Diffstat (limited to 'lib/compiler/src/genop.tab')
-rwxr-xr-xlib/compiler/src/genop.tab10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/compiler/src/genop.tab b/lib/compiler/src/genop.tab
index 397e478e1e..d59bb241a8 100755
--- a/lib/compiler/src/genop.tab
+++ b/lib/compiler/src/genop.tab
@@ -554,3 +554,13 @@ BEAM_FORMAT_NUMBER=0
## Do a garbage collection if necessary to allocate space on the heap
## for the result.
160: build_stacktrace/0
+
+## @spec raw_raise
+## @doc This instruction works like the erlang:raise/3 BIF, except that the
+## stacktrace in x(2) must be a raw stacktrace.
+## x(0) is the class of the exception (error, exit, or throw),
+## x(1) is the exception term, and x(2) is the raw stackframe.
+## If x(0) is not a valid class, the instruction will not throw an
+## exception, but store the atom 'badarg' in x(0) and execute the
+## next instruction.
+161: raw_raise/0