Commit 137ff440 authored by Deepti Gandluri's avatar Deepti Gandluri Committed by Commit Bot

Revert "[csa] Ensure the requested allocation size fits in a Smi"

This reverts commit 515cc07d.

Reason for revert: Tree closed on mkgrokdump failures
https://logs.chromium.org/v/?s=chromium%2Fbb%2Fclient.v8%2FV8_Mac64%2F22277%2F%2B%2Frecipes%2Fsteps%2FCheck%2F0%2Flogs%2Fmkgrokdump%2F0
https://logs.chromium.org/v/?s=chromium%2Fbb%2Fclient.v8%2FV8_Linux64%2F24882%2F%2B%2Frecipes%2Fsteps%2FCheck_-_noavx%2F0%2Flogs%2Fmkgrokdump%2F0
https://logs.chromium.org/v/?s=chromium%2Fbb%2Fclient.v8%2FV8_Win64%2F24413%2F%2B%2Frecipes%2Fsteps%2FCheck%2F0%2Flogs%2Fmkgrokdump%2F0

Original change's description:
> [csa] Ensure the requested allocation size fits in a Smi
> 
> In CSA::AllocateRaw, ensure that the given allocation size fits into a
> Smi.
> 
> Bug: chromium:848672
> Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
> Change-Id: I4e74791296163188b1ca77cae8226a9833fba8ef
> Reviewed-on: https://chromium-review.googlesource.com/1084930
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Reviewed-by: Igor Sheludko <ishell@chromium.org>
> Commit-Queue: Jakob Gruber <jgruber@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53495}

TBR=yangguo@chromium.org,jgruber@chromium.org,ishell@chromium.org

Change-Id: I4d1019c03b393c1a59e5eca558d9cd26ce63e17a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:848672
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/1085647Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53496}
parent 515cc07d
......@@ -534,18 +534,6 @@ TNode<Smi> CodeStubAssembler::SmiFromInt32(SloppyTNode<Int32T> value) {
WordShl(value_intptr, SmiShiftBitsConstant()));
}
TNode<BoolT> CodeStubAssembler::IsValidPositiveSmi(TNode<IntPtrT> value) {
intptr_t constant_value;
if (ToIntPtrConstant(value, constant_value)) {
return (static_cast<uintptr_t>(constant_value) <=
static_cast<uintptr_t>(Smi::kMaxValue))
? Int32TrueConstant()
: Int32FalseConstant();
}
return UintPtrLessThanOrEqual(value, IntPtrConstant(Smi::kMaxValue));
}
TNode<Smi> CodeStubAssembler::SmiTag(SloppyTNode<IntPtrT> value) {
int32_t constant_value;
if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) {
......@@ -1036,19 +1024,6 @@ void CodeStubAssembler::GotoIfForceSlowPath(Label* if_true) {
Node* CodeStubAssembler::AllocateRaw(Node* size_in_bytes, AllocationFlags flags,
Node* top_address, Node* limit_address) {
// TODO(jgruber, chromium:848672): TNodeify AllocateRaw.
// TODO(jgruber, chromium:848672): Call FatalProcessOutOfMemory if this fails.
{
intptr_t constant_value;
if (ToIntPtrConstant(size_in_bytes, constant_value)) {
CHECK(Internals::IsValidSmi(constant_value));
CHECK_GT(constant_value, 0);
} else {
CSA_CHECK(this,
IsValidPositiveSmi(UncheckedCast<IntPtrT>(size_in_bytes)));
}
}
Node* top = Load(MachineType::Pointer(), top_address);
Node* limit = Load(MachineType::Pointer(), limit_address);
......
......@@ -274,9 +274,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Object> index,
TNode<IntPtrT> length);
// Returns true iff the given value fits into smi range and is >= 0.
TNode<BoolT> IsValidPositiveSmi(TNode<IntPtrT> value);
// Tag an IntPtr as a Smi value.
TNode<Smi> SmiTag(SloppyTNode<IntPtrT> value);
// Untag a Smi value as an IntPtr.
......
......@@ -209,49 +209,6 @@ TEST(ToUint32) {
ft.CheckThrows(factory->match_symbol());
}
namespace {
void IsValidPositiveSmiCase(Isolate* isolate, intptr_t value, bool expected) {
const int kNumParams = 0;
CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeStubAssembler m(asm_tester.state());
m.Return(
m.SelectBooleanConstant(m.IsValidPositiveSmi(m.IntPtrConstant(value))));
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
MaybeHandle<Object> maybe_handle = ft.Call();
if (expected) {
CHECK(maybe_handle.ToHandleChecked()->IsTrue(isolate));
} else {
CHECK(maybe_handle.ToHandleChecked()->IsFalse(isolate));
}
}
} // namespace
TEST(IsValidPositiveSmi) {
Isolate* isolate(CcTest::InitIsolateOnce());
IsValidPositiveSmiCase(isolate, -1, false);
IsValidPositiveSmiCase(isolate, 0, true);
IsValidPositiveSmiCase(isolate, 1, true);
#ifdef V8_TARGET_ARCH_32_BIT
IsValidPositiveSmiCase(isolate, 0x3FFFFFFFU, true);
IsValidPositiveSmiCase(isolate, 0xC0000000U, false);
IsValidPositiveSmiCase(isolate, 0x40000000U, false);
IsValidPositiveSmiCase(isolate, 0xBFFFFFFFU, false);
#else
typedef std::numeric_limits<int32_t> int32_limits;
IsValidPositiveSmiCase(isolate, int32_limits::max(), true);
IsValidPositiveSmiCase(isolate, int32_limits::min(), false);
IsValidPositiveSmiCase(isolate,
static_cast<intptr_t>(int32_limits::max()) + 1, false);
IsValidPositiveSmiCase(isolate,
static_cast<intptr_t>(int32_limits::min()) - 1, false);
#endif
}
TEST(FixedArrayAccessSmiIndex) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
......
......@@ -4,7 +4,7 @@
[
# Only test for default mode x64.
['variant != default or arch != x64 or asan == True', {
['variant != default or arch != x64', {
'*': [SKIP],
}], # variant != default or arch != x64
]
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