File: debug-macro-shims.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (128 lines) | stat: -rw-r--r-- 5,458 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright 2020 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.

#ifndef V8_TORQUE_DEBUG_MACRO_SHIMS_H_
#define V8_TORQUE_DEBUG_MACRO_SHIMS_H_

// This file contains implementations of a few macros that are defined
// as external in Torque, so that generated debug code can work.

#include "src/numbers/integer-literal.h"
#include "src/objects/smi.h"
#include "tools/debug_helper/debug-helper-internal.h"

// For Object::ReadField<T>.
#define READ_FIELD_OR_FAIL(Type, destination, accessor, object, offset) \
  do {                                                                  \
    Type value{};                                                       \
    d::MemoryAccessResult validity =                                    \
        accessor(object - kHeapObjectTag + offset,                      \
                 reinterpret_cast<Type*>(&value), sizeof(value));       \
    if (validity != d::MemoryAccessResult::kOk) return {validity, {}};  \
    destination = value;                                                \
  } while (false)

// For TaggedField<T>::load.
#define READ_TAGGED_FIELD_OR_FAIL(destination, accessor, object, offset) \
  do {                                                                   \
    Tagged_t value{};                                                    \
    d::MemoryAccessResult validity =                                     \
        accessor(object - kHeapObjectTag + offset,                       \
                 reinterpret_cast<uint8_t*>(&value), sizeof(value));     \
    if (validity != d::MemoryAccessResult::kOk) return {validity, {}};   \
    destination = EnsureDecompressed(value, object);                     \
  } while (false)

// Process Value struct.
#define ASSIGN_OR_RETURN(dest, val)                   \
  do {                                                \
    if ((val).validity != d::MemoryAccessResult::kOk) \
      return {(val).validity, {}};                    \
    dest = (val).value;                               \
  } while (false)

namespace v8 {
namespace internal {
namespace debug_helper_internal {
namespace TorqueDebugMacroShims {
namespace CodeStubAssembler {

inline Value<bool> BoolConstant(d::MemoryAccessor accessor, bool b) {
  return {d::MemoryAccessResult::kOk, b};
}
inline Value<intptr_t> ChangeInt32ToIntPtr(d::MemoryAccessor accessor,
                                           int32_t i) {
  return {d::MemoryAccessResult::kOk, i};
}
inline Value<uintptr_t> ChangeUint32ToWord(d::MemoryAccessor accessor,
                                           uint32_t u) {
  return {d::MemoryAccessResult::kOk, u};
}
inline Value<intptr_t> IntPtrAdd(d::MemoryAccessor accessor, intptr_t a,
                                 intptr_t b) {
  return {d::MemoryAccessResult::kOk, a + b};
}
inline Value<intptr_t> IntPtrMul(d::MemoryAccessor accessor, intptr_t a,
                                 intptr_t b) {
  return {d::MemoryAccessResult::kOk, a * b};
}
inline Value<bool> IntPtrLessThan(d::MemoryAccessor accessor, intptr_t a,
                                  intptr_t b) {
  return {d::MemoryAccessResult::kOk, a < b};
}
inline Value<bool> IntPtrLessThanOrEqual(d::MemoryAccessor accessor, intptr_t a,
                                         intptr_t b) {
  return {d::MemoryAccessResult::kOk, a <= b};
}
inline Value<intptr_t> Signed(d::MemoryAccessor accessor, uintptr_t u) {
  return {d::MemoryAccessResult::kOk, static_cast<intptr_t>(u)};
}
inline Value<int32_t> SmiUntag(d::MemoryAccessor accessor, uintptr_t s_t) {
  Tagged<Smi> s(s_t);
  return {d::MemoryAccessResult::kOk, s.value()};
}
inline Value<uintptr_t> SmiFromInt32(d::MemoryAccessor accessor, int32_t i) {
  return {d::MemoryAccessResult::kOk, Smi::FromInt(i).ptr()};
}
inline Value<bool> UintPtrLessThan(d::MemoryAccessor accessor, uintptr_t a,
                                   uintptr_t b) {
  return {d::MemoryAccessResult::kOk, a < b};
}
inline Value<uint32_t> Unsigned(d::MemoryAccessor accessor, int32_t s) {
  return {d::MemoryAccessResult::kOk, static_cast<uint32_t>(s)};
}
#if V8_HOST_ARCH_64_BIT
inline Value<uintptr_t> Unsigned(d::MemoryAccessor accessor, intptr_t s) {
  return {d::MemoryAccessResult::kOk, static_cast<uintptr_t>(s)};
}
#endif
inline Value<bool> Word32Equal(d::MemoryAccessor accessor, uint32_t a,
                               uint32_t b) {
  return {d::MemoryAccessResult::kOk, a == b};
}
inline Value<bool> Word32NotEqual(d::MemoryAccessor accessor, uint32_t a,
                                  uint32_t b) {
  return {d::MemoryAccessResult::kOk, a != b};
}
// This is used in a nested call where we cannot pass Value<int32_t>.
inline int31_t ConstexprIntegerLiteralToInt31(d::MemoryAccessor accessor,
                                              const IntegerLiteral& i) {
  return i.To<int32_t>();
}
inline int32_t ConstexprIntegerLiteralToInt32(d::MemoryAccessor accessor,
                                              const IntegerLiteral& i) {
  return i.To<int32_t>();
}
inline intptr_t ConstexprIntegerLiteralToIntptr(d::MemoryAccessor accessor,
                                                const IntegerLiteral& i) {
  return i.To<intptr_t>();
}

}  // namespace CodeStubAssembler
}  // namespace TorqueDebugMacroShims
}  // namespace debug_helper_internal
}  // namespace internal
}  // namespace v8

#endif  // V8_TORQUE_DEBUG_MACRO_SHIMS_H_