Commit 90da4e72 authored by jgruber's avatar jgruber Committed by Commit Bot

[builtins] Remove .incbin test

The .byte directive will be used instead of .incbin since the latter
comes with complications involving build-time dependency detection.

Drive-by-edits: Move macro definitions closer to their use-sites.

TBR=rmcilroy@chromium.org

Cq-Include-Trybots: luci.v8.try:v8_win64_msvc_compile_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng
Bug: v8:6666
Change-Id: Ibda0b3577688248dbf627cb69965d28309193859
Reviewed-on: https://chromium-review.googlesource.com/906488
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51147}
parent 03efbd4c
......@@ -6,18 +6,6 @@
'variables': {
'v8_code': 1,
'generated_file': '<(SHARED_INTERMEDIATE_DIR)/resources.cc',
'inputs': [
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-arm.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-arm64.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-ia32.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-mips.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-mips64.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-ppc.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-s390.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-x64-win.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/f-x64.bin',
'<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/string.bin',
],
'cctest_sources': [
'../test/cctest/compiler/c-signature.h',
'../test/cctest/compiler/call-tester.h',
......@@ -314,7 +302,6 @@
'type': 'executable',
'dependencies': [
'resources',
'test-isolate-independent-builtins-files',
'v8.gyp:v8_libbase',
'v8.gyp:v8_libplatform',
],
......@@ -424,27 +411,6 @@
}],
],
},
{
'target_name': 'test-isolate-independent-builtins-files',
'type': 'none',
'copies': [
{
'destination': '<(SHARED_INTERMEDIATE_DIR)/test-isolate-independent-builtins/',
'files': [
'../test/cctest/test-isolate-independent-builtins/f-arm.bin',
'../test/cctest/test-isolate-independent-builtins/f-arm64.bin',
'../test/cctest/test-isolate-independent-builtins/f-ia32.bin',
'../test/cctest/test-isolate-independent-builtins/f-mips.bin',
'../test/cctest/test-isolate-independent-builtins/f-mips64.bin',
'../test/cctest/test-isolate-independent-builtins/f-ppc.bin',
'../test/cctest/test-isolate-independent-builtins/f-s390.bin',
'../test/cctest/test-isolate-independent-builtins/f-x64-win.bin',
'../test/cctest/test-isolate-independent-builtins/f-x64.bin',
'../test/cctest/test-isolate-independent-builtins/string.bin',
],
},
],
},
{
'target_name': 'resources',
'type': 'none',
......
......@@ -35,20 +35,6 @@ v8_executable("cctest") {
v8_source_set("cctest_sources") {
testonly = true
# Create a dependency from this target to the generated files below.
inputs = [
"$root_gen_dir/test-isolate-independent-builtins/f-arm64.bin",
"$root_gen_dir/test-isolate-independent-builtins/f-arm.bin",
"$root_gen_dir/test-isolate-independent-builtins/f-ia32.bin",
"$root_gen_dir/test-isolate-independent-builtins/f-mips64.bin",
"$root_gen_dir/test-isolate-independent-builtins/f-mips.bin",
"$root_gen_dir/test-isolate-independent-builtins/f-ppc.bin",
"$root_gen_dir/test-isolate-independent-builtins/f-s390.bin",
"$root_gen_dir/test-isolate-independent-builtins/f-x64.bin",
"$root_gen_dir/test-isolate-independent-builtins/f-x64-win.bin",
"$root_gen_dir/test-isolate-independent-builtins/string.bin",
]
sources = [
"$target_gen_dir/resources.cc",
......@@ -375,7 +361,6 @@ v8_source_set("cctest_sources") {
public_deps = [
":resources",
":test-isolate-independent-builtins-files",
"../..:v8_initializers",
"../..:v8_libbase",
"../..:v8_libplatform",
......@@ -424,25 +409,6 @@ v8_source_set("cctest_sources") {
}
}
copy("test-isolate-independent-builtins-files") {
sources = [
"test-isolate-independent-builtins/f-arm.bin",
"test-isolate-independent-builtins/f-arm64.bin",
"test-isolate-independent-builtins/f-ia32.bin",
"test-isolate-independent-builtins/f-mips.bin",
"test-isolate-independent-builtins/f-mips64.bin",
"test-isolate-independent-builtins/f-ppc.bin",
"test-isolate-independent-builtins/f-s390.bin",
"test-isolate-independent-builtins/f-x64-win.bin",
"test-isolate-independent-builtins/f-x64.bin",
"test-isolate-independent-builtins/string.bin",
]
outputs = [
"$root_gen_dir/test-isolate-independent-builtins/{{source_file_part}}",
]
}
action("resources") {
visibility = [ ":*" ] # Only targets in this file can depend on this.
......
......@@ -11,36 +11,10 @@
#include "src/simulator.h"
#include "src/snapshot/snapshot.h"
// To generate the binary files for the test function (used in the IncbinInText
// below), enable this section and run GenerateTestFunctionData once on each
// arch.
// To generate the binary files for the test function, enable this section and
// run GenerateTestFunctionData once on each arch.
#define GENERATE_TEST_FUNCTION_DATA false
// Arch-specific defines.
#if V8_TARGET_ARCH_IA32
#define TEST_FUNCTION_FILE "f-ia32.bin"
#elif V8_TARGET_ARCH_X64 && _WIN64
#define TEST_FUNCTION_FILE "f-x64-win.bin"
#elif V8_TARGET_ARCH_X64
#define TEST_FUNCTION_FILE "f-x64.bin"
#elif V8_TARGET_ARCH_ARM64
#define TEST_FUNCTION_FILE "f-arm64.bin"
#elif V8_TARGET_ARCH_ARM
#define TEST_FUNCTION_FILE "f-arm.bin"
#elif V8_TARGET_ARCH_PPC
#define TEST_FUNCTION_FILE "f-ppc.bin"
#elif V8_TARGET_ARCH_MIPS
#define TEST_FUNCTION_FILE "f-mips.bin"
#elif V8_TARGET_ARCH_MIPS64
#define TEST_FUNCTION_FILE "f-mips64.bin"
#elif V8_TARGET_ARCH_S390
#define TEST_FUNCTION_FILE "f-s390.bin"
#else
#error "Unknown architecture."
#endif
#define __ masm.
namespace v8 {
namespace internal {
namespace test_isolate_independent_builtins {
......@@ -108,68 +82,42 @@ TEST(VerifyBuiltinsIsolateIndependence) {
CHECK(!found_mismatch);
}
// .incbin macros.
#if defined(V8_OS_MACOSX)
#define ASM_RODATA_SECTION ".const_data\n"
#define ASM_TEXT_SECTION ".text\n"
#define ASM_MANGLE_LABEL "_"
#define ASM_GLOBAL(NAME) ".globl " ASM_MANGLE_LABEL NAME "\n"
#elif defined(V8_OS_WIN)
#define ASM_RODATA_SECTION ".section .rodata\n"
#define ASM_TEXT_SECTION ".section .text\n"
#if defined(V8_TARGET_ARCH_X64)
#define ASM_MANGLE_LABEL ""
#else
#define ASM_MANGLE_LABEL "_"
#endif
#define ASM_GLOBAL(NAME) ".global " ASM_MANGLE_LABEL NAME "\n"
#else
#define ASM_RODATA_SECTION ".section .rodata\n"
#define ASM_TEXT_SECTION ".section .text\n"
#define ASM_MANGLE_LABEL ""
#define ASM_GLOBAL(NAME) ".global " ASM_MANGLE_LABEL NAME "\n"
#endif
// clang-format off
#define EMBED_IN_RODATA_HEADER(LABEL) \
__asm__(ASM_RODATA_SECTION \
ASM_GLOBAL(#LABEL) \
".balign 16\n" \
ASM_MANGLE_LABEL #LABEL ":\n");
#define EMBED_IN_TEXT_HEADER(LABEL) \
__asm__(ASM_TEXT_SECTION \
ASM_GLOBAL(#LABEL) \
".balign 16\n" \
ASM_MANGLE_LABEL #LABEL ":\n");
#define INCBIN_RODATA(LABEL, FILE) \
EMBED_IN_RODATA_HEADER(LABEL) \
__asm__(".incbin \"" FILE "\"\n"); \
extern "C" V8_ALIGNED(16) const char LABEL[]
#define INCBIN_TEXT(LABEL, FILE) \
EMBED_IN_TEXT_HEADER(LABEL) \
__asm__(".incbin \"" FILE "\"\n"); \
extern "C" V8_ALIGNED(16) const char LABEL[]
// clang-format on
// V8_CC_MSVC is true for both MSVC and clang on windows. clang can handle
// .incbin but MSVC cannot, and thus we need a more precise compiler detection
// that can distinguish between the two. clang on windows sets both __clang__
// and _MSC_VER, MSVC sets only _MSC_VER.
// __asm__-style inline assembly but MSVC cannot, and thus we need a more
// precise compiler detection that can distinguish between the two. clang on
// windows sets both __clang__ and _MSC_VER, MSVC sets only _MSC_VER.
#if defined(_MSC_VER) && !defined(__clang__)
#define V8_COMPILER_IS_MSVC
#endif
#ifndef V8_COMPILER_IS_MSVC
INCBIN_RODATA(test_string_bytes,
"gen/test-isolate-independent-builtins/string.bin");
INCBIN_TEXT(test_function_bytes,
"gen/test-isolate-independent-builtins/" TEST_FUNCTION_FILE);
#if GENERATE_TEST_FUNCTION_DATA
// Arch-specific defines.
#if V8_TARGET_ARCH_IA32
#define TEST_FUNCTION_FILE "f-ia32.bin"
#elif V8_TARGET_ARCH_X64 && _WIN64
#define TEST_FUNCTION_FILE "f-x64-win.bin"
#elif V8_TARGET_ARCH_X64
#define TEST_FUNCTION_FILE "f-x64.bin"
#elif V8_TARGET_ARCH_ARM64
#define TEST_FUNCTION_FILE "f-arm64.bin"
#elif V8_TARGET_ARCH_ARM
#define TEST_FUNCTION_FILE "f-arm.bin"
#elif V8_TARGET_ARCH_PPC
#define TEST_FUNCTION_FILE "f-ppc.bin"
#elif V8_TARGET_ARCH_MIPS
#define TEST_FUNCTION_FILE "f-mips.bin"
#elif V8_TARGET_ARCH_MIPS64
#define TEST_FUNCTION_FILE "f-mips64.bin"
#elif V8_TARGET_ARCH_S390
#define TEST_FUNCTION_FILE "f-s390.bin"
#else
#error "Unknown architecture."
#endif
#define __ masm.
TEST(GenerateTestFunctionData) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
......@@ -246,21 +194,6 @@ TEST(GenerateTestFunctionData) {
}
#endif // GENERATE_TEST_FUNCTION_DATA
TEST(IncbinInRodata) {
CHECK_EQ(0, std::strcmp("0123456789\n", test_string_bytes));
}
TEST(IncbinInText) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
auto f = GeneratedCode<int(int, int)>::FromAddress(
isolate, const_cast<char*>(test_function_bytes));
CHECK_EQ(7, f.Call(3, 4));
CHECK_EQ(11, f.Call(5, 6));
}
// Repeat the same tests, but using the .byte directive instead of .incbin.
#if V8_TARGET_ARCH_IA32
#define FUNCTION_BYTES \
".byte 0x8b, 0x44, 0x24, 0x04, 0x03, 0x44, 0x24, 0x08, 0xc3\n"
......@@ -290,7 +223,42 @@ TEST(IncbinInText) {
#error "Unknown architecture."
#endif
// .byte macros to handle small differences across operating systems.
#if defined(V8_OS_MACOSX)
#define ASM_RODATA_SECTION ".const_data\n"
#define ASM_TEXT_SECTION ".text\n"
#define ASM_MANGLE_LABEL "_"
#define ASM_GLOBAL(NAME) ".globl " ASM_MANGLE_LABEL NAME "\n"
#elif defined(V8_OS_WIN)
#define ASM_RODATA_SECTION ".section .rodata\n"
#define ASM_TEXT_SECTION ".section .text\n"
#if defined(V8_TARGET_ARCH_X64)
#define ASM_MANGLE_LABEL ""
#else
#define ASM_MANGLE_LABEL "_"
#endif
#define ASM_GLOBAL(NAME) ".global " ASM_MANGLE_LABEL NAME "\n"
#else
#define ASM_RODATA_SECTION ".section .rodata\n"
#define ASM_TEXT_SECTION ".section .text\n"
#define ASM_MANGLE_LABEL ""
#define ASM_GLOBAL(NAME) ".global " ASM_MANGLE_LABEL NAME "\n"
#endif
// clang-format off
#define EMBED_IN_RODATA_HEADER(LABEL) \
__asm__(ASM_RODATA_SECTION \
ASM_GLOBAL(#LABEL) \
".balign 16\n" \
ASM_MANGLE_LABEL #LABEL ":\n");
#define EMBED_IN_TEXT_HEADER(LABEL) \
__asm__(ASM_TEXT_SECTION \
ASM_GLOBAL(#LABEL) \
".balign 16\n" \
ASM_MANGLE_LABEL #LABEL ":\n");
EMBED_IN_RODATA_HEADER(test_string0_bytes)
__asm__(".byte 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37\n"
".byte 0x38, 0x39, 0x0a, 0x00\n");
......@@ -301,6 +269,10 @@ __asm__(FUNCTION_BYTES);
extern "C" V8_ALIGNED(16) const char test_function0_bytes[];
// clang-format on
// A historical note: We use .byte over .incbin since the latter leads to
// complications involving generation of build-time dependencies. Goma parses
// #include statements, and clang has -MD/-MMD. Neither recognize .incbin.
TEST(ByteInRodata) {
CHECK_EQ(0, std::strcmp("0123456789\n", test_string0_bytes));
}
......@@ -325,8 +297,6 @@ TEST(ByteInText) {
#undef EMBED_IN_TEXT_HEADER
#undef FUNCTION_BYTES
#undef GENERATE_TEST_FUNCTION_DATA
#undef INCBIN_RODATA
#undef INCBIN_TEXT
#undef TEST_FUNCTION_FILE
} // namespace test_isolate_independent_builtins
......
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