Age | Commit message (Collapse) | Author | |
---|---|---|---|
2017-11-30 | Add syntax in try/catch to retrieve the stacktrace directly | Bjö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-10-21 | Optimize instructions for comparing a register with a literal | Björn Gustavsson | |
We can avoid calling eq() from the is_eq_exact_literal/3 and is_ne_exact_literal/3 instructions if the source operand is an immediate (since a literal is either a boxed or a list, never an immediate). | |||
2017-10-09 | Slightly speed up try/catch | Björn Gustavsson | |
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. | |||
2017-10-01 | Move out variables from the head of combined instructions | Björn Gustavsson | |
Move out from the head the variables that are only used in the excute phase. | |||
2017-10-01 | instrs.tab: Add missing -no_next directives | Björn Gustavsson | |
2017-09-13 | Refactor instructions to support relative jumps | Björn Gustavsson | |
Introduce new macros that can be used for relative jumps and use them consistently. Test that everything works by using a non-zero constant JUMP_OFFSET. The loader subtracts JUMP_OFFSET from loaded labels, and all instructions that use 'f' operands add it back. | |||
2017-09-11 | Avoid using $Src more than once | Björn Gustavsson | |
The C compiler will probably optimize this, but just to be sure... | |||
2017-09-04 | Don't allow macros to assign to hard-coded variables | Björn Gustavsson | |
It's bad style. Pass the name of the variable as an extra argument to the macro. | |||
2017-09-04 | Eliminate unecessary instruction macro i_move_call_only() | Björn Gustavsson | |
2017-08-31 | Add missing -no_next directives | Björn Gustavsson | |
2017-08-31 | Eliminate three arguments for the apply() helper | Björn Gustavsson | |
We don't need to pass x(0), x(1), and x(2) because they can already be found in the register array. | |||
2017-08-31 | Add annotations for likely/unlikely | Björn Gustavsson | |
In a correct Erlang programs, we can expect that: * A GC test instruction (such as test_heap) is more likely not to do the GC. * A BIF is more likely to succeed than to fail. * A BIF is more likely to fail in a guard than in a body. * An apply or fun call is likely to succeed. Annotate conditions accordingly. | |||
2017-08-22 | Add missing -no_next for badarg instruction | Björn Gustavsson | |
2017-08-11 | Break out most instructions from beam_emu.c | Björn Gustavsson | |
2017-08-08 | Simplify specifying implementation of instructions | Björn Gustavsson | |
Eliminate the need to write pre-processor macros for each instruction. Instead allow the implementation of instruction to be written in C directly in the .tab files. Rewrite all existing macros in this way and remove the %macro directive. |