• Tobias Tebbi's avatar
    [torque] add union types · bf9d2893
    Tobias Tebbi authored
    This adds support for union types to Torque.
    
    There is a new type expression
    A | B
    to form the union of the type expressions A and B.
    This is only possible if A and B have a common supertype, to prevent
    nonsensical unions of types with different representations.
    
    Union types are normalized:
    A | B == B | A
    A | (B | C) == (A | B) | C
    A | A == A
    
    The subtyping rules are defined recursively:
    (A | B) <: C  if  A <: C and B <: C
    A <: (B | C)  if  A <: B or A <: C
    
    This allows to define Object as a union type:
    
    type Tagged generates 'TNode<Object>';
    type Smi extends Tagged generates 'TNode<Smi>';
    type HeapObject extends Tagged generates 'TNode<HeapObject>';
    type Object = Smi | HeapObject;
    
    The type {Tagged} is introduced to have a common supertype of all
    tagged values, but we should not use it directly, because {Object}
    contains the additional information that there is nothing but {Smi}
    and {HeapObject} values.
    
    When mapping union types to CSA types, we select the most specific
    common supertype. For Number and Numeric, we already use union types
    on the CSA side. Since it is not possible to map to CSA union types
    in general, we special-case these two union types to map them to
    the CSA union types we already use.
    
    Bug: v8:7793
    Change-Id: I7a4e466436f55d04012f29ef17acfdb957653908
    Reviewed-on: https://chromium-review.googlesource.com/1076132Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
    Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#53411}
    bf9d2893
Name
Last commit
Last update
benchmarks Loading commit data...
build_overrides Loading commit data...
docs Loading commit data...
gni Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.editorconfig Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.vpython Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...