Skip to content

Commit b049880

Browse files
kljohannConstellation
authored andcommitted
[JSC] Fix wrong member access due to DECLARE_VISIT_CHILDREN macro
https://bugs.webkit.org/show_bug.cgi?id=296688 Reviewed by Yusuke Suzuki. Using the DECLARE_VISIT_CHILDREN macro in private/protected sections can leak subsequent members, as the macro ends with a public access specifier. This change moves all uses of the macro into the public section of their respective classes and selectively makes members used in existing code public. * Source/JavaScriptCore/runtime/JSBoundFunction.h: Move DECLARE_VISIT_CHILDREN macro to the public section. (JSC::JSBoundFunction::isTainted): New public getter for m_isTainted. * Source/JavaScriptCore/interpreter/Interpreter.cpp: (JSC::Interpreter::executeCall): Use new isTainted() getter. * Source/JavaScriptCore/runtime/IntlDateTimeFormat.h: Move DECLARE_VISIT_CHILDREN macro to the public section. * Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp: (JSC::handleDateTimeValue): Made TU-local as it is only used by host functions within this file. (JSC::IntlDateTimeFormat::handleDateTimeValue): Deleted. * Source/JavaScriptCore/runtime/IntlNumberFormat.h: Move DECLARE_VISIT_CHILDREN macro to the public section. Add missing friend declarations. (JSC::IntlNumberFormat::trailingZeroDisplayString): Made public for use in IntlPluralRules::resolvedOptions. * Source/JavaScriptCore/runtime/IntlPluralRules.h: Move DECLARE_VISIT_CHILDREN macro to the public section. Add missing friend declaration. * Source/JavaScriptCore/runtime/RegExpObject.h: Move DECLARE_VISIT_CHILDREN macro to the public section. (JSC::RegExpObject::lastIndexIsWritable): Make public for use in regExpProtoFuncSearch. * Source/JavaScriptCore/tools/JSDollarVM.cpp: (JSC::JSDollarVM::WasmStreamingCompiler): Add missing private access specifier. * Source/JavaScriptCore/API/JSCallbackObject.h: * Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h: * Source/JavaScriptCore/runtime/AbstractModuleRecord.h: * Source/JavaScriptCore/runtime/EvalExecutable.h: * Source/JavaScriptCore/runtime/GenericArgumentsImpl.h: * Source/JavaScriptCore/runtime/IntlCollator.h: * Source/JavaScriptCore/runtime/IntlLocale.h: * Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h: * Source/JavaScriptCore/runtime/JSArrayBufferView.h: * Source/JavaScriptCore/runtime/JSAsyncDisposableStack.h: * Source/JavaScriptCore/runtime/JSAsyncFromSyncIterator.h: * Source/JavaScriptCore/runtime/JSCallee.h: * Source/JavaScriptCore/runtime/JSDisposableStack.h: * Source/JavaScriptCore/runtime/JSFunction.h: * Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h: * Source/JavaScriptCore/runtime/JSGlobalProxy.h: * Source/JavaScriptCore/runtime/JSInternalFieldObjectImpl.h: * Source/JavaScriptCore/runtime/JSLexicalEnvironment.h: * Source/JavaScriptCore/runtime/JSMapIterator.h: * Source/JavaScriptCore/runtime/JSModuleEnvironment.h: * Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h: * Source/JavaScriptCore/runtime/JSModuleRecord.h: * Source/JavaScriptCore/runtime/JSNativeStdFunction.h: * Source/JavaScriptCore/runtime/JSRegExpStringIterator.h: * Source/JavaScriptCore/runtime/JSRemoteFunction.h: * Source/JavaScriptCore/runtime/JSSetIterator.h: * Source/JavaScriptCore/runtime/JSSymbolTableObject.h: * Source/JavaScriptCore/runtime/JSWrapForValidIterator.h: * Source/JavaScriptCore/runtime/JSWrapperObject.h: * Source/JavaScriptCore/runtime/ModuleProgramExecutable.h: * Source/JavaScriptCore/runtime/ProgramExecutable.h: * Source/JavaScriptCore/runtime/ProxyObject.h: * Source/JavaScriptCore/runtime/ShadowRealmObject.h: * Source/JavaScriptCore/runtime/SyntheticModuleRecord.h: * Source/JavaScriptCore/tools/JSDollarVM.h: * Source/JavaScriptCore/wasm/js/JSWebAssemblyGlobal.h: * Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h: * Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h: * Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h: * Source/JavaScriptCore/wasm/js/JSWebAssemblyTable.h: * Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h: * Source/JavaScriptCore/wasm/js/WebAssemblyFunctionBase.h: * Source/JavaScriptCore/wasm/js/WebAssemblyGCObjectBase.h: * Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h: * Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h: * Source/WebCore/bindings/js/JSDOMBuiltinConstructorBase.h: * Source/WebCore/bindings/js/JSShadowRealmGlobalScopeBase.h: * Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.h: * Source/WebCore/bindings/js/JSWorkletGlobalScopeBase.h: Move DECLARE_VISIT_CHILDREN macro to the public section. Canonical link: https://commits.webkit.org/298066@main
1 parent 9e1954b commit b049880

