]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - llvm/InitializeLLVM.cpp
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / llvm / InitializeLLVM.cpp
index 870688e7984fb88b0c722d29d62ccb58e13ffd5a..47348bc394a50449a30f4392b75034ce75aa573c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #if HAVE(LLVM)
 
 #include "LLVMAPI.h"
+#include "Options.h"
 #include <pthread.h>
+#include <wtf/DataLog.h>
 
 namespace JSC {
 
 static pthread_once_t initializeLLVMOnceKey = PTHREAD_ONCE_INIT;
 
+static void initializeLLVMImpl()
+{
+    const bool verbose =
+        Options::verboseFTLCompilation()
+        || Options::showFTLDisassembly()
+        || Options::verboseFTLFailure()
+        || Options::verboseCompilation()
+        || Options::showDFGDisassembly()
+        || Options::showDisassembly();
+    
+    LLVMInitializerFunction initializer = getLLVMInitializerFunction(verbose);
+    if (!initializer)
+        return;
+    
+    bool enableFastISel = Options::enableLLVMFastISel();
+    llvm = initializer(WTFLogAlwaysAndCrash, &enableFastISel);
+    if (!llvm) {
+        if (verbose)
+            dataLog("LLVM initilization failed.\n");
+    }
+    if (Options::enableLLVMFastISel() && !enableFastISel) {
+        if (verbose)
+            dataLog("Fast ISel requested but LLVM not new enough.\n");
+    }
+    
+    enableLLVMFastISel = enableFastISel;
+}
+
 bool initializeLLVM()
 {
     pthread_once(&initializeLLVMOnceKey, initializeLLVMImpl);