mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-06 00:31:27 +00:00
Backed out 4 changesets (bug 1574002) for causing spidermonkey bustage on Disassemble.h CLOSED TREE
Backed out changeset ac0c1beee54f (bug 1574002) Backed out changeset 3807af5c121a (bug 1574002) Backed out changeset 9f6b91a72f1f (bug 1574002) Backed out changeset 7e315ddebb02 (bug 1574002)
This commit is contained in:
parent
4578dc085b
commit
813ffcab93
@ -77,7 +77,6 @@
|
||||
#include "vm/TraceLogging.h"
|
||||
#include "wasm/AsmJS.h"
|
||||
#include "wasm/WasmBaselineCompile.h"
|
||||
#include "wasm/WasmInstance.h"
|
||||
#include "wasm/WasmJS.h"
|
||||
#include "wasm/WasmModule.h"
|
||||
#include "wasm/WasmSignalHandlers.h"
|
||||
@ -874,42 +873,6 @@ static bool WasmTextToBinary(JSContext* cx, unsigned argc, Value* vp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ConvertToTier(JSContext* cx, HandleValue value,
|
||||
const wasm::Code& code, wasm::Tier* tier) {
|
||||
RootedString option(cx, JS::ToString(cx, value));
|
||||
|
||||
if (!option) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool stableTier = false;
|
||||
bool bestTier = false;
|
||||
bool baselineTier = false;
|
||||
bool ionTier = false;
|
||||
|
||||
if (!JS_StringEqualsAscii(cx, option, "stable", &stableTier) ||
|
||||
!JS_StringEqualsAscii(cx, option, "best", &bestTier) ||
|
||||
!JS_StringEqualsAscii(cx, option, "baseline", &baselineTier) ||
|
||||
!JS_StringEqualsAscii(cx, option, "ion", &ionTier)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stableTier) {
|
||||
*tier = code.stableTier();
|
||||
} else if (bestTier) {
|
||||
*tier = code.bestTier();
|
||||
} else if (baselineTier) {
|
||||
*tier = wasm::Tier::Baseline;
|
||||
} else if (ionTier) {
|
||||
*tier = wasm::Tier::Optimized;
|
||||
} else {
|
||||
// You can omit the argument but you can't pass just anything you like
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool WasmExtractCode(JSContext* cx, unsigned argc, Value* vp) {
|
||||
if (!cx->options().wasm()) {
|
||||
JS_ReportErrorASCII(cx, "wasm support unavailable");
|
||||
@ -930,12 +893,39 @@ static bool WasmExtractCode(JSContext* cx, unsigned argc, Value* vp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wasm::Tier tier = module->module().code().stableTier();
|
||||
;
|
||||
if (args.length() > 1 &&
|
||||
!ConvertToTier(cx, args[1], module->module().code(), &tier)) {
|
||||
args.rval().setNull();
|
||||
return false;
|
||||
bool stableTier = false;
|
||||
bool bestTier = false;
|
||||
bool baselineTier = false;
|
||||
bool ionTier = false;
|
||||
if (args.length() > 1) {
|
||||
JSString* opt = JS::ToString(cx, args[1]);
|
||||
if (!opt) {
|
||||
return false;
|
||||
}
|
||||
if (!JS_StringEqualsAscii(cx, opt, "stable", &stableTier) ||
|
||||
!JS_StringEqualsAscii(cx, opt, "best", &bestTier) ||
|
||||
!JS_StringEqualsAscii(cx, opt, "baseline", &baselineTier) ||
|
||||
!JS_StringEqualsAscii(cx, opt, "ion", &ionTier)) {
|
||||
return false;
|
||||
}
|
||||
// You can omit the argument but you can't pass just anything you like
|
||||
if (!(stableTier || bestTier || baselineTier || ionTier)) {
|
||||
args.rval().setNull();
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
stableTier = true;
|
||||
}
|
||||
|
||||
wasm::Tier tier;
|
||||
if (stableTier) {
|
||||
tier = module->module().code().stableTier();
|
||||
} else if (bestTier) {
|
||||
tier = module->module().code().bestTier();
|
||||
} else if (baselineTier) {
|
||||
tier = wasm::Tier::Baseline;
|
||||
} else {
|
||||
tier = wasm::Tier::Optimized;
|
||||
}
|
||||
|
||||
RootedValue result(cx);
|
||||
@ -947,51 +937,6 @@ static bool WasmExtractCode(JSContext* cx, unsigned argc, Value* vp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool WasmDisassemble(JSContext* cx, unsigned argc, Value* vp) {
|
||||
if (!cx->options().wasm()) {
|
||||
JS_ReportErrorASCII(cx, "wasm support unavailable");
|
||||
return false;
|
||||
}
|
||||
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
args.rval().set(UndefinedValue());
|
||||
|
||||
if (!args.get(0).isObject()) {
|
||||
JS_ReportErrorASCII(cx, "argument is not an object");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedFunction func(cx, args[0].toObject().maybeUnwrapIf<JSFunction>());
|
||||
|
||||
if (!func || !wasm::IsWasmExportedFunction(func)) {
|
||||
JS_ReportErrorASCII(cx, "argument is not an exported wasm function");
|
||||
return false;
|
||||
}
|
||||
|
||||
wasm::Instance& instance = wasm::ExportedFunctionToInstance(func);
|
||||
uint32_t funcIndex = wasm::ExportedFunctionToFuncIndex(func);
|
||||
|
||||
wasm::Tier tier = instance.code().stableTier();
|
||||
|
||||
if (args.length() > 1 &&
|
||||
!ConvertToTier(cx, args[1], instance.code(), &tier)) {
|
||||
JS_ReportErrorASCII(cx, "invalid tier");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!instance.code().hasTier(tier)) {
|
||||
JS_ReportErrorASCII(cx, "function missing selected tier");
|
||||
return false;
|
||||
}
|
||||
|
||||
instance.disassembleExport(cx, funcIndex, tier, [](const char* text) {
|
||||
fprintf(stderr, "%s\n", text);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum class Flag { Tier2Complete, Deserialized };
|
||||
|
||||
static bool WasmReturnFlag(JSContext* cx, unsigned argc, Value* vp, Flag flag) {
|
||||
@ -6397,12 +6342,6 @@ gc::ZealModeHelpText),
|
||||
" cannot be satisfied then null is returned. If the request is 'ion' then block\n"
|
||||
" until background compilation is complete."),
|
||||
|
||||
JS_FN_HELP("wasmDis", WasmDisassemble, 1, 0,
|
||||
"wasmDis(function[, tier])",
|
||||
" Disassembles generated machine code from an exported WebAssembly function.\n"
|
||||
" The tier is a string, 'stable', 'best', 'baseline', or 'ion'; the default is\n"
|
||||
" 'stable'."),
|
||||
|
||||
JS_FN_HELP("wasmHasTier2CompilationCompleted", WasmHasTier2CompilationCompleted, 1, 0,
|
||||
"wasmHasTier2CompilationCompleted(module)",
|
||||
" Returns a boolean indicating whether a given module has finished compiled code for tier2. \n"
|
||||
|
@ -1,93 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "jit/Disassemble.h"
|
||||
#include "js/Printf.h"
|
||||
|
||||
#if defined(JS_JITSPEW)
|
||||
# if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)
|
||||
# include "zydis/ZydisAPI.h"
|
||||
# elif defined(JS_CODEGEN_ARM64)
|
||||
# include "jit/arm64/vixl/Disasm-vixl.h"
|
||||
# elif defined(JS_CODEGEN_ARM)
|
||||
# include "jit/arm/disasm/Disasm-arm.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace js {
|
||||
namespace jit {
|
||||
|
||||
#if defined(JS_JITSPEW) && (defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64))
|
||||
|
||||
void Disassemble(uint8_t* code, size_t length, InstrCallback callback) {
|
||||
zydisDisassemble(code, length, callback);
|
||||
}
|
||||
|
||||
#elif defined(JS_JITSPEW) && defined(JS_CODEGEN_ARM64)
|
||||
|
||||
class ARM64Disassembler : public vixl::Disassembler {
|
||||
public:
|
||||
explicit ARM64Disassembler(InstrCallback callback) : callback_(callback) {}
|
||||
|
||||
protected:
|
||||
void ProcessOutput(const Instruction* instr) override {
|
||||
UniqueChars formatted = JS_smprintf("0x%p %08x %s", instr,
|
||||
instr->InstructionBits(), GetOutput());
|
||||
callback_(formatted.get());
|
||||
}
|
||||
|
||||
private:
|
||||
InstrCallback callback_;
|
||||
};
|
||||
|
||||
void Disassemble(uint8_t* code, size_t length, InstrCallback callback) {
|
||||
ARM64Disassembler dis(callback);
|
||||
vixl::Decoder decoder;
|
||||
decoder.AppendVisitor(&dis);
|
||||
|
||||
uint8_t* instr = code;
|
||||
uint8_t* end = code + length;
|
||||
|
||||
while (instr < end) {
|
||||
decoder.Decode(reinterpret_cast<vixl::Instruction*>(instr));
|
||||
|
||||
instr += sizeof(vixl::Instr);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(JS_JITSPEW) && defined(JS_CODEGEN_ARM)
|
||||
|
||||
void Disassemble(uint8_t* code, size_t length, InstrCallback callback) {
|
||||
disasm::NameConverter converter;
|
||||
disasm::Disassembler d(converter);
|
||||
|
||||
uint8_t* instr = code;
|
||||
uint8_t* end = code + length;
|
||||
|
||||
while (instr < end) {
|
||||
disasm::EmbeddedVector<char, disasm::ReasonableBufferSize> buffer;
|
||||
buffer[0] = '\0';
|
||||
uint8_t* next_instr = instr + d.InstructionDecode(buffer, instr);
|
||||
|
||||
UniqueChars formatted =
|
||||
JS_smprintf("0x%p %08x %s\n", instr,
|
||||
*reinterpret_cast<int32_t*>(instr), buffer.start());
|
||||
callback(formatted.get());
|
||||
|
||||
instr = next_instr;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void Disassemble(uint8_t* code, size_t length, InstrCallback callback) {
|
||||
callback("*** No disassembly available ***\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace jit
|
||||
} // namespace js
|
@ -1,20 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef jit_Disassemble_h
|
||||
#define jit_Disassemble_h
|
||||
|
||||
namespace js {
|
||||
namespace jit {
|
||||
|
||||
typedef void (*InstrCallback)(const char* text);
|
||||
|
||||
extern void Disassemble(uint8_t* code, size_t length, InstrCallback callback);
|
||||
|
||||
} // namespace jit
|
||||
} // namespace js
|
||||
|
||||
#endif /* jit_Disassemble_h */
|
@ -51,7 +51,6 @@ UNIFIED_SOURCES += [
|
||||
'CacheIRSpewer.cpp',
|
||||
'CodeGenerator.cpp',
|
||||
'CompileWrappers.cpp',
|
||||
'Disassemble.cpp',
|
||||
'EdgeCaseAnalysis.cpp',
|
||||
'EffectiveAddressAnalysis.cpp',
|
||||
'ExecutableAllocator.cpp',
|
||||
|
@ -20,12 +20,15 @@
|
||||
|
||||
#include "mozilla/ScopeExit.h"
|
||||
|
||||
#include "jit/Disassemble.h"
|
||||
#include "js/Printf.h"
|
||||
|
||||
#include "wasm/cranelift/baldrapi.h"
|
||||
#include "wasm/cranelift/clifapi.h"
|
||||
#include "wasm/WasmGenerator.h"
|
||||
#if defined(JS_CODEGEN_X64) && defined(JS_JITSPEW) && \
|
||||
defined(ENABLE_WASM_CRANELIFT)
|
||||
# include "zydis/ZydisAPI.h"
|
||||
#endif
|
||||
|
||||
#include "jit/MacroAssembler-inl.h"
|
||||
|
||||
@ -69,6 +72,17 @@ static inline SymbolicAddress ToSymbolicAddress(BD_SymbolicAddress bd) {
|
||||
MOZ_CRASH("unknown baldrdash symbolic address");
|
||||
}
|
||||
|
||||
static void DisassembleCode(uint8_t* code, size_t codeLen) {
|
||||
#if defined(JS_CODEGEN_X64) && defined(JS_JITSPEW) && \
|
||||
defined(ENABLE_WASM_CRANELIFT)
|
||||
zydisDisassemble(code, codeLen, [](const char* text) {
|
||||
JitSpew(JitSpew_Codegen, "%s", text);
|
||||
});
|
||||
#else
|
||||
JitSpew(JitSpew_Codegen, "*** No disassembly available ***");
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool GenerateCraneliftCode(WasmMacroAssembler& masm,
|
||||
const CraneliftCompiledFunc& func,
|
||||
const FuncTypeIdDesc& funcTypeId,
|
||||
@ -452,10 +466,7 @@ bool wasm::CraneliftCompileFunctions(const ModuleEnvironment& env,
|
||||
size_t codeRangeIndex = firstCodeRangeIndex + i;
|
||||
uint32_t codeStart = codeRanges[codeRangeIndex].begin();
|
||||
uint32_t codeEnd = codeRanges[codeRangeIndex].end();
|
||||
|
||||
jit::Disassemble(
|
||||
codeBuf + codeStart, codeEnd - codeStart,
|
||||
[](const char* text) { JitSpew(JitSpew_Codegen, "%s", text); });
|
||||
DisassembleCode(codeBuf + codeStart, codeEnd - codeStart);
|
||||
|
||||
JitSpew(JitSpew_Codegen, "# End of wasm cranelift code for index %d",
|
||||
funcIndex);
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "wasm/WasmInstance.h"
|
||||
|
||||
#include "jit/AtomicOperations.h"
|
||||
#include "jit/Disassemble.h"
|
||||
#include "jit/InlinableNatives.h"
|
||||
#include "jit/JitCommon.h"
|
||||
#include "jit/JitRealm.h"
|
||||
@ -2001,21 +2000,6 @@ void Instance::destroyBreakpointSite(JSFreeOp* fop, uint32_t offset) {
|
||||
return debug().destroyBreakpointSite(fop, this, offset);
|
||||
}
|
||||
|
||||
void Instance::disassembleExport(JSContext* cx, uint32_t funcIndex, Tier tier,
|
||||
PrintCallback callback) const {
|
||||
const MetadataTier& metadataTier = metadata(tier);
|
||||
const FuncExport& funcExport = metadataTier.lookupFuncExport(funcIndex);
|
||||
const CodeRange& range = metadataTier.codeRange(funcExport);
|
||||
const CodeTier& codeTier = code(tier);
|
||||
const ModuleSegment& segment = codeTier.segment();
|
||||
|
||||
MOZ_ASSERT(range.begin() < segment.length());
|
||||
MOZ_ASSERT(range.end() < segment.length());
|
||||
|
||||
uint8_t* functionCode = segment.base() + range.begin();
|
||||
jit::Disassemble(functionCode, range.end() - range.begin(), callback);
|
||||
}
|
||||
|
||||
void Instance::addSizeOfMisc(MallocSizeOf mallocSizeOf,
|
||||
Metadata::SeenSet* seenMetadata,
|
||||
Code::SeenSet* seenCode,
|
||||
|
@ -177,11 +177,6 @@ class Instance {
|
||||
Code::SeenSet* seenCode, Table::SeenSet* seenTables,
|
||||
size_t* code, size_t* data) const;
|
||||
|
||||
// Wasm disassembly support
|
||||
|
||||
void disassembleExport(JSContext* cx, uint32_t funcIndex, Tier tier,
|
||||
PrintCallback callback) const;
|
||||
|
||||
public:
|
||||
// Functions to be called directly from wasm code.
|
||||
static int32_t callImport_void(Instance*, int32_t, int32_t, uint64_t*);
|
||||
|
@ -2522,8 +2522,6 @@ bool IsCodegenDebugEnabled(DebugChannel channel);
|
||||
void DebugCodegen(DebugChannel channel, const char* fmt, ...)
|
||||
MOZ_FORMAT_PRINTF(2, 3);
|
||||
|
||||
typedef void (*PrintCallback)(const char* text);
|
||||
|
||||
} // namespace wasm
|
||||
} // namespace js
|
||||
|
||||
|
@ -11,7 +11,7 @@ LOCAL_INCLUDES += [
|
||||
include('../js-config.mozbuild')
|
||||
include('../js-cxxflags.mozbuild')
|
||||
|
||||
if (CONFIG['JS_CODEGEN_X64'] or CONFIG['JS_CODEGEN_X86']) and CONFIG['JS_JITSPEW']:
|
||||
if CONFIG['JS_CODEGEN_X64'] and CONFIG['JS_JITSPEW'] and CONFIG['ENABLE_WASM_CRANELIFT']:
|
||||
SOURCES += [
|
||||
'Zycore/Allocator.c',
|
||||
'Zycore/API/Memory.c',
|
||||
|
@ -111,7 +111,7 @@ LOCAL_INCLUDES += [
|
||||
include('../js-config.mozbuild')
|
||||
include('../js-cxxflags.mozbuild')
|
||||
|
||||
if (CONFIG['JS_CODEGEN_X64'] or CONFIG['JS_CODEGEN_X86']) and CONFIG['JS_JITSPEW']:
|
||||
if CONFIG['JS_CODEGEN_X64'] and CONFIG['JS_JITSPEW'] and CONFIG['ENABLE_WASM_CRANELIFT']:
|
||||
SOURCES += [
|
||||
EOF
|
||||
for fn in $(find . -name '*.c' -o -name '*.cpp' | ( LC_ALL=C sort --ignore-case ) | sed 's/\.\///'); do
|
||||
|
Loading…
x
Reference in New Issue
Block a user