v8/tools/debug_helper/debug-macro-shims.h
Nico Hartmann 362e265d4c Revert "[Torque] Generalize Torque literals to larger size"
This reverts commit 757830b02b.

Reason for revert: Speculatively revert due to a number of
performance regressions

Original change's description:
> [Torque] Generalize Torque literals to larger size
>
> Previously, literals in Torque were stored as double values, which
> made it impossible to precisely represent 64 bit integer values.
> This CL replaces the old literal expression with an integer and
> floating point literal expression that are unbounded in size. We
> allow implicit conversion of these literals to arbitary integer
> and floating point types respectively and insert a corresponding
> bounds check into generated CSA.
>
> Bug: v8:7793
> Change-Id: I46c231aab92bc2f0c26955d1876079f306b358c6
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3329792
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
> Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#78671}

Bug: v8:7793
Change-Id: I9896e28b3c69b8cf2488bf93e993ec320d8c5d2e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3401866
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78706}
2022-01-20 17:13:39 +00:00

108 lines
4.4 KiB
C++

// 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.
// This file contains implementations of a few macros that are defined
// as external in Torque, so that generated debug code can work.
#ifndef V8_TORQUE_DEBUG_MACRO_SHIMS_H_
#define V8_TORQUE_DEBUG_MACRO_SHIMS_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<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) {
Smi s(s_t);
return {d::MemoryAccessResult::kOk, s.value()};
}
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};
}
} // namespace CodeStubAssembler
} // namespace TorqueDebugMacroShims
} // namespace debug_helper_internal
} // namespace internal
} // namespace v8
#endif // V8_TORQUE_DEBUG_MACRO_SHIMS_H_