2022-08-22 15:42:07 +00:00
|
|
|
// Copyright 2022 the V8 project authors. All rights reserved.
|
2014-07-30 13:54:45 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-01-10 10:38:25 +00:00
|
|
|
#include "src/base/overflowing-math.h"
|
2019-05-23 08:51:46 +00:00
|
|
|
#include "src/objects/objects-inl.h"
|
2022-08-22 15:42:07 +00:00
|
|
|
#include "test/common/value-helper.h"
|
|
|
|
#include "test/unittests/compiler/codegen-tester.h"
|
|
|
|
#include "test/unittests/test-utils.h"
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2015-10-30 09:16:26 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
class CodeGenTest : public TestWithIsolateAndZone {
|
|
|
|
public:
|
|
|
|
CodeGenTest() : TestWithIsolateAndZone(kCompressGraphZone) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void RunSmiConstant(int32_t v) {
|
|
|
|
// TODO(dcarney): on x64 Smis are generated with the SmiConstantRegister
|
|
|
|
#if !V8_TARGET_ARCH_X64
|
|
|
|
if (Smi::IsValid(v)) {
|
|
|
|
RawMachineAssemblerTester<Object> m(i_isolate(), zone());
|
|
|
|
m.Return(m.NumberConstant(v));
|
|
|
|
CHECK_EQ(Smi::FromInt(v), m.Call());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunNumberConstant(double v) {
|
|
|
|
RawMachineAssemblerTester<Object> m(i_isolate(), zone());
|
|
|
|
#if V8_TARGET_ARCH_X64
|
|
|
|
// TODO(dcarney): on x64 Smis are generated with the SmiConstantRegister
|
|
|
|
Handle<Object> number = m.isolate()->factory()->NewNumber(v);
|
|
|
|
if (number->IsSmi()) return;
|
|
|
|
#endif
|
|
|
|
m.Return(m.NumberConstant(v));
|
|
|
|
Object result = m.Call();
|
|
|
|
m.CheckNumber(v, result);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(CodeGenTest, CompareWrapper) {
|
2014-07-30 13:54:45 +00:00
|
|
|
// Who tests the testers?
|
|
|
|
// If CompareWrapper is broken, then test expectations will be broken.
|
|
|
|
CompareWrapper wWord32Equal(IrOpcode::kWord32Equal);
|
|
|
|
CompareWrapper wInt32LessThan(IrOpcode::kInt32LessThan);
|
|
|
|
CompareWrapper wInt32LessThanOrEqual(IrOpcode::kInt32LessThanOrEqual);
|
|
|
|
CompareWrapper wUint32LessThan(IrOpcode::kUint32LessThan);
|
|
|
|
CompareWrapper wUint32LessThanOrEqual(IrOpcode::kUint32LessThanOrEqual);
|
|
|
|
|
2019-02-01 14:21:25 +00:00
|
|
|
FOR_INT32_INPUTS(a) {
|
|
|
|
FOR_INT32_INPUTS(b) {
|
2019-02-01 10:37:04 +00:00
|
|
|
CHECK_EQ(a == b, wWord32Equal.Int32Compare(a, b));
|
|
|
|
CHECK_EQ(a < b, wInt32LessThan.Int32Compare(a, b));
|
|
|
|
CHECK_EQ(a <= b, wInt32LessThanOrEqual.Int32Compare(a, b));
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 14:21:25 +00:00
|
|
|
FOR_UINT32_INPUTS(a) {
|
|
|
|
FOR_UINT32_INPUTS(b) {
|
2019-02-01 10:37:04 +00:00
|
|
|
CHECK_EQ(a == b, wWord32Equal.Int32Compare(a, b));
|
|
|
|
CHECK_EQ(a < b, wUint32LessThan.Int32Compare(a, b));
|
|
|
|
CHECK_EQ(a <= b, wUint32LessThanOrEqual.Int32Compare(a, b));
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_EQ(true, wWord32Equal.Int32Compare(0, 0));
|
|
|
|
CHECK_EQ(true, wWord32Equal.Int32Compare(257, 257));
|
|
|
|
CHECK_EQ(true, wWord32Equal.Int32Compare(65539, 65539));
|
|
|
|
CHECK_EQ(true, wWord32Equal.Int32Compare(-1, -1));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(true, wWord32Equal.Int32Compare(0xFFFFFFFF, 0xFFFFFFFF));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(false, wWord32Equal.Int32Compare(0, 1));
|
|
|
|
CHECK_EQ(false, wWord32Equal.Int32Compare(257, 256));
|
|
|
|
CHECK_EQ(false, wWord32Equal.Int32Compare(65539, 65537));
|
|
|
|
CHECK_EQ(false, wWord32Equal.Int32Compare(-1, -2));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(false, wWord32Equal.Int32Compare(0xFFFFFFFF, 0xFFFFFFFE));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(0, 0));
|
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(357, 357));
|
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(75539, 75539));
|
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(-1, -1));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(0xFFFFFFFF, 0xFFFFFFFF));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(true, wInt32LessThan.Int32Compare(0, 1));
|
|
|
|
CHECK_EQ(true, wInt32LessThan.Int32Compare(456, 457));
|
|
|
|
CHECK_EQ(true, wInt32LessThan.Int32Compare(85537, 85539));
|
|
|
|
CHECK_EQ(true, wInt32LessThan.Int32Compare(-2, -1));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(true, wInt32LessThan.Int32Compare(0xFFFFFFFE, 0xFFFFFFFF));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(1, 0));
|
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(457, 456));
|
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(85539, 85537));
|
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(-1, -2));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(false, wInt32LessThan.Int32Compare(0xFFFFFFFF, 0xFFFFFFFE));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(0, 0));
|
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(357, 357));
|
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(75539, 75539));
|
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(-1, -1));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(0xFFFFFFFF, 0xFFFFFFFF));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(0, 1));
|
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(456, 457));
|
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(85537, 85539));
|
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(-2, -1));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(0xFFFFFFFE, 0xFFFFFFFF));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(1, 0));
|
|
|
|
CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(457, 456));
|
|
|
|
CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(85539, 85537));
|
|
|
|
CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(-1, -2));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(0xFFFFFFFF, 0xFFFFFFFE));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
// Unsigned comparisons.
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(0, 0));
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(357, 357));
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(75539, 75539));
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(-1, -1));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(0xFFFFFFFF, 0xFFFFFFFF));
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(0xFFFFFFFF, 0));
|
2014-07-30 13:54:45 +00:00
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(-2999, 0));
|
|
|
|
|
|
|
|
CHECK_EQ(true, wUint32LessThan.Int32Compare(0, 1));
|
|
|
|
CHECK_EQ(true, wUint32LessThan.Int32Compare(456, 457));
|
|
|
|
CHECK_EQ(true, wUint32LessThan.Int32Compare(85537, 85539));
|
|
|
|
CHECK_EQ(true, wUint32LessThan.Int32Compare(-11, -10));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(true, wUint32LessThan.Int32Compare(0xFFFFFFFE, 0xFFFFFFFF));
|
|
|
|
CHECK_EQ(true, wUint32LessThan.Int32Compare(0, 0xFFFFFFFF));
|
2014-07-30 13:54:45 +00:00
|
|
|
CHECK_EQ(true, wUint32LessThan.Int32Compare(0, -2996));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(1, 0));
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(457, 456));
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(85539, 85537));
|
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(-10, -21));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(false, wUint32LessThan.Int32Compare(0xFFFFFFFF, 0xFFFFFFFE));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0, 0));
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(357, 357));
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(75539, 75539));
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(-1, -1));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0xFFFFFFFF, 0xFFFFFFFF));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0, 1));
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(456, 457));
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(85537, 85539));
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(-300, -299));
|
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(-300, -300));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0xFFFFFFFE, 0xFFFFFFFF));
|
2014-07-30 13:54:45 +00:00
|
|
|
CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0, -2995));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(1, 0));
|
|
|
|
CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(457, 456));
|
|
|
|
CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(85539, 85537));
|
|
|
|
CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(-130, -170));
|
2017-12-02 00:30:37 +00:00
|
|
|
CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(0xFFFFFFFF, 0xFFFFFFFE));
|
2014-07-30 13:54:45 +00:00
|
|
|
CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(-2997, 0));
|
|
|
|
|
|
|
|
CompareWrapper wFloat64Equal(IrOpcode::kFloat64Equal);
|
|
|
|
CompareWrapper wFloat64LessThan(IrOpcode::kFloat64LessThan);
|
|
|
|
CompareWrapper wFloat64LessThanOrEqual(IrOpcode::kFloat64LessThanOrEqual);
|
|
|
|
|
|
|
|
// Check NaN handling.
|
2015-01-21 14:38:49 +00:00
|
|
|
double nan = std::numeric_limits<double>::quiet_NaN();
|
2014-12-20 13:17:20 +00:00
|
|
|
double inf = V8_INFINITY;
|
2014-07-30 13:54:45 +00:00
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, 0.0));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, 1.0));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, inf));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, nan));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(0.0, nan));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(1.0, nan));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, nan));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, nan));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, nan));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, 0.0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, 1.0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, nan));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(0.0, nan));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(1.0, nan));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, nan));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(-inf, nan));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, nan));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, 0.0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, 1.0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, nan));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(0.0, nan));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(1.0, nan));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, nan));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(-inf, nan));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, nan));
|
|
|
|
|
|
|
|
// Check inf handling.
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, 0.0));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, 1.0));
|
|
|
|
CHECK_EQ(true, wFloat64Equal.Float64Compare(inf, inf));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, -inf));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(0.0, inf));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(1.0, inf));
|
|
|
|
CHECK_EQ(true, wFloat64Equal.Float64Compare(inf, inf));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, inf));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, 0.0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, 1.0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, -inf));
|
|
|
|
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(0.0, inf));
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(1.0, inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, inf));
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(-inf, inf));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, 0.0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, 1.0));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(inf, inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, -inf));
|
|
|
|
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(0.0, inf));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(1.0, inf));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(inf, inf));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, inf));
|
|
|
|
|
|
|
|
// Check -inf handling.
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, 0.0));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, 1.0));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, inf));
|
|
|
|
CHECK_EQ(true, wFloat64Equal.Float64Compare(-inf, -inf));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(0.0, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(1.0, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, -inf));
|
|
|
|
CHECK_EQ(true, wFloat64Equal.Float64Compare(-inf, -inf));
|
|
|
|
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(-inf, 0.0));
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(-inf, 1.0));
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(-inf, inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(-inf, -inf));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(0.0, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(1.0, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(-inf, -inf));
|
|
|
|
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, 0.0));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, 1.0));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, inf));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, -inf));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(0.0, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(1.0, -inf));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, -inf));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, -inf));
|
|
|
|
|
|
|
|
// Check basic values.
|
|
|
|
CHECK_EQ(true, wFloat64Equal.Float64Compare(0, 0));
|
|
|
|
CHECK_EQ(true, wFloat64Equal.Float64Compare(257.1, 257.1));
|
|
|
|
CHECK_EQ(true, wFloat64Equal.Float64Compare(65539.1, 65539.1));
|
|
|
|
CHECK_EQ(true, wFloat64Equal.Float64Compare(-1.1, -1.1));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(0, 1));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(257.2, 256.2));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(65539.2, 65537.2));
|
|
|
|
CHECK_EQ(false, wFloat64Equal.Float64Compare(-1.2, -2.2));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(0, 0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(357.3, 357.3));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(75539.3, 75539.3));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(-1.3, -1.3));
|
|
|
|
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(0, 1));
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(456.4, 457.4));
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(85537.4, 85539.4));
|
|
|
|
CHECK_EQ(true, wFloat64LessThan.Float64Compare(-2.4, -1.4));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(1, 0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(457.5, 456.5));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(85539.5, 85537.5));
|
|
|
|
CHECK_EQ(false, wFloat64LessThan.Float64Compare(-1.5, -2.5));
|
|
|
|
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(0, 0));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(357.6, 357.6));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(75539.6, 75539.6));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-1.6, -1.6));
|
|
|
|
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(0, 1));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(456.7, 457.7));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(85537.7, 85539.7));
|
|
|
|
CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-2.7, -1.7));
|
|
|
|
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(1, 0));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(457.8, 456.8));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(85539.8, 85537.8));
|
|
|
|
CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(-1.8, -2.8));
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, ParametersEqual) {
|
|
|
|
RawMachineAssemblerTester<int32_t> m(
|
|
|
|
i_isolate(), zone(), MachineType::Int32(), MachineType::Int32());
|
2014-07-30 13:54:45 +00:00
|
|
|
Node* p1 = m.Parameter(1);
|
2015-01-30 09:29:25 +00:00
|
|
|
CHECK(p1);
|
2014-07-30 13:54:45 +00:00
|
|
|
Node* p0 = m.Parameter(0);
|
2015-01-30 09:29:25 +00:00
|
|
|
CHECK(p0);
|
2014-07-30 13:54:45 +00:00
|
|
|
CHECK_EQ(p0, m.Parameter(0));
|
|
|
|
CHECK_EQ(p1, m.Parameter(1));
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunEmpty) {
|
|
|
|
RawMachineAssemblerTester<int32_t> m(i_isolate(), zone());
|
2014-07-30 13:54:45 +00:00
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
CHECK_EQ(0, m.Call());
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunInt32Constants) {
|
2014-07-30 13:54:45 +00:00
|
|
|
FOR_INT32_INPUTS(i) {
|
2022-08-22 15:42:07 +00:00
|
|
|
RawMachineAssemblerTester<int32_t> m(i_isolate(), zone());
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Return(m.Int32Constant(i));
|
|
|
|
CHECK_EQ(i, m.Call());
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunSmiConstants) {
|
2019-01-10 10:38:25 +00:00
|
|
|
for (int32_t i = 1; i < Smi::kMaxValue && i != 0;
|
|
|
|
i = base::ShlWithWraparound(i, 1)) {
|
2014-07-30 13:54:45 +00:00
|
|
|
RunSmiConstant(i);
|
2019-01-10 10:38:25 +00:00
|
|
|
RunSmiConstant(base::MulWithWraparound(3, i));
|
|
|
|
RunSmiConstant(base::MulWithWraparound(5, i));
|
|
|
|
RunSmiConstant(base::NegateWithWraparound(i));
|
2014-07-30 13:54:45 +00:00
|
|
|
RunSmiConstant(i | 1);
|
|
|
|
RunSmiConstant(i | 3);
|
|
|
|
}
|
|
|
|
RunSmiConstant(Smi::kMaxValue);
|
|
|
|
RunSmiConstant(Smi::kMaxValue - 1);
|
|
|
|
RunSmiConstant(Smi::kMinValue);
|
|
|
|
RunSmiConstant(Smi::kMinValue + 1);
|
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
FOR_INT32_INPUTS(i) { RunSmiConstant(i); }
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunNumberConstants) {
|
2019-02-01 10:37:04 +00:00
|
|
|
FOR_FLOAT64_INPUTS(i) { RunNumberConstant(i); }
|
|
|
|
FOR_INT32_INPUTS(i) { RunNumberConstant(i); }
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2019-01-10 10:38:25 +00:00
|
|
|
for (int32_t i = 1; i < Smi::kMaxValue && i != 0;
|
|
|
|
i = base::ShlWithWraparound(i, 1)) {
|
2014-07-30 13:54:45 +00:00
|
|
|
RunNumberConstant(i);
|
2019-01-10 10:38:25 +00:00
|
|
|
RunNumberConstant(base::NegateWithWraparound(i));
|
2014-07-30 13:54:45 +00:00
|
|
|
RunNumberConstant(i | 1);
|
|
|
|
RunNumberConstant(i | 3);
|
|
|
|
}
|
|
|
|
RunNumberConstant(Smi::kMaxValue);
|
|
|
|
RunNumberConstant(Smi::kMaxValue - 1);
|
|
|
|
RunNumberConstant(Smi::kMinValue);
|
|
|
|
RunNumberConstant(Smi::kMinValue + 1);
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunEmptyString) {
|
|
|
|
RawMachineAssemblerTester<Object> m(i_isolate(), zone());
|
2014-07-30 13:54:45 +00:00
|
|
|
m.Return(m.StringConstant("empty"));
|
|
|
|
m.CheckString("empty", m.Call());
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunHeapConstant) {
|
|
|
|
RawMachineAssemblerTester<Object> m(i_isolate(), zone());
|
2014-07-30 13:54:45 +00:00
|
|
|
m.Return(m.StringConstant("empty"));
|
|
|
|
m.CheckString("empty", m.Call());
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunHeapNumberConstant) {
|
|
|
|
RawMachineAssemblerTester<void*> m(i_isolate(), zone());
|
2014-10-07 13:30:28 +00:00
|
|
|
Handle<HeapObject> number = m.isolate()->factory()->NewHeapNumber(100.5);
|
2014-07-30 13:54:45 +00:00
|
|
|
m.Return(m.HeapConstant(number));
|
2018-12-20 15:47:47 +00:00
|
|
|
HeapObject result =
|
2019-01-07 12:28:05 +00:00
|
|
|
HeapObject::cast(Object(reinterpret_cast<Address>(m.Call())));
|
2014-07-30 13:54:45 +00:00
|
|
|
CHECK_EQ(result, *number);
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunParam1) {
|
|
|
|
RawMachineAssemblerTester<int32_t> m(i_isolate(), zone(),
|
|
|
|
MachineType::Int32());
|
2014-07-30 13:54:45 +00:00
|
|
|
m.Return(m.Parameter(0));
|
|
|
|
|
|
|
|
FOR_INT32_INPUTS(i) {
|
2019-02-01 10:37:04 +00:00
|
|
|
int32_t result = m.Call(i);
|
|
|
|
CHECK_EQ(i, result);
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunParam2_1) {
|
|
|
|
RawMachineAssemblerTester<int32_t> m(
|
|
|
|
i_isolate(), zone(), MachineType::Int32(), MachineType::Int32());
|
2014-07-30 13:54:45 +00:00
|
|
|
Node* p0 = m.Parameter(0);
|
|
|
|
Node* p1 = m.Parameter(1);
|
|
|
|
m.Return(p0);
|
|
|
|
USE(p1);
|
|
|
|
|
|
|
|
FOR_INT32_INPUTS(i) {
|
2019-02-01 10:37:04 +00:00
|
|
|
int32_t result = m.Call(i, -9999);
|
|
|
|
CHECK_EQ(i, result);
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunParam2_2) {
|
|
|
|
RawMachineAssemblerTester<int32_t> m(
|
|
|
|
i_isolate(), zone(), MachineType::Int32(), MachineType::Int32());
|
2014-07-30 13:54:45 +00:00
|
|
|
Node* p0 = m.Parameter(0);
|
|
|
|
Node* p1 = m.Parameter(1);
|
|
|
|
m.Return(p1);
|
|
|
|
USE(p0);
|
|
|
|
|
|
|
|
FOR_INT32_INPUTS(i) {
|
2019-02-01 10:37:04 +00:00
|
|
|
int32_t result = m.Call(-7777, i);
|
|
|
|
CHECK_EQ(i, result);
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunParam3) {
|
2014-07-30 13:54:45 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2015-12-10 09:03:30 +00:00
|
|
|
RawMachineAssemblerTester<int32_t> m(
|
2022-08-22 15:42:07 +00:00
|
|
|
i_isolate(), zone(), MachineType::Int32(), MachineType::Int32(),
|
|
|
|
MachineType::Int32());
|
2014-07-30 13:54:45 +00:00
|
|
|
Node* nodes[] = {m.Parameter(0), m.Parameter(1), m.Parameter(2)};
|
|
|
|
m.Return(nodes[i]);
|
|
|
|
|
|
|
|
int p[] = {-99, -77, -88};
|
|
|
|
FOR_INT32_INPUTS(j) {
|
2019-02-01 10:37:04 +00:00
|
|
|
p[i] = j;
|
2014-07-30 13:54:45 +00:00
|
|
|
int32_t result = m.Call(p[0], p[1], p[2]);
|
2019-02-01 10:37:04 +00:00
|
|
|
CHECK_EQ(j, result);
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunBinopTester) {
|
2014-07-30 13:54:45 +00:00
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
RawMachineAssemblerTester<int32_t> m(i_isolate(), zone());
|
2014-07-30 13:54:45 +00:00
|
|
|
Int32BinopTester bt(&m);
|
|
|
|
bt.AddReturn(bt.param0);
|
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
FOR_INT32_INPUTS(i) { CHECK_EQ(i, bt.call(i, 777)); }
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
RawMachineAssemblerTester<int32_t> m(i_isolate(), zone());
|
2014-07-30 13:54:45 +00:00
|
|
|
Int32BinopTester bt(&m);
|
|
|
|
bt.AddReturn(bt.param1);
|
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
FOR_INT32_INPUTS(i) { CHECK_EQ(i, bt.call(666, i)); }
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
RawMachineAssemblerTester<int32_t> m(i_isolate(), zone());
|
2014-07-30 13:54:45 +00:00
|
|
|
Float64BinopTester bt(&m);
|
|
|
|
bt.AddReturn(bt.param0);
|
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(i, bt.call(i, 9.0)); }
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
RawMachineAssemblerTester<int32_t> m(i_isolate(), zone());
|
2014-07-30 13:54:45 +00:00
|
|
|
Float64BinopTester bt(&m);
|
|
|
|
bt.AddReturn(bt.param1);
|
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(i, bt.call(-11.25, i)); }
|
2014-07-30 13:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-30 09:16:26 +00:00
|
|
|
|
2015-10-30 21:32:35 +00:00
|
|
|
#if V8_TARGET_ARCH_64_BIT
|
|
|
|
// TODO(ahaas): run int64 tests on all platforms when supported.
|
2019-01-10 10:38:25 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
int64_t Add4(int64_t a, int64_t b, int64_t c, int64_t d) {
|
|
|
|
// Operate on uint64_t values to avoid undefined behavior.
|
|
|
|
return static_cast<int64_t>(
|
|
|
|
static_cast<uint64_t>(a) + static_cast<uint64_t>(b) +
|
|
|
|
static_cast<uint64_t>(c) + static_cast<uint64_t>(d));
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t Add3(int64_t a, int64_t b, int64_t c) { return Add4(a, b, c, 0); }
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2022-08-22 15:42:07 +00:00
|
|
|
TEST_F(CodeGenTest, RunBufferedRawMachineAssemblerTesterTester) {
|
2015-10-30 21:32:35 +00:00
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
BufferedRawMachineAssemblerTester<int64_t> m(i_isolate(), zone());
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Return(m.Int64Constant(0x12500000000));
|
|
|
|
CHECK_EQ(0x12500000000, m.Call());
|
|
|
|
}
|
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
BufferedRawMachineAssemblerTester<double> m(i_isolate(), zone(),
|
|
|
|
MachineType::Float64());
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Return(m.Parameter(0));
|
2019-02-01 10:37:04 +00:00
|
|
|
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(i, m.Call(i)); }
|
2015-10-30 21:32:35 +00:00
|
|
|
}
|
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
BufferedRawMachineAssemblerTester<int64_t> m(
|
|
|
|
i_isolate(), zone(), MachineType::Int64(), MachineType::Int64());
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Return(m.Int64Add(m.Parameter(0), m.Parameter(1)));
|
|
|
|
FOR_INT64_INPUTS(i) {
|
|
|
|
FOR_INT64_INPUTS(j) {
|
2019-02-01 10:37:04 +00:00
|
|
|
CHECK_EQ(base::AddWithWraparound(i, j), m.Call(i, j));
|
|
|
|
CHECK_EQ(base::AddWithWraparound(j, i), m.Call(j, i));
|
2015-10-30 21:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2015-12-10 09:03:30 +00:00
|
|
|
BufferedRawMachineAssemblerTester<int64_t> m(
|
2022-08-22 15:42:07 +00:00
|
|
|
i_isolate(), zone(), MachineType::Int64(), MachineType::Int64(),
|
|
|
|
MachineType::Int64());
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Return(
|
|
|
|
m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)));
|
|
|
|
FOR_INT64_INPUTS(i) {
|
|
|
|
FOR_INT64_INPUTS(j) {
|
2019-02-01 10:37:04 +00:00
|
|
|
CHECK_EQ(Add3(i, i, j), m.Call(i, i, j));
|
|
|
|
CHECK_EQ(Add3(i, j, i), m.Call(i, j, i));
|
|
|
|
CHECK_EQ(Add3(j, i, i), m.Call(j, i, i));
|
2015-10-30 21:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2015-12-10 09:03:30 +00:00
|
|
|
BufferedRawMachineAssemblerTester<int64_t> m(
|
2022-08-22 15:42:07 +00:00
|
|
|
i_isolate(), zone(), MachineType::Int64(), MachineType::Int64(),
|
|
|
|
MachineType::Int64(), MachineType::Int64());
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Return(m.Int64Add(
|
|
|
|
m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)),
|
|
|
|
m.Parameter(3)));
|
|
|
|
FOR_INT64_INPUTS(i) {
|
|
|
|
FOR_INT64_INPUTS(j) {
|
2019-02-01 10:37:04 +00:00
|
|
|
CHECK_EQ(Add4(i, i, i, j), m.Call(i, i, i, j));
|
|
|
|
CHECK_EQ(Add4(i, i, j, i), m.Call(i, i, j, i));
|
|
|
|
CHECK_EQ(Add4(i, j, i, i), m.Call(i, j, i, i));
|
|
|
|
CHECK_EQ(Add4(j, i, i, i), m.Call(j, i, i, i));
|
2015-10-30 21:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
BufferedRawMachineAssemblerTester<void> m(i_isolate(), zone());
|
2015-10-30 21:32:35 +00:00
|
|
|
int64_t result;
|
2015-12-11 15:34:00 +00:00
|
|
|
m.Store(MachineTypeForC<int64_t>().representation(),
|
|
|
|
m.PointerConstant(&result), m.Int64Constant(0x12500000000),
|
|
|
|
kNoWriteBarrier);
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
m.Call();
|
|
|
|
CHECK_EQ(0x12500000000, result);
|
|
|
|
}
|
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
BufferedRawMachineAssemblerTester<void> m(i_isolate(), zone(),
|
|
|
|
MachineType::Float64());
|
2015-10-30 21:32:35 +00:00
|
|
|
double result;
|
2015-12-11 15:34:00 +00:00
|
|
|
m.Store(MachineTypeForC<double>().representation(),
|
|
|
|
m.PointerConstant(&result), m.Parameter(0), kNoWriteBarrier);
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
FOR_FLOAT64_INPUTS(i) {
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(i);
|
|
|
|
CHECK_DOUBLE_EQ(i, result);
|
2015-10-30 21:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2022-08-22 15:42:07 +00:00
|
|
|
BufferedRawMachineAssemblerTester<void> m(
|
|
|
|
i_isolate(), zone(), MachineType::Int64(), MachineType::Int64());
|
2015-10-30 21:32:35 +00:00
|
|
|
int64_t result;
|
2015-12-11 15:34:00 +00:00
|
|
|
m.Store(MachineTypeForC<int64_t>().representation(),
|
|
|
|
m.PointerConstant(&result),
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Int64Add(m.Parameter(0), m.Parameter(1)), kNoWriteBarrier);
|
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
FOR_INT64_INPUTS(i) {
|
|
|
|
FOR_INT64_INPUTS(j) {
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(i, j);
|
|
|
|
CHECK_EQ(base::AddWithWraparound(i, j), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(j, i);
|
|
|
|
CHECK_EQ(base::AddWithWraparound(j, i), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2015-12-10 09:03:30 +00:00
|
|
|
BufferedRawMachineAssemblerTester<void> m(
|
2022-08-22 15:42:07 +00:00
|
|
|
i_isolate(), zone(), MachineType::Int64(), MachineType::Int64(),
|
|
|
|
MachineType::Int64());
|
2015-10-30 21:32:35 +00:00
|
|
|
int64_t result;
|
|
|
|
m.Store(
|
2015-12-11 15:34:00 +00:00
|
|
|
MachineTypeForC<int64_t>().representation(), m.PointerConstant(&result),
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)),
|
|
|
|
kNoWriteBarrier);
|
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
FOR_INT64_INPUTS(i) {
|
|
|
|
FOR_INT64_INPUTS(j) {
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(i, i, j);
|
|
|
|
CHECK_EQ(Add3(i, i, j), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(i, j, i);
|
|
|
|
CHECK_EQ(Add3(i, j, i), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(j, i, i);
|
|
|
|
CHECK_EQ(Add3(j, i, i), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
2015-12-10 09:03:30 +00:00
|
|
|
BufferedRawMachineAssemblerTester<void> m(
|
2022-08-22 15:42:07 +00:00
|
|
|
i_isolate(), zone(), MachineType::Int64(), MachineType::Int64(),
|
|
|
|
MachineType::Int64(), MachineType::Int64());
|
2015-10-30 21:32:35 +00:00
|
|
|
int64_t result;
|
2015-12-11 15:34:00 +00:00
|
|
|
m.Store(MachineTypeForC<int64_t>().representation(),
|
|
|
|
m.PointerConstant(&result),
|
2015-10-30 21:32:35 +00:00
|
|
|
m.Int64Add(m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)),
|
|
|
|
m.Parameter(2)),
|
|
|
|
m.Parameter(3)),
|
|
|
|
kNoWriteBarrier);
|
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
FOR_INT64_INPUTS(i) {
|
|
|
|
FOR_INT64_INPUTS(j) {
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(i, i, i, j);
|
|
|
|
CHECK_EQ(Add4(i, i, i, j), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(i, i, j, i);
|
|
|
|
CHECK_EQ(Add4(i, i, j, i), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(i, j, i, i);
|
|
|
|
CHECK_EQ(Add4(i, j, i, i), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
|
2019-02-01 10:37:04 +00:00
|
|
|
m.Call(j, i, i, i);
|
|
|
|
CHECK_EQ(Add4(j, i, i, i), result);
|
2015-10-30 21:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2015-10-30 09:16:26 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|