2017-09-11 13:44:42 +00:00
|
|
|
// 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.
|
|
|
|
|
2019-05-27 08:15:15 +00:00
|
|
|
#include "test/unittests/codegen/code-stub-assembler-unittest.h"
|
2017-09-11 13:44:42 +00:00
|
|
|
|
|
|
|
#include "src/compiler/node.h"
|
2019-05-22 07:55:37 +00:00
|
|
|
#include "src/execution/isolate.h"
|
2017-09-11 13:44:42 +00:00
|
|
|
#include "test/unittests/compiler/compiler-test-utils.h"
|
|
|
|
#include "test/unittests/compiler/node-test-utils.h"
|
|
|
|
|
|
|
|
using ::testing::_;
|
|
|
|
|
|
|
|
namespace c = v8::internal::compiler;
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
CodeStubAssemblerTestState::CodeStubAssemblerTestState(
|
|
|
|
CodeStubAssemblerTest* test)
|
2021-08-12 11:17:00 +00:00
|
|
|
: compiler::CodeAssemblerState(test->isolate(), test->zone(),
|
|
|
|
VoidDescriptor{}, CodeKind::FOR_TESTING,
|
|
|
|
"test") {}
|
2017-09-11 13:44:42 +00:00
|
|
|
|
|
|
|
TARGET_TEST_F(CodeStubAssemblerTest, SmiTag) {
|
|
|
|
CodeStubAssemblerTestState state(this);
|
|
|
|
CodeStubAssemblerForTest m(&state);
|
2019-08-22 09:56:32 +00:00
|
|
|
TNode<IntPtrT> value = m.IntPtrConstant(44);
|
2017-09-11 13:44:42 +00:00
|
|
|
EXPECT_THAT(m.SmiTag(value),
|
2018-11-13 16:28:21 +00:00
|
|
|
IsBitcastWordToTaggedSigned(c::IsIntPtrConstant(
|
2017-09-11 13:44:42 +00:00
|
|
|
static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize))));
|
2019-08-22 09:56:32 +00:00
|
|
|
EXPECT_THAT(m.SmiUntag(m.ReinterpretCast<Smi>(value)),
|
2017-09-11 13:44:42 +00:00
|
|
|
c::IsIntPtrConstant(static_cast<intptr_t>(44) >>
|
|
|
|
(kSmiShiftSize + kSmiTagSize)));
|
|
|
|
}
|
|
|
|
|
|
|
|
TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMax) {
|
|
|
|
CodeStubAssemblerTestState state(this);
|
|
|
|
CodeStubAssemblerForTest m(&state);
|
|
|
|
{
|
2019-08-22 09:56:32 +00:00
|
|
|
TNode<IntPtrT> a = m.IntPtrConstant(100);
|
|
|
|
TNode<IntPtrT> b = m.IntPtrConstant(1);
|
|
|
|
TNode<IntPtrT> z = m.IntPtrMax(a, b);
|
2017-09-11 13:44:42 +00:00
|
|
|
EXPECT_THAT(z, c::IsIntPtrConstant(100));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMin) {
|
|
|
|
CodeStubAssemblerTestState state(this);
|
|
|
|
CodeStubAssemblerForTest m(&state);
|
|
|
|
{
|
2019-08-22 09:56:32 +00:00
|
|
|
TNode<IntPtrT> a = m.IntPtrConstant(100);
|
|
|
|
TNode<IntPtrT> b = m.IntPtrConstant(1);
|
|
|
|
TNode<IntPtrT> z = m.IntPtrMin(a, b);
|
2017-09-11 13:44:42 +00:00
|
|
|
EXPECT_THAT(z, c::IsIntPtrConstant(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|