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_OBJECTS_TYPE_HINTS_H_
6 #define V8_OBJECTS_TYPE_HINTS_H_
7
8 #include "src/base/flags.h"
9 #include "src/utils/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 kNumber,
20 kNumberOrOddball,
21 kString,
22 kBigInt,
23 kAny
24 };
25
hash_value(BinaryOperationHint hint)26 inline size_t hash_value(BinaryOperationHint hint) {
27 return static_cast<unsigned>(hint);
28 }
29
30 std::ostream& operator<<(std::ostream&, BinaryOperationHint);
31
32 // Type hints for an compare operation.
33 enum class CompareOperationHint : uint8_t {
34 kNone,
35 kSignedSmall,
36 kNumber,
37 kNumberOrBoolean,
38 kNumberOrOddball,
39 kInternalizedString,
40 kString,
41 kSymbol,
42 kBigInt,
43 kReceiver,
44 kReceiverOrNullOrUndefined,
45 kAny
46 };
47
hash_value(CompareOperationHint hint)48 inline size_t hash_value(CompareOperationHint hint) {
49 return static_cast<unsigned>(hint);
50 }
51
52 std::ostream& operator<<(std::ostream&, CompareOperationHint);
53
54 // Type hints for for..in statements.
55 enum class ForInHint : uint8_t {
56 kNone,
57 kEnumCacheKeysAndIndices,
58 kEnumCacheKeys,
59 kAny
60 };
61
62 std::ostream& operator<<(std::ostream&, ForInHint);
63
64 enum StringAddFlags {
65 // Omit both parameter checks.
66 STRING_ADD_CHECK_NONE,
67 // Convert parameters when check fails (instead of throwing an exception).
68 STRING_ADD_CONVERT_LEFT,
69 STRING_ADD_CONVERT_RIGHT,
70 };
71
72 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags);
73
74 } // namespace internal
75 } // namespace v8
76
77 #endif // V8_OBJECTS_TYPE_HINTS_H_
78