aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/cerl
AgeCommit message (Collapse)Author
2016-09-05Implement the new ceil/1 and floor/1 guard BIFsBjörn Gustavsson
Implement as ceil/1 and floor/1 as new guard BIFs (essentially part of Erlang language). They are guard BIFs because trunc/1 is a guard BIF. It would be strange to have trunc/1 as a part of the language, but not ceil/1 and floor/1.
2016-08-31dialyzer: Optimize an opaque type caseHans Bolinder
Fix a mistake in commit 85f6fe3b. Instead of using the declared opaque type, the form's type is used in a case where the opaque type is turned into a non-opaque type. The result is more general types (smaller Erlang terms) and faster analyses.
2016-06-28erl_types: Normalise X:=none() pairs in t_map/3Magnus Lång
t_map/3 previously required callers to perform this normalisation, but as t_from_form/5 would sometimes fail to do so, this requirement is relaxed. Bug (ERL-177) reported and shrunk by Luke Imhoff.
2016-06-15hipe: Pattern matching compilation of binaries and bistringsKostis Sagonas
The Core Erlang pattern matching compiler was written long ago, at a time when binaries and bistrings did not really exist in Erlang. This patch, taken from the code of CutEr where it's used for more than a year now, extends the transformation for pattern matching compilation to also include binaries and bistrings. Some code that was found erroneous and causes errors when compiling the transformed code to native code was also taken out while at it. Thanks to @aggelgian for most of the changes in the code.
2016-06-10Merge branch 'hasse/dialyzer/improve_from_form/OTP-13547'Hans Bolinder
* hasse/dialyzer/improve_from_form/OTP-13547: Update primary bootstrap stdlib: Correct types and specs dialyzer: Minor adjustments dialyzer: Suppress unmatched_return for send/2 dialyzer: Improve the translation of forms to types dialyzer: Use a cache when translating forms to types dialyzer: Prepare erl_types:t_from_form() for a cache dialyzer: Optimize erl_types:t_form_form() dialyzer: Correct types syntax_tools: Correct types erts: Correct character repr in doc of the abstract format stdlib: Correct types and specs
2016-06-09Remove support for '...' in Maps typesHans Bolinder
It is possible that '...' is added later (OTP 20.0), but for now we are not sure of all details.
2016-06-09dialyzer: Improve the translation of forms to typesHans Bolinder
Spend less of the limited resources on recursive types.
2016-06-09dialyzer: Use a cache when translating forms to typesHans Bolinder
2016-06-09dialyzer: Prepare erl_types:t_from_form() for a cacheHans Bolinder
No change of functionality.
2016-06-09dialyzer: Optimize erl_types:t_form_form()Hans Bolinder
When the translation from forms to types exceeds some limit, it is faster to try small depths first.
2016-06-09dialyzer: Correct typesHans Bolinder
2016-05-31Fix name of compiler option and the related warningsKostis Sagonas
2016-05-30Reintroduce erlang:halt/0/1 in erl_bif_types.erlSverker Eriksson
Removed in f9cb80861f169743 when changed impl from C to Erlang. But seems they are needed to keep dialyzer tests happy. Also improved bif_SUITE:shadow_comments to include all exported in module erlang, not just the "snifs". ...which detected that apply/2 was missing Shadowed comment as well.
2016-05-25erts: Implement halt/0 and halt/1 in ErlangSverker Eriksson
just to make things simpler.
2016-05-04Declare the erl_types:var_table() type as opaqueKostis Sagonas
and do the following changes: in erl_types: export the type and an appropriate constructor for it in dialyzer_contracts: perform all necessary code modifications to fix all dialyzer warnings Although no warnings are reported by dialyzer, it's quite possible that these are not the only places where the opacity of the var_table() data structure is violated. But I decided to leave these places for a better version of dialyzer to discover...
2016-05-04hipe: Use maps for unification and substitutionHans Bolinder
2016-05-04dialyzer: Use maps instead of dictHans Bolinder
Optimization: A few dictionaries are maps instead of dicts.
2016-04-29dialyzer: Fix a bug in the translation of forms to typesHans Bolinder
A bug is fixed, but there are more problems. Modify erl_types.erl like this: -define(EXPAND_LIMIT, 500). and bogus warnings are output (again). Callbacks and specs are compared (subtype) in dialyzer_behaviour. If they are expanded to different depths, then invalid warnings can be generated.
2016-04-28erl_types: Don't consider opaque keys singletonMagnus Lång
Opaque singleton keys have the unfortunate property, unlike any other singleton type, to overlap with other singleton types that do not have the same internal representation. Therefore, we must not keep opaque singletons in the Pairs list in a map type.
2016-04-28erl_types: Fix t_subtract/2 correctness bugMagnus Lång
t_subtract/2 would break its postcondition by always returning the underapproximation none() when given a variable on the right hand side. This broke map type parsing, since it relied on t_subtract/2 to tell it when map keys would shadow each other.
2016-04-28erl_types: Fix crash merging maps with opaque keysMagnus Lång
Opaque keys in maps broke an assumption in erl_types:mapmerge_otherv/3 (that the infinimum of a singleton type and some other type would either be none() or that same singleton type), causing a case_clause crash.
2016-04-28erl_bif_types: Add a selection of maps BIFsMagnus Lång
* maps:from_list/1 * maps:get/2 * maps:is_key/2 * maps:merge/2 * maps:put/3 * maps:size/1 * maps:to_list/1 * maps:update/3
2016-04-28erl_types: Add a map type representationMagnus Lång
The type of a map is represented as a three-tuple {Pairs, DefaultKey, DefaultValue}. DefaultKey and DefaultValue are types. Pairs is a list of three-tuples {Key, mandatory | optional, Value}, where Key and Value are types. All types Key must be singleton, or "known at compile time," as the EEP put it. Examples: #{integer()=>list()} {[], integer(), list()} #{a=>char(), b=>atom()} {[{a, optional, char()}, {b, optional, atom()}], none(), none()} map() {[], any(), any()} A more formal description of the representation and its invariants can be found in erl_types.erl Special thanks to Daniel S. McCain (@dsmccain) that co-authored a very early version of this with me back in April 2014, although only the singleton type logic remains from that version.
2016-03-15update copyright-yearHenrik Nord
2016-02-10Merge branch 'maint'Hans Bolinder
* maint: dialyzer: Correct byte_size() and comparisons Conflicts: lib/hipe/cerl/erl_bif_types.erl
2016-02-09dialyzer: Correct byte_size() and comparisonsHans Bolinder
The argument of byte_size() is a bitstring(). The code in erl_bif_types that finds cases where comparisons always return true or false is corrected when it comes to maps and bit strings.
2016-02-02Merge branch 'maint'Zandra
Conflicts: erts/emulator/beam/beam_emu.c
2016-02-02Merge branch 'margnus1/bs_unit_fix' into maintZandra
* margnus1/bs_unit_fix: hipe: Fix signed compares of unsigned sizes beam: Fix overflow bug in i_bs_add_jId hipe: Add tests for bad bit syntax float sizes Add a case testing the handling of guards involving binaries Add some more binary syntax construction tests hipe: Guard against enormous numbers in ranges hipe: Fix constructing huge binaries hipe: Fix binary constructions failing with badarith Add missing corner-case to bs_construct_SUITE hipe: Allow unsigned args in hipe_rtl_arith hipe: test unit size match in bs_put_binary_all hipe: test unit size match in bs_append Fix hipe_rtl_binary_construct:floorlog2/1 OTP-13272
2016-02-01dialyzer: Remove t_parameterized_module/0 from erl_typesStavros Aronis
Parameterized modules are no longer supported, so module() can only be an atom().
2016-01-26Refactor usage of opaques() typeLuca Favatella
2016-01-20hipe: Improve typesHans Bolinder
2016-01-18Merge branch 'maint'Björn-Egil Dahlberg
2016-01-18Merge branch 'egil/improve-map-cerl-prettypr/OTP-13238' into maintBjörn-Egil Dahlberg
* egil/improve-map-cerl-prettypr/OTP-13238: compiler, hipe: Fix pretty printing of Core Maps hipe: Fix map pretty printing of pairs dialyzer: Update Maps tests
2016-01-15Merge branch 'maint'Hans Bolinder
* maint: dialyzer: Correct handling of parameters of opaque types
2016-01-15dialyzer: Correct handling of parameters of opaque typesHans Bolinder
Correction of commit d57f5e.
2016-01-14compiler, hipe: Fix pretty printing of Core MapsBjörn-Egil Dahlberg
Literal maps could cause dialyzer to crash when pretty printing the results. Reported-by: Chris McGrath <[email protected]>
2016-01-14hipe: Fix map pretty printing of pairsBjörn-Egil Dahlberg
In commit f667931e2905797ffab63e224e56eaf07f77178a the core format changed for map pairs. Let dialyzer and hipe pretty printing of maps also adhere to those changes. An Erlang map update, M#{foo := 1, bar => 2} will now be printed as: ~{ 'foo' := 1, 'bar' => 2 | M }~
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-11-16Merge branch 'lucafavatella/dialyzer-remote-type'Henrik Nord
* lucafavatella/dialyzer-remote-type: Delete remote types-related dead code in erl_types OTP-13104
2015-10-30hipe/dialyzer: Remove functions from erl_bif_typesHans Bolinder
2015-10-27Merge branch 'maint'Henrik Nord
2015-10-27Merge branch 'lucafavatella/dialyzer-fun-literal-arity' into maintHenrik Nord
* lucafavatella/dialyzer-fun-literal-arity: Teach Dialyzer arity of funs with literal arity OTP-13068
2015-10-18Delete remote types-related dead code in erl_typesLuca Favatella
Code became dead in 854ee8b.
2015-10-09Update and cleanup HiPE recordsKostis Sagonas
The bulk of the changes concerns cleanups and code refactorings concerning record constructions that assigned 'undefined' to record fields whose type did not contain this value. See commit 8ce35b2. While at it, some new type definitions were introduced and type names were used instead of record type notation. Minor code cleaups were also done.
2015-10-08Take out automatic insertion of 'undefined' from typed record fieldsKostis Sagonas
Background ----------- In record fields with a type declaration but without an initializer, the Erlang parser inserted automatically the singleton type 'undefined' to the list of declared types, if that value was not present there. I.e. the record declaration: -record(rec, {f1 :: float(), f2 = 42 :: integer(), f3 :: some_mod:some_typ()}). was translated by the parser to: -record(rec, {f1 :: float() | 'undefined', f2 = 42 :: integer(), f3 :: some_mod:some_typ() | 'undefined'}). The rationale for this was that creation of a "dummy" #rec{} record should not result in a warning from dialyzer that e.g. the implicit initialization of the #rec.f1 field violates its type declaration. Problems --------- This seemingly innocent action has some unforeseen consequences. For starters, there is no way for programmers to declare that e.g. only floats make sense for the f1 field of #rec{} records when there is no `obvious' default initializer for this field. (This also affects tools like PropEr that use these declarations produced by the Erlang parser to generate random instances of records for testing purposes.) It also means that dialyzer does not warn if e.g. an is_atom/1 test or something more exotic like an atom_to_list/1 call is performed on the value of the f1 field. Similarly, there is no way to extend dialyzer to warn if it finds record constructions where f1 is not initialized to some float. Last but not least, it is semantically problematic when the type of the field is an opaque type: creating a union of an opaque and a structured type is very problematic for analysis because it fundamentally breaks the opacity of the term at that point. Change ------- To solve these problems the parser will not automatically insert the 'undefined' value anymore; instead the user has the option to choose the places where this value makes sense (for the field) and where it does not and insert the | 'undefined' there manually. Consequences of this change ---------------------------- This change means that dialyzer will issue a warning for all places where records with uninitialized fields are created and those fields have a declared type that is incompatible with 'undefined' (e.g. float()). This warning can be suppressed easily by adding | 'undefined' to the type of this field. This also adds documentation that the user really intends to create records where this field is uninitialized.
2015-09-09Merge branch 'maint'Hans Bolinder
* maint: dialyzer: Correct the handling of parameters of opaque types
2015-09-09dialyzer: Correct the handling of parameters of opaque typesHans Bolinder
Prior to this commit, the fact that parameters of opaque types are expanded differently depending on the current values of limits used during expansion, caused problems later when the types of parameters are used for determining if opaque types are comparable.
2015-09-07Merge branch 'maint'Hans Bolinder
* maint: dialyzer: Fix erlang:abs/1
2015-09-04dialyzer: Fix erlang:abs/1Hans Bolinder
Fix the range type of erlang:abs/1.
2015-08-25Merge branch 'maint'Hans Bolinder
* maint: dialyzer: Correct the timing of the phase called 'remote' dialyzer: Optimize expansion of parameters of opaque types dialyzer: Optimize the expansion of parameterized types somewhat dialyzer: Improve the handling of recursive parameterized opaque types dialyzer: Generalize an argument of erl_types:t_from_form()