Source/JavaScriptCore/ChangeLog

 12020-06-11 Saam Barati <sbarati@apple.com>
 2
 3 Replace uses of black/white list with block/allow list
 4 https://bugs.webkit.org/show_bug.cgi?id=213084
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 We should be using racially neutral names in our code. From Chromium style guide:
 9
 10 "Terms such as 'blacklist' and 'whitelist' reinforce the notion that
 11 black==bad and white==good."
 12
 13 * JavaScriptCore.xcodeproj/project.pbxproj:
 14 * Sources.txt:
 15 * b3/air/AirLowerAfterRegAlloc.cpp:
 16 (JSC::B3::Air::lowerAfterRegAlloc):
 17 * dfg/DFGDriver.cpp:
 18 (JSC::DFG::ensureGlobalDFGAllowList):
 19 (JSC::DFG::compileImpl):
 20 (JSC::DFG::ensureGlobalDFGWhitelist): Deleted.
 21 * dfg/DFGTierUpCheckInjectionPhase.cpp:
 22 (JSC::DFG::ensureGlobalFTLAllowList):
 23 (JSC::DFG::TierUpCheckInjectionPhase::run):
 24 (JSC::DFG::ensureGlobalFTLWhitelist): Deleted.
 25 * heap/MachineStackMarker.cpp:
 26 * inspector/scripts/codegen/objc_generator.py:
 27 (ObjCGenerator.should_generate_types_for_domain):
 28 (ObjCGenerator.should_generate_commands_for_domain):
 29 (ObjCGenerator.should_generate_events_for_domain):
 30 * llint/LLIntSlowPaths.cpp:
 31 (JSC::LLInt::ensureGlobalJITAllowList):
 32 (JSC::LLInt::shouldJIT):
 33 (JSC::LLInt::ensureGlobalJITWhitelist): Deleted.
 34 * runtime/OptionsList.h:
 35 * tools/FunctionAllowList.cpp: Copied from Source/JavaScriptCore/tools/FunctionWhitelist.cpp.
 36 (JSC::FunctionAllowList::FunctionAllowList):
 37 (JSC::FunctionAllowList::contains const):
 38 (JSC::FunctionWhitelist::FunctionWhitelist): Deleted.
 39 (JSC::FunctionWhitelist::contains const): Deleted.
 40 * tools/FunctionAllowList.h: Copied from Source/JavaScriptCore/tools/FunctionWhitelist.h.
 41 * tools/FunctionWhitelist.cpp: Removed.
 42 * tools/FunctionWhitelist.h: Removed.
 43
1442020-06-11 Alexey Shvayka <shvaikalesh@gmail.com>
245
346 RegExp.prototype getters should throw on cross-realm access
262911

Source/JavaScriptCore/Sources.txt

@@JSCBuiltins.cpp
10091009
10101010tools/CellList.cpp
10111011tools/CompilerTimingScope.cpp
 1012tools/FunctionAllowList.cpp
10121013tools/FunctionOverrides.cpp
1013 tools/FunctionWhitelist.cpp
10141014tools/HeapVerifier.cpp
10151015tools/Integrity.cpp
10161016tools/JSDollarVM.cpp
262908

Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

901901 52678F8F1A031009006A306D /* BasicBlockLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 52678F8D1A031009006A306D /* BasicBlockLocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
902902 52678F911A04177C006A306D /* ControlFlowProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 52678F901A04177C006A306D /* ControlFlowProfiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
903903 526AC4B71E977C5D003500E1 /* WasmCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 526AC4B51E977C5D003500E1 /* WasmCodeBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
 904 52770A0A2492A7CA006D6B60 /* FunctionAllowList.h in Headers */ = {isa = PBXBuildFile; fileRef = 52770A092492A7BD006D6B60 /* FunctionAllowList.h */; };
904905 527CE35422555FE500C6F382 /* JSToWasmICCallee.h in Headers */ = {isa = PBXBuildFile; fileRef = 527CE35322555FDD00C6F382 /* JSToWasmICCallee.h */; };
905906 52847ADC21FFB8690061A9DB /* WasmAirIRGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 52847ADA21FFB8630061A9DB /* WasmAirIRGenerator.h */; };
906907 52B310FB1974AE610080857C /* FunctionHasExecutedCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B310FA1974AE610080857C /* FunctionHasExecutedCache.h */; settings = {ATTRIBUTES = (Private, ); }; };

