Commit 63228e26 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr][csa] Support TaggedIndex in CSA

Bug: v8:10047
Change-Id: I140fcf453ce7dd6189e0f643f95570163b625456
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2043831
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66173}
parent e85ffb46
......@@ -718,6 +718,18 @@ TNode<BoolT> CodeStubAssembler::IsValidSmiIndex(TNode<Smi> smi) {
return Int32TrueConstant();
}
TNode<IntPtrT> CodeStubAssembler::TaggedIndexToIntPtr(
TNode<TaggedIndex> value) {
return Signed(WordSar(BitcastTaggedToWordForTagAndSmiBits(value),
IntPtrConstant(kSmiTagSize)));
}
TNode<TaggedIndex> CodeStubAssembler::IntPtrToTaggedIndex(
TNode<IntPtrT> value) {
return ReinterpretCast<TaggedIndex>(
BitcastWordToTaggedSigned(WordShl(value, IntPtrConstant(kSmiTagSize))));
}
TNode<Smi> CodeStubAssembler::NormalizeSmiIndex(TNode<Smi> smi_index) {
if (COMPRESS_POINTERS_BOOL) {
TNode<Int32T> raw =
......
......@@ -18,6 +18,7 @@
#include "src/objects/promise.h"
#include "src/objects/shared-function-info.h"
#include "src/objects/smi.h"
#include "src/objects/tagged-index.h"
#include "src/roots/roots.h"
#include "torque-generated/exported-macros-assembler-tq.h"
......@@ -384,6 +385,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
#error Unknown architecture.
#endif
TNode<IntPtrT> TaggedIndexToIntPtr(TNode<TaggedIndex> value);
TNode<TaggedIndex> IntPtrToTaggedIndex(TNode<IntPtrT> value);
// Pointer compression specific. Returns true if the upper 32 bits of a Smi
// contain the sign of a lower 32 bits (i.e. not corrupted) so that the Smi
// can be directly used as an index in element offset computation.
......
......@@ -13,6 +13,8 @@ namespace internal {
class HeapNumber;
class BigInt;
class Object;
class Smi;
class TaggedIndex;
namespace compiler {
......@@ -130,6 +132,10 @@ template <>
struct MachineTypeOf<Smi> {
static constexpr MachineType value = MachineType::TaggedSigned();
};
template <>
struct MachineTypeOf<TaggedIndex> {
static constexpr MachineType value = MachineType::Pointer();
};
template <class HeapObjectSubtype>
struct MachineTypeOf<HeapObjectSubtype,
typename std::enable_if<std::is_base_of<
......
......@@ -257,6 +257,11 @@ TNode<IntPtrT> CodeAssembler::IntPtrConstant(intptr_t value) {
return UncheckedCast<IntPtrT>(jsgraph()->IntPtrConstant(value));
}
TNode<TaggedIndex> CodeAssembler::TaggedIndexConstant(intptr_t value) {
DCHECK(TaggedIndex::IsValid(value));
return UncheckedCast<TaggedIndex>(raw_assembler()->IntPtrConstant(value));
}
TNode<Number> CodeAssembler::NumberConstant(double value) {
int smi_value;
if (DoubleToSmiInteger(value, &smi_value)) {
......
......@@ -29,6 +29,8 @@
#include "src/objects/maybe-object.h"
#include "src/objects/objects.h"
#include "src/objects/oddball.h"
#include "src/objects/smi.h"
#include "src/objects/tagged-index.h"
#include "src/runtime/runtime.h"
#include "src/utils/allocation.h"
#include "src/zone/zone-containers.h"
......@@ -164,6 +166,7 @@ struct ObjectTypeOf {};
};
OBJECT_TYPE_CASE(Object)
OBJECT_TYPE_CASE(Smi)
OBJECT_TYPE_CASE(TaggedIndex)
OBJECT_TYPE_CASE(HeapObject)
OBJECT_TYPE_LIST(OBJECT_TYPE_CASE)
HEAP_OBJECT_ORDINARY_TYPE_LIST(OBJECT_TYPE_CASE)
......@@ -509,6 +512,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
TNode<UintPtrT> UintPtrConstant(uintptr_t value) {
return Unsigned(IntPtrConstant(bit_cast<intptr_t>(value)));
}
TNode<TaggedIndex> TaggedIndexConstant(intptr_t value);
TNode<RawPtrT> PointerConstant(void* value) {
return ReinterpretCast<RawPtrT>(IntPtrConstant(bit_cast<intptr_t>(value)));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment