Revert "[cctest] Clarify that tests for sync instructions are simulator specific"

This reverts commit 4013518fe3.

Reason for revert:
https://build.chromium.org/p/client.v8.ports/builders/V8%20Linux%20-%20arm64%20-%20sim%20-%20gc%20stress

Original change's description:
> [cctest] Clarify that tests for sync instructions are simulator specific
> 
> Some tests were recently added to test-simulator-arm.cc, however this file is
> meant for tests that are specific to the simulator and therefore are not written
> to work on hardware. While this sounds surprising, the reason is that our simulation
> of synchronisation instructions is more conservative than on hardware.
> 
> To make this more clear, this patch renames the "test-simulator-arm{,64}.cc"
> files to "test-sync-primitives-arm{,64}.cc", and moves the vneg and vabs tests
> into "test-assembler-arm.cc" which is were tests that are garanteed to work in
> either native or simulated environments live.
> 
> Finally, take the opportunity to share a little bit of code.
> 
> Bug: v8:6963
> Change-Id: Ifb85d3671c823b9bba73d09f419536b089a4e87c
> Reviewed-on: https://chromium-review.googlesource.com/749387
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Commit-Queue: Pierre Langlois <pierre.langlois@arm.com>
> Cr-Commit-Position: refs/heads/master@{#49073}

TBR=clemensh@chromium.org,pierre.langlois@arm.com,bmeurer@chromium.org

Change-Id: I1bfb4e9c7c18b716f417a84b18a14cb2e1fa3a7a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6963
Reviewed-on: https://chromium-review.googlesource.com/750624
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49074}
This commit is contained in:
Michael Achenbach 2017-11-02 11:38:43 +00:00 committed by Commit Bot
parent 4013518fe3
commit 1feadfe81b
7 changed files with 201 additions and 275 deletions

View File

@ -249,8 +249,6 @@ v8_source_set("cctest_sources") {
if (v8_current_cpu == "arm") {
sources += [ ### gcmole(arch:arm) ###
"assembler-helper-arm.cc",
"assembler-helper-arm.h",
"test-assembler-arm.cc",
"test-code-stubs-arm.cc",
"test-code-stubs.cc",
@ -258,7 +256,7 @@ v8_source_set("cctest_sources") {
"test-disasm-arm.cc",
"test-macro-assembler-arm.cc",
"test-run-wasm-relocation-arm.cc",
"test-sync-primitives-arm.cc",
"test-simulator-arm.cc",
]
} else if (v8_current_cpu == "arm64") {
sources += [ ### gcmole(arch:arm64) ###
@ -271,7 +269,7 @@ v8_source_set("cctest_sources") {
"test-javascript-arm64.cc",
"test-js-arm64-variables.cc",
"test-run-wasm-relocation-arm64.cc",
"test-sync-primitives-arm64.cc",
"test-simulator-arm64.cc",
"test-utils-arm64.cc",
"test-utils-arm64.h",
]

View File

@ -1,33 +0,0 @@
// 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/cctest/assembler-helper-arm.h"
#include "src/v8.h"
#include "test/cctest/cctest.h"
#include "src/isolate-inl.h"
namespace v8 {
namespace internal {
Address AssembleCode(std::function<void(Assembler&)> assemble) {
Isolate* isolate = CcTest::i_isolate();
Assembler assm(isolate, nullptr, 0);
assemble(assm);
assm.bx(lr);
CodeDesc desc;
assm.GetCode(isolate, &desc);
Handle<Code> code =
isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>());
if (FLAG_print_code) {
code->Print();
}
return code->entry();
}
} // namespace internal
} // namespace v8

View File

@ -1,28 +0,0 @@
// 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.
#ifndef V8_CCTEST_ASSEMBLER_HELPER_ARM_H_
#define V8_CCTEST_ASSEMBLER_HELPER_ARM_H_
#include <functional>
#include "src/macro-assembler.h"
namespace v8 {
namespace internal {
// These function prototypes have 5 arguments since they are used with the
// CALL_GENERATED_CODE macro.
typedef Object* (*F_iiiii)(int x, int p1, int p2, int p3, int p4);
typedef Object* (*F_piiii)(void* p0, int p1, int p2, int p3, int p4);
typedef Object* (*F_ppiii)(void* p0, void* p1, int p2, int p3, int p4);
typedef Object* (*F_pppii)(void* p0, void* p1, void* p2, int p3, int p4);
typedef Object* (*F_ippii)(int p0, void* p1, void* p2, int p3, int p4);
Address AssembleCode(std::function<void(Assembler&)> assemble);
} // namespace internal
} // namespace v8
#endif // V8_CCTEST_ASSEMBLER_HELPER_ARM_H_

View File

@ -244,8 +244,6 @@
'test-run-wasm-relocation-x64.cc',
],
'cctest_sources_arm': [ ### gcmole(arch:arm) ###
'assembler-helper-arm.cc',
'assembler-helper-arm.h',
'test-assembler-arm.cc',
'test-code-stubs.cc',
'test-code-stubs.h',
@ -253,7 +251,7 @@
'test-disasm-arm.cc',
'test-macro-assembler-arm.cc',
'test-run-wasm-relocation-arm.cc',
'test-sync-primitives-arm.cc',
'test-simulator-arm.cc',
],
'cctest_sources_arm64': [ ### gcmole(arch:arm64) ###
'test-utils-arm64.cc',
@ -267,7 +265,7 @@
'test-javascript-arm64.cc',
'test-js-arm64-variables.cc',
'test-run-wasm-relocation-arm64.cc',
'test-sync-primitives-arm64.cc',
'test-simulator-arm64.cc',
],
'cctest_sources_s390': [ ### gcmole(arch:s390) ###
'test-assembler-s390.cc',

View File

@ -36,9 +36,7 @@
#include "src/macro-assembler.h"
#include "src/ostreams.h"
#include "src/v8.h"
#include "test/cctest/assembler-helper-arm.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
namespace v8 {
namespace internal {
@ -46,6 +44,13 @@ namespace test_assembler_arm {
using base::RandomNumberGenerator;
// Define these function prototypes to match JSEntryFunction in execution.cc.
typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4);
typedef Object* (*F2)(int x, int y, int p2, int p3, int p4);
typedef Object* (*F3)(void* p0, int p1, int p2, int p3, int p4);
typedef Object* (*F4)(void* p0, void* p1, int p2, int p3, int p4);
typedef Object* (*F5)(uint32_t p0, void* p1, void* p2, int p3, int p4);
#define __ assm.
TEST(0) {
@ -66,7 +71,7 @@ TEST(0) {
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F2 f = FUNCTION_CAST<F2>(code->entry());
int res =
reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 3, 4, 0, 0, 0));
::printf("f() = %d\n", res);
@ -103,7 +108,7 @@ TEST(1) {
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
int res =
reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 100, 0, 0, 0, 0));
::printf("f() = %d\n", res);
@ -149,7 +154,7 @@ TEST(2) {
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
int res =
reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 10, 0, 0, 0, 0));
::printf("f() = %d\n", res);
@ -197,7 +202,7 @@ TEST(3) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
t.i = 100000;
t.c = 10;
t.s = 1000;
@ -329,7 +334,7 @@ TEST(4) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
t.a = 1.5;
t.b = 2.75;
t.c = 17.17;
@ -392,7 +397,7 @@ TEST(5) {
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = reinterpret_cast<int>(
CALL_GENERATED_CODE(isolate, f, 0xAAAAAAAA, 0, 0, 0, 0));
::printf("f() = %d\n", res);
@ -424,7 +429,7 @@ TEST(6) {
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
int res = reinterpret_cast<int>(
CALL_GENERATED_CODE(isolate, f, 0xFFFF, 0, 0, 0, 0));
::printf("f() = %d\n", res);
@ -493,7 +498,7 @@ static void TestRoundingMode(VCVTTypes types,
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
int res =
reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
::printf("res = %d\n", res);
@ -676,7 +681,7 @@ TEST(8) {
OFStream os(stdout);
code->Print(os);
#endif
F_ppiii fn = FUNCTION_CAST<F_ppiii>(code->entry());
F4 fn = FUNCTION_CAST<F4>(code->entry());
d.a = 1.1;
d.b = 2.2;
d.c = 3.3;
@ -786,7 +791,7 @@ TEST(9) {
OFStream os(stdout);
code->Print(os);
#endif
F_ppiii fn = FUNCTION_CAST<F_ppiii>(code->entry());
F4 fn = FUNCTION_CAST<F4>(code->entry());
d.a = 1.1;
d.b = 2.2;
d.c = 3.3;
@ -892,7 +897,7 @@ TEST(10) {
OFStream os(stdout);
code->Print(os);
#endif
F_ppiii fn = FUNCTION_CAST<F_ppiii>(code->entry());
F4 fn = FUNCTION_CAST<F4>(code->entry());
d.a = 1.1;
d.b = 2.2;
d.c = 3.3;
@ -987,7 +992,7 @@ TEST(11) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy = CALL_GENERATED_CODE(isolate, f, &i, 0, 0, 0, 0);
USE(dummy);
@ -1114,7 +1119,7 @@ TEST(13) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
t.a = 1.5;
t.b = 2.75;
t.c = 17.17;
@ -1187,7 +1192,7 @@ TEST(14) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
t.left = bit_cast<double>(kHoleNanInt64);
t.right = 1;
t.add_result = 0;
@ -2068,7 +2073,7 @@ TEST(15) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
t.src0 = 0x01020304;
t.src1 = 0x11121314;
t.src2 = 0x21222324;
@ -2345,7 +2350,7 @@ TEST(16) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
t.src0 = 0x01020304;
t.src1 = 0x11121314;
t.src2 = 0x11121300;
@ -2426,7 +2431,7 @@ TEST(sdiv) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy;
TEST_SDIV(0, kMinInt, 0);
TEST_SDIV(0, 1024, 0);
@ -2490,7 +2495,7 @@ TEST(udiv) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy;
TEST_UDIV(0u, 0, 0);
TEST_UDIV(0u, 1024, 0);
@ -2520,7 +2525,7 @@ TEST(smmla) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt(), y = rng->NextInt(), z = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, y, z, 0);
@ -2546,7 +2551,7 @@ TEST(smmul) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt(), y = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, y, 0, 0);
@ -2572,7 +2577,7 @@ TEST(sxtb) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, 0, 0, 0);
@ -2598,7 +2603,7 @@ TEST(sxtab) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt(), y = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, y, 0, 0);
@ -2624,7 +2629,7 @@ TEST(sxth) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, 0, 0, 0);
@ -2650,7 +2655,7 @@ TEST(sxtah) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt(), y = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, y, 0, 0);
@ -2676,7 +2681,7 @@ TEST(uxtb) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, 0, 0, 0);
@ -2702,7 +2707,7 @@ TEST(uxtab) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt(), y = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, y, 0, 0);
@ -2728,7 +2733,7 @@ TEST(uxth) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, 0, 0, 0);
@ -2754,7 +2759,7 @@ TEST(uxtah) {
#ifdef OBJECT_PRINT
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
for (size_t i = 0; i < 128; ++i) {
int32_t r, x = rng->NextInt(), y = rng->NextInt();
Object* dummy = CALL_GENERATED_CODE(isolate, f, &r, x, y, 0, 0);
@ -2798,7 +2803,7 @@ TEST(rbit) {
code->Print(std::cout);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy = nullptr;
TEST_RBIT(0xffffffff, 0xffffffff);
TEST_RBIT(0x00000000, 0x00000000);
@ -2875,7 +2880,7 @@ TEST(code_relative_offset) {
assm.GetCode(isolate, &desc);
Handle<Code> code =
isolate->factory()->NewCode(desc, Code::STUB, code_object);
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
int res =
reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 21, 0, 0, 0, 0));
::printf("f() = %d\n", res);
@ -2919,7 +2924,7 @@ TEST(msr_mrs) {
OFStream os(stdout);
code->Print(os);
#endif
F_ippii f = FUNCTION_CAST<F_ippii>(code->entry());
F5 f = FUNCTION_CAST<F5>(code->entry());
Object* dummy = nullptr;
USE(dummy);
@ -3020,7 +3025,7 @@ TEST(ARMv8_float32_vrintX) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy = nullptr;
USE(dummy);
@ -3125,7 +3130,7 @@ TEST(ARMv8_vrintX) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy = nullptr;
USE(dummy);
@ -3265,7 +3270,7 @@ TEST(ARMv8_vsel) {
OFStream os(stdout);
code->Print(os);
#endif
F_ippii f = FUNCTION_CAST<F_ippii>(code->entry());
F5 f = FUNCTION_CAST<F5>(code->entry());
Object* dummy = nullptr;
USE(dummy);
@ -3359,7 +3364,7 @@ TEST(ARMv8_vminmax_f64) {
OFStream os(stdout);
code->Print(os);
#endif
F_ppiii f = FUNCTION_CAST<F_ppiii>(code->entry());
F4 f = FUNCTION_CAST<F4>(code->entry());
Object* dummy = nullptr;
USE(dummy);
@ -3441,7 +3446,7 @@ TEST(ARMv8_vminmax_f32) {
OFStream os(stdout);
code->Print(os);
#endif
F_ppiii f = FUNCTION_CAST<F_ppiii>(code->entry());
F4 f = FUNCTION_CAST<F4>(code->entry());
Object* dummy = nullptr;
USE(dummy);
@ -3482,7 +3487,7 @@ TEST(ARMv8_vminmax_f32) {
}
template <typename T, typename Inputs, typename Results>
static F_ppiii GenerateMacroFloatMinMax(MacroAssembler& assm) {
static F4 GenerateMacroFloatMinMax(MacroAssembler& assm) {
T a = T::from_code(0); // d0/s0
T b = T::from_code(1); // d1/s1
T c = T::from_code(2); // d2/s2
@ -3573,7 +3578,7 @@ static F_ppiii GenerateMacroFloatMinMax(MacroAssembler& assm) {
OFStream os(stdout);
code->Print(os);
#endif
return FUNCTION_CAST<F_ppiii>(code->entry());
return FUNCTION_CAST<F4>(code->entry());
}
TEST(macro_float_minmax_f64) {
@ -3600,7 +3605,7 @@ TEST(macro_float_minmax_f64) {
double max_aba_;
};
F_ppiii f = GenerateMacroFloatMinMax<DwVfpRegister, Inputs, Results>(assm);
F4 f = GenerateMacroFloatMinMax<DwVfpRegister, Inputs, Results>(assm);
Object* dummy = nullptr;
USE(dummy);
@ -3668,7 +3673,7 @@ TEST(macro_float_minmax_f32) {
float max_aba_;
};
F_ppiii f = GenerateMacroFloatMinMax<SwVfpRegister, Inputs, Results>(assm);
F4 f = GenerateMacroFloatMinMax<SwVfpRegister, Inputs, Results>(assm);
Object* dummy = nullptr;
USE(dummy);
@ -3741,7 +3746,7 @@ TEST(unaligned_loads) {
OFStream os(stdout);
code->Print(os);
#endif
F_ppiii f = FUNCTION_CAST<F_ppiii>(code->entry());
F4 f = FUNCTION_CAST<F4>(code->entry());
Object* dummy = nullptr;
USE(dummy);
@ -3787,7 +3792,7 @@ TEST(unaligned_stores) {
OFStream os(stdout);
code->Print(os);
#endif
F_ppiii f = FUNCTION_CAST<F_ppiii>(code->entry());
F4 f = FUNCTION_CAST<F4>(code->entry());
Object* dummy = nullptr;
USE(dummy);
@ -3890,7 +3895,7 @@ TEST(vswp) {
OFStream os(stdout);
code->Print(os);
#endif
F_piiii f = FUNCTION_CAST<F_piiii>(code->entry());
F3 f = FUNCTION_CAST<F3>(code->entry());
Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
USE(dummy);
CHECK_EQ(minus_one, t.vswp_d0);
@ -4008,7 +4013,7 @@ TEST(split_add_immediate) {
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
uint32_t res =
reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
::printf("f() = 0x%x\n", res);
@ -4029,7 +4034,7 @@ TEST(split_add_immediate) {
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
uint32_t res =
reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
::printf("f() = 0x%x\n", res);
@ -4053,7 +4058,7 @@ TEST(split_add_immediate) {
OFStream os(stdout);
code->Print(os);
#endif
F_iiiii f = FUNCTION_CAST<F_iiiii>(code->entry());
F1 f = FUNCTION_CAST<F1>(code->entry());
uint32_t res =
reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
::printf("f() = 0x%x\n", res);
@ -4061,106 +4066,6 @@ TEST(split_add_immediate) {
}
}
namespace {
std::vector<Float32> Float32Inputs() {
std::vector<Float32> inputs;
FOR_FLOAT32_INPUTS(f) {
inputs.push_back(Float32::FromBits(bit_cast<uint32_t>(*f)));
}
FOR_UINT32_INPUTS(bits) { inputs.push_back(Float32::FromBits(*bits)); }
return inputs;
}
std::vector<Float64> Float64Inputs() {
std::vector<Float64> inputs;
FOR_FLOAT64_INPUTS(f) {
inputs.push_back(Float64::FromBits(bit_cast<uint64_t>(*f)));
}
FOR_UINT64_INPUTS(bits) { inputs.push_back(Float64::FromBits(*bits)); }
return inputs;
}
} // namespace
TEST(vabs_32) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
F_iiiii f = FUNCTION_CAST<F_iiiii>(AssembleCode([](Assembler& assm) {
__ vmov(s0, r0);
__ vabs(s0, s0);
__ vmov(r0, s0);
}));
for (Float32 f32 : Float32Inputs()) {
Float32 res = Float32::FromBits(reinterpret_cast<uint32_t>(
CALL_GENERATED_CODE(isolate, f, f32.get_bits(), 0, 0, 0, 0)));
Float32 exp = Float32::FromBits(f32.get_bits() & ~(1 << 31));
CHECK_EQ(exp.get_bits(), res.get_bits());
}
}
TEST(vabs_64) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
F_iiiii f = FUNCTION_CAST<F_iiiii>(AssembleCode([](Assembler& assm) {
__ vmov(d0, r0, r1);
__ vabs(d0, d0);
__ vmov(r1, r0, d0);
}));
for (Float64 f64 : Float64Inputs()) {
uint32_t p0 = static_cast<uint32_t>(f64.get_bits());
uint32_t p1 = static_cast<uint32_t>(f64.get_bits() >> 32);
uint32_t res = reinterpret_cast<uint32_t>(
CALL_GENERATED_CODE(isolate, f, p0, p1, 0, 0, 0));
Float64 exp = Float64::FromBits(f64.get_bits() & ~(1ull << 63));
// We just get back the top word, so only compare that one.
CHECK_EQ(exp.get_bits() >> 32, res);
}
}
TEST(vneg_32) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
F_iiiii f = FUNCTION_CAST<F_iiiii>(AssembleCode([](Assembler& assm) {
__ vmov(s0, r0);
__ vneg(s0, s0);
__ vmov(r0, s0);
}));
for (Float32 f32 : Float32Inputs()) {
Float32 res = Float32::FromBits(reinterpret_cast<uint32_t>(
CALL_GENERATED_CODE(isolate, f, f32.get_bits(), 0, 0, 0, 0)));
Float32 exp = Float32::FromBits(f32.get_bits() ^ (1 << 31));
CHECK_EQ(exp.get_bits(), res.get_bits());
}
}
TEST(vneg_64) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
F_iiiii f = FUNCTION_CAST<F_iiiii>(AssembleCode([](Assembler& assm) {
__ vmov(d0, r0, r1);
__ vneg(d0, d0);
__ vmov(r1, r0, d0);
}));
for (Float64 f64 : Float64Inputs()) {
uint32_t p0 = static_cast<uint32_t>(f64.get_bits());
uint32_t p1 = static_cast<uint32_t>(f64.get_bits() >> 32);
uint32_t res = reinterpret_cast<uint32_t>(
CALL_GENERATED_CODE(isolate, f, p0, p1, 0, 0, 0));
Float64 exp = Float64::FromBits(f64.get_bits() ^ (1ull << 63));
// We just get back the top word, so only compare that one.
CHECK_EQ(exp.get_bits() >> 32, res);
}
}
#undef __
} // namespace test_assembler_arm

View File

@ -26,8 +26,8 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "src/v8.h"
#include "test/cctest/assembler-helper-arm.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "src/arm/simulator-arm.h"
#include "src/assembler-inl.h"
@ -38,25 +38,14 @@
namespace v8 {
namespace internal {
// These tests rely on the behaviour specific to the simulator so we cannot
// expect the same results on real hardware. The reason for this is that our
// simulation of synchronisation primitives is more conservative than the
// reality.
// For example:
// ldrex r1, [r2] ; Load acquire at address r2; r2 is now marked as exclusive.
// ldr r0, [r4] ; This is a normal load, and at a different address.
// ; However, any memory accesses can potentially clear the
// ; exclusivity (See ARM DDI 0406C.c A3.4.5). This is unlikely
// ; on real hardware but to be conservative, the simulator
// ; always does it.
// strex r3, r1, [r2] ; As a result, this will always fail in the simulator
// ; but will likely succeed on hardware.
#if defined(USE_SIMULATOR)
#ifndef V8_TARGET_LITTLE_ENDIAN
#error Expected ARM to be little-endian
#endif
// Define these function prototypes to match JSEntryFunction in execution.cc.
typedef Object* (*F_iiiii)(int p0, int p1, int p2, int p3, int p4);
typedef Object* (*F_piiii)(void* p0, int p1, int p2, int p3, int p4);
#define __ assm.
namespace {
@ -179,6 +168,22 @@ void AssembleMemoryAccess(Assembler* assembler, MemoryAccess access,
}
}
Address AssembleCode(std::function<void(Assembler&)> assemble) {
Isolate* isolate = CcTest::i_isolate();
Assembler assm(isolate, nullptr, 0);
assemble(assm);
__ bx(lr);
CodeDesc desc;
assm.GetCode(isolate, &desc);
Handle<Code> code =
isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>());
return code->entry();
}
#if defined(USE_SIMULATOR)
void AssembleLoadExcl(Assembler* assembler, MemoryAccess access,
Register value_reg, Register addr_reg) {
DCHECK(access.kind == MemoryAccess::Kind::LoadExcl);
@ -223,9 +228,32 @@ void TestInvalidateExclusiveAccess(TestData initial_data, MemoryAccess access1,
break;
}
}
#endif
std::vector<Float32> Float32Inputs() {
std::vector<Float32> inputs;
FOR_FLOAT32_INPUTS(f) {
inputs.push_back(Float32::FromBits(bit_cast<uint32_t>(*f)));
}
FOR_UINT32_INPUTS(bits) { inputs.push_back(Float32::FromBits(*bits)); }
return inputs;
}
std::vector<Float64> Float64Inputs() {
std::vector<Float64> inputs;
FOR_FLOAT64_INPUTS(f) {
inputs.push_back(Float64::FromBits(bit_cast<uint64_t>(*f)));
}
FOR_UINT64_INPUTS(bits) { inputs.push_back(Float64::FromBits(*bits)); }
return inputs;
}
} // namespace
// TODO(rodolph.perfetta@arm.com): Enable this test for native hardware, see
// http://crbug.com/v8/6963.
#if defined(USE_SIMULATOR)
TEST(simulator_invalidate_exclusive_access) {
using Kind = MemoryAccess::Kind;
using Size = MemoryAccess::Size;
@ -262,10 +290,10 @@ TEST(simulator_invalidate_exclusive_access) {
0, TestData(7));
}
namespace {
#endif // USE_SIMULATOR
int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data,
MemoryAccess access) {
static int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data,
MemoryAccess access) {
HandleScope scope(isolate);
F_piiii f = FUNCTION_CAST<F_piiii>(AssembleCode([&](Assembler& assm) {
AssembleMemoryAccess(&assm, access, r0, r2, r1);
@ -275,8 +303,6 @@ int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data,
CALL_GENERATED_CODE(isolate, f, test_data, 0, 0, 0, 0));
}
} // namespace
class MemoryAccessThread : public v8::base::Thread {
public:
MemoryAccessThread()
@ -344,6 +370,10 @@ class MemoryAccessThread : public v8::base::Thread {
v8::Isolate* isolate_;
};
// TODO(rodolph.perfetta@arm.com): Enable this test for native hardware, see
// http://crbug.com/v8/6963.
#if defined(USE_SIMULATOR)
TEST(simulator_invalidate_exclusive_access_threaded) {
using Kind = MemoryAccess::Kind;
using Size = MemoryAccess::Size;
@ -392,9 +422,87 @@ TEST(simulator_invalidate_exclusive_access_threaded) {
thread.Join();
}
#undef __
#endif // USE_SIMULATOR
#endif // defined(USE_SIMULATOR)
TEST(simulator_vabs_32) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
F_iiiii f = FUNCTION_CAST<F_iiiii>(AssembleCode([](Assembler& assm) {
__ vmov(s0, r0);
__ vabs(s0, s0);
__ vmov(r0, s0);
}));
for (Float32 f32 : Float32Inputs()) {
Float32 res = Float32::FromBits(reinterpret_cast<uint32_t>(
CALL_GENERATED_CODE(isolate, f, f32.get_bits(), 0, 0, 0, 0)));
Float32 exp = Float32::FromBits(f32.get_bits() & ~(1 << 31));
CHECK_EQ(exp.get_bits(), res.get_bits());
}
}
TEST(simulator_vabs_64) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
F_iiiii f = FUNCTION_CAST<F_iiiii>(AssembleCode([](Assembler& assm) {
__ vmov(d0, r0, r1);
__ vabs(d0, d0);
__ vmov(r1, r0, d0);
}));
for (Float64 f64 : Float64Inputs()) {
uint32_t p0 = static_cast<uint32_t>(f64.get_bits());
uint32_t p1 = static_cast<uint32_t>(f64.get_bits() >> 32);
uint32_t res = reinterpret_cast<uint32_t>(
CALL_GENERATED_CODE(isolate, f, p0, p1, 0, 0, 0));
Float64 exp = Float64::FromBits(f64.get_bits() & ~(1ull << 63));
// We just get back the top word, so only compare that one.
CHECK_EQ(exp.get_bits() >> 32, res);
}
}
TEST(simulator_vneg_32) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
F_iiiii f = FUNCTION_CAST<F_iiiii>(AssembleCode([](Assembler& assm) {
__ vmov(s0, r0);
__ vneg(s0, s0);
__ vmov(r0, s0);
}));
for (Float32 f32 : Float32Inputs()) {
Float32 res = Float32::FromBits(reinterpret_cast<uint32_t>(
CALL_GENERATED_CODE(isolate, f, f32.get_bits(), 0, 0, 0, 0)));
Float32 exp = Float32::FromBits(f32.get_bits() ^ (1 << 31));
CHECK_EQ(exp.get_bits(), res.get_bits());
}
}
TEST(simulator_vneg_64) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
F_iiiii f = FUNCTION_CAST<F_iiiii>(AssembleCode([](Assembler& assm) {
__ vmov(d0, r0, r1);
__ vneg(d0, d0);
__ vmov(r1, r0, d0);
}));
for (Float64 f64 : Float64Inputs()) {
uint32_t p0 = static_cast<uint32_t>(f64.get_bits());
uint32_t p1 = static_cast<uint32_t>(f64.get_bits() >> 32);
uint32_t res = reinterpret_cast<uint32_t>(
CALL_GENERATED_CODE(isolate, f, p0, p1, 0, 0, 0));
Float64 exp = Float64::FromBits(f64.get_bits() ^ (1ull << 63));
// We just get back the top word, so only compare that one.
CHECK_EQ(exp.get_bits() >> 32, res);
}
}
#undef __
} // namespace internal
} // namespace v8

View File

@ -36,19 +36,6 @@
namespace v8 {
namespace internal {
// These tests rely on the behaviour specific to the simulator so we cannot
// expect the same results on real hardware. The reason for this is that our
// simulation of synchronisation primitives is more conservative than the
// reality.
// For example:
// ldxr x1, [x2] ; Load acquire at address x2; x2 is now marked as exclusive.
// ldr x0, [x4] ; This is a normal load, and at a different address.
// ; However, any memory accesses can potentially clear the
// ; exclusivity (See ARM DDI 0487B.a B2.9.5). This is unlikely
// ; on real hardware but to be conservative, the simulator
// ; always does it.
// stxr w3, x1, [x2] ; As a result, this will always fail in the simulator but
// ; will likely succeed on hardware.
#if defined(USE_SIMULATOR)
#ifndef V8_TARGET_LITTLE_ENDIAN
@ -93,11 +80,9 @@ struct TestData {
int dummy;
};
namespace {
void AssembleMemoryAccess(MacroAssembler* assembler, MemoryAccess access,
Register dest_reg, Register value_reg,
Register addr_reg) {
static void AssembleMemoryAccess(MacroAssembler* assembler, MemoryAccess access,
Register dest_reg, Register value_reg,
Register addr_reg) {
MacroAssembler& masm = *assembler;
__ Add(addr_reg, x0, Operand(access.offset));
@ -177,22 +162,22 @@ void AssembleMemoryAccess(MacroAssembler* assembler, MemoryAccess access,
}
}
void AssembleLoadExcl(MacroAssembler* assembler, MemoryAccess access,
Register value_reg, Register addr_reg) {
static void AssembleLoadExcl(MacroAssembler* assembler, MemoryAccess access,
Register value_reg, Register addr_reg) {
DCHECK(access.kind == MemoryAccess::Kind::LoadExcl);
AssembleMemoryAccess(assembler, access, no_reg, value_reg, addr_reg);
}
void AssembleStoreExcl(MacroAssembler* assembler, MemoryAccess access,
Register dest_reg, Register value_reg,
Register addr_reg) {
static void AssembleStoreExcl(MacroAssembler* assembler, MemoryAccess access,
Register dest_reg, Register value_reg,
Register addr_reg) {
DCHECK(access.kind == MemoryAccess::Kind::StoreExcl);
AssembleMemoryAccess(assembler, access, dest_reg, value_reg, addr_reg);
}
void TestInvalidateExclusiveAccess(TestData initial_data, MemoryAccess access1,
MemoryAccess access2, MemoryAccess access3,
int expected_res, TestData expected_data) {
static void TestInvalidateExclusiveAccess(
TestData initial_data, MemoryAccess access1, MemoryAccess access2,
MemoryAccess access3, int expected_res, TestData expected_data) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
MacroAssembler masm(isolate, nullptr, 0,
@ -207,7 +192,6 @@ void TestInvalidateExclusiveAccess(TestData initial_data, MemoryAccess access1,
masm.GetCode(isolate, &desc);
Handle<Code> code =
isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>());
TestData t = initial_data;
Simulator::CallArgument args[] = {
Simulator::CallArgument(reinterpret_cast<uintptr_t>(&t)),
@ -231,8 +215,6 @@ void TestInvalidateExclusiveAccess(TestData initial_data, MemoryAccess access1,
}
}
} // namespace
TEST(simulator_invalidate_exclusive_access) {
using Kind = MemoryAccess::Kind;
using Size = MemoryAccess::Size;
@ -269,10 +251,8 @@ TEST(simulator_invalidate_exclusive_access) {
0, TestData(7));
}
namespace {
int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data,
MemoryAccess access) {
static int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data,
MemoryAccess access) {
HandleScope scope(isolate);
MacroAssembler masm(isolate, nullptr, 0,
v8::internal::CodeObjectRequired::kYes);
@ -290,8 +270,6 @@ int ExecuteMemoryAccess(Isolate* isolate, TestData* test_data,
return Simulator::current(isolate)->wreg(0);
}
} // namespace
class MemoryAccessThread : public v8::base::Thread {
public:
MemoryAccessThread()