19311932 FE99B2491C24C3D300C82159 /* JITNegGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE99B2481C24B6D300C82159 /* JITNegGenerator.h */; };
19321933 FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861E182B7A0400F6D851 /* Breakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
19331934 FEA08621182B7A0400F6D851 /* DebuggerPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */; settings = {ATTRIBUTES = (Private, ); }; };
1934  FEA0C4031CDD7D1D00481991 /* FunctionWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0C4011CDD7D0E00481991 /* FunctionWhitelist.h */; };
19351935 FEA3BBA8212B655900E93AD1 /* CallFrameInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA3BBA7212B655800E93AD1 /* CallFrameInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
19361936 FEA3BBAC212C97CB00E93AD1 /* DFGCFG.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA3BBAB212C97CB00E93AD1 /* DFGCFG.h */; };
19371937 FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEB51F6B1A97B688001F921C /* Regress141809.mm */; };

35733573 526AC4B41E977C5D003500E1 /* WasmCodeBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmCodeBlock.cpp; sourceTree = "<group>"; };
35743574 526AC4B51E977C5D003500E1 /* WasmCodeBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmCodeBlock.h; sourceTree = "<group>"; };
35753575 5272987B235FC8BA005C982C /* GCMemoryOperations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GCMemoryOperations.h; sourceTree = "<group>"; };
 3576 52770A082492A7BD006D6B60 /* FunctionAllowList.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionAllowList.cpp; sourceTree = "<group>"; };
 3577 52770A092492A7BD006D6B60 /* FunctionAllowList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FunctionAllowList.h; sourceTree = "<group>"; };
35763578 527773DD1AAF83AC00BDE7E8 /* RuntimeType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeType.cpp; sourceTree = "<group>"; };
35773579 527CE35222555FDD00C6F382 /* JSToWasmICCallee.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = JSToWasmICCallee.cpp; path = js/JSToWasmICCallee.cpp; sourceTree = "<group>"; };
35783580 527CE35322555FDD00C6F382 /* JSToWasmICCallee.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = JSToWasmICCallee.h; path = js/JSToWasmICCallee.h; sourceTree = "<group>"; };

52255227 FE99B2481C24B6D300C82159 /* JITNegGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITNegGenerator.h; sourceTree = "<group>"; };
52265228 FEA0861E182B7A0400F6D851 /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakpoint.h; sourceTree = "<group>"; };
52275229 FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerPrimitives.h; sourceTree = "<group>"; };
5228  FEA0C4001CDD7D0E00481991 /* FunctionWhitelist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionWhitelist.cpp; sourceTree = "<group>"; };
5229  FEA0C4011CDD7D0E00481991 /* FunctionWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionWhitelist.h; sourceTree = "<group>"; };
52305230 FEA3BBA7212B655800E93AD1 /* CallFrameInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallFrameInlines.h; sourceTree = "<group>"; };
52315231 FEA3BBAB212C97CB00E93AD1 /* DFGCFG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGCFG.h; path = dfg/DFGCFG.h; sourceTree = "<group>"; };
52325232 FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerARM64.cpp; sourceTree = "<group>"; };

77417741 0F4F11E6209BCDA100709654 /* CompilerTimingScope.h */,
77427742 FE4BFF291AD476E700088F87 /* FunctionOverrides.cpp */,
77437743 FE4BFF2A1AD476E700088F87 /* FunctionOverrides.h */,
7744  FEA0C4001CDD7D0E00481991 /* FunctionWhitelist.cpp */,
7745  FEA0C4011CDD7D0E00481991 /* FunctionWhitelist.h */,
77467744 FE1BD0221E72052F00134BC9 /* HeapVerifier.cpp */,
77477745 FE1BD0231E72052F00134BC9 /* HeapVerifier.h */,
 7746 52770A082492A7BD006D6B60 /* FunctionAllowList.cpp */,
 7747 52770A092492A7BD006D6B60 /* FunctionAllowList.h */,
