Changeset 182483 in webkit for trunk/Source/JavaScriptCore/llvm
- Timestamp:
- Apr 7, 2015, 12:41:12 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore/llvm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/llvm/InitializeLLVM.cpp
r166948 r182483 1 1 /* 2 * Copyright (C) 2013 , 2014Apple Inc. All rights reserved.2 * Copyright (C) 2013-2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 31 31 #include "LLVMAPI.h" 32 #include "Options.h" 32 33 #include <pthread.h> 34 #include <wtf/DataLog.h> 33 35 34 36 namespace JSC { 35 37 36 38 static pthread_once_t initializeLLVMOnceKey = PTHREAD_ONCE_INIT; 39 40 static void initializeLLVMImpl() 41 { 42 const bool verbose = 43 Options::verboseFTLCompilation() 44 || Options::showFTLDisassembly() 45 || Options::verboseFTLFailure() 46 || Options::verboseCompilation() 47 || Options::showDFGDisassembly() 48 || Options::showDisassembly(); 49 50 LLVMInitializerFunction initializer = getLLVMInitializerFunction(verbose); 51 if (!initializer) 52 return; 53 54 bool enableFastISel = Options::enableLLVMFastISel(); 55 llvm = initializer(WTFLogAlwaysAndCrash, &enableFastISel); 56 if (!llvm) { 57 if (verbose) 58 dataLog("LLVM initilization failed.\n"); 59 } 60 if (Options::enableLLVMFastISel() && !enableFastISel) { 61 if (verbose) 62 dataLog("Fast ISel requested but LLVM not new enough.\n"); 63 } 64 65 enableLLVMFastISel = enableFastISel; 66 } 37 67 38 68 bool initializeLLVM() -
trunk/Source/JavaScriptCore/llvm/InitializeLLVM.h
r171391 r182483 1 1 /* 2 * Copyright (C) 2013 , 2014Apple Inc. All rights reserved.2 * Copyright (C) 2013-2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if HAVE(LLVM) 30 30 31 #include "LLVMAPI.h" 31 32 #include <string> 32 33 #include <wtf/text/CString.h> … … 34 35 namespace JSC { 35 36 36 void initializeLLVMImpl(); 37 typedef void (*LoggerFunction)(const char*, ...) WTF_ATTRIBUTE_PRINTF(1, 2); 38 typedef LLVMAPI* (*LLVMInitializerFunction)(LoggerFunction, bool* enableFastISel); 39 40 LLVMInitializerFunction getLLVMInitializerFunction(bool verbose); 37 41 38 42 extern const CString* llvmBitcodeLibraryForInliningPath; 39 43 40 // You m sut call this before using JSC::llvm. It's safe to call this multiple times.44 // You must call this before using JSC::llvm. It's safe to call this multiple times. 41 45 // Returns true if we successfully loaded LLVM. Returns false if we didn't. 42 46 bool initializeLLVM(); -
trunk/Source/JavaScriptCore/llvm/InitializeLLVMLinux.cpp
r161498 r182483 2 2 * Copyright (C) 2013 University of Szeged. All rights reserved. 3 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 4 * Copyright (C) 2015 Apple Inc. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 34 35 namespace JSC { 35 36 36 void initializeLLVMImpl()37 LLVMInitializerFunction getLLVMInitializerFunction(bool verbose) 37 38 { 38 initializeLLVMPOSIX("libllvmForJSC.so");39 return getLLVMInitializerFunctionPOSIX("libllvmForJSC.so", verbose); 39 40 } 40 41 -
trunk/Source/JavaScriptCore/llvm/InitializeLLVMMac.cpp
r171391 r182483 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 38 38 namespace JSC { 39 39 40 void initializeLLVMImpl()40 LLVMInitializerFunction getLLVMInitializerFunction(bool verbose) 41 41 { 42 initializeLLVMPOSIX(toCString(bundlePath().data(), "/Libraries/libllvmForJSC.dylib").data());42 return getLLVMInitializerFunctionPOSIX(toCString(bundlePath().data(), "/Libraries/libllvmForJSC.dylib").data(), verbose); 43 43 } 44 44 -
trunk/Source/JavaScriptCore/llvm/InitializeLLVMPOSIX.cpp
r180622 r182483 1 1 /* 2 * Copyright (C) 2013 , 2014Apple Inc. All rights reserved.2 * Copyright (C) 2013-2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 namespace JSC { 37 37 38 typedef void (*LoggerFunction)(const char*, ...) WTF_ATTRIBUTE_PRINTF(1, 2); 39 typedef LLVMAPI* (*InitializerFunction)(LoggerFunction); 40 41 void initializeLLVMPOSIX(const char* libraryName) 38 LLVMInitializerFunction getLLVMInitializerFunctionPOSIX(const char* libraryName, bool verbose) 42 39 { 43 const bool verbose =44 Options::verboseFTLCompilation()45 || Options::showFTLDisassembly()46 || Options::verboseFTLFailure()47 || Options::verboseCompilation()48 || Options::showDFGDisassembly()49 || Options::showDisassembly();50 51 40 int flags = RTLD_NOW; 52 41 … … 64 53 if (verbose) 65 54 dataLog("Failed to load LLVM library at ", libraryName, ": ", dlerror(), "\n"); 66 return ;55 return nullptr; 67 56 } 68 57 69 58 const char* symbolName = "initializeAndGetJSCLLVMAPI"; 70 InitializerFunction initializer = bitwise_cast<InitializerFunction>(59 LLVMInitializerFunction initializer = bitwise_cast<LLVMInitializerFunction>( 71 60 dlsym(library, symbolName)); 72 61 if (!initializer) { 73 62 if (verbose) 74 63 dataLog("Failed to find ", symbolName, " in ", libraryName, ": ", dlerror()); 75 return ;64 return nullptr; 76 65 } 77 66 78 llvm = initializer(WTFLogAlwaysAndCrash); 79 if (!llvm) { 80 if (verbose) 81 dataLog("LLVM initilization failed.\n"); 82 } 67 return initializer; 83 68 } 84 69 -
trunk/Source/JavaScriptCore/llvm/InitializeLLVMPOSIX.h
r164424 r182483 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if HAVE(LLVM) 30 30 31 #include "InitializeLLVM.h" 32 31 33 namespace JSC { 32 34 33 void initializeLLVMPOSIX(const char* libraryName);35 LLVMInitializerFunction getLLVMInitializerFunctionPOSIX(const char* libraryName, bool verbose); 34 36 35 37 } // namespace JSC -
trunk/Source/JavaScriptCore/llvm/InitializeLLVMWin.cpp
r170130 r182483 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 namespace JSC { 35 35 36 typedef LLVMAPI* (*InitializerFunction)(void(*)(const char*, ...)); 37 38 void initializeLLVMImpl() 36 LLVMInitializerFunction getLLVMInitializerFunction(bool /* verbose */) 39 37 { 40 38 const wchar_t* libraryName = L"libllvmForJSC.dll"; … … 43 41 44 42 if (!library) 45 return ;43 return nullptr; 46 44 47 45 const char* symbolName = "initializeAndGetJSCLLVMAPI"; 48 InitializerFunction initializer = bitwise_cast<InitializerFunction>(GetProcAddress(library, symbolName)); 49 if (initializer) 50 llvm = initializer(WTFLogAlwaysAndCrash); 46 return bitwise_cast<LLVMInitializerFunction>(GetProcAddress(library, symbolName)); 51 47 } 52 48 -
trunk/Source/JavaScriptCore/llvm/LLVMAPI.cpp
r157260 r182483 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 33 33 LLVMAPI* llvm; 34 bool enableLLVMFastISel; 34 35 35 36 } -
trunk/Source/JavaScriptCore/llvm/LLVMAPI.h
r164424 r182483 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 FOR_EACH_LLVM_API_FUNCTION(LLVM_API_FUNCTION_DECLARATION) 40 40 #undef LLVM_API_FUNCTION_DECLARATION 41 42 // Functions that we add conditionally. 43 void (*AddLowerSwitchPass)(LLVMPassManagerRef PM); 41 44 }; 42 45 43 46 extern LLVMAPI* llvm; 47 extern bool enableLLVMFastISel; 44 48 45 49 } // namespace JSC -
trunk/Source/JavaScriptCore/llvm/library/LLVMExports.cpp
r181083 r182483 55 55 56 56 static void llvmCrash(const char*) NO_RETURN; 57 extern "C" WTF_EXPORT_PRIVATE JSC::LLVMAPI* initializeAndGetJSCLLVMAPI(void (*)(const char*, ...) NO_RETURN); 57 extern "C" WTF_EXPORT_PRIVATE JSC::LLVMAPI* initializeAndGetJSCLLVMAPI( 58 void (*)(const char*, ...) NO_RETURN, bool* enableFastISel); 58 59 59 60 static void llvmCrash(const char* reason) … … 62 63 } 63 64 64 extern "C" JSC::LLVMAPI* initializeAndGetJSCLLVMAPI(void (*callback)(const char*, ...) NO_RETURN) 65 template<typename... Args> 66 void initCommandLine(Args... args) 67 { 68 const char* theArgs[] = { args... }; 69 llvm::cl::ParseCommandLineOptions(sizeof(theArgs) / sizeof(const char*), theArgs); 70 } 71 72 extern "C" JSC::LLVMAPI* initializeAndGetJSCLLVMAPI( 73 void (*callback)(const char*, ...) NO_RETURN, 74 bool* enableFastISel) 65 75 { 66 76 g_llvmTrapCallback = callback; … … 100 110 #endif 101 111 102 const char* args[] = { 103 "llvmForJSC.dylib", 104 "-enable-patchpoint-liveness=true" 105 }; 106 llvm::cl::ParseCommandLineOptions(sizeof(args) / sizeof(const char*), args); 112 #if LLVM_VERSION_MAJOR >= 4 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6) 113 // It's OK to have fast ISel, if it was requested. 114 #else 115 // We don't have enough support for fast ISel. Disable it. 116 *enableFastISel = false; 117 #endif 118 119 if (*enableFastISel) 120 initCommandLine("llvmForJSC.dylib", "-enable-misched=false", "-regalloc=basic"); 121 else 122 initCommandLine("llvmForJSC.dylib", "-enable-patchpoint-liveness=true"); 107 123 108 124 JSC::LLVMAPI* result = new JSC::LLVMAPI; 125 126 // Initialize the whole thing to null. 127 memset(result, 0, sizeof(*result)); 109 128 110 129 #define LLVM_API_FUNCTION_ASSIGNMENT(returnType, name, signature) \ … … 112 131 FOR_EACH_LLVM_API_FUNCTION(LLVM_API_FUNCTION_ASSIGNMENT); 113 132 #undef LLVM_API_FUNCTION_ASSIGNMENT 133 134 // Handle conditionally available functions. 135 #if LLVM_VERSION_MAJOR >= 4 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6) 136 result->AddLowerSwitchPass = LLVMAddLowerSwitchPass; 137 #endif 114 138 115 139 return result;
Note:
See TracChangeset
for help on using the changeset viewer.