Skip to content
Permalink
Browse files
Use dladdr to get labels instead of stashing them in the JITOperation…
…Annotation.

https://bugs.webkit.org/show_bug.cgi?id=240895

Reviewed by Saam Barati.

We no longer need to stash these label strings in the JITOperationAnnotations.

This change also fixes an ASAN crasher.  As such, we can re-enable
ENABLE(JIT_OPERATION_DISASSEMBLY) even when ASAN_ENABLED.

* Source/JavaScriptCore/assembler/JITOperationList.cpp:
(JSC::JITOperationList::addDisassemblyLabels):
* Source/JavaScriptCore/assembler/JITOperationValidation.h:
* Source/WTF/wtf/PlatformCallingConventions.h:
* Source/WTF/wtf/PlatformEnable.h:

Canonical link: https://commits.webkit.org/250947@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294788 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mark Lam committed May 25, 2022
1 parent cd44c39 commit 1768e5e5f017a6ceac86594a3fc2fa4b439c46ff
Showing 4 changed files with 21 additions and 21 deletions.
@@ -33,6 +33,11 @@
#include "Opcode.h"
#include "Options.h"

#if HAVE(DLADDR)
#include <cxxabi.h>
#include <dlfcn.h>
#endif

namespace JSC {

#if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY)
@@ -114,28 +119,26 @@ LLINT_DECLARE_ROUTINE_VALIDATE(checkpoint_osr_exit_from_inlined_call_trampoline)
LLINT_DECLARE_ROUTINE_VALIDATE(normal_osr_exit_trampoline);
LLINT_DECLARE_ROUTINE_VALIDATE(fuzzer_return_early_from_loop_hint);

#if ENABLE(JIT_OPERATION_VALIDATION) && ENABLE(JIT_OPERATION_DISASSEMBLY)
#define LLINT_OP_EXTRAS(validateLabel, nameStr) bitwise_cast<void*>(validateLabel), nameStr
#elif ENABLE(JIT_OPERATION_VALIDATION)
#define LLINT_OP_EXTRAS(validateLabel, nameStr) bitwise_cast<void*>(validateLabel)
#if ENABLE(JIT_OPERATION_VALIDATION)
#define LLINT_OP_EXTRAS(validateLabel) bitwise_cast<void*>(validateLabel)
#else // ENABLE(JIT_OPERATION_DISASSEMBLY)
#define LLINT_OP_EXTRAS(validateLabel, nameStr) nameStr
#define LLINT_OP_EXTRAS(validateLabel)
#endif

#define LLINT_ROUTINE(functionName) { \
bitwise_cast<void*>(LLInt::getCodeFunctionPtr<CFunctionPtrTag>(functionName)), \
LLINT_OP_EXTRAS(LLINT_ROUTINE_VALIDATE(functionName), #functionName) \
LLINT_OP_EXTRAS(LLINT_ROUTINE_VALIDATE(functionName)) \
},

#define LLINT_OP(name) { \
bitwise_cast<void*>(LLInt::getCodeFunctionPtr<CFunctionPtrTag>(name)), \
LLINT_OP_EXTRAS(LLINT_RETURN_VALIDATE(name), #name) \
LLINT_OP_EXTRAS(LLINT_RETURN_VALIDATE(name)) \
}, { \
bitwise_cast<void*>(LLInt::getWide16CodeFunctionPtr<CFunctionPtrTag>(name)), \
LLINT_OP_EXTRAS(LLINT_RETURN_WIDE16_VALIDATE(name), #name " [wide16]") \
LLINT_OP_EXTRAS(LLINT_RETURN_WIDE16_VALIDATE(name)) \
}, { \
bitwise_cast<void*>(LLInt::getWide32CodeFunctionPtr<CFunctionPtrTag>(name)), \
LLINT_OP_EXTRAS(LLINT_RETURN_WIDE32_VALIDATE(name), #name " [wide32]") \
LLINT_OP_EXTRAS(LLINT_RETURN_WIDE32_VALIDATE(name)) \
},

#define LLINT_RETURN_LOCATION(name, ...) \
@@ -231,7 +234,9 @@ SUPPRESS_ASAN void JITOperationList::addDisassemblyLabels(const JITOperationAnno
#else
auto* operation = current->operation;
#endif
registerLabel(removeCodePtrTag(operation), current->name);
Dl_info info;
if (dladdr(operation, &info) && info.dli_sname)
registerLabel(removeCodePtrTag(operation), info.dli_sname);
}
}

@@ -52,9 +52,6 @@ struct JITOperationAnnotation {
#if ENABLE(JIT_OPERATION_VALIDATION)
void* operationWithValidation;
#endif
#if ENABLE(JIT_OPERATION_DISASSEMBLY)
const char* name;
#endif
};

#if ENABLE(JIT_OPERATION_VALIDATION)
@@ -86,16 +86,14 @@

#if ENABLE(JIT_OPERATION_VALIDATION) || ENABLE(JIT_OPERATION_DISASSEMBLY)

#if ENABLE(JIT_OPERATION_VALIDATION) && ENABLE(JIT_OPERATION_DISASSEMBLY)
#define JSC_ANNOTATE_JIT_OPERATION_EXTRAS(validateFunction, name) (void*)validateFunction, name
#elif ENABLE(JIT_OPERATION_VALIDATION)
#define JSC_ANNOTATE_JIT_OPERATION_EXTRAS(validateFunction, name) (void*)validateFunction
#else // ENABLE(JIT_OPERATION_DISASSEMBLY)
#define JSC_ANNOTATE_JIT_OPERATION_EXTRAS(validateFunction, name) name
#if ENABLE(JIT_OPERATION_VALIDATION)
#define JSC_ANNOTATE_JIT_OPERATION_EXTRAS(validateFunction) (void*)validateFunction
#else
#define JSC_ANNOTATE_JIT_OPERATION_EXTRAS(validateFunction)
#endif

#define JSC_ANNOTATE_JIT_OPERATION_INTERNAL(function) \
constexpr JSC::JITOperationAnnotation _JITTargetID_##function __attribute__((used, section("__DATA_CONST,__jsc_ops"))) = { (void*)function, JSC_ANNOTATE_JIT_OPERATION_EXTRAS(function##Validate, #function) };
constexpr JSC::JITOperationAnnotation _JITTargetID_##function __attribute__((used, section("__DATA_CONST,__jsc_ops"))) = { (void*)function, JSC_ANNOTATE_JIT_OPERATION_EXTRAS(function##Validate) };

#define JSC_ANNOTATE_JIT_OPERATION(function) \
JSC_DECLARE_AND_DEFINE_JIT_OPERATION_VALIDATION(function); \
@@ -849,7 +849,7 @@
#define ENABLE_JIT_OPERATION_VALIDATION 1
#endif

#if USE(APPLE_INTERNAL_SDK) && ENABLE(DISASSEMBLER) && CPU(ARM64E) && !ASAN_ENABLED
#if USE(APPLE_INTERNAL_SDK) && ENABLE(DISASSEMBLER) && CPU(ARM64E) && HAVE(DLADDR)
#define ENABLE_JIT_OPERATION_DISASSEMBLY 1
#endif

0 comments on commit 1768e5e

Please sign in to comment.