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