Title: [200543] trunk/Source/_javascript_Core
Revision
200543
Author
[email protected]
Date
2016-05-07 09:20:16 -0700 (Sat, 07 May 2016)

Log Message

Add JSC options bytecodeRangeToJITCompile and jitWhitelist.
https://bugs.webkit.org/show_bug.cgi?id=157428

Reviewed by Michael Saboff.

1. Added Options::bytecodeRangeToJITCompile and Options::jitWhitelist options.

2. Moved DFGFunctionWhitelist* to FunctionWhitelist* and made it generic so that
   it can be used for more than one whitelist instance.  In this case, we now have
   two: the dfgWhitelist and the jitWhitelist.

3. Added "can compile" checks in LLInt::shouldJIT() to check
   Options::bytecodeRangeToJITCompile and Options::jitWhitelist.

* CMakeLists.txt:
* _javascript_Core.xcodeproj/project.pbxproj:
* dfg/DFGDriver.cpp:
(JSC::DFG::getNumCompilations):
(JSC::DFG::ensureGlobalDFGWhitelist):
(JSC::DFG::compileImpl):
* dfg/DFGFunctionWhitelist.cpp: Removed.
* dfg/DFGFunctionWhitelist.h: Removed.

* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::ensureGlobalJITWhitelist):
(JSC::LLInt::shouldJIT):

* runtime/Options.h:

* tools/FunctionWhitelist.cpp: Copied from Source/_javascript_Core/dfg/DFGFunctionWhitelist.cpp.
(JSC::FunctionWhitelist::FunctionWhitelist):
(JSC::FunctionWhitelist::contains):
(JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): Deleted.
(JSC::DFG::FunctionWhitelist::FunctionWhitelist): Deleted.
(JSC::DFG::FunctionWhitelist::parseFunctionNamesInFile): Deleted.
(JSC::DFG::FunctionWhitelist::contains): Deleted.
* tools/FunctionWhitelist.h: Copied from Source/_javascript_Core/dfg/DFGFunctionWhitelist.h.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (200542 => 200543)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2016-05-07 13:03:58 UTC (rev 200542)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2016-05-07 16:20:16 UTC (rev 200543)
@@ -289,7 +289,6 @@
     dfg/DFGFlushedAt.cpp
     dfg/DFGLiveCatchVariablePreservationPhase.cpp
     dfg/DFGFrozenValue.cpp
-    dfg/DFGFunctionWhitelist.cpp
     dfg/DFGGraph.cpp
     dfg/DFGGraphSafepoint.cpp
     dfg/DFGHeapLocation.cpp
@@ -826,6 +825,7 @@
     tools/CodeProfile.cpp
     tools/CodeProfiling.cpp
     tools/FunctionOverrides.cpp
+    tools/FunctionWhitelist.cpp
     tools/JSDollarVM.cpp
     tools/JSDollarVMPrototype.cpp
 

Modified: trunk/Source/_javascript_Core/ChangeLog (200542 => 200543)


