afd83c074f
This enables using TNode types without including code-assembler.h, which is useful when generating CallInterfaceDescriptors. As a drive-by, this moves TNode from v8::internal::compiler to v8::internal. It's only used outside of the compiler anyway. Change-Id: I3d938c22366a3570315041683094f77b0d1096a2 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1798425 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Michael Stanton <mvstanton@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#63721}
65 lines
2.1 KiB
C++
65 lines
2.1 KiB
C++
// Copyright 2017 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.
|
|
|
|
#include "test/unittests/codegen/code-stub-assembler-unittest.h"
|
|
|
|
#include "src/codegen/code-factory.h"
|
|
#include "src/codegen/interface-descriptors.h"
|
|
#include "src/compiler/node.h"
|
|
#include "src/execution/isolate.h"
|
|
#include "src/objects/objects-inl.h"
|
|
#include "test/unittests/compiler/compiler-test-utils.h"
|
|
#include "test/unittests/compiler/node-test-utils.h"
|
|
|
|
using ::testing::_;
|
|
using v8::internal::compiler::Node;
|
|
|
|
namespace c = v8::internal::compiler;
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
CodeStubAssemblerTestState::CodeStubAssemblerTestState(
|
|
CodeStubAssemblerTest* test)
|
|
: compiler::CodeAssemblerState(
|
|
test->isolate(), test->zone(), VoidDescriptor{}, Code::STUB, "test",
|
|
PoisoningMitigationLevel::kPoisonCriticalOnly) {}
|
|
|
|
TARGET_TEST_F(CodeStubAssemblerTest, SmiTag) {
|
|
CodeStubAssemblerTestState state(this);
|
|
CodeStubAssemblerForTest m(&state);
|
|
TNode<IntPtrT> value = m.IntPtrConstant(44);
|
|
EXPECT_THAT(m.SmiTag(value),
|
|
IsBitcastWordToTaggedSigned(c::IsIntPtrConstant(
|
|
static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize))));
|
|
EXPECT_THAT(m.SmiUntag(m.ReinterpretCast<Smi>(value)),
|
|
c::IsIntPtrConstant(static_cast<intptr_t>(44) >>
|
|
(kSmiShiftSize + kSmiTagSize)));
|
|
}
|
|
|
|
TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMax) {
|
|
CodeStubAssemblerTestState state(this);
|
|
CodeStubAssemblerForTest m(&state);
|
|
{
|
|
TNode<IntPtrT> a = m.IntPtrConstant(100);
|
|
TNode<IntPtrT> b = m.IntPtrConstant(1);
|
|
TNode<IntPtrT> z = m.IntPtrMax(a, b);
|
|
EXPECT_THAT(z, c::IsIntPtrConstant(100));
|
|
}
|
|
}
|
|
|
|
TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMin) {
|
|
CodeStubAssemblerTestState state(this);
|
|
CodeStubAssemblerForTest m(&state);
|
|
{
|
|
TNode<IntPtrT> a = m.IntPtrConstant(100);
|
|
TNode<IntPtrT> b = m.IntPtrConstant(1);
|
|
TNode<IntPtrT> z = m.IntPtrMin(a, b);
|
|
EXPECT_THAT(z, c::IsIntPtrConstant(1));
|
|
}
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|