[wasm] Distinguish Liftoff code from Turbofan code
For memory tracing, output a 'T' for Turbofan code and an 'L' for Liftoff code. To do this, the WasmCodeWrapper now has some dispatch functions which work for both on-the-heap and off-the-heap code. We can probably refactor more code by having this mechanism. Since the output of --wasm-trace-memory differs now between Turbofan and Liftoff, the message test is split in two. R=titzer@chromium.org CC=mstarzinger@chromium.org Bug: v8:6600 Change-Id: Ic5fd18c631f5c8aaad19d639df75b18098895b5a Reviewed-on: https://chromium-review.googlesource.com/868214 Reviewed-by: Ben Titzer <titzer@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#50655}
This commit is contained in:
parent
342befe018
commit
41f231a25a
@ -1727,6 +1727,13 @@ Address WasmCompiledFrame::GetCallerStackPointer() const {
|
||||
return fp() + ExitFrameConstants::kCallerSPOffset;
|
||||
}
|
||||
|
||||
WasmCodeWrapper WasmCompiledFrame::wasm_code() const {
|
||||
return FLAG_wasm_jit_to_native
|
||||
? WasmCodeWrapper(
|
||||
isolate()->wasm_engine()->code_manager()->LookupCode(pc()))
|
||||
: WasmCodeWrapper(Handle<Code>(LookupCode(), isolate()));
|
||||
}
|
||||
|
||||
WasmInstanceObject* WasmCompiledFrame::wasm_instance() const {
|
||||
WasmInstanceObject* obj =
|
||||
FLAG_wasm_jit_to_native
|
||||
@ -1752,26 +1759,9 @@ int WasmCompiledFrame::position() const {
|
||||
|
||||
void WasmCompiledFrame::Summarize(std::vector<FrameSummary>* functions) const {
|
||||
DCHECK(functions->empty());
|
||||
WasmCodeWrapper code;
|
||||
Handle<WasmInstanceObject> instance;
|
||||
int offset = -1;
|
||||
if (FLAG_wasm_jit_to_native) {
|
||||
code = WasmCodeWrapper(
|
||||
isolate()->wasm_engine()->code_manager()->LookupCode(pc()));
|
||||
offset =
|
||||
static_cast<int>(pc() - code.GetWasmCode()->instructions().start());
|
||||
instance = Handle<WasmInstanceObject>(
|
||||
WasmInstanceObject::cast(code.GetWasmCode()
|
||||
->owner()
|
||||
->compiled_module()
|
||||
->weak_owning_instance()
|
||||
->value()),
|
||||
isolate());
|
||||
} else {
|
||||
code = WasmCodeWrapper(Handle<Code>(LookupCode(), isolate()));
|
||||
offset = static_cast<int>(pc() - code.GetCode()->instruction_start());
|
||||
instance = Handle<WasmInstanceObject>(wasm_instance(), isolate());
|
||||
}
|
||||
WasmCodeWrapper code = wasm_code();
|
||||
int offset = static_cast<int>(pc() - code.instructions().start());
|
||||
Handle<WasmInstanceObject> instance = code.wasm_instance();
|
||||
FrameSummary::WasmCompiledFrameSummary summary(
|
||||
isolate(), instance, code, offset, at_to_number_conversion());
|
||||
functions->push_back(summary);
|
||||
|
@ -968,6 +968,7 @@ class WasmCompiledFrame final : public StandardFrame {
|
||||
|
||||
// Accessors.
|
||||
WasmInstanceObject* wasm_instance() const;
|
||||
WasmCodeWrapper wasm_code() const;
|
||||
uint32_t function_index() const;
|
||||
Script* script() const override;
|
||||
int position() const override;
|
||||
|
@ -1126,9 +1126,11 @@ RUNTIME_FUNCTION(Runtime_WasmTraceMemory) {
|
||||
// TODO(titzer): eliminate dependency on WasmModule definition here.
|
||||
int func_start =
|
||||
frame->wasm_instance()->module()->functions[func_index].code.offset();
|
||||
// TODO(clemensh): Determine compiler (TurboFan / Liftoff).
|
||||
wasm::TraceMemoryOperation(wasm::ExecutionEngine::kTurbofan, info, func_index,
|
||||
pos - func_start, mem_start);
|
||||
wasm::ExecutionEngine eng = frame->wasm_code().is_liftoff()
|
||||
? wasm::ExecutionEngine::kLiftoff
|
||||
: wasm::ExecutionEngine::kTurbofan;
|
||||
wasm::TraceMemoryOperation(eng, info, func_index, pos - func_start,
|
||||
mem_start);
|
||||
return isolate->heap()->undefined_value();
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
#include "src/wasm/wasm-code-wrapper.h"
|
||||
|
||||
#include "src/objects.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/objects/code.h"
|
||||
#include "src/wasm/wasm-code-manager.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -46,5 +47,23 @@ void WasmCodeWrapper::Disassemble(const char* name, Isolate* isolate,
|
||||
}
|
||||
#endif
|
||||
|
||||
bool WasmCodeWrapper::is_liftoff() const {
|
||||
return IsCodeObject() ? !GetCode()->is_turbofanned()
|
||||
: GetWasmCode()->is_liftoff();
|
||||
}
|
||||
|
||||
Vector<uint8_t> WasmCodeWrapper::instructions() const {
|
||||
if (!IsCodeObject()) return GetWasmCode()->instructions();
|
||||
Handle<Code> code = GetCode();
|
||||
return {code->instruction_start(),
|
||||
static_cast<size_t>(code->instruction_size())};
|
||||
}
|
||||
|
||||
Handle<WasmInstanceObject> WasmCodeWrapper::wasm_instance() const {
|
||||
return IsCodeObject()
|
||||
? handle(WasmInstanceObject::GetOwningInstanceGC(*GetCode()))
|
||||
: handle(WasmInstanceObject::GetOwningInstance(GetWasmCode()));
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -13,6 +13,7 @@ class WasmCode;
|
||||
} // namespace wasm
|
||||
|
||||
class Code;
|
||||
class WasmInstanceObject;
|
||||
|
||||
// TODO(mtrofin): remove once we remove FLAG_wasm_jit_to_native
|
||||
class WasmCodeWrapper {
|
||||
@ -25,6 +26,11 @@ class WasmCodeWrapper {
|
||||
const wasm::WasmCode* GetWasmCode() const;
|
||||
bool is_null() const { return code_ptr_.wasm_code_ == nullptr; }
|
||||
bool IsCodeObject() const;
|
||||
bool is_liftoff() const;
|
||||
|
||||
Vector<uint8_t> instructions() const;
|
||||
|
||||
Handle<WasmInstanceObject> wasm_instance() const;
|
||||
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
void Disassemble(const char* name, Isolate* isolate, std::ostream& os) const;
|
||||
|
@ -36,4 +36,11 @@
|
||||
# tested standalone.
|
||||
'fail/modules-skip*': [SKIP],
|
||||
}], # ALWAYS
|
||||
|
||||
# Liftoff is currently only sufficiently implemented on x64 and ia32.
|
||||
# TODO(clemensh): Implement on all other platforms (crbug.com/v8/6600).
|
||||
['arch != x64 and arch != ia32', {
|
||||
'wasm-trace-memory-liftoff': [SKIP],
|
||||
}], # arch != x64 and arch != ia32
|
||||
|
||||
]
|
||||
|
7
test/message/wasm-trace-memory-liftoff.js
Normal file
7
test/message/wasm-trace-memory-liftoff.js
Normal file
@ -0,0 +1,7 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --no-stress-opt --expose-wasm --wasm-trace-memory --liftoff
|
||||
|
||||
load("test/message/wasm-trace-memory.js");
|
9
test/message/wasm-trace-memory-liftoff.out
Normal file
9
test/message/wasm-trace-memory-liftoff.out
Normal file
@ -0,0 +1,9 @@
|
||||
L 0+0x3 load @00000004 i32:0 / 00000000
|
||||
L 1+0x3 load @00000001 i8:0 / 00
|
||||
L 3+0x5 store @00000004 i32:305419896 / 12345678
|
||||
L 0+0x3 load @00000002 i32:1450704896 / 56780000
|
||||
L 1+0x3 load @00000006 i8:52 / 34
|
||||
L 2+0x3 load @00000002 f32:68169720922112.000000 / 56780000
|
||||
L 4+0x5 store @00000004 i8:171 / ab
|
||||
L 0+0x3 load @00000002 i32:1454047232 / 56ab0000
|
||||
L 2+0x3 load @00000002 f32:94008244174848.000000 / 56ab0000
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --no-stress-opt --expose-wasm --wasm-trace-memory
|
||||
// Flags: --no-stress-opt --expose-wasm --wasm-trace-memory --no-liftoff
|
||||
|
||||
load("test/mjsunit/wasm/wasm-constants.js");
|
||||
load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
Loading…
Reference in New Issue
Block a user