--- trunk/Source/_javascript_Core/ChangeLog	2016-05-07 13:03:58 UTC (rev 200542)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-05-07 16:20:16 UTC (rev 200543)
@@ -1,3 +1,43 @@
+2016-05-07  Mark Lam  <[email protected]>
+
+        Add JSC options bytecodeRangeToJITCompile and jitWhitelist.
+        https://bugs.webkit.org/show_bug.cgi?id=157428
+
+        Reviewed by Michael Saboff.
+
+        1. Added Options::bytecodeRangeToJITCompile and Options::jitWhitelist options.
+
+        2. Moved DFGFunctionWhitelist* to FunctionWhitelist* and made it generic so that
+           it can be used for more than one whitelist instance.  In this case, we now have
+           two: the dfgWhitelist and the jitWhitelist.
+
+        3. Added "can compile" checks in LLInt::shouldJIT() to check
+           Options::bytecodeRangeToJITCompile and Options::jitWhitelist.
+
+        * CMakeLists.txt:
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * dfg/DFGDriver.cpp:
+        (JSC::DFG::getNumCompilations):
+        (JSC::DFG::ensureGlobalDFGWhitelist):
+        (JSC::DFG::compileImpl):
+        * dfg/DFGFunctionWhitelist.cpp: Removed.
+        * dfg/DFGFunctionWhitelist.h: Removed.
+
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::ensureGlobalJITWhitelist):
+        (JSC::LLInt::shouldJIT):
+
+        * runtime/Options.h:
+
+        * tools/FunctionWhitelist.cpp: Copied from Source/_javascript_Core/dfg/DFGFunctionWhitelist.cpp.
+        (JSC::FunctionWhitelist::FunctionWhitelist):
+        (JSC::FunctionWhitelist::contains):
+        (JSC::DFG::FunctionWhitelist::ensureGlobalWhitelist): Deleted.
+        (JSC::DFG::FunctionWhitelist::FunctionWhitelist): Deleted.
+        (JSC::DFG::FunctionWhitelist::parseFunctionNamesInFile): Deleted.
+        (JSC::DFG::FunctionWhitelist::contains): Deleted.
+        * tools/FunctionWhitelist.h: Copied from Source/_javascript_Core/dfg/DFGFunctionWhitelist.h.
+
 2016-05-07  Benjamin Poulain  <[email protected]>
 
         [JSC][32bit] stress/tagged-templates-template-object.js fails in debug

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (200542 => 200543)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2016-05-07 13:03:58 UTC (rev 200542)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2016-05-07 16:20:16 UTC (rev 200543)
@@ -1131,8 +1131,6 @@
 		2A83638618D7D0EE0000EBCC /* EdenGCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A83638418D7D0EE0000EBCC /* EdenGCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2A83638918D7D0FE0000EBCC /* FullGCActivityCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2A83638718D7D0FE0000EBCC /* FullGCActivityCallback.cpp */; };
 		2A83638A18D7D0FE0000EBCC /* FullGCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A83638818D7D0FE0000EBCC /* FullGCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		2A88067819107D5500CB0BBB /* DFGFunctionWhitelist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2A88067619107D5500CB0BBB /* DFGFunctionWhitelist.cpp */; };
-		2A88067919107D5500CB0BBB /* DFGFunctionWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A88067719107D5500CB0BBB /* DFGFunctionWhitelist.h */; };
 		2AAAA31218BD49D100394CC8 /* StructureIDBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AAAA31018BD49D100394CC8 /* StructureIDBlob.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2AABCDE718EF294200002096 /* GCLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AABCDE618EF294200002096 /* GCLogging.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2AACE63C18CA5A0300ED0191 /* GCActivityCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AACE63A18CA5A0300ED0191 /* GCActivityCallback.cpp */; };
@@ -2094,6 +2092,8 @@
 		FE99B24A1C24C3D700C82159 /* JITNegGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE99B2471C24B6D300C82159 /* JITNegGenerator.cpp */; };
 		FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861E182B7A0400F6D851 /* Breakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FEA08621182B7A0400F6D851 /* DebuggerPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		FEA0C4021CDD7D1D00481991 /* FunctionWhitelist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEA0C4001CDD7D0E00481991 /* FunctionWhitelist.cpp */; };
+		FEA0C4031CDD7D1D00481991 /* FunctionWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0C4011CDD7D0E00481991 /* FunctionWhitelist.h */; };
 		FEA1E4391C213A2B00277A16 /* ValueProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEA1E4381C213A2600277A16 /* ValueProfile.cpp */; };
 		FEB137571BB11EF900CD5100 /* MacroAssemblerARM64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */; };
 		FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEB51F6B1A97B688001F921C /* Regress141809.mm */; };