77487748 FEC5797423105F4200BCA83F /* Integrity.cpp */,
77497749 FEC5797523105F4300BCA83F /* Integrity.h */,
77507750 FEC579772310954B00BCA83F /* IntegrityInlines.h */,

92079207 FE1BD01E1E72002A00134BC9 /* CellList.h in Headers */,
92089208 FE1BD0211E72027900134BC9 /* CellProfile.h in Headers */,
92099209 FEC160322339E9F900A04CB8 /* CellSize.h in Headers */,
 9210 52770A0A2492A7CA006D6B60 /* FunctionAllowList.h in Headers */,
92109211 0F1C3DDA1BBCE09E00E523E4 /* CellState.h in Headers */,
92119212 5338E2A72396EFFB00C61BAD /* CheckpointOSRExitSideState.h in Headers */,
92129213 BC6AAAE50E1F426500AD87D8 /* ClassInfo.h in Headers */,

95859586 FE4BFF2C1AD476E700088F87 /* FunctionOverrides.h in Headers */,
95869587 BC18C4050E16F5CD00B34460 /* FunctionPrototype.h in Headers */,
95879588 62D2D3901ADF103F000206C1 /* FunctionRareData.h in Headers */,
9588  FEA0C4031CDD7D1D00481991 /* FunctionWhitelist.h in Headers */,
95899589 E33A94972255323300D42B06 /* FuzzerAgent.h in Headers */,
95909590 CECFAD362372DAD000291599 /* FuzzerPredictions.h in Headers */,
95919591 2AACE63D18CA5A0300ED0191 /* GCActivityCallback.h in Headers */,
262908

Source/JavaScriptCore/b3/air/AirLowerAfterRegAlloc.cpp

@@void lowerAfterRegAlloc(Code& code)
111111 // If we run after stack allocation then we cannot use those callee saves that aren't in
112112 // the callee save list. Note that we are only run after stack allocation in -O1, so this
113113 // kind of slop is OK.
114  RegisterSet blacklistedCalleeSaves;
 114 RegisterSet disallowedCalleeSaves;
