source: webkit/trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp

Last change on this file was 278253, checked in by Darin Adler, 4 years ago

Remove WTF::Optional synonym for std::optional, using that class template directly instead
https://bugs.webkit.org/show_bug.cgi?id=226433

Reviewed by Chris Dumez.

Source/JavaScriptCore:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.
  • inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:

(ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead
of Optional<>. Also use * instead of value() and nest the definition of the local inside an if
statement in the case where it's an optional.

  • inspector/scripts/tests/expected/*: Regenerated these results.

Source/WebCore:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebCore/PAL:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebDriver:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebKit:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.
  • Scripts/webkit/tests: Regenerated expected results, by running the command "python

Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?)

Source/WebKitLegacy/ios:

  • WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename

Optional<> to std::optional<>.

Source/WebKitLegacy/mac:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebKitLegacy/win:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WTF:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.
  • wtf/Optional.h: Remove WTF::Optional.

Tools:

  • <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.
  • Property svn:eol-style set to native
File size: 4.3 KB
Line 
1/*
2 * Copyright (C) 2011-2021 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "DFGDriver.h"
28
29#include "CodeBlock.h"
30#include "DFGJITCode.h"
31#include "DFGPlan.h"
32#include "DFGThunks.h"
33#include "FunctionAllowlist.h"
34#include "JITCode.h"
35#include "JITWorklist.h"
36#include "Options.h"
37#include "ThunkGenerators.h"
38#include "TypeProfilerLog.h"
39#include <wtf/NeverDestroyed.h>
40
41namespace JSC { namespace DFG {
42
43static unsigned numCompilations;
44
45unsigned getNumCompilations()
46{
47 return numCompilations;
48}
49
50#if ENABLE(DFG_JIT)
51static FunctionAllowlist& ensureGlobalDFGAllowlist()
52{
53 static LazyNeverDestroyed<FunctionAllowlist> dfgAllowlist;
54 static std::once_flag initializeAllowlistFlag;
55 std::call_once(initializeAllowlistFlag, [] {
56 const char* functionAllowlistFile = Options::dfgAllowlist();
57 dfgAllowlist.construct(functionAllowlistFile);
58 });
59 return dfgAllowlist;
60}
61
62static CompilationResult compileImpl(
63 VM& vm, CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, JITCompilationMode mode,
64 BytecodeIndex osrEntryBytecodeIndex, const Operands<std::optional<JSValue>>& mustHandleValues,
65 Ref<DeferredCompilationCallback>&& callback)
66{
67 if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionsSize())
68 || !ensureGlobalDFGAllowlist().contains(codeBlock))
69 return CompilationFailed;
70
71 numCompilations++;
72
73 ASSERT(codeBlock);
74 ASSERT(codeBlock->alternative());
75 ASSERT(JITCode::isBaselineCode(codeBlock->alternative()->jitType()));
76 ASSERT(!profiledDFGCodeBlock || profiledDFGCodeBlock->jitType() == JITType::DFGJIT);
77
78 if (logCompilationChanges(mode))
79 dataLog("DFG(Driver) compiling ", *codeBlock, " with ", mode, ", instructions size = ", codeBlock->instructionsSize(), "\n");
80
81 if (vm.typeProfiler())
82 vm.typeProfilerLog()->processLogEntries(vm, "Preparing for DFG compilation."_s);
83
84 Ref<Plan> plan = adoptRef(
85 *new Plan(codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues));
86
87 plan->setCallback(WTFMove(callback));
88 JITWorklist& worklist = JITWorklist::ensureGlobalWorklist();
89 dataLogLnIf(Options::useConcurrentJIT() && logCompilationChanges(mode), "Deferring DFG compilation of ", *codeBlock, " with queue length ", worklist.queueLength(), ".\n");
90 return worklist.enqueue(WTFMove(plan));
91}
92#else // ENABLE(DFG_JIT)
93static CompilationResult compileImpl(
94 VM&, CodeBlock*, CodeBlock*, JITCompilationMode, BytecodeIndex, const Operands<std::optional<JSValue>>&,
95 Ref<DeferredCompilationCallback>&&)
96{
97 return CompilationFailed;
98}
99#endif // ENABLE(DFG_JIT)
100
101CompilationResult compile(
102 VM& vm, CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, JITCompilationMode mode,
103 BytecodeIndex osrEntryBytecodeIndex, const Operands<std::optional<JSValue>>& mustHandleValues,
104 Ref<DeferredCompilationCallback>&& callback)
105{
106 CompilationResult result = compileImpl(
107 vm, codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues,
108 callback.copyRef());
109 return result;
110}
111
112} } // namespace JSC::DFG
Note: See TracBrowser for help on using the repository browser.