Changeset 264688 in webkit
- Timestamp:
- Jul 21, 2020, 6:40:59 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 1 deleted
- 20 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/JavaScriptCore/CMakeLists.txt ¶
r264639 r264688 839 839 runtime/DirectEvalExecutable.h 840 840 runtime/DisallowScope.h 841 runtime/DisallowVM Reentry.h841 runtime/DisallowVMEntry.h 842 842 runtime/DumpContext.h 843 843 runtime/ECMAMode.h -
TabularUnified trunk/Source/JavaScriptCore/ChangeLog ¶
r264679 r264688 1 2020-07-21 Mark Lam <mark.lam@apple.com> 2 3 Simplify DisallowScope, DisallowGC, and DisallowVMReentry implementations. 4 https://bugs.webkit.org/show_bug.cgi?id=214539 5 <rdar://problem/65795729> 6 7 Reviewed by Keith Miller. 8 9 Previously, DisallowScope needed to support enabling and disabling. This was 10 only needed to enable the implementation of ObjectInitializationScope. Now, we 11 can make the DisallowGC and DisallowVMReentry inside ObjectInitializationScope 12 optional with WTF::Optional. With that we can simplify these scopes and make 13 them true RAII scope objects. 14 15 This patch also does the following: 16 17 1. Renamed DisallowVMReentry to DisallowVMEntry. 18 The scope can be used to disable VM entry completely. There's no need to 19 restrict it to only re-entries. 20 21 2. Enforcement of DisallowVMReentry is now done in the LLInt's doVMEntry() instead 22 of the VMEntryScope's constructor. This is a stronger guarantee. 23 24 If Options::crashOnDisallowedVMEntry() is true, the VM will crash if it sees 25 an attempt to enter the VM while disallowed. 26 27 If Options::crashOnDisallowedVMEntry() is false, an attempt to call into the VM 28 while disallowed will return immediately with an undefined result without 29 invoking any script. 30 31 By default, Options::crashOnDisallowedVMEntry() is true if ASSERT_ENABLED is 32 true. 33 34 3. Change DisallowScope and DisallowGC to be based on ASSERT_ENABLED instead of NEBUG. 35 36 4. Make DisallowVMEntry always enforceable, not just when ASSERT_ENABLED. 37 It's enforcement action depends on Options::crashOnDisallowedVMEntry() as 38 described above. 39 40 * CMakeLists.txt: 41 * JavaScriptCore.xcodeproj/project.pbxproj: 42 * Sources.txt: 43 * heap/DeferGC.cpp: 44 * heap/DeferGC.h: 45 (JSC::DisallowGC::DisallowGC): 46 (JSC::DisallowGC::initialize): 47 * interpreter/Interpreter.cpp: 48 (JSC::Interpreter::executeProgram): 49 (JSC::Interpreter::executeCall): 50 (JSC::Interpreter::executeConstruct): 51 (JSC::Interpreter::execute): 52 (JSC::Interpreter::executeModuleProgram): 53 * llint/LLIntSlowPaths.cpp: 54 (JSC::LLInt::llint_check_vm_entry_permission): 55 * llint/LLIntSlowPaths.h: 56 * llint/LowLevelInterpreter32_64.asm: 57 * llint/LowLevelInterpreter64.asm: 58 * runtime/DisallowScope.h: 59 (JSC::DisallowScope::DisallowScope): 60 (JSC::DisallowScope::~DisallowScope): 61 (JSC::DisallowScope::isInEffectOnCurrentThread): 62 (JSC::DisallowScope::enable): Deleted. 63 (JSC::DisallowScope::disable): Deleted. 64 (JSC::DisallowScope::enterScope): Deleted. 65 (JSC::DisallowScope::exitScope): Deleted. 66 * runtime/DisallowVMEntry.h: Copied from Source/JavaScriptCore/runtime/DisallowVMReentry.h. 67 (JSC::DisallowVMEntryImpl::DisallowVMEntryImpl): 68 (JSC::DisallowVMEntryImpl::~DisallowVMEntryImpl): 69 (JSC::DisallowVMEntryImpl::isEngaged const): 70 (JSC::DisallowVMEntryImpl::release): 71 (JSC::DisallowVMReentry::DisallowVMReentry): Deleted. 72 (JSC::DisallowVMReentry::initialize): Deleted. 73 (JSC::DisallowVMReentry::scopeReentryCount): Deleted. 74 (JSC::DisallowVMReentry::setScopeReentryCount): Deleted. 75 * runtime/DisallowVMReentry.cpp: Removed. 76 * runtime/DisallowVMReentry.h: Removed. 77 * runtime/InitializeThreading.cpp: 78 (JSC::initialize): 79 * runtime/JSArray.cpp: 80 (JSC::JSArray::tryCreateUninitializedRestricted): 81 * runtime/ObjectInitializationScope.cpp: 82 (JSC::ObjectInitializationScope::ObjectInitializationScope): 83 (JSC::ObjectInitializationScope::notifyAllocated): 84 (JSC::ObjectInitializationScope::notifyInitialized): 85 * runtime/ObjectInitializationScope.h: 86 (JSC::ObjectInitializationScope::vm const): 87 (JSC::ObjectInitializationScope::ObjectInitializationScope): 88 (JSC::ObjectInitializationScope::~ObjectInitializationScope): 89 (JSC::ObjectInitializationScope::notifyAllocated): 90 (JSC::ObjectInitializationScope::notifyInitialized): 91 * runtime/OptionsList.h: 92 * runtime/RegExpMatchesArray.h: 93 (JSC::tryCreateUninitializedRegExpMatchesArray): 94 * runtime/VM.h: 95 * runtime/VMEntryScope.cpp: 96 (JSC::VMEntryScope::VMEntryScope): 97 1 98 2020-07-21 Mark Lam <mark.lam@apple.com> 2 99 -
TabularUnified trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj ¶
r264639 r264688 1926 1926 FE533CA61F217DB30016A1FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; }; 1927 1927 FE533CAD1F217EA50016A1FE /* testmasm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE533CA01F217C310016A1FE /* testmasm.cpp */; }; 1928 FE54DEFB1E8C6D8800A892C5 /* DisallowVM Reentry.h in Headers */ = {isa = PBXBuildFile; fileRef = FE54DEFA1E8C6D7200A892C5 /* DisallowVMReentry.h */; settings = {ATTRIBUTES = (Private, ); }; };1928 FE54DEFB1E8C6D8800A892C5 /* DisallowVMEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = FE54DEFA1E8C6D7200A892C5 /* DisallowVMEntry.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1929 1929 FE54DEFF1E8D76FA00A892C5 /* DisallowScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE54DEFE1E8D742800A892C5 /* DisallowScope.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1930 1930 FE5628CE1E99513200C49E45 /* AirPrintSpecial.h in Headers */ = {isa = PBXBuildFile; fileRef = FE5628CC1E99512400C49E45 /* AirPrintSpecial.h */; }; … … 5226 5226 FE533CA01F217C310016A1FE /* testmasm.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = testmasm.cpp; sourceTree = "<group>"; }; 5227 5227 FE533CAC1F217DB40016A1FE /* testmasm */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testmasm; sourceTree = BUILT_PRODUCTS_DIR; }; 5228 FE54DEFA1E8C6D7200A892C5 /* DisallowVMReentry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisallowVMReentry.h; sourceTree = "<group>"; }; 5229 FE54DEFC1E8C6DFF00A892C5 /* DisallowVMReentry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisallowVMReentry.cpp; sourceTree = "<group>"; }; 5228 FE54DEFA1E8C6D7200A892C5 /* DisallowVMEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisallowVMEntry.h; sourceTree = "<group>"; }; 5230 5229 FE54DEFE1E8D742800A892C5 /* DisallowScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisallowScope.h; sourceTree = "<group>"; }; 5231 5230 FE5628CB1E99512400C49E45 /* AirPrintSpecial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirPrintSpecial.cpp; path = b3/air/AirPrintSpecial.cpp; sourceTree = "<group>"; }; … … 7173 7172 14386A731DD69895008652C4 /* DirectEvalExecutable.h */, 7174 7173 FE54DEFE1E8D742800A892C5 /* DisallowScope.h */, 7175 FE54DEFC1E8C6DFF00A892C5 /* DisallowVMReentry.cpp */, 7176 FE54DEFA1E8C6D7200A892C5 /* DisallowVMReentry.h */, 7174 FE54DEFA1E8C6D7200A892C5 /* DisallowVMEntry.h */, 7177 7175 E31618101EC5FE080006A218 /* DOMAnnotation.h */, 7178 7176 E31618111EC5FE080006A218 /* DOMAttributeGetterSetter.cpp */, … … 9529 9527 0F37308F1C0CD68500052BFA /* DisallowMacroScratchRegisterUsage.h in Headers */, 9530 9528 FE54DEFF1E8D76FA00A892C5 /* DisallowScope.h in Headers */, 9531 FE54DEFB1E8C6D8800A892C5 /* DisallowVM Reentry.h in Headers */,9529 FE54DEFB1E8C6D8800A892C5 /* DisallowVMEntry.h in Headers */, 9532 9530 0FF42731158EBD54004CB9FF /* Disassembler.h in Headers */, 9533 9531 E31618131EC5FE170006A218 /* DOMAnnotation.h in Headers */, -
TabularUnified trunk/Source/JavaScriptCore/Sources.txt ¶
r264639 r264688 767 767 runtime/DirectArgumentsOffset.cpp 768 768 runtime/DirectEvalExecutable.cpp 769 runtime/DisallowVMReentry.cpp770 769 runtime/DoublePredictionFuzzerAgent.cpp 771 770 runtime/DumpContext.cpp -
TabularUnified trunk/Source/JavaScriptCore/heap/DeferGC.cpp ¶
r261755 r264688 1 1 /* 2 * Copyright (C) 2013-20 17Apple Inc. All rights reserved.2 * Copyright (C) 2013-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 namespace JSC { 30 30 31 #if ndef NDEBUG31 #if ASSERT_ENABLED 32 32 LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> DisallowGC::s_scopeReentryCount; 33 33 #endif -
TabularUnified trunk/Source/JavaScriptCore/heap/DeferGC.h ¶
r262570 r264688 78 78 typedef DisallowScope<DisallowGC> Base; 79 79 public: 80 #ifdef NDEBUG 81 82 ALWAYS_INLINE DisallowGC(bool = false) { } 83 ALWAYS_INLINE static void initialize() { } 84 85 #else // not NDEBUG 86 87 DisallowGC(bool enabled = true) 88 : Base(enabled) 89 { } 80 #if ASSERT_ENABLED 81 DisallowGC() = default; 90 82 91 83 static void initialize() … … 106 98 JS_EXPORT_PRIVATE static LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> s_scopeReentryCount; 107 99 108 #endif // NDEBUG 100 #else 101 ALWAYS_INLINE DisallowGC() { } // We need this to placate Clang due to unused warnings. 102 ALWAYS_INLINE static void initialize() { } 103 #endif // ASSERT_ENABLED 109 104 110 105 friend class DisallowScope<DisallowGC>; -
TabularUnified trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp ¶
r261895 r264688 1 1 /* 2 * Copyright (C) 2008-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2008-2020 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> 4 4 * … … 826 826 } 827 827 828 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable. 829 830 RefPtr<JITCode> jitCode = program->generatedJITCode(); 831 828 RefPtr<JITCode> jitCode; 832 829 ProtoCallFrame protoCallFrame; 833 protoCallFrame.init(codeBlock, globalObject, globalCallee, thisObj, 1); 830 { 831 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable. 832 jitCode = program->generatedJITCode(); 833 protoCallFrame.init(codeBlock, globalObject, globalCallee, thisObj, 1); 834 } 834 835 835 836 // Execute the code: 836 disallowGC.disable();837 837 throwScope.release(); 838 838 ASSERT(jitCode == program->generatedJITCode().ptr()); … … 891 891 } 892 892 893 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable.894 895 893 RefPtr<JITCode> jitCode; 896 if (isJSCall)897 jitCode = callData.js.functionExecutable->generatedJITCodeForCall();898 899 894 ProtoCallFrame protoCallFrame; 900 protoCallFrame.init(newCodeBlock, globalObject, function, thisValue, argsCount, args.data()); 895 { 896 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable. 897 if (isJSCall) 898 jitCode = callData.js.functionExecutable->generatedJITCodeForCall(); 899 protoCallFrame.init(newCodeBlock, globalObject, function, thisValue, argsCount, args.data()); 900 } 901 901 902 902 JSValue result; 903 { 904 // Execute the code: 905 disallowGC.disable(); 906 if (isJSCall) { 907 throwScope.release(); 908 ASSERT(jitCode == callData.js.functionExecutable->generatedJITCodeForCall().ptr()); 909 result = jitCode->execute(&vm, &protoCallFrame); 910 } else { 911 result = JSValue::decode(vmEntryToNative(callData.native.function.rawPointer(), &vm, &protoCallFrame)); 912 RETURN_IF_EXCEPTION(throwScope, JSValue()); 913 } 903 // Execute the code: 904 if (isJSCall) { 905 throwScope.release(); 906 ASSERT(jitCode == callData.js.functionExecutable->generatedJITCodeForCall().ptr()); 907 result = jitCode->execute(&vm, &protoCallFrame); 908 } else { 909 result = JSValue::decode(vmEntryToNative(callData.native.function.rawPointer(), &vm, &protoCallFrame)); 910 RETURN_IF_EXCEPTION(throwScope, JSValue()); 914 911 } 915 912 … … 973 970 } 974 971 975 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable.976 977 972 RefPtr<JITCode> jitCode; 978 if (isJSConstruct)979 jitCode = constructData.js.functionExecutable->generatedJITCodeForConstruct();980 981 973 ProtoCallFrame protoCallFrame; 982 protoCallFrame.init(newCodeBlock, globalObject, constructor, newTarget, argsCount, args.data()); 974 { 975 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable. 976 if (isJSConstruct) 977 jitCode = constructData.js.functionExecutable->generatedJITCodeForConstruct(); 978 protoCallFrame.init(newCodeBlock, globalObject, constructor, newTarget, argsCount, args.data()); 979 } 983 980 984 981 JSValue result; 985 { 986 // Execute the code. 987 disallowGC.disable(); 988 if (isJSConstruct) { 989 ASSERT(jitCode == constructData.js.functionExecutable->generatedJITCodeForConstruct().ptr()); 990 result = jitCode->execute(&vm, &protoCallFrame); 991 } else { 992 result = JSValue::decode(vmEntryToNative(constructData.native.function.rawPointer(), &vm, &protoCallFrame)); 993 994 if (LIKELY(!throwScope.exception())) 995 RELEASE_ASSERT(result.isObject()); 996 } 982 // Execute the code. 983 if (isJSConstruct) { 984 ASSERT(jitCode == constructData.js.functionExecutable->generatedJITCodeForConstruct().ptr()); 985 result = jitCode->execute(&vm, &protoCallFrame); 986 } else { 987 result = JSValue::decode(vmEntryToNative(constructData.native.function.rawPointer(), &vm, &protoCallFrame)); 988 989 if (LIKELY(!throwScope.exception())) 990 RELEASE_ASSERT(result.isObject()); 997 991 } 998 992 … … 1194 1188 } 1195 1189 1196 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable. 1197 1198 RefPtr<JITCode> jitCode = eval->generatedJITCode(); 1199 1190 RefPtr<JITCode> jitCode; 1200 1191 ProtoCallFrame protoCallFrame; 1201 protoCallFrame.init(codeBlock, globalObject, callee, thisValue, 1); 1192 { 1193 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable. 1194 jitCode = eval->generatedJITCode(); 1195 protoCallFrame.init(codeBlock, globalObject, callee, thisValue, 1); 1196 } 1202 1197 1203 1198 // Execute the code: 1204 disallowGC.disable();1205 1199 throwScope.release(); 1206 1200 ASSERT(jitCode == eval->generatedJITCode().ptr()); … … 1252 1246 } 1253 1247 1254 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable. 1255 1256 RefPtr<JITCode> jitCode = executable->generatedJITCode(); 1257 1258 // The |this| of the module is always `undefined`. 1259 // http://www.ecma-international.org/ecma-262/6.0/#sec-module-environment-records-hasthisbinding 1260 // http://www.ecma-international.org/ecma-262/6.0/#sec-module-environment-records-getthisbinding 1248 RefPtr<JITCode> jitCode; 1261 1249 ProtoCallFrame protoCallFrame; 1262 protoCallFrame.init(codeBlock, globalObject, callee, jsUndefined(), 1); 1250 { 1251 DisallowGC disallowGC; // Ensure no GC happens. GC can replace CodeBlock in Executable. 1252 jitCode = executable->generatedJITCode(); 1253 // The |this| of the module is always `undefined`. 1254 // http://www.ecma-international.org/ecma-262/6.0/#sec-module-environment-records-hasthisbinding 1255 // http://www.ecma-international.org/ecma-262/6.0/#sec-module-environment-records-getthisbinding 1256 protoCallFrame.init(codeBlock, globalObject, callee, jsUndefined(), 1); 1257 } 1263 1258 1264 1259 // Execute the code: 1265 disallowGC.disable();1266 1260 throwScope.release(); 1267 1261 ASSERT(jitCode == executable->generatedJITCode().ptr()); -
TabularUnified trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp ¶
r264679 r264688 2317 2317 } 2318 2318 2319 extern "C" SlowPathReturnType llint_check_vm_entry_permission(VM* vm, ProtoCallFrame*) 2320 { 2321 ASSERT_UNUSED(vm, vm->disallowVMEntryCount); 2322 if (Options::crashOnDisallowedVMEntry()) 2323 CRASH(); 2324 2325 // Else return, and let doVMEntry return undefined. 2326 return encodeResult(nullptr, nullptr); 2327 } 2328 2319 2329 extern "C" void llint_dump_value(EncodedJSValue value); 2320 2330 extern "C" void llint_dump_value(EncodedJSValue value) -
TabularUnified trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.h ¶
r262613 r264688 1 1 /* 2 * Copyright (C) 2011-20 18Apple Inc. All rights reserved.2 * Copyright (C) 2011-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 148 148 extern "C" SlowPathReturnType llint_stack_check_at_vm_entry(VM*, Register*) WTF_INTERNAL; 149 149 #endif 150 extern "C" SlowPathReturnType llint_check_vm_entry_permission(VM*, ProtoCallFrame*) WTF_INTERNAL; 150 151 extern "C" NO_RETURN_DUE_TO_CRASH void llint_crash() WTF_INTERNAL; 151 152 -
TabularUnified trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm ¶
r264504 r264688 1 # Copyright (C) 2011-20 19Apple Inc. All rights reserved.1 # Copyright (C) 2011-2020 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 171 171 # aliasing problems with our arguments. 172 172 173 loadi VM::disallowVMEntryCount[vm], t4 174 btinz t4, .checkVMEntryPermission 175 173 176 if ARMv7 174 177 vmEntryRecord(cfr, t3) … … 317 320 end 318 321 322 popCalleeSaves() 323 functionEpilogue() 324 ret 325 326 .checkVMEntryPermission: 327 move vm, a0 328 move protoCallFrame, a1 329 cCall2(_llint_check_vm_entry_permission) 330 move UndefinedTag, r0 331 move 0, r1 332 333 subp cfr, CalleeRegisterSaveSize, sp 319 334 popCalleeSaves() 320 335 functionEpilogue() -
TabularUnified trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm ¶
r264504 r264688 167 167 checkStackPointerAlignment(t4, 0xbad0dc01) 168 168 169 loadi VM::disallowVMEntryCount[vm], t4 170 btinz t4, .checkVMEntryPermission 171 169 172 storep vm, VMEntryRecord::m_vm[sp] 170 173 loadp VM::topCallFrame[vm], t4 … … 282 285 subp cfr, CalleeRegisterSaveSize, sp 283 286 287 popCalleeSaves() 288 functionEpilogue() 289 ret 290 291 .checkVMEntryPermission: 292 move vm, a0 293 move protoCallFrame, a1 294 cCall2(_llint_check_vm_entry_permission) 295 move ValueUndefined, r0 296 297 subp cfr, CalleeRegisterSaveSize, sp 284 298 popCalleeSaves() 285 299 functionEpilogue() -
TabularUnified trunk/Source/JavaScriptCore/runtime/DisallowScope.h ¶
r258443 r264688 1 1 /* 2 * Copyright (C) 2017-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 WTF_FORBID_HEAP_ALLOCATION; 37 37 public: 38 #ifdef NDEBUG 39 40 ALWAYS_INLINE DisallowScope(bool = false) { } 41 ALWAYS_INLINE ~DisallowScope() { } 42 ALWAYS_INLINE static bool isInEffectOnCurrentThread() { return false; } 43 ALWAYS_INLINE void enable() { } 44 ALWAYS_INLINE void disable() { } 45 46 #else // not NDEBUG 47 48 DisallowScope(bool enabled = true) 38 #if ASSERT_ENABLED 39 DisallowScope() 49 40 { 50 m_isEnabled = enabled; 51 if (m_isEnabled) 52 enterScope(); 41 auto count = T::scopeReentryCount(); 42 T::setScopeReentryCount(++count); 53 43 } 54 44 55 45 ~DisallowScope() 56 46 { 57 if (m_isEnabled) 58 exitScope(); 47 auto count = T::scopeReentryCount(); 48 ASSERT(count); 49 T::setScopeReentryCount(--count); 59 50 } 60 51 … … 64 55 } 65 56 66 void enable() 67 { 68 m_isEnabled = true; 69 enterScope(); 70 } 71 72 void disable() 73 { 74 m_isEnabled = false; 75 exitScope(); 76 } 77 78 private: 79 void enterScope() 80 { 81 auto count = T::scopeReentryCount(); 82 T::setScopeReentryCount(++count); 83 } 84 85 void exitScope() 86 { 87 auto count = T::scopeReentryCount(); 88 ASSERT(count); 89 T::setScopeReentryCount(--count); 90 } 91 92 bool m_isEnabled; 93 #endif // NDEBUG 57 #else // not ASSERT_ENABLED 58 ALWAYS_INLINE DisallowScope() { } // We need this to placate Clang due to unused warnings. 59 ALWAYS_INLINE static bool isInEffectOnCurrentThread() { return false; } 60 #endif // ASSERT_ENABLED 94 61 }; 95 62 -
TabularUnified trunk/Source/JavaScriptCore/runtime/DisallowVMEntry.h ¶
r264687 r264688 1 1 /* 2 * Copyright (C) 2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include "DisallowScope.h"29 #include <wtf/NeverDestroyed.h>30 #include <wtf/ThreadSpecific.h>31 32 28 namespace JSC { 33 29 34 class DisallowVMReentry : public DisallowScope<DisallowVMReentry> { 35 WTF_MAKE_NONCOPYABLE(DisallowVMReentry); 36 typedef DisallowScope<DisallowVMReentry> Base; 30 class VM; 31 32 // The only reason we implement DisallowVMEntry as specialization of a template 33 // is so that we can work around having to #include VM.h, which can hurt build 34 // time. This defers the cost of #include'ing VM.h to only the clients that 35 // need it. 36 37 template<typename VMType = VM> 38 class DisallowVMEntryImpl { 39 WTF_MAKE_NONCOPYABLE(DisallowVMEntryImpl); 37 40 public: 38 #ifdef NDEBUG 41 DisallowVMEntryImpl(VMType& vm) 42 : m_vm(&vm) 43 { 44 m_vm->disallowVMEntryCount++; 45 } 39 46 40 ALWAYS_INLINE DisallowVMReentry(bool = false) { } 41 ALWAYS_INLINE static void initialize() { } 42 43 #else // not NDEBUG 44 45 DisallowVMReentry(bool enabled = true) 46 : Base(enabled) 47 { } 48 49 static void initialize() 47 ~DisallowVMEntryImpl() 50 48 { 51 s_scopeReentryCount.construct(); 49 RELEASE_ASSERT(m_vm->disallowVMEntryCount); 50 m_vm->disallowVMEntryCount--; 51 m_vm = nullptr; 52 52 } 53 53 54 54 private: 55 static unsigned scopeReentryCount() 56 { 57 return *s_scopeReentryCount.get(); 58 } 59 static void setScopeReentryCount(unsigned value) 60 { 61 *s_scopeReentryCount.get() = value; 62 } 63 64 JS_EXPORT_PRIVATE static LazyNeverDestroyed<ThreadSpecific<unsigned, WTF::CanBeGCThread::True>> s_scopeReentryCount; 65 66 #endif // NDEBUG 67 68 friend class DisallowScope<DisallowVMReentry>; 55 VMType* m_vm; 69 56 }; 70 57 58 using DisallowVMEntry = DisallowVMEntryImpl<VM>; 59 71 60 } // namespace JSC -
TabularUnified trunk/Source/JavaScriptCore/runtime/InitializeThreading.cpp ¶
r263635 r264688 30 30 #include "InitializeThreading.h" 31 31 32 #include "DisallowVMReentry.h"33 32 #include "ExecutableAllocator.h" 34 33 #include "JSCConfig.h" … … 79 78 80 79 LLInt::initialize(); 81 #ifndef NDEBUG82 80 DisallowGC::initialize(); 83 DisallowVMReentry::initialize(); 84 #endif 81 85 82 initializeSuperSampler(); 86 83 Thread& thread = Thread::current(); -
TabularUnified trunk/Source/JavaScriptCore/runtime/JSArray.cpp ¶
r261755 r264688 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2003-20 19Apple Inc. All rights reserved.3 * Copyright (C) 2003-2020 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2003 Peter Kelly (pmk@post.com) 5 5 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) … … 97 97 JSArray* result = createWithButterfly(vm, deferralContext, structure, butterfly); 98 98 99 const bool createUninitialized = true; 100 scope.notifyAllocated(result, createUninitialized); 99 scope.notifyAllocated(result); 101 100 return result; 102 101 } -
TabularUnified trunk/Source/JavaScriptCore/runtime/ObjectInitializationScope.cpp ¶
r261993 r264688 1 1 /* 2 * Copyright (C) 2017-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 namespace JSC { 36 36 37 #ifndef NDEBUG 37 #if ASSERT_ENABLED 38 38 39 ObjectInitializationScope::ObjectInitializationScope(VM& vm) 39 40 : m_vm(vm) 40 , m_disallowGC(false)41 , m_disallowVMReentry(false)42 41 { 43 42 } … … 51 50 } 52 51 53 void ObjectInitializationScope::notifyAllocated(JSObject* object , bool wasCreatedUninitialized)52 void ObjectInitializationScope::notifyAllocated(JSObject* object) 54 53 { 55 if (wasCreatedUninitialized) { 56 m_disallowGC.enable(); 57 m_disallowVMReentry.enable(); 58 m_object = object; 59 } else 60 verifyPropertiesAreInitialized(object); 54 ASSERT(!m_disallowGC); 55 ASSERT(!m_disallowVMEntry); 56 m_disallowGC.emplace(); 57 m_disallowVMEntry.emplace(m_vm); 58 m_object = object; 61 59 } 62 60 … … 64 62 { 65 63 if (m_object) { 66 m_disallowGC. disable();67 m_disallowVM Reentry.disable();64 m_disallowGC.reset(); 65 m_disallowVMEntry.reset(); 68 66 m_object = nullptr; 69 67 } … … 115 113 } 116 114 } 117 #endif 115 116 #endif // ASSERT_ENABLED 118 117 119 118 } // namespace JSC -
TabularUnified trunk/Source/JavaScriptCore/runtime/ObjectInitializationScope.h ¶
r251690 r264688 1 1 /* 2 * Copyright (C) 2017-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 28 28 #include "DeferGC.h" 29 #include "DisallowVM Reentry.h"29 #include "DisallowVMEntry.h" 30 30 #include "VM.h" 31 #include <wtf/Optional.h> 31 32 32 33 namespace JSC { … … 35 36 class JSObject; 36 37 37 #ifdef NDEBUG 38 #if ASSERT_ENABLED 39 40 class ObjectInitializationScope { 41 public: 42 JS_EXPORT_PRIVATE ObjectInitializationScope(VM&); 43 JS_EXPORT_PRIVATE ~ObjectInitializationScope(); 44 45 VM& vm() const { return m_vm; } 46 void notifyAllocated(JSObject*); 47 void notifyInitialized(JSObject*); 48 49 private: 50 void verifyPropertiesAreInitialized(JSObject*); 51 52 VM& m_vm; 53 Optional<DisallowGC> m_disallowGC; 54 Optional<DisallowVMEntry> m_disallowVMEntry; 55 JSObject* m_object { nullptr }; 56 }; 57 58 #else // not ASSERT_ENABLED 38 59 39 60 class ObjectInitializationScope { … … 48 69 49 70 ALWAYS_INLINE VM& vm() const { return m_vm; } 50 ALWAYS_INLINE void notifyAllocated(JSObject* , bool) { }71 ALWAYS_INLINE void notifyAllocated(JSObject*) { } 51 72 ALWAYS_INLINE void notifyInitialized(JSObject*) { } 52 73 … … 55 76 }; 56 77 57 #else // not NDEBUG 58 59 class ObjectInitializationScope { 60 public: 61 JS_EXPORT_PRIVATE ObjectInitializationScope(VM&); 62 JS_EXPORT_PRIVATE ~ObjectInitializationScope(); 63 64 VM& vm() const { return m_vm; } 65 void notifyAllocated(JSObject*, bool wasCreatedUninitialized); 66 void notifyInitialized(JSObject*); 67 68 private: 69 void verifyPropertiesAreInitialized(JSObject*); 70 71 VM& m_vm; 72 DisallowGC m_disallowGC; 73 DisallowVMReentry m_disallowVMReentry; 74 JSObject* m_object { nullptr }; 75 }; 76 77 #endif // NDEBUG 78 #endif // ASSERT_ENABLED 78 79 79 80 } // namespace JSC -
TabularUnified trunk/Source/JavaScriptCore/runtime/OptionsList.h ¶
r264672 r264688 95 95 v(Unsigned, reservedZoneSize, 64 * KB, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \ 96 96 \ 97 v(Bool, crashOnDisallowedVMEntry, ASSERT_ENABLED, Normal, "Forces a crash if we attempt to enter the VM when disallowed") \ 97 98 v(Bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \ 98 99 v(Unsigned, jitMemoryReservationSize, 0, Normal, "Set this number to change the executable allocation size in ExecutableAllocatorFixedVMPool. (In bytes.)") \ -
TabularUnified trunk/Source/JavaScriptCore/runtime/RegExpMatchesArray.h ¶
r262570 r264688 55 55 JSArray* result = JSArray::createWithButterfly(vm, deferralContext, structure, butterfly); 56 56 57 const bool createUninitialized = true; 58 scope.notifyAllocated(result, createUninitialized); 57 scope.notifyAllocated(result); 59 58 return result; 60 59 } -
TabularUnified trunk/Source/JavaScriptCore/runtime/VM.h ¶
r264639 r264688 36 36 #include "DateInstanceCache.h" 37 37 #include "DeleteAllCodeEffort.h" 38 #include "DisallowVMEntry.h" 38 39 #include "ExceptionEventLocation.h" 39 40 #include "ExecutableAllocator.h" … … 953 954 void scanSideState(ConservativeRoots&) const; 954 955 956 unsigned disallowVMEntryCount { 0 }; 955 957 VMEntryScope* entryScope; 956 958 -
TabularUnified trunk/Source/JavaScriptCore/runtime/VMEntryScope.cpp ¶
r261755 r264688 1 1 /* 2 * Copyright (C) 2013-20 18Apple Inc. All rights reserved.2 * Copyright (C) 2013-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #include "VMEntryScope.h" 28 28 29 #include "DisallowVMReentry.h"30 29 #include "Options.h" 31 30 #include "SamplingProfiler.h" … … 40 39 , m_globalObject(globalObject) 41 40 { 42 ASSERT(!DisallowVMReentry::isInEffectOnCurrentThread());43 41 if (!vm.entryScope) { 44 42 vm.entryScope = this;
Note:
See TracChangeset
for help on using the changeset viewer.