1. 12 Jun, 2018 1 commit
    • Daniel Clifford's avatar
      [torque] Turn implicit converts/unsafe_casts into generics · bbbfd81c
      Daniel Clifford authored
      In the process:
        - Add strict ordering of Types so that name mangling is consistent
          and build time. Previously, the UnionType stored the union's
          types in a std::set<const Type*>, which did not have a consistent
          ordering of the types in the set.
        - Add a int31 type to enable consistency and correctness of
          handling of 'constexpr int31' values on the C++ side.
        - By removing the "implicit" keyword for operators, there is now
          one less difference between operators and calls, another
          incremental step in unifying operators and calls.
        - Enable external (i.e. C++-defined) generic specializations
        - Add CSA support for checking double ElementsKinds, including
          tests.
        - Clean up some constexpr/non-constexpr handling of ElementsKinds.
      
      Bug: v8:7793
      Change-Id: I27699aba70b98ebf5466e5b62b045d7b1dad62c8
      Reviewed-on: https://chromium-review.googlesource.com/1091155
      Commit-Queue: Daniel Clifford <danno@chromium.org>
      Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53664}
      bbbfd81c
  2. 07 Jun, 2018 1 commit
  3. 06 Jun, 2018 1 commit
    • Daniel Clifford's avatar
      [torque] Implement parameter overloading in generics · 06f2a5c2
      Daniel Clifford authored
      This allows redifinitions of generics with the same name but differing parameter
      type lists, e.g.
      
        macro coerce<Dest: type>(from: HeapObject): Dest;
        coerce<int32>(from: HeapObject): int32 {...}
        macro coerce<Dest: type>(from: Smi): Dest;
        coerce<int32>(from: Smi): int32 {...}
      
      In order to allow multiple overloads of generic macros with the same name,
      a more nuanced lookup of calls has been implemented using the
      ParameterDifference utility class. There is still work to be done to unify
      when ParameterDifference is used for lookup (e.g. removing it from operator
      lookup when operators become simple aliases for macro names), but that work
      will be done in a separate CL.
      
      As part of this CL, the custom handling of "cast<>" operator in the .g4
      grammar has been removed and replaced by a handful of equivalent overloads of
      a generic "cast" macro.
      
      Bug: v8:7793
      Change-Id: Ibb2cdd3d58632b7f7f7ba683499f9688ae07f4f8
      Reviewed-on: https://chromium-review.googlesource.com/1087873
      Commit-Queue: Daniel Clifford <danno@chromium.org>
      Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53562}
      06f2a5c2
  4. 05 Jun, 2018 2 commits
  5. 04 Jun, 2018 2 commits
    • Daniel Clifford's avatar
      [torque] Remove try/catch (only support try/label) · 675c1de5
      Daniel Clifford authored
      In the process, also fix the make-torque-parser.py script to work in its new
      location.
      
      Bug: v8:7793
      Change-Id: I376a5f73ec9f7cc87995928397c6e399b1a490d8
      Reviewed-on: https://chromium-review.googlesource.com/1084838
      Commit-Queue: Daniel Clifford <danno@chromium.org>
      Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53504}
      675c1de5
    • Tobias Tebbi's avatar
      [torque] resolve operator overloads correctly · 0c62c81d
      Tobias Tebbi authored
      This implements a reasonable overload resolution strategy for operators:
      
      An overload is selected if it is strictly better than all alternatives.
      This means that it has to be strictly better in at least one parameter,
      and better or equally good in all others.
      
      When comparing a pair of corresponding parameters of two overloads...
      ... they are considered equally good if:
          - They are equal.
          - Both require some implicit conversion.
      ... one is considered better if:
          - It is a strict subtype of the other.
          - It doesn't require an implicit conversion, while the other does.
      
      If no overload is strictly better than all alternatives, this results
      in a compile error.
      
      Bug: v8:7793
      Change-Id: I8c7aadce5799ef0f854887b039e94c9c0363816d
      Reviewed-on: https://chromium-review.googlesource.com/1076292
      Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
      Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53492}
      0c62c81d
  6. 30 May, 2018 1 commit
  7. 29 May, 2018 4 commits
    • Simon Zünd's avatar
      [torque] Add unsafe cast to Torque. · 9ef4df2f
      Simon Zünd authored
      This CL is a proposal to add "checked" casts (CAST in CSA) to the Torque language.
      The CL adds the "unsafe_cast<>" operator that emits a "CAST".
      
      Example:
      
      let n: Number = ...;
      ...
      if (TaggedIsSmi(n)) {
        let m: Smi = unsafe_cast<Smi>(n);
        ...
      }
      
      The cast wont incur a runtime overhead now.
      
      R=tebbi@chromium.org
      
      Change-Id: I9fca90d1d11e61617ba0270e5022fd66200e2195
      Reviewed-on: https://chromium-review.googlesource.com/1070151
      Commit-Queue: Simon Zünd <szuend@google.com>
      Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53416}
      9ef4df2f
    • 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
    • Tobias Tebbi's avatar
      [cleanup] improve types in base.tq and use LoadTypedArrayLength everywhere · 54f77c42
      Tobias Tebbi authored
      Bug: v8:7754
      Change-Id: I8548d0e07fabc23bb5f65b1f91683c756195ae1b
      Reviewed-on: https://chromium-review.googlesource.com/1071654Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
      Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
      Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53398}
      54f77c42
    • Tobias Tebbi's avatar
      [torque] require exact match in return type for cast-like operations · 506d49fb
      Tobias Tebbi authored
      This fixes the bug that cast<A>(...) could be interpreted as
      cast<B>(...) if B is a subtype of A.
      
      Bug: v8:7793
      
      Change-Id: Ia03ce832f8c14ced09114d41c935be06d4629d99
      Reviewed-on: https://chromium-review.googlesource.com/1075890
      Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
      Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53397}
      506d49fb
  8. 25 May, 2018 1 commit
  9. 24 May, 2018 2 commits
  10. 23 May, 2018 2 commits
  11. 22 May, 2018 4 commits
  12. 18 May, 2018 2 commits
  13. 17 May, 2018 1 commit
  14. 16 May, 2018 3 commits
  15. 15 May, 2018 1 commit
  16. 13 May, 2018 2 commits
  17. 08 May, 2018 1 commit
  18. 07 May, 2018 1 commit
    • Daniel Clifford's avatar
      [torque] 'bool' is now 'true|false' not 'yes|no' · dd5cdcee
      Daniel Clifford authored
      In the process, rename Boolean constants (i.e. JavaScript constants),
      to 'True' and 'False'. This uncovered a bug in the internal handling
      of True/False labels was fixed (they shouldn't be Values and Torque
      shouldn't conflate Labels with other Declarables, throwing exceptions
      when they're improperly used in the wrong context). Furthermore,
      the internal labels used for True and False for if statements
      have been renamed so that they can't be aliased from user Torque code.
      
      Change-Id: I09dbd2241d2bc2f1daff53862dee1b601810060c
      Reviewed-on: https://chromium-review.googlesource.com/1044370Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
      Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53026}
      dd5cdcee
  19. 04 May, 2018 4 commits
    • Daniel Clifford's avatar
      [torque]: Add constexpr keyword/types for compile-time evaluation · aeb86d57
      Daniel Clifford authored
      Torque expressions of type constexpr are evaluated at compile-time
      rather than runtime. They are backed by C++ types rather than
      TNode<X> types, so the macro functions that are called by generated
      C++ code expect values to be computed when the snapshot is generated
      rather than by TurboFan-generated code.
      
      Specifically, "if" statements can have a constexpr modifier. With this
      modifier, a type of "constexpr bool" is expected rather than "bool",
      and in that case instead of generating a CSA BranchIf, it generates
      a C++ "if (<bool expression>)" that generates code for only the true or
      false path based on the bool value at torque-execution (compile time)
      rather than generating both paths (including inserting phi nodes
      for variables modified on either branch at the re-merge at the end
      of the if) and dynamically dispatching to the true or false path
      during d8/Chrome/node.js execution (runtime) using a CSA BranchIf.
      
      Change-Id: I8238e25aaadbfc618847e04556e96a3949ea5a8d
      Reviewed-on: https://chromium-review.googlesource.com/1042085
      Commit-Queue: Daniel Clifford <danno@chromium.org>
      Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#53001}
      aeb86d57
    • Daniel Clifford's avatar
      [torque]: Fix bugs reported by Peter Wong · be9b5f4c
      Daniel Clifford authored
      * Empty string literals (e.g. "" and '') were not recognized a strings. This is
        now fixed.
      * return statements without expressions (e.g. for functions with void return
        types) caused crashes.
      
      Change-Id: Ied60f9abffca457a0d85c9e01e3795839fe777c9
      Reviewed-on: https://chromium-review.googlesource.com/1042310
      Commit-Queue: Daniel Clifford <danno@chromium.org>
      Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#52997}
      be9b5f4c
    • Clemens Hammacher's avatar
      [base] Move implicit_cast to macros.h · 1a6cf58b
      Clemens Hammacher authored
      macros.h already not only defines macros, but also templatized helpers
      like {bit_cast} and {arraysize}. Thus {implicit_cast} also belongs
      there.
      
      R=tebbi@chromium.org
      
      Bug: v8:7570
      Change-Id: Iaea6075dad359d62498453575f22d73ca84e2323
      Reviewed-on: https://chromium-review.googlesource.com/1042401
      Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
      Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#52991}
      1a6cf58b
    • Daniel Clifford's avatar
      [Torque]: add assert(), unreachable and debug statements · 9cd8995f
      Daniel Clifford authored
      - In debug builds, 'assert(<expr>)' evaluates and aborts execution
        if the provided Torque expression is false at runtime.
        assert(<expr>) supports the same set of expressions protocols
        as Toruqe's if statement, i.e. both bool values and BranchIf-
        style tests. Upon failure, the assertion prints the Torque
        source code of the failed expression, not the generated CSA
        code.
      - 'unreachable' calls CSA's Unreachable() and signals to Torque
        that code execution cannot continue (i.e. its statement
        returns the 'never' type). In debug builds, the line number
        and position of the statement are printed before breaking.
      - 'debug' calls CSA's DebugBreak(). In debug builds, the line
        number and position of the 'debug' are printed before breaking.
      
      Change-Id: I4efd052536bb402c097a0d5f7be56e154b5b3676
      Reviewed-on: https://chromium-review.googlesource.com/1042570
      Commit-Queue: Daniel Clifford <danno@chromium.org>
      Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#52984}
      9cd8995f
  20. 03 May, 2018 1 commit
    • Daniel Clifford's avatar
      Refactor/cleanup various Torque classes, inclduing making Type a Declarable · 90415437
      Daniel Clifford authored
      This is a preparatory step for implementing generics. Along the way, clean up
      and encapsulate a bunch of code, including:
      
      * Fully encapsulate Scope by adding the new class ScopeChain that provide an
        abstraction for creating and activating scopes.
      * Untangle Modules and Scopes.
      * Unify scope activation so that it is always associated with an AST node
        and triggered by a RAII helper class.
      * Unify (somewhat) how builtins and macros are created, fixing a few
        inconsistencies with when and how parameters and their types are declared.
      * Create a new Declarations class that brokers between the visitor classes and
        the ScopeChain. This moves handling of declaration-related errors out of the
        visitors but also makes it possible to do so without polluting Scope and
        ScopeChain with details about resolving SourcePositions in error cases.
      
      Change-Id: I180017d4cf39ccf5ef1d20b84f53284c252f8d87
      Reviewed-on: https://chromium-review.googlesource.com/1038504
      Commit-Queue: Daniel Clifford <danno@chromium.org>
      Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#52947}
      90415437
  21. 25 Apr, 2018 1 commit
  22. 24 Apr, 2018 2 commits