Ignore:
Timestamp:
Jul 24, 2013, 9:04:05 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: JSC's disassembly infrastructure should be able to disassemble the code that LLVM generates
https://bugs.webkit.org/show_bug.cgi?id=118148

Source/JavaScriptCore:

Reviewed by Anders Carlsson.

Oh boy. UDis86 cannot disassemble the AVX (or whatever it's called) stuff
that LLVM generates for floating point. So the right decision is to
switch to the LLVM disassembler, right? Wrong!! LLVM's disassembler
cannot disassemble the load-from-absolute-address-into-%rax instructions
that our JIT generates quite a lot of.

So, this keeps the UDis86 disassembler, but adds the LLVM disassembler,
and requires the caller of disassemble() to hint which one is likely to
be less wrong for the given code.

Maybe in the future LLVM will catch up to UDis86, but it's definitely not
there right now.

This now allows us to disassemble all of the code that LLVM generates.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • disassembler/Disassembler.cpp:

(JSC::disassemble):

  • disassembler/Disassembler.h:

(JSC::tryToDisassemble):
(JSC):

  • disassembler/LLVMDisassembler.cpp: Added.

(JSC):
(JSC::symbolLookupCallback):
(JSC::tryToDisassembleWithLLVM):

  • disassembler/LLVMDisassembler.h: Added.

(JSC):
(JSC::tryToDisassembleWithLLVM):

  • disassembler/UDis86Disassembler.cpp:

(JSC::tryToDisassembleWithUDis86):

  • disassembler/UDis86Disassembler.h: Added.

(JSC):
(JSC::tryToDisassembleWithUDis86):

  • disassembler/X86Disassembler.cpp: Added.

(JSC):
(JSC::tryToDisassemble):

  • ftl/FTLAbbreviatedTypes.h:
  • ftl/FTLCompile.cpp:

(JSC::FTL::compile):

  • ftl/FTLJITCode.h:
  • ftl/FTLJITFinalizer.h:
  • ftl/FTLLLVMHeaders.h: Removed.
  • ftl/FTLLink.cpp:
  • runtime/InitializeThreading.cpp:

(JSC::initializeThreadingOnce):

  • runtime/Options.h:

(JSC):

Source/WTF:

Reviewed by Anders Carlsson.

We now use LLVM for two things: disassembler and FTL. Separate out the question
of whether we have LLVM (HAVE(LLVM)) from whether we want to use the LLVM
disassembler (USE(LLVM_DISASSEMBLER)) and whether we enable the FTL
(ENABLE(FTL_JIT)).

Also move the cruft for including LLVM headers into WTF since now we use it in
a bunch of places, not all related to FTL. There's no obvious place to put that
file in JSC so I put it in WTF.

  • WTF.xcodeproj/project.pbxproj:
  • wtf/LLVMHeaders.h: Copied from Source/JavaScriptCore/ftl/FTLLLVMHeaders.h.
  • wtf/Platform.h:
Location:
trunk/Source/JavaScriptCore/disassembler
Files:
2 added
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/disassembler/Disassembler.cpp

    r135640 r153256  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3232namespace JSC {
    3333
    34 void disassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out)
     34void disassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out, InstructionSubsetHint subsetHint)
    3535{
    36     if (tryToDisassemble(codePtr, size, prefix, out))
     36    if (tryToDisassemble(codePtr, size, prefix, out, subsetHint))
    3737        return;
    3838   
  • trunk/Source/JavaScriptCore/disassembler/Disassembler.h

    r135640 r153256  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434class MacroAssemblerCodePtr;
    3535
     36enum InstructionSubsetHint { MacroAssemblerSubset, LLVMSubset };
     37
    3638#if ENABLE(DISASSEMBLER)
    37 bool tryToDisassemble(const MacroAssemblerCodePtr&, size_t, const char* prefix, PrintStream&);
     39bool tryToDisassemble(const MacroAssemblerCodePtr&, size_t, const char* prefix, PrintStream&, InstructionSubsetHint = MacroAssemblerSubset);
    3840#else
    39 inline bool tryToDisassemble(const MacroAssemblerCodePtr&, size_t, const char*, PrintStream&)
     41inline bool tryToDisassemble(const MacroAssemblerCodePtr&, size_t, const char*, PrintStream&, InstructionSubsetHint = MacroAssemblerSubset)
    4042{
    4143    return false;
     
    4547// Prints either the disassembly, or a line of text indicating that disassembly failed and
    4648// the range of machine code addresses.
    47 void disassemble(const MacroAssemblerCodePtr&, size_t, const char* prefix, PrintStream& out);
     49void disassemble(const MacroAssemblerCodePtr&, size_t, const char* prefix, PrintStream& out, InstructionSubsetHint = MacroAssemblerSubset);
    4850
    4951} // namespace JSC
  • trunk/Source/JavaScriptCore/disassembler/LLVMDisassembler.h

    r153255 r153256  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
     26#ifndef LLVMDisassembler_h
     27#define LLVMDisassembler_h
     28
    2729#include "Disassembler.h"
    28 
    29 #include "MacroAssemblerCodeRef.h"
    30 #include <wtf/DataLog.h>
    3130
    3231namespace JSC {
    3332
    34 void disassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out)
    35 {
    36     if (tryToDisassemble(codePtr, size, prefix, out))
    37         return;
    38    
    39     out.printf("%sdisassembly not available for range %p...%p\n", prefix, codePtr.executableAddress(), static_cast<char*>(codePtr.executableAddress()) + size);
    40 }
     33#if USE(LLVM_DISASSEMBLER)
     34
     35bool tryToDisassembleWithLLVM(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out, InstructionSubsetHint);
     36
     37#else // USE(LLVM_DISASSEMBLER)
     38
     39inline bool tryToDisassembleWithLLVM(const MacroAssemblerCodePtr&, size_t, const char*, PrintStream&, InstructionSubsetHint) { return false; }
     40
     41#endif // USE(LLVM_DISASSEMBLER)
    4142
    4243} // namespace JSC
    4344
     45#endif // LLVMDisassembler_h
     46
  • trunk/Source/JavaScriptCore/disassembler/UDis86Disassembler.cpp

    r135640 r153256  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "Disassembler.h"
     27#include "UDis86Disassembler.h"
    2828
    2929#if USE(UDIS86)
     
    3434namespace JSC {
    3535
    36 bool tryToDisassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out)
     36bool tryToDisassembleWithUDis86(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out, InstructionSubsetHint)
    3737{
    3838    ud_t disassembler;
  • trunk/Source/JavaScriptCore/disassembler/UDis86Disassembler.h

    r153255 r153256  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
     26#ifndef UDis86Disassembler_h
     27#define UDis86Disassembler_h
     28
    2729#include "Disassembler.h"
    28 
    29 #include "MacroAssemblerCodeRef.h"
    30 #include <wtf/DataLog.h>
    3130
    3231namespace JSC {
    3332
    34 void disassemble(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out)
    35 {
    36     if (tryToDisassemble(codePtr, size, prefix, out))
    37         return;
    38    
    39     out.printf("%sdisassembly not available for range %p...%p\n", prefix, codePtr.executableAddress(), static_cast<char*>(codePtr.executableAddress()) + size);
    40 }
     33#if USE(UDIS86)
     34
     35bool tryToDisassembleWithUDis86(const MacroAssemblerCodePtr& codePtr, size_t size, const char* prefix, PrintStream& out, InstructionSubsetHint);
     36
     37#else // USE(UDIS86)
     38
     39inline bool tryToDisassembleWithUDis86(const MacroAssemblerCodePtr&, size_t, const char*, PrintStream&, InstructionSubsetHint) { return false; }
     40
     41#endif // USE(UDIS86)
    4142
    4243} // namespace JSC
    4344
     45#endif // UDis86Disassembler_h
     46
Note: See TracChangeset for help on using the changeset viewer.