94b088ca3c
This is a first step towards moving Turbofan code generation off the main thread. Summary of the changes: - AssemblerBase no longer has a pointer to the isolate. Instead, its constructor receives the few things that it needs from the isolate (on most architectures this is just the serializer_enabled flag). - RelocInfo no longer has a pointer to the isolate. Instead, the functions that need it take it as an argument. (There are currently still a few that implicitly access the isolate through a HeapObject.) - The MacroAssembler now explicitly holds a pointer to the isolate (before, it used to get it from the Assembler). - The jit_cookie also moved from AssemblerBase to the MacroAssemblers, since it's not used at all in the Assemblers. - A few architectures implemented parts of the Assembler with the help of a Codepatcher that is based on MacroAssembler. Since the Assembler no longer has the isolate, but the MacroAssembler still needs it, this doesn't work anymore. Instead, these Assemblers now use a new PatchingAssembler. BUG=v8:6048 Review-Url: https://codereview.chromium.org/2732273003 Cr-Commit-Position: refs/heads/master@{#43890}
62 lines
3.5 KiB
C++
62 lines
3.5 KiB
C++
// Copyright 2015 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 <stdlib.h>
|
|
|
|
#include "src/assembler-inl.h"
|
|
#include "src/objects-inl.h"
|
|
#include "src/v8.h"
|
|
#include "test/cctest/cctest.h"
|
|
#include "test/cctest/compiler/c-signature.h"
|
|
#include "test/cctest/wasm/wasm-run-utils.h"
|
|
|
|
using namespace v8::internal;
|
|
using namespace v8::internal::compiler;
|
|
|
|
#define FOREACH_TYPE(TEST_BODY) \
|
|
TEST_BODY(int32_t, WASM_I32_ADD) \
|
|
TEST_BODY(int64_t, WASM_I64_ADD) \
|
|
TEST_BODY(float, WASM_F32_ADD) \
|
|
TEST_BODY(double, WASM_F64_ADD)
|
|
|
|
#define LOAD_SET_GLOBAL_TEST_BODY(C_TYPE, ADD) \
|
|
TEST(WasmRelocateGlobal_##C_TYPE) { \
|
|
WasmRunner<C_TYPE, C_TYPE> r(kExecuteCompiled); \
|
|
Isolate* isolate = CcTest::i_isolate(); \
|
|
\
|
|
r.module().AddGlobal<C_TYPE>(); \
|
|
r.module().AddGlobal<C_TYPE>(); \
|
|
\
|
|
/* global = global + p0 */ \
|
|
BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \
|
|
WASM_GET_GLOBAL(0)); \
|
|
CHECK_EQ(1, r.module().instance->function_code.size()); \
|
|
\
|
|
int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \
|
|
\
|
|
Handle<Code> code = r.module().instance->function_code[0]; \
|
|
\
|
|
Address old_start = r.module().instance->globals_start; \
|
|
Address new_start = old_start + 1; \
|
|
\
|
|
Address old_addresses[4]; \
|
|
uint32_t address_index = 0U; \
|
|
for (RelocIterator it(*code, filter); !it.done(); it.next()) { \
|
|
old_addresses[address_index] = it.rinfo()->wasm_global_reference(); \
|
|
it.rinfo()->update_wasm_global_reference(isolate, old_start, new_start); \
|
|
++address_index; \
|
|
} \
|
|
CHECK_LE(address_index, 4U); \
|
|
\
|
|
address_index = 0U; \
|
|
for (RelocIterator it(*code, filter); !it.done(); it.next()) { \
|
|
CHECK_EQ(old_addresses[address_index] + 1, \
|
|
it.rinfo()->wasm_global_reference()); \
|
|
++address_index; \
|
|
} \
|
|
CHECK_LE(address_index, 4U); \
|
|
}
|
|
|
|
FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY)
|