57 files changed

Lines changed: 135 additions & 94 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/JavaScriptCore/API/JSCallbackObject.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ class JSCallbackObject final : public Parent {
191191
static EncodedJSValue constructImpl(JSGlobalObject*, CallFrame*);
192192
static EncodedJSValue staticFunctionGetterImpl(JSGlobalObject*, EncodedJSValue, PropertyName);
193193
static EncodedJSValue callbackGetterImpl(JSGlobalObject*, EncodedJSValue, PropertyName);
194+
195+
DECLARE_VISIT_CHILDREN;
194196

195197
private:
196198
JSCallbackObject(JSGlobalObject*, Structure*, JSClassRef, void* data);
@@ -218,8 +220,6 @@ class JSCallbackObject final : public Parent {
218220
static CallData getConstructData(JSCell*);
219221
static CallData getCallData(JSCell*);
220222

221-
DECLARE_VISIT_CHILDREN;
222-
223223
void init(JSGlobalObject*);
224224

225225
static JSCallbackObject* asCallbackObject(JSValue);

‎Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,12 @@ class UnlinkedCodeBlock : public JSCell {
520520
#endif
521521

522522
protected:
523-
DECLARE_VISIT_CHILDREN;
524523
static size_t estimatedSize(JSCell*, VM&);
525524

526525
public:
527526
DECLARE_INFO;
527+
528+
DECLARE_VISIT_CHILDREN;
528529
};
529530

530531
}

‎Source/JavaScriptCore/interpreter/Interpreter.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ JSValue Interpreter::executeCall(JSObject* function, const CallData& callData, J
12571257

12581258
// Only one-level unwrap is enough! We already made JSBoundFunction's nest smaller.
12591259
auto* boundFunction = jsCast<JSBoundFunction*>(function);
1260-
if (boundFunction->m_isTainted)
1260+
if (boundFunction->isTainted())
12611261
vm.setMightBeExecutingTaintedCode();
12621262
if (!boundFunction->boundArgsLength()) {
12631263
// This is the simplest path, just replacing |this|. We do not need to go to executeBoundCall.

‎Source/JavaScriptCore/runtime/AbstractModuleRecord.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ class AbstractModuleRecord : public JSInternalFieldObjectImpl<2> {
159159
WriteBarrier<Unknown>& internalField(Field field) { return Base::internalField(static_cast<uint32_t>(field)); }
160160
WriteBarrier<Unknown> internalField(Field field) const { return Base::internalField(static_cast<uint32_t>(field)); }
161161

162+
DECLARE_VISIT_CHILDREN;
163+
162164
protected:
163165
AbstractModuleRecord(VM&, Structure*, const Identifier&);
164166
void finishCreation(JSGlobalObject*, VM&);
165167

166-
DECLARE_VISIT_CHILDREN;
167-
168168
void setModuleEnvironment(JSGlobalObject*, JSModuleEnvironment*);
169169

170170
private:

‎Source/JavaScriptCore/runtime/EvalExecutable.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class EvalExecutable : public GlobalExecutable {
6363

6464
DECLARE_INFO;
6565

66+
DECLARE_VISIT_CHILDREN;
67+
6668
unsigned numVariables() { return unlinkedCodeBlock()->numVariables(); }
6769
std::span<const Identifier> variables() const { return unlinkedCodeBlock()->variables(); }
6870

@@ -83,8 +85,6 @@ class EvalExecutable : public GlobalExecutable {
8385
using Base::finishCreation;
8486
EvalExecutable(JSGlobalObject*, const SourceCode&, LexicallyScopedFeatures, DerivedContextType, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, NeedsClassFieldInitializer, PrivateBrandRequirement);
8587

86-
DECLARE_VISIT_CHILDREN;
87-
8888
unsigned m_needsClassFieldInitializer : 1;
8989
unsigned m_privateBrandRequirement : 1;
9090

‎Source/JavaScriptCore/runtime/GenericArgumentsImpl.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ class GenericArgumentsImpl : public JSNonFinalObject {
3838
using Base = JSNonFinalObject;
3939
static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetOwnPropertyNames | OverridesPut | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero;
4040

41+
DECLARE_VISIT_CHILDREN;
42+
4143
protected:
4244
GenericArgumentsImpl(VM& vm, Structure* structure)
4345
: Base(vm, structure)
4446
{
4547
}
4648

47-
DECLARE_VISIT_CHILDREN;
4849
static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&);
4950
static bool getOwnPropertySlotByIndex(JSObject*, JSGlobalObject*, unsigned propertyName, PropertySlot&);
5051
static void getOwnPropertyNames(JSObject*, JSGlobalObject*, PropertyNameArray&, DontEnumPropertiesMode);

‎Source/JavaScriptCore/runtime/IntlCollator.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class IntlCollator final : public JSNonFinalObject {
5858

5959
DECLARE_INFO;
6060

61+
DECLARE_VISIT_CHILDREN;
62+
6163
void initializeCollator(JSGlobalObject*, JSValue locales, JSValue optionsValue);
6264
UCollationResult compareStrings(JSGlobalObject*, StringView, StringView) const;
6365
JSObject* resolvedOptions(JSGlobalObject*) const;
@@ -81,7 +83,6 @@ class IntlCollator final : public JSNonFinalObject {
8183
private:
8284
IntlCollator(VM&, Structure*);
8385
DECLARE_DEFAULT_FINISH_CREATION;
84-
DECLARE_VISIT_CHILDREN;
8586

8687
bool updateCanDoASCIIUCADUCETComparison() const;
8788

‎Source/JavaScriptCore/runtime/IntlDateTimeFormat.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class IntlDateTimeFormat final : public JSNonFinalObject {
6464

6565
DECLARE_INFO;
6666

67+
DECLARE_VISIT_CHILDREN;
68+
6769
enum class RequiredComponent : uint8_t { Date, Time, Any };
6870
enum class Defaults : uint8_t { Date, Time, All };
6971
void initializeDateTimeFormat(JSGlobalObject*, JSValue locales, JSValue options, RequiredComponent, Defaults);
@@ -84,14 +86,11 @@ class IntlDateTimeFormat final : public JSNonFinalObject {
8486
private:
8587
IntlDateTimeFormat(VM&, Structure*);
8688
DECLARE_DEFAULT_FINISH_CREATION;
87-
DECLARE_VISIT_CHILDREN;
8889

8990
static Vector<String> localeData(const String&, RelevantExtensionKey);
9091

9192
UDateIntervalFormat* createDateIntervalFormatIfNecessary(JSGlobalObject*);
9293

93-
static double handleDateTimeValue(JSGlobalObject*, JSValue);
94-
9594
enum class Weekday : uint8_t { None, Narrow, Short, Long };
9695
enum class Era : uint8_t { None, Narrow, Short, Long };
9796
enum class Year : uint8_t { None, TwoDigit, Numeric };

‎Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void IntlDateTimeFormatPrototype::finishCreation(VM& vm, JSGlobalObject* globalO
8989

9090
// HandleDateTimeValue ( dateTimeFormat, x )
9191
// https://tc39.es/proposal-temporal/#sec-temporal-handledatetimevalue
92-
double IntlDateTimeFormat::handleDateTimeValue(JSGlobalObject* globalObject, JSValue x)
92+
static double handleDateTimeValue(JSGlobalObject* globalObject, JSValue x)
9393
{
9494
VM& vm = globalObject->vm();
9595
auto scope = DECLARE_THROW_SCOPE(vm);
@@ -120,7 +120,7 @@ JSC_DEFINE_HOST_FUNCTION(intlDateTimeFormatFuncFormatDateTime, (JSGlobalObject*
120120
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.DateTimeFormat.prototype.format called on value that's not a DateTimeFormat"_s));
121121

122122
JSValue date = callFrame->argument(0);
123-
double value = IntlDateTimeFormat::handleDateTimeValue(globalObject, date);
123+
double value = handleDateTimeValue(globalObject, date);
124124
RETURN_IF_EXCEPTION(scope, { });
125125

126126
RELEASE_AND_RETURN(scope, JSValue::encode(format->format(globalObject, value)));
@@ -173,7 +173,7 @@ JSC_DEFINE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncFormatToParts, (JSGlobal
173173
return JSValue::encode(throwTypeError(globalObject, scope, "Intl.DateTimeFormat.prototype.formatToParts called on value that's not a DateTimeFormat"_s));
174174

175175
JSValue date = callFrame->argument(0);
176-
double value = IntlDateTimeFormat::handleDateTimeValue(globalObject, date);
176+
double value = handleDateTimeValue(globalObject, date);
177177
RETURN_IF_EXCEPTION(scope, { });
178178

179179
RELEASE_AND_RETURN(scope, JSValue::encode(dateTimeFormat->formatToParts(globalObject, value)));
@@ -196,9 +196,9 @@ JSC_DEFINE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncFormatRange, (JSGlobalOb
196196
if (startDateValue.isUndefined() || endDateValue.isUndefined())
197197
return throwVMTypeError(globalObject, scope, "startDate or endDate is undefined"_s);
198198

199-
double startDate = IntlDateTimeFormat::handleDateTimeValue(globalObject, startDateValue);
199+
double startDate = handleDateTimeValue(globalObject, startDateValue);
200200
RETURN_IF_EXCEPTION(scope, { });
201-
double endDate = IntlDateTimeFormat::handleDateTimeValue(globalObject, endDateValue);
201+
double endDate = handleDateTimeValue(globalObject, endDateValue);
202202
RETURN_IF_EXCEPTION(scope, { });
203203

204204
RELEASE_AND_RETURN(scope, JSValue::encode(dateTimeFormat->formatRange(globalObject, startDate, endDate)));
@@ -221,9 +221,9 @@ JSC_DEFINE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncFormatRangeToParts, (JSG
221221
if (startDateValue.isUndefined() || endDateValue.isUndefined())
222222
return throwVMTypeError(globalObject, scope, "startDate or endDate is undefined"_s);
223223

224-
double startDate = IntlDateTimeFormat::handleDateTimeValue(globalObject, startDateValue);
224+
double startDate = handleDateTimeValue(globalObject, startDateValue);
225225
RETURN_IF_EXCEPTION(scope, { });
226-
double endDate = IntlDateTimeFormat::handleDateTimeValue(globalObject, endDateValue);
226+
double endDate = handleDateTimeValue(globalObject, endDateValue);
227227
RETURN_IF_EXCEPTION(scope, { });
228228

229229
RELEASE_AND_RETURN(scope, JSValue::encode(dateTimeFormat->formatRangeToParts(globalObject, startDate, endDate)));

‎Source/JavaScriptCore/runtime/IntlLocale.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class IntlLocale final : public JSNonFinalObject {
5252

5353
DECLARE_INFO;
5454

55+
DECLARE_VISIT_CHILDREN;
56+
5557
void initializeLocale(JSGlobalObject*, const String& tag, JSValue optionsValue);
5658
void initializeLocale(JSGlobalObject*, JSValue tagValue, JSValue optionsValue);
5759
const String& maximal();
@@ -82,7 +84,6 @@ class IntlLocale final : public JSNonFinalObject {
8284
private:
8385
IntlLocale(VM&, Structure*);
8486
DECLARE_DEFAULT_FINISH_CREATION;
85-
DECLARE_VISIT_CHILDREN;
8687

8788
String keywordValue(ASCIILiteral, bool isBoolean = false) const;
8889

0 commit comments

Comments
 (0)