@@ -3265,8 +3265,6 @@
 		2A83638418D7D0EE0000EBCC /* EdenGCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EdenGCActivityCallback.h; sourceTree = "<group>"; };
 		2A83638718D7D0FE0000EBCC /* FullGCActivityCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FullGCActivityCallback.cpp; sourceTree = "<group>"; };
 		2A83638818D7D0FE0000EBCC /* FullGCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullGCActivityCallback.h; sourceTree = "<group>"; };
-		2A88067619107D5500CB0BBB /* DFGFunctionWhitelist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGFunctionWhitelist.cpp; path = dfg/DFGFunctionWhitelist.cpp; sourceTree = "<group>"; };
-		2A88067719107D5500CB0BBB /* DFGFunctionWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGFunctionWhitelist.h; path = dfg/DFGFunctionWhitelist.h; sourceTree = "<group>"; };
 		2AAAA31018BD49D100394CC8 /* StructureIDBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureIDBlob.h; sourceTree = "<group>"; };
 		2AABCDE618EF294200002096 /* GCLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCLogging.h; sourceTree = "<group>"; };
 		2AACE63A18CA5A0300ED0191 /* GCActivityCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GCActivityCallback.cpp; sourceTree = "<group>"; };
@@ -4347,6 +4345,8 @@
 		FE99B2481C24B6D300C82159 /* JITNegGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITNegGenerator.h; sourceTree = "<group>"; };
 		FEA0861E182B7A0400F6D851 /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakpoint.h; sourceTree = "<group>"; };
 		FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerPrimitives.h; sourceTree = "<group>"; };
+		FEA0C4001CDD7D0E00481991 /* FunctionWhitelist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionWhitelist.cpp; sourceTree = "<group>"; };
+		FEA0C4011CDD7D0E00481991 /* FunctionWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionWhitelist.h; sourceTree = "<group>"; };
 		FEA1E4381C213A2600277A16 /* ValueProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ValueProfile.cpp; sourceTree = "<group>"; };
 		FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerARM64.cpp; sourceTree = "<group>"; };
 		FEB51F6A1A97B688001F921C /* Regress141809.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Regress141809.h; path = API/tests/Regress141809.h; sourceTree = "<group>"; };
@@ -6060,6 +6060,8 @@
 				8603CEF314C7546400AE59E3 /* CodeProfiling.h */,
 				FE4BFF291AD476E700088F87 /* FunctionOverrides.cpp */,
 				FE4BFF2A1AD476E700088F87 /* FunctionOverrides.h */,
+				FEA0C4001CDD7D0E00481991 /* FunctionWhitelist.cpp */,
+				FEA0C4011CDD7D0E00481991 /* FunctionWhitelist.h */,
 				FE384EE11ADDB7AD0055DE2C /* JSDollarVM.cpp */,
 				FE384EE21ADDB7AD0055DE2C /* JSDollarVM.h */,
 				FE384EE31ADDB7AD0055DE2C /* JSDollarVMPrototype.cpp */,
@@ -6214,8 +6216,6 @@
 				0F2DD8101AB3D8BE00BBB8E8 /* DFGForAllKills.h */,
 				0F69CC86193AC60A0045759E /* DFGFrozenValue.cpp */,
 				0F69CC87193AC60A0045759E /* DFGFrozenValue.h */,
-				2A88067619107D5500CB0BBB /* DFGFunctionWhitelist.cpp */,
-				2A88067719107D5500CB0BBB /* DFGFunctionWhitelist.h */,
 				86EC9DB61328DF82002B2AD7 /* DFGGenerationInfo.h */,
 				86EC9DB71328DF82002B2AD7 /* DFGGraph.cpp */,
 				86EC9DB81328DF82002B2AD7 /* DFGGraph.h */,
@@ -7078,6 +7078,7 @@
 				99DA00A81BD5993100F4575C /* builtins_generate_combined_implementation.py in Headers */,
 				99DA00A91BD5993100F4575C /* builtins_generate_separate_header.py in Headers */,
 				0F338E111BF0276C0013C88F /* B3OpaqueByproduct.h in Headers */,
