• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_TYPE_HINTS_H_
6 #define V8_TYPE_HINTS_H_
7 
8 #include "src/base/flags.h"
9 #include "src/utils.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 // Type hints for an binary operation.
15 enum class BinaryOperationHint : uint8_t {
16   kNone,
17   kSignedSmall,
18   kSignedSmallInputs,
19   kSigned32,
20   kNumber,
21   kNumberOrOddball,
22   kString,
23   kBigInt,
24   kAny
25 };
26 
hash_value(BinaryOperationHint hint)27 inline size_t hash_value(BinaryOperationHint hint) {
28   return static_cast<unsigned>(hint);
29 }
30 
31 std::ostream& operator<<(std::ostream&, BinaryOperationHint);
32 
33 // Type hints for an compare operation.
34 enum class CompareOperationHint : uint8_t {
35   kNone,
36   kSignedSmall,
37   kNumber,
38   kNumberOrOddball,
39   kInternalizedString,
40   kString,
41   kSymbol,
42   kBigInt,
43   kReceiver,
44   kAny
45 };
46 
hash_value(CompareOperationHint hint)47 inline size_t hash_value(CompareOperationHint hint) {
48   return static_cast<unsigned>(hint);
49 }
50 
51 std::ostream& operator<<(std::ostream&, CompareOperationHint);
52 
53 // Type hints for for..in statements.
54 enum class ForInHint : uint8_t {
55   kNone,
56   kEnumCacheKeysAndIndices,
57   kEnumCacheKeys,
58   kAny
59 };
60 
61 std::ostream& operator<<(std::ostream&, ForInHint);
62 
63 enum StringAddFlags {
64   // Omit both parameter checks.
65   STRING_ADD_CHECK_NONE,
66   // Convert parameters when check fails (instead of throwing an exception).
67   STRING_ADD_CONVERT_LEFT,
68   STRING_ADD_CONVERT_RIGHT,
69 };
70 
71 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags);
72 
73 }  // namespace internal
74 }  // namespace v8
75 
76 #endif  // V8_TYPE_HINTS_H_
77