aboutsummaryrefslogtreecommitdiffstats
path: root/erts
AgeCommit message (Collapse)Author
2017-10-01Add CHECK_ALIGNED() for testing storage destinationsBjörn Gustavsson
Add the CHECK_ALIGNED() macro that can be used for testing that the storage destination is word-aligned.
2017-10-01instrs.tab: Add missing -no_next directivesBjörn Gustavsson
2017-10-01beam_load.c: Generalize the 'P' operator in the packing engineBjörn Gustavsson
In the 'P' operator, don't assume that a packed target label ('f' or 'j') is always the leftmost argument. Instead, transfer the patch position from the accumulator to the stack.
2017-10-01Break out most of the initialization from process_main()Björn Gustavsson
process_main() is already too big.
2017-10-01Eliminate the OpCode() macroBjörn Gustavsson
Introduce the IsOpCode() macro that can be used to compare instructions.
2017-10-01Eliminate unnecessary and inconsistent castsBjörn Gustavsson
Consider the types in the code below: BeamInstr* I; . . . BeamInstr* next; next = (BeamInstr *) *I; Goto(next); This is illogical. If 'I' points to a BeamInstr, then 'next' should be a BeamInstr, not a pointer to a BeamInstr. The Goto() macros does not require a pointer, because it will cast its argument to a void* anyway. Therefore, this code example can be simplified to: BeamInstr* I; . . . BeamInstr next; next = *I; Goto(next); Similarly, we can remove the casts in the macros when NO_JUMP_TABLE is defined.
2017-10-01Refactor macros for accessing Beam instructionsBjörn Gustavsson
The BeamOp() macro in erl_vm.h is clumsy to use. All users cast the return value to BeamInstr. Define new macros that are easier to use. In the future, we might want to pack an operand into the same word as the pointer to the instruction, so we will define two macros. BeamIsOpCode() is used to rewrite code like this: if (Instr == (BeamInstr) BeamOp(op_i_func_info_IaaI) { ... } to: if (BeamIsOpCode(Instr, op_i_func_info_IaaI)) { ... } BeamOpCodeAddr(op_apply_bif) is used when we need the address for an instruction. Also elimiminate the global variables em_* in beam_emu.c. They are not really needed. Use the BeamOpCodeAddr() macro instead.
2017-10-01beam_emu: Make order of macros consistentBjörn Gustavsson
The inconsistent order has annoyed me for a long time. While at it, also remove the unecessary definition of LabelAddr() if NO_JUMP_TABLE is defined.
2017-10-01beam_SUITE: Strengthen test of packed registersBjörn Gustavsson
Test more instructions and use register numbers >= 512.
2017-09-28Eliminate MY_IS_SSMALL()Björn Gustavsson
For a long time, there has been the two macros IS_SSMALL() and MY_IS_SSMALL() that do exactly the same thing. There should only be one, and it should be called IS_SSMALL(). However, we must decide which implementation to use. When MY_IS_SSMALL() was introduced a long time ago, it was the most efficient. In a modern C compiler, there might not be any difference. To find out, I used the following small C program to examine the code generation: #include <stdio.h> typedef unsigned int Uint32; typedef unsigned long Uint64; typedef long Sint; #define SWORD_CONSTANT(Const) Const##L #define SMALL_BITS (64-4) #define MAX_SMALL ((SWORD_CONSTANT(1) << (SMALL_BITS-1))-1) #define MIN_SMALL (-(SWORD_CONSTANT(1) << (SMALL_BITS-1))) #define MY_IS_SSMALL32(x) (((Uint32) ((((x)) >> (SMALL_BITS-1)) + 1)) < 2) #define MY_IS_SSMALL64(x) (((Uint64) ((((x)) >> (SMALL_BITS-1)) + 1)) < 2) #define MY_IS_SSMALL(x) (sizeof(x) == sizeof(Uint32) ? MY_IS_SSMALL32(x) : MY_IS_SSMALL64(x)) #define IS_SSMALL(x) (((x) >= MIN_SMALL) && ((x) <= MAX_SMALL)) void original(Sint n) { if (IS_SSMALL(n)) { printf("yes\n"); } } void enhanced(Sint n) { if (MY_IS_SSMALL(n)) { printf("yes\n"); } } gcc 7.2 produced the following code for the original() function: .LC0: .string "yes" original(long): movabs rax, 576460752303423488 add rdi, rax movabs rax, 1152921504606846975 cmp rdi, rax jbe .L4 rep ret .L4: mov edi, OFFSET FLAT:.LC0 jmp puts clang 5.0.0 produced the following code which is slightly better: original(long): movabs rax, 576460752303423488 add rax, rdi shr rax, 60 jne .LBB0_1 mov edi, .Lstr jmp puts # TAILCALL .LBB0_1: ret .Lstr: .asciz "yes" However, in the context of beam_emu.c, clang could produce similar to what gcc produced. gcc 7.2 produced the following code when MY_IS_SSMALL() was used: .LC0: .string "yes" enhanced(long): sar rdi, 59 add rdi, 1 cmp rdi, 1 jbe .L4 rep ret .L4: mov edi, OFFSET FLAT:.LC0 jmp puts clang produced similar code. This code seems to be the cheapest. There are four instructions, and there is no loading of huge integer constants.
2017-09-27Merge branch 'lukas/erts/fix_threads_error_printout'Lukas Larsson
* lukas/erts/fix_threads_error_printout: erts: Print the error reason when threads fail to start
2017-09-27Merge branch 'kvakvs/zero-size-read_file/ERL-327/PR-1524/OTP-14637'Lukas Larsson
* kvakvs/zero-size-read_file/ERL-327/PR-1524/OTP-14637: erts: On zero-size files attempt to read until EOF
2017-09-27erts: On zero-size files attempt to read until EOFDmytro Lytovchenko
2017-09-26Merge branch 'maint'Henrik Nord
2017-09-25Merge pull request #1572 from gregors/update_docsRickard Green
fix off by one error in docs
2017-09-25Merge branch 'bjorn/speed-up-disassembler'Björn Gustavsson
* bjorn/speed-up-disassembler: Add testing of erts_debug:df() to the emulator smoke tests Speed up erts_debug:df()
2017-09-22Update release notesErlang/OTP
2017-09-22Update version numbersErlang/OTP
2017-09-22Merge branch 'maint'John Högberg
2017-09-22Correctly append sub-binaries in iolist_to_iovecJohn Högberg
The byte_offset of sub-binaries wasn't taken into account for ProcBins, subtly ruining the results. The test suite didn't catch it since it didn't check for sub-binaries in particular, and only checked for equality between variations -- not whether the output was equal to the input.
2017-09-22Add testing of erts_debug:df() to the emulator smoke testsBjörn Gustavsson
It is too easy to break the disassembler. Make sure that we notice.
2017-09-21erts: Print the error reason when threads fail to startLukas Larsson
2017-09-20erts, stdlib: Fix xmllint warningHans Bolinder
2017-09-18fix off by one error in docsGregory Ostermayr
2017-09-15Merge branch 'siri/string-new-api'Siri Hansen
* siri/string-new-api: (28 commits) hipe (test): Do not use deprecated functions in string(3) dialyzer (test): Do not use deprecated functions in string(3) eunit (test): Do not use deprecated functions in string(3) system (test): Do not use deprecated functions in string(3) system (test): Do not use deprecated functions in string(3) mnesia (test): Do not use deprecated functions in string(3) Deprecate old string functions observer: Do not use deprecated functions in string(3) common_test: Do not use deprecated functions in string(3) eldap: Do not use deprecated functions in string(3) et: Do not use deprecated functions in string(3) os_mon: Do not use deprecated functions in string(3) debugger: Do not use deprecated functions in string(3) runtime_tools: Do not use deprecated functions in string(3) asn1: Do not use deprecated functions in string(3) compiler: Do not use deprecated functions in string(3) sasl: Do not use deprecated functions in string(3) reltool: Do not use deprecated functions in string(3) kernel: Do not use deprecated functions in string(3) hipe: Do not use deprecated functions in string(3) ... Conflicts: lib/eunit/src/eunit_lib.erl lib/observer/src/crashdump_viewer.erl lib/reltool/src/reltool_target.erl
2017-09-15system (test): Do not use deprecated functions in string(3)Dan Gudmundsson
2017-09-15Merge branch 'maint'Sverker Eriksson
2017-09-15Merge branch 'sverker/on_load-on_load-bug/OTP-14612' into maintSverker Eriksson
* sverker/on_load-on_load-bug/OTP-14612: erts: Fix 'on_load' tracing bug for modules with -on_load code_SUITE:on_load_trace_on_load
2017-09-15Merge branch 'bjorn/erts/pack-combined'Björn Gustavsson
* bjorn/erts/pack-combined: Pack combined instructions beam_makeops: Refactor code generation Correct disassembly of select instructions
2017-09-15Merge branch 'maint'Björn Gustavsson
* maint: Document that the compiler may optimize away atoms
2017-09-15Merge pull request #1566 from bjorng/bjorn/erts/fix-existing-atom-doc/ERL-453Björn Gustavsson
Document that the compiler may optimize away atoms OTP-14614
2017-09-15Merge branch 'lukas/erts/remove-dirty-scheduler-defines/OTP-14613'Lukas Larsson
* lukas/erts/remove-dirty-scheduler-defines/OTP-14613: erts: Remove possibility to disable dirty schedulers
2017-09-14Merge branch 'maint'Péter Dimitrov
* maint: Updated OTP version Update release notes Update version numbers inets: httpd correct server_name environment value inets: httpd - Add chunk handling of client data inets: Restore old behavior when parsing "+" inets: prepare for release
2017-09-14Merge branch 'maint-20' into maintPéter Dimitrov
* maint-20: Updated OTP version Update release notes Update version numbers inets: httpd correct server_name environment value inets: httpd - Add chunk handling of client data inets: Restore old behavior when parsing "+" inets: prepare for release
2017-09-14Pack combined instructionsBjörn Gustavsson
2017-09-14beam_makeops: Refactor code generationBjörn Gustavsson
The refactoring will simplify packing of combined instructions.
2017-09-14Correct disassembly of select instructionsBjörn Gustavsson
Make sure to use the 'unpacked[-1]' when accessing the unpacked arguments.
2017-09-14Merge branch 'bjorn/erts/relative-jumps'Björn Gustavsson
* bjorn/erts/relative-jumps: Pack failure labels in i_select_val2 and i_select_tuple_arity2 Optimize i_select_tuple_arity2 and is_select_lins Rewrite select_val_bins so that its labels can be packed Pack sequences of trailing 'f' operands Implement packing of 'f' and 'j' Make sure that mask literals are 64 bits Use relative failure labels Add information about offset to common group start position Remove JUMP_OFFSET Refactor instructions to support relative jumps Introduce a new trace_jump/1 instruction for tracing Avoid using $Src more than once
2017-09-14Pack failure labels in i_select_val2 and i_select_tuple_arity2Björn Gustavsson
2017-09-14Optimize i_select_tuple_arity2 and is_select_linsBjörn Gustavsson
Don't save a pointer to the default failure label. That could relieve register pressure. Instead, if we'll need to signal an error in i_select_tuple_arity2, delay to the execution phase. That should be a clear win because i_select_tuple_arity2 very rarely fails because of the term being selected is not a tuple.
2017-09-14Rewrite select_val_bins so that its labels can be packedBjörn Gustavsson
2017-09-14Pack sequences of trailing 'f' operandsBjörn Gustavsson
Pack sequences of trailing 'f' operands for instructions such at jump_on_val or i_select_val_lins.
2017-09-14Implement packing of 'f' and 'j'Björn Gustavsson
2017-09-14Make sure that mask literals are 64 bitsBjörn Gustavsson
Use the "ull" suffix for the mask literals instead of "ul" to ensure that the literals are 64 bits also on Windows.
2017-09-14Use relative failure labelsBjörn Gustavsson
Relative failure in itself is not an optimization, but we plan to pack failure labels in the future to save memory.
2017-09-14Add information about offset to common group start positionBjörn Gustavsson
2017-09-14Remove JUMP_OFFSETBjörn Gustavsson
It has served its purpose.
2017-09-14Document that the compiler may optimize away atomsBjörn Gustavsson
The following code could fail in the call to list_existing_atom/1: String = atom_to_list(some_atom), Atom = list_to_existing_atom(String) because the compiler will rewrite the code to: String = "some_atom", Atom = list_to_existing_atom(String) If some_atom is not used in another place, it will not exist. The compiler could be updated to preserve the atom in this simple case, but it would be hard to make sure that the compiler never loses atoms that exist in the source text. It also difficult to imagine a real world use case where this would be a problem. If an atom is mentioned only in a way that the compiler can optimize away, is there really any need to create the atom at all in list_to_existing_atom/1? Therefore, it is better to place the responsibility that the atom exists on the user of list_to_existing_atom/1. Update the documentation to mention that the compiler may optimize away atoms. https://bugs.erlang.org/browse/ERL-453
2017-09-14Merge branch 'maint'Dan Gudmundsson
* maint: stdlib: Fix jumping to beginning or end of line Fix del_chars not considering wide chars and update buffer length before calling write_buf Make cp_pos_to_col function aware of the ANSI escape codes
2017-09-14Merge pull request #1549 from ggcampinho/fix-move-cursorDan Gudmundsson
Consider ANSI escape codes on cp_pos_to_col