+				FEA0C4031CDD7D1D00481991 /* FunctionWhitelist.h in Headers */,
 				99DA00AA1BD5993100F4575C /* builtins_generate_separate_implementation.py in Headers */,
 				99DA00A31BD5993100F4575C /* builtins_generator.py in Headers */,
 				FE3A06A61C10B72D00390FDD /* JITBitOrGenerator.h in Headers */,
@@ -7267,7 +7268,6 @@
 				A7D89CF817A0B8CC00773AD8 /* DFGFlushFormat.h in Headers */,
 				0F2DD8151AB3D8BE00BBB8E8 /* DFGForAllKills.h in Headers */,
 				0F69CC89193AC60A0045759E /* DFGFrozenValue.h in Headers */,
-				2A88067919107D5500CB0BBB /* DFGFunctionWhitelist.h in Headers */,
 				86EC9DC61328DF82002B2AD7 /* DFGGenerationInfo.h in Headers */,
 				86EC9DC81328DF82002B2AD7 /* DFGGraph.h in Headers */,
 				0F2FCCFA18A60070001A27F8 /* DFGGraphSafepoint.h in Headers */,
@@ -8834,7 +8834,6 @@
 				0F9D339617FFC4E60073C2BC /* DFGFlushedAt.cpp in Sources */,
 				A7D89CF717A0B8CC00773AD8 /* DFGFlushFormat.cpp in Sources */,
 				0F69CC88193AC60A0045759E /* DFGFrozenValue.cpp in Sources */,
-				2A88067819107D5500CB0BBB /* DFGFunctionWhitelist.cpp in Sources */,
 				86EC9DC71328DF82002B2AD7 /* DFGGraph.cpp in Sources */,
 				0F2FCCF918A60070001A27F8 /* DFGGraphSafepoint.cpp in Sources */,
 				0FB17660196B8F9E0091052A /* DFGHeapLocation.cpp in Sources */,
@@ -8849,6 +8848,7 @@
 				86EC9DCB1328DF82002B2AD7 /* DFGJITCompiler.cpp in Sources */,
 				A78A9778179738B8009DF744 /* DFGJITFinalizer.cpp in Sources */,
 				0FC97F3F18202119002C9B26 /* DFGJumpReplacement.cpp in Sources */,
+				FEA0C4021CDD7D1D00481991 /* FunctionWhitelist.cpp in Sources */,
 				A73A535A1799CD5D00170C19 /* DFGLazyJSValue.cpp in Sources */,
 				62F2AA371B0BEDE300610C7A /* DFGLazyNode.cpp in Sources */,
 				A7D9A29717A0BC7400EE2618 /* DFGLICMPhase.cpp in Sources */,

Modified: trunk/Source/_javascript_Core/dfg/DFGDriver.cpp (200542 => 200543)


--- trunk/Source/_javascript_Core/dfg/DFGDriver.cpp	2016-05-07 13:03:58 UTC (rev 200542)
+++ trunk/Source/_javascript_Core/dfg/DFGDriver.cpp	2016-05-07 16:20:16 UTC (rev 200543)
@@ -30,16 +30,17 @@
 #include "JSString.h"
 
 #include "CodeBlock.h"
-#include "DFGFunctionWhitelist.h"
 #include "DFGJITCode.h"
 #include "DFGPlan.h"
 #include "DFGThunks.h"
 #include "DFGWorklist.h"
+#include "FunctionWhitelist.h"
 #include "JITCode.h"
 #include "JSCInlines.h"
 #include "Options.h"
 #include "TypeProfilerLog.h"
 #include <wtf/Atomics.h>
+#include <wtf/NeverDestroyed.h>
 
 #if ENABLE(FTL_JIT)
 #include "FTLThunks.h"
@@ -55,13 +56,24 @@
 }
 
 #if ENABLE(DFG_JIT)
