type-hints.h 1.57 KB
Newer Older
1 2 3 4
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef V8_TYPE_HINTS_H_
#define V8_TYPE_HINTS_H_
7

8
#include "src/base/flags.h"
9 10 11 12 13 14
#include "src/utils.h"

namespace v8 {
namespace internal {

// Type hints for an binary operation.
15 16 17
enum class BinaryOperationHint : uint8_t {
  kNone,
  kSignedSmall,
18
  kSignedSmallInputs,
19
  kSigned32,
20
  kNumber,
21
  kNumberOrOddball,
22
  kString,
23
  kBigInt,
24
  kAny
25 26
};

27 28 29
inline size_t hash_value(BinaryOperationHint hint) {
  return static_cast<unsigned>(hint);
}
30

31 32 33 34 35 36 37 38
std::ostream& operator<<(std::ostream&, BinaryOperationHint);

// Type hints for an compare operation.
enum class CompareOperationHint : uint8_t {
  kNone,
  kSignedSmall,
  kNumber,
  kNumberOrOddball,
39
  kInternalizedString,
40
  kString,
41
  kSymbol,
42
  kBigInt,
43
  kReceiver,
44
  kAny
45 46
};

47 48 49 50 51
inline size_t hash_value(CompareOperationHint hint) {
  return static_cast<unsigned>(hint);
}

std::ostream& operator<<(std::ostream&, CompareOperationHint);
52

53 54 55 56 57 58 59 60 61 62
// Type hints for for..in statements.
enum class ForInHint : uint8_t {
  kNone,
  kEnumCacheKeysAndIndices,
  kEnumCacheKeys,
  kAny
};

std::ostream& operator<<(std::ostream&, ForInHint);

63 64
enum StringAddFlags {
  // Omit both parameter checks.
65
  STRING_ADD_CHECK_NONE,
66
  // Convert parameters when check fails (instead of throwing an exception).
67 68
  STRING_ADD_CONVERT_LEFT,
  STRING_ADD_CONVERT_RIGHT,
69 70 71 72
};

std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags);

73 74 75
}  // namespace internal
}  // namespace v8

76
#endif  // V8_TYPE_HINTS_H_