115115 if (code.stackIsAllocated()) {
116  blacklistedCalleeSaves = RegisterSet::calleeSaveRegisters();
117  blacklistedCalleeSaves.exclude(code.calleeSaveRegisters());
 116 disallowedCalleeSaves = RegisterSet::calleeSaveRegisters();
 117 disallowedCalleeSaves.exclude(code.calleeSaveRegisters());
118118 }
119119
120120 auto getScratches = [&] (RegisterSet set, Bank bank) -> std::array<Arg, 2> {

@@void lowerAfterRegAlloc(Code& code)
122122 for (unsigned i = 0; i < 2; ++i) {
123123 bool found = false;
124124 for (Reg reg : code.regsInPriorityOrder(bank)) {
125  if (!set.get(reg) && !blacklistedCalleeSaves.get(reg)) {
 125 if (!set.get(reg) && !disallowedCalleeSaves.get(reg)) {
126126 result[i] = Tmp(reg);
127127 set.set(reg);
128128 found = true;
262908

Source/JavaScriptCore/dfg/DFGDriver.cpp

3131#include "DFGPlan.h"
3232#include "DFGThunks.h"
3333#include "DFGWorklist.h"
34 #include "FunctionWhitelist.h"
 34#include "FunctionAllowList.h"
3535#include "JITCode.h"
3636#include "Options.h"
3737#include "ThunkGenerators.h"

@@unsigned getNumCompilations()
4848}
4949
5050#if ENABLE(DFG_JIT)
51 static FunctionWhitelist& ensureGlobalDFGWhitelist()
 51static FunctionAllowList& ensureGlobalDFGAllowList()
5252{
53  static LazyNeverDestroyed<FunctionWhitelist> dfgWhitelist;
54  static std::once_flag initializeWhitelistFlag;
55  std::call_once(initializeWhitelistFlag, [] {
56  const char* functionWhitelistFile = Options::dfgWhitelist();
57  dfgWhitelist.construct(functionWhitelistFile);
 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);
5858 });
59  return dfgWhitelist;
 59 return dfgAllowList;
6060}
6161
6262static CompilationResult compileImpl(

@@static CompilationResult compileImpl(
6565 Ref<DeferredCompilationCallback>&& callback)
6666{
6767 if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionsSize())
68  || !ensureGlobalDFGWhitelist().contains(codeBlock))
 68 || !ensureGlobalDFGAllowList().contains(codeBlock))
6969 return CompilationFailed;
7070
7171 numCompilations++;
262908

Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp

3333#include "DFGNaturalLoops.h"
3434#include "DFGPhase.h"
3535#include "FTLCapabilities.h"
36 #include "FunctionWhitelist.h"
 36#include "FunctionAllowList.h"
3737#include "JSCJSValueInlines.h"
3838#include <wtf/NeverDestroyed.h>
3939
4040namespace JSC { namespace DFG {
4141
42 static FunctionWhitelist& ensureGlobalFTLWhitelist()
 42static FunctionAllowList& ensureGlobalFTLAllowList()
4343{
44  static LazyNeverDestroyed<FunctionWhitelist> ftlWhitelist;
45  static std::once_flag initializeWhitelistFlag;
46  std::call_once(initializeWhitelistFlag, [] {
47  const char* functionWhitelistFile = Options::ftlWhitelist();
48  ftlWhitelist.construct(functionWhitelistFile);
 44 static LazyNeverDestroyed<FunctionAllowList> ftlAllowList;
 45 static std::once_flag initializeAllowListFlag;
 46 std::call_once(initializeAllowListFlag, [] {
 47 const char* functionAllowListFile = Options::ftlAllowList();
 48 ftlAllowList.construct(functionAllowListFile);
4949 });
50  return ftlWhitelist;
 50 return ftlAllowList;
5151}
5252
5353using NaturalLoop = CPSNaturalLoop;

@@public:
7272 if (!Options::bytecodeRangeToFTLCompile().isInRange(m_graph.m_profiledBlock->instructionsSize()))
7373 return false;
7474
75  if (!ensureGlobalFTLWhitelist().contains(m_graph.m_profiledBlock))
 75 if (!ensureGlobalFTLAllowList().contains(m_graph.m_profiledBlock))
7676 return false;
7777
7878#if ENABLE(FTL_JIT)
262908

Source/JavaScriptCore/heap/MachineStackMarker.cpp

@@static void copyMemory(void* dst, const
100100// acquire a lock. Since 'thread' is suspended, trying to acquire a lock
101101// will deadlock if 'thread' holds that lock.
102102// This function, specifically the memory copying, was causing problems with Address Sanitizer in
103 // apps. Since we cannot blacklist the system memcpy we must use our own naive implementation,
 103// apps. Since we cannot disallow the system memcpy we must use our own naive implementation,
104104// copyMemory, for ASan to work on either instrumented or non-instrumented builds. This is not a
105105// significant performance loss as tryCopyOtherThreadStack is only called as part of an O(heapsize)
106106// operation. As the heap is generally much larger than the stack the performance hit is minimal.
262908

Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py

@@class ObjCGenerator(Generator):
131131 if self.model().framework is Frameworks.Test:
132132 return True
133133
134  whitelist = set(ObjCGenerator.DOMAINS_TO_GENERATE)
135  whitelist.update(set(['Console', 'Debugger', 'Runtime']))
136  return domain.domain_name in whitelist
 134 allowlist = set(ObjCGenerator.DOMAINS_TO_GENERATE)
 135 allowlist.update(set(['Console', 'Debugger', 'Runtime']))
 136 return domain.domain_name in allowlist
137137
138138 def should_generate_commands_for_domain(self, domain):
139139 if not len(self.commands_for_domain(domain)):

@@class ObjCGenerator(Generator):
142142 if self.model().framework is Frameworks.Test:
143143 return True
144144
145  whitelist = set(ObjCGenerator.DOMAINS_TO_GENERATE)
146  return domain.domain_name in whitelist
 145 allowlist = set(ObjCGenerator.DOMAINS_TO_GENERATE)
 146 return domain.domain_name in allowlist
147147
148148 def should_generate_events_for_domain(self, domain):
149149 if not len(self.events_for_domain(domain)):

@@class ObjCGenerator(Generator):
152152 if self.model().framework is Frameworks.Test:
153153 return True
154154
155  whitelist = set(ObjCGenerator.DOMAINS_TO_GENERATE)
156  whitelist.add('Console')
157  return domain.domain_name in whitelist
 155 allowlist = set(ObjCGenerator.DOMAINS_TO_GENERATE)
 156 allowlist.add('Console')
 157 return domain.domain_name in allowlist
158158
159159 # ObjC enum and type names.
160160
262908

Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

3838#include "ExceptionFuzz.h"
3939#include "FrameTracers.h"
4040#include "FunctionCodeBlock.h"
41 #include "FunctionWhitelist.h"
 41#include "FunctionAllowList.h"
4242#include "GetterSetter.h"
4343#include "HostCallReturnValue.h"
4444#include "JITExceptions.h"

@@LLINT_SLOW_PATH_DECL(trace)
340340enum EntryKind { Prologue, ArityCheck };
341341
342342#if ENABLE(JIT)
343 static FunctionWhitelist& ensureGlobalJITWhitelist()
 343static FunctionAllowList& ensureGlobalJITAllowList()
344344{
345  static LazyNeverDestroyed<FunctionWhitelist> baselineWhitelist;
346  static std::once_flag initializeWhitelistFlag;
347  std::call_once(initializeWhitelistFlag, [] {
348  const char* functionWhitelistFile = Options::jitWhitelist();
349  baselineWhitelist.construct(functionWhitelistFile);
 345 static LazyNeverDestroyed<FunctionAllowList> baselineAllowList;
 346 static std::once_flag initializeAllowListFlag;
 347 std::call_once(initializeAllowListFlag, [] {
 348 const char* functionAllowListFile = Options::jitAllowList();
 349 baselineAllowList.construct(functionAllowListFile);
350350 });
351  return baselineWhitelist;
 351 return baselineAllowList;
352352}
353353
354354inline bool shouldJIT(CodeBlock* codeBlock)
355355{
356356 if (!Options::bytecodeRangeToJITCompile().isInRange(codeBlock->instructionsSize())
357  || !ensureGlobalJITWhitelist().contains(codeBlock))
 357 || !ensureGlobalJITAllowList().contains(codeBlock))
358358 return false;
359359
360360 return VM::canUseJIT() && Options::useBaselineJIT();
262908

Source/JavaScriptCore/runtime/OptionsList.h

@@constexpr bool enableWebAssemblyStreamin
135135 v(OptionRange, bytecodeRangeToJITCompile, 0, Normal, "bytecode size range to allow compilation on, e.g. 1:100") \
136136 v(OptionRange, bytecodeRangeToDFGCompile, 0, Normal, "bytecode size range to allow DFG compilation on, e.g. 1:100") \
137137 v(OptionRange, bytecodeRangeToFTLCompile, 0, Normal, "bytecode size range to allow FTL compilation on, e.g. 1:100") \
138  v(OptionString, jitWhitelist, nullptr, Normal, "file with list of function signatures to allow compilation on") \
139  v(OptionString, dfgWhitelist, nullptr, Normal, "file with list of function signatures to allow DFG compilation on") \
140  v(OptionString, ftlWhitelist, nullptr, Normal, "file with list of function signatures to allow FTL compilation on") \
 138 v(OptionString, jitAllowList, nullptr, Normal, "file with newline separated list of function signatures to allow compilation on") \
 139 v(OptionString, dfgAllowList, nullptr, Normal, "file with newline separated list of function signatures to allow DFG compilation on") \
 140 v(OptionString, ftlAllowList, nullptr, Normal, "file with newline separated list of function signatures to allow FTL compilation on") \
141141 v(Bool, dumpSourceAtDFGTime, false, Normal, "dumps source code of JS function being DFG compiled") \
142142 v(Bool, dumpBytecodeAtDFGTime, false, Normal, "dumps bytecode of JS function being DFG compiled") \
143143 v(Bool, dumpGraphAfterParsing, false, Normal, nullptr) \

@@constexpr bool enableWebAssemblyStreamin
367367 v(Bool, collectSamplingProfilerDataForJSCShell, false, Normal, "This corresponds to the JSC shell's --sample option.") \
368368 v(Unsigned, samplingProfilerTopFunctionsCount, 12, Normal, "Number of top functions to report when using the command line interface.") \
369369 v(Unsigned, samplingProfilerTopBytecodesCount, 40, Normal, "Number of top bytecodes to report when using the command line interface.") \
370  v(OptionString, samplingProfilerPath, nullptr, Normal, "The path to the directory to write sampiling profiler output to. This probably will not work with WK2 unless the path is in the whitelist.") \
 370 v(OptionString, samplingProfilerPath, nullptr, Normal, "The path to the directory to write sampiling profiler output to. This probably will not work with WK2 unless the path is in the sandbox.") \
371371 v(Bool, sampleCCode, false, Normal, "Causes the sampling profiler to record profiling data for C frames.") \
372372 \
373373 v(Bool, alwaysGeneratePCToCodeOriginMap, false, Normal, "This will make sure we always generate a PCToCodeOriginMap for JITed code.") \
262908

Source/JavaScriptCore/tools/FunctionAllowList.cpp

 1/*
 2 * Copyright (C) 2014, 2016 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. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "FunctionWhitelist.h"
 28
 29#if ENABLE(JIT)
 30
 31#include "CodeBlock.h"
 32#include <stdio.h>
 33#include <string.h>
 34
 35namespace JSC {
 36
 37FunctionWhitelist::FunctionWhitelist(const char* filename)
 38{
 39 if (!filename)
 40 return;
 41
 42 FILE* f = fopen(filename, "r");
 43 if (!f) {
 44 dataLogF("Failed to open file %s. Did you add the file-read-data entitlement to WebProcess.sb?\n", filename);
 45 return;
 46 }
 47
 48 m_hasActiveWhitelist = true;
 49
 50 char* line;
 51 char buffer[BUFSIZ];
 52 while ((line = fgets(buffer, sizeof(buffer), f))) {
 53 if (strstr(line, "//") == line)
 54 continue;
 55
 56 // Get rid of newlines at the ends of the strings.
 57 size_t length = strlen(line);
 58 if (line[length - 1] == '\n') {
 59 line[length - 1] = '\0';
 60 length--;
 61 }
 62
 63 // Skip empty lines.
 64 if (!length)
 65 continue;
 66
 67 m_entries.add(String(line, length));
 68 }
 69
 70 int result = fclose(f);
 71 if (result)
 72 dataLogF("Failed to close file %s: %s\n", filename, strerror(errno));
 73}
 74
 75bool FunctionWhitelist::contains(CodeBlock* codeBlock) const
 76{
 77 if (!m_hasActiveWhitelist)
 78 return true;
 79
 80 if (m_entries.isEmpty())
 81 return false;
 82
 83 String name = String::fromUTF8(codeBlock->inferredName());
 84 if (m_entries.contains(name))
 85 return true;
 86
 87 String hash = String::fromUTF8(codeBlock->hashAsStringIfPossible());
 88 if (m_entries.contains(hash))
 89 return true;
 90
 91 return m_entries.contains(name + '#' + hash);
 92}
 93
 94} // namespace JSC
 95
 96#endif // ENABLE(JIT)
 97
262908

Source/JavaScriptCore/tools/FunctionAllowList.cpp

11/*
2  * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
 2 * Copyright (C) 2014, 2016, 2020 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

2424 */
2525
2626#include "config.h"
27 #include "FunctionWhitelist.h"
 27#include "FunctionAllowList.h"
2828
2929#if ENABLE(JIT)
3030

3434
3535namespace JSC {
3636
37 FunctionWhitelist::FunctionWhitelist(const char* filename)
 37FunctionAllowList::FunctionAllowList(const char* filename)
3838{
3939 if (!filename)
4040 return;

@@FunctionWhitelist::FunctionWhitelist(con
4545 return;
4646 }
4747
48  m_hasActiveWhitelist = true;
 48 m_hasActiveAllowList = true;
4949
5050 char* line;
5151 char buffer[BUFSIZ];

@@FunctionWhitelist::FunctionWhitelist(con
7272 dataLogF("Failed to close file %s: %s\n", filename, strerror(errno));
7373}
7474
75 bool FunctionWhitelist::contains(CodeBlock* codeBlock) const
 75bool FunctionAllowList::contains(CodeBlock* codeBlock) const
7676{
77  if (!m_hasActiveWhitelist)
 77 if (!m_hasActiveAllowList)
7878 return true;
7979
8080 if (m_entries.isEmpty())
262908

Source/JavaScriptCore/tools/FunctionAllowList.h

 1/*
 2 * Copyright (C) 2014, 2016 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. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include <wtf/HashSet.h>
 29#include <wtf/text/WTFString.h>
 30
 31namespace JSC {
 32
 33class CodeBlock;
 34
 35class FunctionWhitelist {
 36public:
 37 explicit FunctionWhitelist(const char*);
 38
 39 bool contains(CodeBlock*) const;
 40
 41private:
 42 HashSet<String> m_entries;
 43 bool m_hasActiveWhitelist { false };
 44};
 45
 46} // namespace JSC
262908

Source/JavaScriptCore/tools/FunctionAllowList.h

11/*
2  * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
 2 * Copyright (C) 2014, 2016, 2020 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@namespace JSC {
3232
3333class CodeBlock;
3434
35 class FunctionWhitelist {
 35class FunctionAllowList {
3636public:
37  explicit FunctionWhitelist(const char*);
 37 explicit FunctionAllowList(const char*);
3838
3939 bool contains(CodeBlock*) const;
4040
4141private:
4242 HashSet<String> m_entries;
43  bool m_hasActiveWhitelist { false };
 43 bool m_hasActiveAllowList { false };
4444};
4545
4646} // namespace JSC
262908

Source/JavaScriptCore/tools/FunctionWhitelist.cpp

1 /*
2  * Copyright (C) 2014, 2016 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. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "FunctionWhitelist.h"
28 
29 #if ENABLE(JIT)
30 
31 #include "CodeBlock.h"
32 #include <stdio.h>
33 #include <string.h>
34 
35 namespace JSC {
36 
37 FunctionWhitelist::FunctionWhitelist(const char* filename)
38 {
39  if (!filename)
40  return;
41 
42  FILE* f = fopen(filename, "r");
43  if (!f) {
44  dataLogF("Failed to open file %s. Did you add the file-read-data entitlement to WebProcess.sb?\n", filename);
45  return;
46  }
47 
48  m_hasActiveWhitelist = true;
49 
50  char* line;
51  char buffer[BUFSIZ];
52  while ((line = fgets(buffer, sizeof(buffer), f))) {
53  if (strstr(line, "//") == line)
54  continue;
55 
56  // Get rid of newlines at the ends of the strings.
57  size_t length = strlen(line);
58  if (line[length - 1] == '\n') {
59  line[length - 1] = '\0';
60  length--;
61  }
62 
63  // Skip empty lines.
64  if (!length)
65  continue;
66 
67  m_entries.add(String(line, length));
68  }
69 
70  int result = fclose(f);
71  if (result)
72  dataLogF("Failed to close file %s: %s\n", filename, strerror(errno));
73 }
74 
75 bool FunctionWhitelist::contains(CodeBlock* codeBlock) const
76 {
77  if (!m_hasActiveWhitelist)
78  return true;
79 
80  if (m_entries.isEmpty())
81  return false;
82 
83  String name = String::fromUTF8(codeBlock->inferredName());
84  if (m_entries.contains(name))
85  return true;
86 
87  String hash = String::fromUTF8(codeBlock->hashAsStringIfPossible());
88  if (m_entries.contains(hash))
89  return true;
90 
91  return m_entries.contains(name + '#' + hash);
92 }
93 
94 } // namespace JSC
95 
96 #endif // ENABLE(JIT)
97 
262908

Source/JavaScriptCore/tools/FunctionWhitelist.h

1 /*
2  * Copyright (C) 2014, 2016 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. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #pragma once
27 
28 #include <wtf/HashSet.h>
29 #include <wtf/text/WTFString.h>
30 
31 namespace JSC {
32 
33 class CodeBlock;
34 
35 class FunctionWhitelist {
36 public:
37  explicit FunctionWhitelist(const char*);
38 
39  bool contains(CodeBlock*) const;
40 
41 private:
42  HashSet<String> m_entries;
43  bool m_hasActiveWhitelist { false };
44 };
45 
46 } // namespace JSC
262908