+static FunctionWhitelist& ensureGlobalDFGWhitelist()
+{
+    static LazyNeverDestroyed<FunctionWhitelist> dfgWhitelist;
+    static std::once_flag initializeWhitelistFlag;
+    std::call_once(initializeWhitelistFlag, [] {
+        const char* functionWhitelistFile = Options::dfgWhitelist();
+        dfgWhitelist.construct(functionWhitelistFile);
+    });
+    return dfgWhitelist;
+}
+
 static CompilationResult compileImpl(
     VM& vm, CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationMode mode,
     unsigned osrEntryBytecodeIndex, const Operands<JSValue>& mustHandleValues,
     PassRefPtr<DeferredCompilationCallback> callback)
 {
     if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount())
-        || !FunctionWhitelist::ensureGlobalWhitelist().contains(codeBlock))
+        || !ensureGlobalDFGWhitelist().contains(codeBlock))
         return CompilationFailed;
     
     numCompilations++;

Deleted: trunk/Source/_javascript_Core/dfg/DFGFunctionWhitelist.cpp (200542 => 200543)


--- trunk/Source/_javascript_Core/dfg/DFGFunctionWhitelist.cpp	2016-05-07 13:03:58 UTC (rev 200542)
+++ trunk/Source/_javascript_Core/dfg/DFGFunctionWhitelist.cpp	2016-05-07 16:20:16 UTC (rev 200543)
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DFGFunctionWhitelist.h"
-
-#if ENABLE(DFG_JIT)
-
-#include "CodeBlock.h"
-#include "Options.h"
-#include <stdio.h>
-#include <string.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/text/StringBuilder.h>
-
-namespace JSC { namespace DFG {
-
-FunctionWhitelist& FunctionWhitelist::ensureGlobalWhitelist()
-{
-    static LazyNeverDestroyed<FunctionWhitelist> functionWhitelist;
-    static std::once_flag initializeWhitelistFlag;
-    std::call_once(initializeWhitelistFlag, [] {
-        const char* functionWhitelistFile = Options::dfgWhitelist();
-        functionWhitelist.construct(functionWhitelistFile);
-    });
-    return functionWhitelist;
-}
-
-FunctionWhitelist::FunctionWhitelist(const char* filename)
-{
-    parseFunctionNamesInFile(filename);
-}
-
-void FunctionWhitelist::parseFunctionNamesInFile(const char* filename)
-{
-    if (!filename)
-        return;
-
-    FILE* f = fopen(filename, "r");
-    if (!f) {
-        dataLogF("Failed to open file %s. Did you add the file-read-data entitlement to WebProcess.sb?\n", filename); 
-        return;
-    }
-
-    char* line;
-    char buffer[BUFSIZ];
-    while ((line = fgets(buffer, sizeof(buffer), f))) {
-        if (strstr(line, "//") == line)
-            continue;
-
-        // Get rid of newlines at the ends of the strings.
-        size_t length = strlen(line);
-        if (line[length - 1] == '\n') {
-            line[length - 1] = '\0';
-            length--;
-        }
-
-        // Skip empty lines.
-        if (!length)
-            continue;
-        
-        m_entries.add(String(line, length));
-    }
-
-    int result = fclose(f);
-    if (result)
-        dataLogF("Failed to close file %s: %s\n", filename, strerror(errno));
-}
-
-bool FunctionWhitelist::contains(CodeBlock* codeBlock) const 
-{
-    ASSERT(!isCompilationThread());
-    if (!Options::dfgWhitelist())
-        return true;
-
-    if (m_entries.isEmpty())
-        return false;
-
-    String name = String::fromUTF8(codeBlock->inferredName());
-    if (m_entries.contains(name))
-        return true;
-
-    String hash = String::fromUTF8(codeBlock->hashAsStringIfPossible());
-    if (m_entries.contains(hash))
-        return true;
-
-    return m_entries.contains(name + '#' + hash);
-}
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
-

Deleted: trunk/Source/_javascript_Core/dfg/DFGFunctionWhitelist.h (200542 => 200543)


--- trunk/Source/_javascript_Core/dfg/DFGFunctionWhitelist.h	2016-05-07 13:03:58 UTC (rev 200542)
+++ trunk/Source/_javascript_Core/dfg/DFGFunctionWhitelist.h	2016-05-07 16:20:16 UTC (rev 200543)
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DFGFunctionWhitelist_h
-#define DFGFunctionWhitelist_h
-
-#if ENABLE(DFG_JIT)
-
-#include <wtf/HashSet.h>
-#include <wtf/text/WTFString.h>
-
-namespace JSC { 
-
-class CodeBlock;
-
-namespace DFG {
-
-class FunctionWhitelist {
-public:
-    static FunctionWhitelist& ensureGlobalWhitelist();
-    explicit FunctionWhitelist(const char*);
-
-    bool contains(CodeBlock*) const;
-
-private:
-    void parseFunctionNamesInFile(const char*);
-
-    HashSet<String> m_entries;
-};
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
-
-#endif // DFGFunctionWhitelist_h

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (200542 => 200543)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2016-05-07 13:03:58 UTC (rev 200542)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2016-05-07 16:20:16 UTC (rev 200543)
@@ -34,6 +34,7 @@
 #include "ErrorHandlingScope.h"
 #include "Exception.h"
 #include "ExceptionFuzz.h"
+#include "FunctionWhitelist.h"
 #include "GetterSetter.h"
 #include "HostCallReturnValue.h"
 #include "Interpreter.h"
@@ -56,6 +57,7 @@
 #include "ShadowChicken.h"
 #include "StructureRareDataInlines.h"
 #include "VMInlines.h"
+#include <wtf/NeverDestroyed.h>
 #include <wtf/StringPrintStream.h>
 
 namespace JSC { namespace LLInt {
@@ -287,8 +289,23 @@
 enum EntryKind { Prologue, ArityCheck };
 
 #if ENABLE(JIT)
-inline bool shouldJIT(ExecState* exec, CodeBlock*)
+static FunctionWhitelist& ensureGlobalJITWhitelist()
 {
+    static LazyNeverDestroyed<FunctionWhitelist> baselineWhitelist;
+    static std::once_flag initializeWhitelistFlag;
+    std::call_once(initializeWhitelistFlag, [] {
+        const char* functionWhitelistFile = Options::jitWhitelist();
+        baselineWhitelist.construct(functionWhitelistFile);
+    });
+    return baselineWhitelist;
+}
+
+inline bool shouldJIT(ExecState* exec, CodeBlock* codeBlock)
+{
+    if (!Options::bytecodeRangeToJITCompile().isInRange(codeBlock->instructionCount())
+        || !ensureGlobalJITWhitelist().contains(codeBlock))
+        return false;
+
     // You can modify this to turn off JITting without rebuilding the world.
     return exec->vm().canUseJIT();
 }

Modified: trunk/Source/_javascript_Core/runtime/Options.h (200542 => 200543)


--- trunk/Source/_javascript_Core/runtime/Options.h	2016-05-07 13:03:58 UTC (rev 200542)
+++ trunk/Source/_javascript_Core/runtime/Options.h	2016-05-07 16:20:16 UTC (rev 200543)
@@ -145,8 +145,10 @@
     v(bool, dumpDFGDisassembly, false, Normal, "dumps disassembly of DFG function upon compilation") \
     v(bool, dumpFTLDisassembly, false, Normal, "dumps disassembly of FTL function upon compilation") \
     v(bool, dumpAllDFGNodes, false, Normal, nullptr) \
+    v(optionRange, bytecodeRangeToJITCompile, 0, Normal, "bytecode size range to allow compilation on, e.g. 1:100") \
     v(optionRange, bytecodeRangeToDFGCompile, 0, Normal, "bytecode size range to allow DFG compilation on, e.g. 1:100") \
     v(optionRange, bytecodeRangeToFTLCompile, 0, Normal, "bytecode size range to allow FTL compilation on, e.g. 1:100") \
+    v(optionString, jitWhitelist, nullptr, Normal, "file with list of function signatures to allow compilation on") \
     v(optionString, dfgWhitelist, nullptr, Normal, "file with list of function signatures to allow DFG compilation on") \
     v(bool, dumpSourceAtDFGTime, false, Normal, "dumps source code of JS function being DFG compiled") \
     v(bool, dumpBytecodeAtDFGTime, false, Normal, "dumps bytecode of JS function being DFG compiled") \

Copied: trunk/Source/_javascript_Core/tools/FunctionWhitelist.cpp (from rev 200530, trunk/Source/_javascript_Core/dfg/DFGFunctionWhitelist.cpp) (0 => 200543)


--- trunk/Source/_javascript_Core/tools/FunctionWhitelist.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/tools/FunctionWhitelist.cpp	2016-05-07 16:20:16 UTC (rev 200543)
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FunctionWhitelist.h"
+
+#if ENABLE(JIT)
+
+#include "CodeBlock.h"
+#include "Options.h"
+#include <stdio.h>
+#include <string.h>
+#include <wtf/text/StringBuilder.h>
+
+namespace JSC {
+
+FunctionWhitelist::FunctionWhitelist(const char* filename)
+{
+    if (!filename)
+        return;
+
+    FILE* f = fopen(filename, "r");
+    if (!f) {
+        dataLogF("Failed to open file %s. Did you add the file-read-data entitlement to WebProcess.sb?\n", filename); 
+        return;
+    }
+
+    m_hasActiveWhitelist = true;
+
+    char* line;
+    char buffer[BUFSIZ];
+    while ((line = fgets(buffer, sizeof(buffer), f))) {
+        if (strstr(line, "//") == line)
+            continue;
+
+        // Get rid of newlines at the ends of the strings.
+        size_t length = strlen(line);
+        if (line[length - 1] == '\n') {
+            line[length - 1] = '\0';
+            length--;
+        }
+
+        // Skip empty lines.
+        if (!length)
+            continue;
+        
+        m_entries.add(String(line, length));
+    }
+
+    int result = fclose(f);
+    if (result)
+        dataLogF("Failed to close file %s: %s\n", filename, strerror(errno));
+}
+
+bool FunctionWhitelist::contains(CodeBlock* codeBlock) const
+{
+    ASSERT(!isCompilationThread());
+    if (!m_hasActiveWhitelist)
+        return true;
+
+    if (m_entries.isEmpty())
+        return false;
+
+    String name = String::fromUTF8(codeBlock->inferredName());
+    if (m_entries.contains(name))
+        return true;
+
+    String hash = String::fromUTF8(codeBlock->hashAsStringIfPossible());
+    if (m_entries.contains(hash))
+        return true;
+
+    return m_entries.contains(name + '#' + hash);
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+

Copied: trunk/Source/_javascript_Core/tools/FunctionWhitelist.h (from rev 200530, trunk/Source/_javascript_Core/dfg/DFGFunctionWhitelist.h) (0 => 200543)


--- trunk/Source/_javascript_Core/tools/FunctionWhitelist.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/tools/FunctionWhitelist.h	2016-05-07 16:20:16 UTC (rev 200543)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FunctionWhitelist_h
+#define FunctionWhitelist_h
+
+#include <wtf/HashSet.h>
+#include <wtf/text/WTFString.h>
+
+namespace JSC { 
+
+class CodeBlock;
+
+class FunctionWhitelist {
+public:
+    explicit FunctionWhitelist(const char*);
+
+    bool contains(CodeBlock*) const;
+
+private:
+    HashSet<String> m_entries;
+    bool m_hasActiveWhitelist { false };
+};
+
+} // namespace JSC
+
+#endif // FunctionWhitelist_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to