Changeset 259547 in webkit
- Timestamp:
- Apr 5, 2020, 1:34:43 AM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r259436 r259547 821 821 runtime/DisallowVMReentry.h 822 822 runtime/DumpContext.h 823 runtime/EnsureStillAliveHere.h 823 824 runtime/EnumerationMode.h 824 825 runtime/Error.h -
trunk/Source/JavaScriptCore/ChangeLog
r259546 r259547 1 2020-04-05 Mark Lam <mark.lam@apple.com> 2 3 Add some structureID integrity checks to various runtime functions. 4 https://bugs.webkit.org/show_bug.cgi?id=210015 5 <rdar://problem/58116514> 6 7 Reviewed by Keith Miller. 8 9 Specifically, implementations of toString(), toValue(), and a few others. 10 I also moved the HeapCell version of ensureStillAliveHere() into the new 11 EnsureStillAliveHere.h/cpp since it's useful for any pointers, not just HeapCells. 12 13 This change is performance neutral on JetStream 2.0, Speedometer-2, and PLT5. 14 15 * CMakeLists.txt: 16 * JavaScriptCore.xcodeproj/project.pbxproj: 17 * Sources.txt: 18 * heap/HeapCell.cpp: 19 (JSC::ensureStillAliveHere): Deleted. 20 * heap/HeapCell.h: 21 (JSC::ensureStillAliveHere): Deleted. 22 * heap/SlotVisitor.cpp: 23 (JSC::SlotVisitor::appendJSCellOrAuxiliary): 24 * runtime/ArrayPrototype.cpp: 25 (JSC::arrayProtoFuncToString): 26 * runtime/BigIntPrototype.cpp: 27 (JSC::bigIntProtoFuncToStringImpl): 28 (JSC::bigIntProtoFuncValueOf): 29 * runtime/BooleanPrototype.cpp: 30 (JSC::booleanProtoFuncToString): 31 (JSC::booleanProtoFuncValueOf): 32 * runtime/DatePrototype.cpp: 33 (JSC::formatLocaleDate): 34 (JSC::formateDateInstance): 35 (JSC::dateProtoFuncToISOString): 36 (JSC::dateProtoFuncToPrimitiveSymbol): 37 * runtime/EnsureStillAliveHere.cpp: Added. 38 (JSC::ensureStillAliveHere): 39 * runtime/EnsureStillAliveHere.h: Added. 40 (JSC::ensureStillAliveHere): 41 * runtime/ErrorInstance.cpp: 42 (JSC::ErrorInstance::sanitizedToString): 43 * runtime/ErrorPrototype.cpp: 44 (JSC::errorProtoFuncToString): 45 * runtime/FunctionPrototype.cpp: 46 (JSC::functionProtoFuncToString): 47 * runtime/JSCell.cpp: 48 (JSC::JSCell::toObjectSlow const): 49 * runtime/NumberPrototype.cpp: 50 (JSC::toThisNumber): 51 * runtime/ObjectPrototype.cpp: 52 (JSC::objectProtoFuncValueOf): 53 (JSC::objectProtoFuncToString): 54 * runtime/RegExpPrototype.cpp: 55 (JSC::regExpProtoFuncToString): 56 * runtime/StringPrototype.cpp: 57 (JSC::stringProtoFuncToString): 58 * runtime/StructureIDTable.h: 59 (JSC::StructureIDTable::validate): 60 (JSC::StructureIDTable::isValid): Deleted. 61 * runtime/SymbolPrototype.cpp: 62 (JSC::symbolProtoGetterDescription): 63 (JSC::symbolProtoFuncToString): 64 (JSC::symbolProtoFuncValueOf): 65 * tools/Integrity.h: 66 * tools/IntegrityInlines.h: 67 (JSC::Integrity::auditStructureID): 68 * wasm/js/WebAssemblyGlobalPrototype.cpp: 69 (JSC::getGlobal): 70 1 71 2020-04-05 Alexey Shvayka <shvaikalesh@gmail.com> 2 72 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r259545 r259547 1888 1888 FE318FE01CAC982F00DFCC54 /* ECMAScriptSpecInternalFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = FE318FDE1CAC8C5300DFCC54 /* ECMAScriptSpecInternalFunctions.h */; }; 1889 1889 FE3422121D6B81C30032BE88 /* ThrowScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3422111D6B818C0032BE88 /* ThrowScope.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1890 FE34EE2124398AAE00AA2E7C /* EnsureStillAliveHere.h in Headers */ = {isa = PBXBuildFile; fileRef = FE34EE2024398A9A00AA2E7C /* EnsureStillAliveHere.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1890 1891 FE3842332324D51B009DD445 /* OptionsList.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3842312324D51B009DD445 /* OptionsList.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1891 1892 FE384EE61ADDB7AD0055DE2C /* JSDollarVM.h in Headers */ = {isa = PBXBuildFile; fileRef = FE384EE21ADDB7AD0055DE2C /* JSDollarVM.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 5122 5123 FE318FDE1CAC8C5300DFCC54 /* ECMAScriptSpecInternalFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ECMAScriptSpecInternalFunctions.h; sourceTree = "<group>"; }; 5123 5124 FE3422111D6B818C0032BE88 /* ThrowScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThrowScope.h; sourceTree = "<group>"; }; 5125 FE34EE2024398A9A00AA2E7C /* EnsureStillAliveHere.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnsureStillAliveHere.h; sourceTree = "<group>"; }; 5126 FE34EE2224398B8500AA2E7C /* EnsureStillAliveHere.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnsureStillAliveHere.cpp; sourceTree = "<group>"; }; 5124 5127 FE35C2F021B1E6C5000F4CA8 /* Template.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = Template.rb; sourceTree = "<group>"; }; 5125 5128 FE35C2F121B1E6C6000F4CA8 /* Fits.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = Fits.rb; sourceTree = "<group>"; }; … … 7111 7114 FE318FDD1CAC8C5300DFCC54 /* ECMAScriptSpecInternalFunctions.cpp */, 7112 7115 FE318FDE1CAC8C5300DFCC54 /* ECMAScriptSpecInternalFunctions.h */, 7116 FE34EE2224398B8500AA2E7C /* EnsureStillAliveHere.cpp */, 7117 FE34EE2024398A9A00AA2E7C /* EnsureStillAliveHere.h */, 7113 7118 2AD2EDFA19799E38004D6478 /* EnumerationMode.h */, 7114 7119 BC337BEA0E1B00CB0076918A /* Error.cpp */, … … 8927 8932 79A228361D35D71F00D8E067 /* ArithProfile.h in Headers */, 8928 8933 0F6B1CB91861244C00845D97 /* ArityCheckMode.h in Headers */, 8934 FE34EE2124398AAE00AA2E7C /* EnsureStillAliveHere.h in Headers */, 8929 8935 A1A009C11831A26E00CF8711 /* ARM64Assembler.h in Headers */, 8930 8936 FE1E2C402240DD6200F6B729 /* ARM64EAssembler.h in Headers */, -
trunk/Source/JavaScriptCore/Sources.txt
r259436 r259547 765 765 runtime/DumpContext.cpp 766 766 runtime/ECMAScriptSpecInternalFunctions.cpp 767 runtime/EnsureStillAliveHere.cpp 767 768 runtime/Error.cpp 768 769 runtime/ErrorConstructor.cpp -
trunk/Source/JavaScriptCore/heap/HeapCell.cpp
r258825 r259547 1 1 /* 2 * Copyright (C) 2016-20 17Apple Inc. All rights reserved.2 * Copyright (C) 2016-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 43 43 } 44 44 45 #if !COMPILER(GCC_COMPATIBLE)46 // This makes the argument opaque from the compiler.47 NEVER_INLINE void ensureStillAliveHere(const void*)48 {49 }50 #endif51 52 45 } // namespace JSC 53 46 -
trunk/Source/JavaScriptCore/heap/HeapCell.h
r258825 r259547 1 1 /* 2 * Copyright (C) 2016-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2016-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 "DestructionMode.h" 29 #include "EnsureStillAliveHere.h" 29 30 30 31 namespace JSC { … … 37 38 class VM; 38 39 struct CellAttributes; 39 40 #if COMPILER(GCC_COMPATIBLE)41 ALWAYS_INLINE void ensureStillAliveHere(const void* pointer)42 {43 asm volatile ("" : : "r"(pointer) : "memory");44 }45 #else46 JS_EXPORT_PRIVATE void ensureStillAliveHere(const void*);47 #endif48 40 49 41 class HeapCell { -
trunk/Source/JavaScriptCore/heap/SlotVisitor.cpp
r258386 r259547 1 1 /* 2 * Copyright (C) 2012-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2012-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 201 201 die("GC scan found object in bad state: structureID is nuked!\n"); 202 202 203 #if USE(JSVALUE64)204 203 // This detects the worst of the badness. 205 if (!heap()->structureIDTable().isValid(structureID)) 206 die("GC scan found corrupt object: structureID is invalid!\n"); 207 #endif 204 Integrity::auditStructureID(heap()->structureIDTable(), structureID); 208 205 }; 209 206 -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r254252 r259547 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) … … 32 32 #include "Error.h" 33 33 #include "GetterSetter.h" 34 #include "IntegrityInlines.h" 34 35 #include "Interpreter.h" 35 36 #include "JIT.h" … … 606 607 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 607 608 609 Integrity::auditStructureID(vm, thisObject->structureID()); 608 610 if (!canUseDefaultArrayJoinForToString(vm, thisObject)) { 609 611 // 2. Let func be the result of calling the [[Get]] internal method of array with argument "join". -
trunk/Source/JavaScriptCore/runtime/BigIntPrototype.cpp
r253865 r259547 1 1 /* 2 2 * Copyright (C) 2017 Caio Lima <ticaiolima@gmail.com>. 3 * Copyright (C) 2017-20 19Apple Inc. All rights reserved.3 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 30 30 #include "BigIntObject.h" 31 31 #include "Error.h" 32 #include "IntegrityInlines.h" 32 33 #include "JSBigInt.h" 33 34 #include "JSCBuiltins.h" … … 102 103 ASSERT(value); 103 104 105 Integrity::auditStructureID(vm, value->structureID()); 104 106 int32_t radix = extractToStringRadixArgument(globalObject, callFrame->argument(0), scope); 105 107 RETURN_IF_EXCEPTION(scope, { }); … … 127 129 { 128 130 VM& vm = globalObject->vm(); 129 if (JSBigInt* value = toThisBigIntValue(vm, callFrame->thisValue()))130 return JSValue::encode(value);131 132 131 auto scope = DECLARE_THROW_SCOPE(vm); 133 return throwVMTypeError(globalObject, scope, "'this' value must be a BigInt or BigIntObject"_s); 132 133 JSBigInt* value = toThisBigIntValue(vm, callFrame->thisValue()); 134 if (!value) 135 return throwVMTypeError(globalObject, scope, "'this' value must be a BigInt or BigIntObject"_s); 136 137 Integrity::auditStructureID(vm, value->structureID()); 138 return JSValue::encode(value); 134 139 } 135 140 -
trunk/Source/JavaScriptCore/runtime/BooleanPrototype.cpp
r251425 r259547 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2003 , 2008, 2011, 2016Apple Inc. All rights reserved.3 * Copyright (C) 2003-2020 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 24 24 #include "Error.h" 25 25 #include "ExceptionHelpers.h" 26 #include "IntegrityInlines.h" 26 27 #include "JSFunction.h" 27 28 #include "JSString.h" … … 81 82 return throwVMTypeError(globalObject, scope); 82 83 84 Integrity::auditStructureID(vm, thisObject->structureID()); 83 85 if (thisObject->internalValue() == jsBoolean(false)) 84 86 return JSValue::encode(vm.smallStrings.falseString()); … … 100 102 return throwVMTypeError(globalObject, scope); 101 103 104 Integrity::auditStructureID(vm, thisObject->structureID()); 102 105 return JSValue::encode(thisObject->internalValue()); 103 106 } -
trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp
r251852 r259547 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2004-20 19Apple Inc. All rights reserved.3 * Copyright (C) 2004-2020 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2008, 2009 Torch Mobile, Inc. All rights reserved. 5 5 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. … … 28 28 #include "DateInstance.h" 29 29 #include "Error.h" 30 #include "IntegrityInlines.h" 30 31 #include "JSCBuiltins.h" 31 32 #include "JSDateMath.h" … … 141 142 } 142 143 143 static JSCell* formatLocaleDate(JSGlobalObject* globalObject, CallFrame* callFrame, DateInstance*, double timeInMilliseconds, LocaleDateTimeFormat format) 144 { 145 VM& vm = globalObject->vm(); 144 static JSCell* formatLocaleDate(JSGlobalObject* globalObject, CallFrame* callFrame, DateInstance* dateObject, double timeInMilliseconds, LocaleDateTimeFormat format) 145 { 146 VM& vm = globalObject->vm(); 147 Integrity::auditStructureID(vm, dateObject->structureID()); 148 146 149 CFDateFormatterStyle dateStyle = (format != LocaleTime ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); 147 150 CFDateFormatterStyle timeStyle = (format != LocaleDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle); … … 172 175 #elif !UCONFIG_NO_FORMATTING 173 176 174 static JSCell* formatLocaleDate(JSGlobalObject* globalObject, CallFrame*, DateInstance*, double timeInMilliseconds, LocaleDateTimeFormat format) 175 { 176 VM& vm = globalObject->vm(); 177 static JSCell* formatLocaleDate(JSGlobalObject* globalObject, CallFrame*, DateInstance* dateObject, double timeInMilliseconds, LocaleDateTimeFormat format) 178 { 179 VM& vm = globalObject->vm(); 180 Integrity::auditStructureID(vm, dateObject->structureID()); 181 177 182 UDateFormatStyle timeStyle = (format != LocaleDate ? UDAT_LONG : UDAT_NONE); 178 183 UDateFormatStyle dateStyle = (format != LocaleTime ? UDAT_LONG : UDAT_NONE); … … 312 317 { 313 318 VM& vm = globalObject->vm(); 319 Integrity::auditStructureID(vm, dateObject->structureID()); 320 314 321 const GregorianDateTime* gregorianDateTime = dateObject->gregorianDateTime(vm); 315 322 if (!gregorianDateTime) … … 329 336 return throwVMTypeError(globalObject, scope); 330 337 338 Integrity::auditStructureID(vm, thisDateObj->structureID()); 331 339 const GregorianDateTime* gregorianDateTime = asUTCVariant 332 340 ? thisDateObj->gregorianDateTimeUTC(vm) … … 544 552 if (UNLIKELY(!thisDateObj)) 545 553 return throwVMTypeError(globalObject, scope); 546 554 555 Integrity::auditStructureID(vm, thisDateObj->structureID()); 547 556 if (!std::isfinite(thisDateObj->internalNumber())) 548 557 return throwVMError(globalObject, scope, createRangeError(globalObject, "Invalid Date"_s)); … … 628 637 return throwVMTypeError(globalObject, scope, "Date.prototype[Symbol.toPrimitive] expected |this| to be an object."); 629 638 JSObject* thisObject = jsCast<JSObject*>(thisValue); 639 Integrity::auditStructureID(vm, thisObject->structureID()); 630 640 631 641 if (!callFrame->argumentCount()) -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp
r257399 r259547 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 * 5 5 * This library is free software; you can redistribute it and/or … … 24 24 #include "CodeBlock.h" 25 25 #include "InlineCallFrame.h" 26 #include "IntegrityInlines.h" 26 27 #include "Interpreter.h" 27 28 #include "JSScope.h" … … 140 141 VM& vm = globalObject->vm(); 141 142 auto scope = DECLARE_THROW_SCOPE(vm); 143 Integrity::auditStructureID(vm, structureID()); 142 144 143 145 JSValue nameValue; -
trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp
r254842 r259547 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 * 5 5 * This library is free software; you can redistribute it and/or … … 23 23 24 24 #include "Error.h" 25 #include "IntegrityInlines.h" 25 26 #include "JSFunction.h" 26 27 #include "JSStringInlines.h" … … 83 84 return throwVMTypeError(globalObject, scope); 84 85 JSObject* thisObj = asObject(thisValue); 86 Integrity::auditStructureID(vm, thisObj->structureID()); 85 87 86 88 // Guard against recursion! -
trunk/Source/JavaScriptCore/runtime/FunctionPrototype.cpp
r254653 r259547 1 1 /* 2 2 * Copyright (C) 1999-2001 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 * 5 5 * This library is free software; you can redistribute it and/or … … 26 26 #include "Error.h" 27 27 #include "GetterSetter.h" 28 #include "IntegrityInlines.h" 28 29 #include "JSAsyncFunction.h" 29 30 #include "JSCInlines.h" … … 85 86 if (thisValue.inherits<JSFunction>(vm)) { 86 87 JSFunction* function = jsCast<JSFunction*>(thisValue); 88 Integrity::auditStructureID(vm, function->structureID()); 87 89 if (function->isHostOrBuiltinFunction()) 88 90 RELEASE_AND_RETURN(scope, JSValue::encode(jsMakeNontrivialString(globalObject, "function ", function->name(vm), "() {\n [native code]\n}"))); … … 141 143 if (thisValue.inherits<InternalFunction>(vm)) { 142 144 InternalFunction* function = jsCast<InternalFunction*>(thisValue); 145 Integrity::auditStructureID(vm, function->structureID()); 143 146 RELEASE_AND_RETURN(scope, JSValue::encode(jsMakeNontrivialString(globalObject, "function ", function->name(), "() {\n [native code]\n}"))); 144 147 } … … 146 149 if (thisValue.isObject()) { 147 150 JSObject* object = asObject(thisValue); 151 Integrity::auditStructureID(vm, object->structureID()); 148 152 if (object->isFunction(vm)) 149 153 RELEASE_AND_RETURN(scope, JSValue::encode(jsMakeNontrivialString(globalObject, "function ", object->classInfo(vm)->className, "() {\n [native code]\n}"))); -
trunk/Source/JavaScriptCore/runtime/JSCell.cpp
r258479 r259547 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2003-20 19Apple Inc. All rights reserved.4 * Copyright (C) 2003-2020 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 26 26 #include "ArrayBufferView.h" 27 27 #include "BlockDirectoryInlines.h" 28 #include "IntegrityInlines.h" 28 29 #include "IsoSubspaceInlines.h" 29 30 #include "JSCInlines.h" … … 192 193 JSObject* JSCell::toObjectSlow(JSGlobalObject* globalObject) const 193 194 { 195 Integrity::auditStructureID(globalObject->vm(), structureID()); 194 196 ASSERT(!isObject()); 195 197 if (isString()) -
trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp
r252256 r259547 1 1 /* 2 2 * Copyright (C) 1999-2000,2003 Harri Porten (porten@kde.org) 3 * Copyright (C) 2007-20 19Apple Inc. All rights reserved.3 * Copyright (C) 2007-2020 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 25 25 #include "BigInteger.h" 26 26 #include "Error.h" 27 #include "IntegrityInlines.h" 27 28 #include "IntlNumberFormat.h" 28 29 #include "IntlObject.h" … … 99 100 100 101 if (auto* numberObject = jsDynamicCast<NumberObject*>(vm, thisValue)) { 102 Integrity::auditStructureID(vm, numberObject->structureID()); 101 103 x = numberObject->internalValue().asNumber(); 102 104 return true; -
trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
r253264 r259547 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2008-20 19Apple Inc. All rights reserved.3 * Copyright (C) 2008-2020 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 25 25 #include "GetterSetter.h" 26 26 #include "HasOwnPropertyCache.h" 27 #include "IntegrityInlines.h" 27 28 #include "JSFunction.h" 28 29 #include "JSString.h" … … 85 86 if (UNLIKELY(!valueObj)) 86 87 return encodedJSValue(); 88 Integrity::auditStructureID(globalObject->vm(), valueObj->structureID()); 87 89 return JSValue::encode(valueObj); 88 90 } … … 322 324 return JSValue::encode(jsUndefined()); 323 325 326 Integrity::auditStructureID(vm, thisObject->structureID()); 324 327 auto result = thisObject->structure(vm)->objectToStringValue(); 325 328 if (result) -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r253865 r259547 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 * 5 5 * This library is free software; you can redistribute it and/or … … 25 25 #include "BuiltinNames.h" 26 26 #include "Error.h" 27 #include "IntegrityInlines.h" 27 28 #include "JSArray.h" 28 29 #include "JSCBuiltins.h" … … 218 219 219 220 JSObject* thisObject = asObject(thisValue); 221 Integrity::auditStructureID(vm, thisObject->structureID()); 220 222 221 223 StringRecursionChecker checker(globalObject, thisObject); -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r259029 r259547 1 1 /* 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 * Copyright (C) 2004-20 19Apple Inc. All rights reserved.3 * Copyright (C) 2004-2020 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2009 Torch Mobile, Inc. 5 5 * Copyright (C) 2015 Jordan Harband (ljharb@gmail.com) … … 30 30 #include "ExecutableBaseInlines.h" 31 31 #include "FrameTracers.h" 32 #include "IntegrityInlines.h" 32 33 #include "InterpreterInlines.h" 33 34 #include "IntlCollator.h" … … 980 981 981 982 auto* stringObject = jsDynamicCast<StringObject*>(vm, thisValue); 982 if (stringObject) 983 return JSValue::encode(stringObject->internalValue()); 984 985 return throwVMTypeError(globalObject, scope); 983 if (!stringObject) 984 return throwVMTypeError(globalObject, scope); 985 986 Integrity::auditStructureID(vm, stringObject->structureID()); 987 return JSValue::encode(stringObject->internalValue()); 986 988 } 987 989 -
trunk/Source/JavaScriptCore/runtime/StructureIDTable.h
r259107 r259547 1 1 /* 2 * Copyright (C) 2013-20 19Apple 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 … … 26 26 #pragma once 27 27 28 #include "EnsureStillAliveHere.h" 28 29 #include "UnusedPointer.h" 29 30 #include <wtf/UniqueArray.h> … … 92 93 void** base() { return reinterpret_cast<void**>(&m_table); } 93 94 94 bool isValid(StructureID); 95 ALWAYS_INLINE void validate(StructureID); 96 95 97 Structure* get(StructureID); 96 98 void deallocateID(Structure*, StructureID); … … 177 179 } 178 180 179 inline bool StructureIDTable::isValid(StructureID structureID) 180 { 181 if (!structureID) 182 return false; 181 ALWAYS_INLINE void StructureIDTable::validate(StructureID structureID) 182 { 183 183 uint32_t structureIndex = structureID >> s_numberOfEntropyBits; 184 if (structureIndex >= m_capacity)185 return false;186 #if CPU(ADDRESS64)187 184 Structure* structure = decode(table()[structureIndex].encodedStructureBits, structureID); 188 if (reinterpret_cast<uintptr_t>(structure) >> s_entropyBitsShiftForStructurePointer) 189 return false; 190 #endif 191 return true; 185 RELEASE_ASSERT(structureIndex < m_capacity); 186 uint64_t value = *bitwise_cast<uint64_t*>(structure); 187 ensureStillAliveHere(value); 192 188 } 193 189 … … 208 204 209 205 void flushOldTables() { } 206 void validate(StructureID) { } 210 207 }; 211 208 -
trunk/Source/JavaScriptCore/runtime/SymbolPrototype.cpp
r253865 r259547 1 1 /* 2 * Copyright (C) 2012-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2012-2020 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. 4 4 * … … 29 29 30 30 #include "Error.h" 31 #include "IntegrityInlines.h" 31 32 #include "JSCInlines.h" 32 33 #include "JSString.h" … … 98 99 return throwVMTypeError(globalObject, scope, SymbolDescriptionTypeError); 99 100 scope.release(); 101 Integrity::auditStructureID(vm, symbol->structureID()); 100 102 const auto description = symbol->description(); 101 103 return JSValue::encode(description.isNull() ? jsUndefined() : jsString(vm, description)); … … 110 112 if (!symbol) 111 113 return throwVMTypeError(globalObject, scope, SymbolToStringTypeError); 114 Integrity::auditStructureID(vm, symbol->structureID()); 112 115 RELEASE_AND_RETURN(scope, JSValue::encode(jsNontrivialString(vm, symbol->descriptiveString()))); 113 116 } … … 122 125 return throwVMTypeError(globalObject, scope, SymbolValueOfTypeError); 123 126 127 Integrity::auditStructureID(vm, symbol->structureID()); 124 128 RELEASE_AND_RETURN(scope, JSValue::encode(symbol)); 125 129 } -
trunk/Source/JavaScriptCore/tools/Integrity.h
r250285 r259547 1 1 /* 2 * Copyright (C) 2019 Apple Inc. All rights reserved.2 * Copyright (C) 2019-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 class JSCell; 35 class StructureIDTable; 35 36 class VM; 36 37 … … 100 101 } 101 102 103 ALWAYS_INLINE void auditStructureID(StructureIDTable&, StructureID); 104 ALWAYS_INLINE void auditStructureID(VM&, StructureID); 105 102 106 } // namespace Integrity 103 107 -
trunk/Source/JavaScriptCore/tools/IntegrityInlines.h
r250285 r259547 1 1 /* 2 * Copyright (C) 2019 Apple Inc. All rights reserved.2 * Copyright (C) 2019-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 74 74 } 75 75 76 ALWAYS_INLINE void auditStructureID(StructureIDTable& table, StructureID id) 77 { 78 table.validate(id); 79 } 80 81 ALWAYS_INLINE void auditStructureID(VM& vm, StructureID id) 82 { 83 auditStructureID(vm.heap.structureIDTable(), id); 84 } 85 76 86 } // namespace Integrity 77 87 } // namespace JSC -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyGlobalPrototype.cpp
r253074 r259547 1 1 /* 2 * Copyright (C) 2019 Apple Inc. All rights reserved.2 * Copyright (C) 2019-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include "FunctionPrototype.h" 32 32 #include "GetterSetter.h" 33 #include "IntegrityInlines.h" 33 34 #include "JSCInlines.h" 34 35 #include "JSWebAssemblyGlobal.h" … … 62 63 return nullptr; 63 64 } 65 Integrity::auditStructureID(vm, result->structureID()); 64 66 return result; 65 67 }
Note:
See TracChangeset
for help on using the changeset viewer.