aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/icode/hipe_icode_primops.erl
AgeCommit message (Collapse)Author
2018-01-22Don't build a stacktrace if it's only passed to erlang:raise/3Björn Gustavsson
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.
2017-11-30Add syntax in try/catch to retrieve the stacktrace directlyBjörn Gustavsson
This commit adds a new syntax for retrieving the stacktrace without calling erlang:get_stacktrace/0. That allow us to deprecate erlang:get_stacktrace/0 and ultimately remove it. The problem with erlang:get_stacktrace/0 is that it can keep huge terms in a process for an indefinite time after an exception. The stacktrace can be huge after a 'function_clause' exception or a failed call to a BIF or operator, because the arguments for the call will be included in the stacktrace. For example: 1> catch abs(lists:seq(1, 1000)). {'EXIT',{badarg,[{erlang,abs, [[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20|...]], []}, {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]}, {erl_eval,expr,5,[{file,"erl_eval.erl"},{line,431}]}, {shell,exprs,7,[{file,"shell.erl"},{line,687}]}, {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]}, {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]}} 2> erlang:get_stacktrace(). [{erlang,abs, [[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22, 23,24|...]], []}, {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]}, {erl_eval,expr,5,[{file,"erl_eval.erl"},{line,431}]}, {shell,exprs,7,[{file,"shell.erl"},{line,687}]}, {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]}, {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}] 3> We can extend the syntax for clauses in try/catch to optionally bind the stacktrace to a variable. Here is an example using the current syntax: try Expr catch C:E -> Stk = erlang:get_stacktrace(), . . . In the new syntax, it would look like: try Expr catch C:E:Stk -> . . . Only a variable (not a pattern) is allowed in the stacktrace position, to discourage matching of the stacktrace. (Matching would also be expensive, because the raw format of the stacktrace would have to be converted to the cooked form before matching.) Note that: try Expr catch E -> . . . is a shorthand for: try Expr catch throw:E -> . . . If the stacktrace is to be retrieved for a throw, the 'throw:' prefix must be explicitly included: try Expr catch throw:E:Stk -> . . .
2017-11-16HiPE: Unique ref receive optMagnus Lång
2016-11-23Correct copyright on remaining hipe filesRichard Carlsson
2016-11-03Fix the native code translation of bs_match_stringKostis Sagonas
This fixes a HiPE bug reported on erlang-questions on 2/11/2016. The BEAM to ICode tranaslation of the bs_match_string instruction, written long ago for binaries (i.e., with byte-sized strings), tried to do a `clever' translation of even bit-sized strings using a HiPE primop that took a `Size' argument expressed in *bytes*. ICode is not really the place to do such a thing, and moreover there is really no reason for the HiPE primop not to take a Size argument expressed in *bits* instead. This commit changes the `Size' argument to be in bits, postpones the translation of the bs_match_string primop Fixed in a pair-programming/debugging session with @margnus1. until RTL and does a proper translation using bit-sized quantities there.
2016-03-15update copyright-yearHenrik Nord
2016-02-07Fix dialyzer warning and some code refactoringKostis Sagonas
A previous commit introduced a change that exposed dead code in this module and caused dialyzer warnings. This dead code was taken out. While at it, performed some code refactoring in the handling of the bs_get_integer primop.
2015-11-27hipe: Guard against enormous numbers in rangesMagnus Lång
This allows us to compile bs_match_int_SUITE with HiPE without a system_limit crash.
2015-11-27hipe: test unit size match in bs_put_binary_allMagnus Lång
The unit size field was previously completely discarded when lowering this instruction from BEAM to Icode. This feature was previously missing and expressions such as <<0, <<1:1>>/binary>> would succeed construction when compiled with HiPE.
2015-06-18Change license text to APLv2Bruce Yinhe
2012-02-09hipe,erts: Debug support for native call traceSverker Eriksson
2011-01-06Fix erroneous fail info of a hipe_bs_primopKostis Sagonas
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP