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 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 kNumberOrBoolean,
39 kNumberOrOddball,
40 kInternalizedString,
41 kString,
42 kSymbol,
43 kBigInt,
44 kReceiver,
45 kReceiverOrNullOrUndefined,
46 kAny
47 };
48
hash_value(CompareOperationHint hint)49 inline size_t hash_value(CompareOperationHint hint) {
50 return static_cast<unsigned>(hint);
51 }
52
53 std::ostream& operator<<(std::ostream&, CompareOperationHint);
54
55 // Type hints for for..in statements.
56 enum class ForInHint : uint8_t {
57 kNone,
58 kEnumCacheKeysAndIndices,
59 kEnumCacheKeys,
60 kAny
61 };
62
63 std::ostream& operator<<(std::ostream&, ForInHint);
64
65 enum StringAddFlags {
66 // Omit both parameter checks.
67 STRING_ADD_CHECK_NONE,
68 // Convert parameters when check fails (instead of throwing an exception).
69 STRING_ADD_CONVERT_LEFT,
70 STRING_ADD_CONVERT_RIGHT,
71 };
72
73 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags);
74
75 } // namespace internal
76 } // namespace v8
77
78 #endif // V8_OBJECTS_TYPE_HINTS_H_
79