[wasm] Disable trap handling for memory64
Trap handling is not implemented yet for memory64. Make sure that no code tries to use it, by setting {NativeModule::bounds_checks_} accordingly. This requires some changes to tests to make sure that the {WasmModule::is_memory64} field is set before creating the corresponding {NativeModule}. R=ahaas@chromium.org Bug: v8:10949 Change-Id: I11d9544b603fc471e3368bb4e7487da4711293a0 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3011167 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#75632}
This commit is contained in:
parent
2276e95ad9
commit
72af112c29
@ -2672,6 +2672,8 @@ class LiftoffCompiler {
|
||||
}
|
||||
|
||||
// Early return for trap handler.
|
||||
DCHECK_IMPLIES(env_->module->is_memory64,
|
||||
env_->bounds_checks == kExplicitBoundsChecks);
|
||||
if (!force_check && !statically_oob &&
|
||||
env_->bounds_checks == kTrapHandler) {
|
||||
// With trap handlers we should not have a register pair as input (we
|
||||
|
@ -837,6 +837,17 @@ size_t WasmCodeAllocator::GetNumCodeSpaces() const {
|
||||
// static
|
||||
constexpr base::AddressRegion WasmCodeAllocator::kUnrestrictedRegion;
|
||||
|
||||
namespace {
|
||||
BoundsCheckStrategy GetBoundsChecks(const WasmModule* module) {
|
||||
if (!FLAG_wasm_bounds_checks) return kNoBoundsChecks;
|
||||
if (FLAG_wasm_enforce_bounds_checks) return kExplicitBoundsChecks;
|
||||
// We do not have trap handler support for memory64 yet.
|
||||
if (module->is_memory64) return kExplicitBoundsChecks;
|
||||
if (trap_handler::IsTrapHandlerEnabled()) return kTrapHandler;
|
||||
return kExplicitBoundsChecks;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
NativeModule::NativeModule(const WasmFeatures& enabled,
|
||||
VirtualMemory code_space,
|
||||
std::shared_ptr<const WasmModule> module,
|
||||
@ -849,12 +860,7 @@ NativeModule::NativeModule(const WasmFeatures& enabled,
|
||||
module_(std::move(module)),
|
||||
import_wrapper_cache_(std::unique_ptr<WasmImportWrapperCache>(
|
||||
new WasmImportWrapperCache())),
|
||||
bounds_checks_(!FLAG_wasm_bounds_checks
|
||||
? kNoBoundsChecks
|
||||
: FLAG_wasm_enforce_bounds_checks ||
|
||||
!trap_handler::IsTrapHandlerEnabled()
|
||||
? kExplicitBoundsChecks
|
||||
: kTrapHandler) {
|
||||
bounds_checks_(GetBoundsChecks(module_.get())) {
|
||||
DCHECK(engine_scope_);
|
||||
// We receive a pointer to an empty {std::shared_ptr}, and install ourselve
|
||||
// there.
|
||||
|
@ -608,7 +608,8 @@ UNINITIALIZED_WASM_EXEC_TEST(TestStackOverflowNotCaught) {
|
||||
LocalContext context(isolate_scope.isolate());
|
||||
|
||||
WasmRunner<uint32_t> r(execution_tier, nullptr, "main",
|
||||
kRuntimeExceptionSupport, isolate_scope.i_isolate());
|
||||
kRuntimeExceptionSupport, kMemory32,
|
||||
isolate_scope.i_isolate());
|
||||
|
||||
// Build a function that calls itself until stack overflow.
|
||||
WasmFunctionCompiler& stack_overflow = r.NewFunction(sigs.v_v());
|
||||
|
@ -17,9 +17,10 @@ template <typename ReturnType, typename... ParamTypes>
|
||||
class Memory64Runner : public WasmRunner<ReturnType, ParamTypes...> {
|
||||
public:
|
||||
explicit Memory64Runner(TestExecutionTier execution_tier)
|
||||
: WasmRunner<ReturnType, ParamTypes...>(execution_tier) {
|
||||
: WasmRunner<ReturnType, ParamTypes...>(execution_tier, nullptr, "main",
|
||||
kNoRuntimeExceptionSupport,
|
||||
kMemory64) {
|
||||
this->builder().EnableFeature(kFeature_memory64);
|
||||
this->builder().SetMemory64();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2456,7 +2456,7 @@ UNINITIALIZED_WASM_EXEC_TEST(ReturnCall_Factorial) {
|
||||
LocalContext current(isolate_scope.isolate());
|
||||
|
||||
WasmRunner<uint32_t, uint32_t> r(execution_tier, nullptr, "main",
|
||||
kRuntimeExceptionSupport,
|
||||
kRuntimeExceptionSupport, kMemory32,
|
||||
isolate_scope.i_isolate());
|
||||
|
||||
WasmFunctionCompiler& fact_aux_fn =
|
||||
@ -2494,7 +2494,7 @@ UNINITIALIZED_WASM_EXEC_TEST(ReturnCall_MutualFactorial) {
|
||||
LocalContext current(isolate_scope.isolate());
|
||||
|
||||
WasmRunner<uint32_t, uint32_t> r(execution_tier, nullptr, "main",
|
||||
kRuntimeExceptionSupport,
|
||||
kRuntimeExceptionSupport, kMemory32,
|
||||
isolate_scope.i_isolate());
|
||||
|
||||
WasmFunctionCompiler& f_fn = r.NewFunction<uint32_t, uint32_t, uint32_t>("f");
|
||||
@ -2541,7 +2541,7 @@ UNINITIALIZED_WASM_EXEC_TEST(ReturnCall_IndirectFactorial) {
|
||||
LocalContext current(isolate_scope.isolate());
|
||||
|
||||
WasmRunner<uint32_t, uint32_t> r(execution_tier, nullptr, "main",
|
||||
kRuntimeExceptionSupport,
|
||||
kRuntimeExceptionSupport, kMemory32,
|
||||
isolate_scope.i_isolate());
|
||||
|
||||
TestSignatures sigs;
|
||||
@ -2590,7 +2590,7 @@ UNINITIALIZED_WASM_EXEC_TEST(ReturnCall_Sum) {
|
||||
LocalContext current(isolate_scope.isolate());
|
||||
|
||||
WasmRunner<int32_t, int32_t> r(execution_tier, nullptr, "main",
|
||||
kRuntimeExceptionSupport,
|
||||
kRuntimeExceptionSupport, kMemory32,
|
||||
isolate_scope.i_isolate());
|
||||
TestSignatures sigs;
|
||||
|
||||
@ -2632,7 +2632,7 @@ UNINITIALIZED_WASM_EXEC_TEST(ReturnCall_Bounce_Sum) {
|
||||
LocalContext current(isolate_scope.isolate());
|
||||
|
||||
WasmRunner<int32_t, int32_t> r(execution_tier, nullptr, "main",
|
||||
kRuntimeExceptionSupport,
|
||||
kRuntimeExceptionSupport, kMemory32,
|
||||
isolate_scope.i_isolate());
|
||||
TestSignatures sigs;
|
||||
|
||||
|
@ -24,13 +24,14 @@ namespace wasm {
|
||||
TestingModuleBuilder::TestingModuleBuilder(
|
||||
Zone* zone, ManuallyImportedJSFunction* maybe_import,
|
||||
TestExecutionTier tier, RuntimeExceptionSupport exception_support,
|
||||
Isolate* isolate)
|
||||
TestingModuleMemoryType mem_type, Isolate* isolate)
|
||||
: test_module_(std::make_shared<WasmModule>()),
|
||||
isolate_(isolate ? isolate : CcTest::InitIsolateOnce()),
|
||||
enabled_features_(WasmFeatures::FromIsolate(isolate_)),
|
||||
execution_tier_(tier),
|
||||
runtime_exception_support_(exception_support) {
|
||||
WasmJs::Install(isolate_, true);
|
||||
test_module_->is_memory64 = mem_type == kMemory64;
|
||||
test_module_->untagged_globals_buffer_size = kMaxGlobalsSize;
|
||||
memset(globals_data_, 0, sizeof(globals_data_));
|
||||
|
||||
|
@ -58,6 +58,8 @@ static_assert(
|
||||
std::underlying_type<TestExecutionTier>::type>::value,
|
||||
"enum types match");
|
||||
|
||||
enum TestingModuleMemoryType { kMemory32, kMemory64 };
|
||||
|
||||
using base::ReadLittleEndianValue;
|
||||
using base::WriteLittleEndianValue;
|
||||
|
||||
@ -101,7 +103,8 @@ struct ManuallyImportedJSFunction {
|
||||
class TestingModuleBuilder {
|
||||
public:
|
||||
TestingModuleBuilder(Zone*, ManuallyImportedJSFunction*, TestExecutionTier,
|
||||
RuntimeExceptionSupport, Isolate* isolate = nullptr);
|
||||
RuntimeExceptionSupport, TestingModuleMemoryType,
|
||||
Isolate* isolate);
|
||||
~TestingModuleBuilder();
|
||||
|
||||
void ChangeOriginToAsmjs() { test_module_->origin = kAsmJsSloppyOrigin; }
|
||||
@ -190,8 +193,6 @@ class TestingModuleBuilder {
|
||||
|
||||
void SetHasSharedMemory() { test_module_->has_shared_memory = true; }
|
||||
|
||||
void SetMemory64() { test_module_->is_memory64 = true; }
|
||||
|
||||
enum FunctionType { kImport, kWasm };
|
||||
uint32_t AddFunction(const FunctionSig* sig, const char* name,
|
||||
FunctionType type);
|
||||
@ -396,12 +397,14 @@ class WasmRunnerBase : public InitializedHandleScope {
|
||||
public:
|
||||
WasmRunnerBase(ManuallyImportedJSFunction* maybe_import,
|
||||
TestExecutionTier execution_tier, int num_params,
|
||||
RuntimeExceptionSupport runtime_exception_support,
|
||||
RuntimeExceptionSupport runtime_exception_support =
|
||||
kNoRuntimeExceptionSupport,
|
||||
TestingModuleMemoryType mem_type = kMemory32,
|
||||
Isolate* isolate = nullptr)
|
||||
: InitializedHandleScope(isolate),
|
||||
zone_(&allocator_, ZONE_NAME, kCompressGraphZone),
|
||||
builder_(&zone_, maybe_import, execution_tier,
|
||||
runtime_exception_support, isolate),
|
||||
runtime_exception_support, mem_type, isolate),
|
||||
wrapper_(&zone_, num_params) {}
|
||||
|
||||
static void SetUpTrapCallback() {
|
||||
@ -563,9 +566,10 @@ class WasmRunner : public WasmRunnerBase {
|
||||
const char* main_fn_name = "main",
|
||||
RuntimeExceptionSupport runtime_exception_support =
|
||||
kNoRuntimeExceptionSupport,
|
||||
TestingModuleMemoryType mem_type = kMemory32,
|
||||
Isolate* isolate = nullptr)
|
||||
: WasmRunnerBase(maybe_import, execution_tier, sizeof...(ParamTypes),
|
||||
runtime_exception_support, isolate) {
|
||||
runtime_exception_support, mem_type, isolate) {
|
||||
WasmFunctionCompiler& main_fn =
|
||||
NewFunction<ReturnType, ParamTypes...>(main_fn_name);
|
||||
// Non-zero if there is an import.
|
||||
|
Loading…
Reference in New Issue
Block a user