Commit a2afcc1c authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Fix failures in --no-wasm-jit-to-native mode

This CL fixes several unrelated failures with --no-wasm-jit-to-native.
A follow-up CL will then add a new test variant with that flag.

R=ahaas@chromium.org

Bug: v8:7417
Change-Id: I40a7be53a50d0efbbec8de49aceeb4a43a1f41de
Reviewed-on: https://chromium-review.googlesource.com/909212Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51200}
parent 56bc149d
......@@ -60,9 +60,14 @@ class MovableLabel {
};
#endif
wasm::WasmValue WasmPtrValue(void* ptr) {
wasm::WasmValue WasmPtrValue(uintptr_t ptr) {
using int_t = std::conditional<kPointerSize == 8, uint64_t, uint32_t>::type;
return wasm::WasmValue(reinterpret_cast<int_t>(ptr));
static_assert(sizeof(int_t) == sizeof(uintptr_t), "weird uintptr_t");
return wasm::WasmValue(static_cast<int_t>(ptr));
}
wasm::WasmValue WasmPtrValue(void* ptr) {
return WasmPtrValue(reinterpret_cast<uintptr_t>(ptr));
}
class LiftoffCompiler {
......@@ -1126,6 +1131,11 @@ class LiftoffCompiler {
__ Load(scratch, scratch.gp(), no_reg,
Foreign::kForeignAddressOffset - kHeapObjectTag, kPointerLoadType,
pinned);
} else {
// Move the pointer from the Code object to the instruction start.
__ LoadConstant(tmp_const,
WasmPtrValue(Code::kHeaderSize - kHeapObjectTag));
__ emit_ptrsize_add(scratch.gp(), scratch.gp(), tmp_const.gp());
}
source_position_table_builder_->AddPosition(
......
......@@ -681,7 +681,8 @@ compiler::ModuleEnv CreateModuleEnvFromCompiledModule(
std::vector<GlobalHandleAddress> function_tables;
int num_function_tables = static_cast<int>(module->function_tables.size());
FixedArray* ft = compiled_module->function_tables();
FixedArray* ft =
num_function_tables == 0 ? nullptr : compiled_module->function_tables();
for (int i = 0; i < num_function_tables; ++i) {
// TODO(clemensh): defer these handles for concurrent compilation.
function_tables.push_back(WasmCompiledModule::GetTableValue(ft, i));
......@@ -3281,17 +3282,20 @@ void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table,
Code::cast(code_table->get(static_cast<int>(func_index)));
// Only increase the counter for lazy compile builtins (it's not
// needed otherwise).
if (code->is_wasm_code()) continue;
DCHECK_EQ(Builtins::kWasmCompileLazy, code->builtin_index());
if (code->builtin_index() != Builtins::kWasmCompileLazy) {
DCHECK(code->kind() == Code::WASM_FUNCTION ||
code->kind() == Code::WASM_TO_JS_FUNCTION);
continue;
}
} else {
const wasm::WasmCode* code = native_module->GetCode(func_index);
// Only increase the counter for lazy compile builtins (it's not
// needed otherwise).
if (code->kind() == wasm::WasmCode::kFunction ||
code->kind() == wasm::WasmCode::kWasmToJsWrapper) {
if (code->kind() != wasm::WasmCode::kLazyStub) {
DCHECK(code->kind() == wasm::WasmCode::kFunction ||
code->kind() == wasm::WasmCode::kWasmToJsWrapper);
continue;
}
DCHECK_EQ(wasm::WasmCode::kLazyStub, code->kind());
}
++num_table_exports[func_index];
}
......
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