Skip to content

Commit ed9f215

Browse files
author
Alexey Shvayka
committed
[JSC] Validate that HasStaticPropertyTable is present only if there is a static property table
https://bugs.webkit.org/show_bug.cgi?id=270889 <rdar://problem/124493762> Reviewed by Yusuke Suzuki. This change: 1) Removes empty static property tables. 2) Removes HasStaticPropertyTable structure flag from classes without static property tables. 3) Fixes bindings generator condition for setting HasStaticPropertyTable to match the condition for setting `staticPropHashTable`, which isn't observable because we eagerly reify all static properties. 4) Adds an assertion to validate that HasStaticPropertyTable is present only if there is an own or inherited static property table. 1) and 2) are performance micro-optimizations that avoid calling into getOwnStaticPropertySlot() for property lookup if there is no static property table, own nor inherited, while 4) ensures consistency across the JSC codebase. * Source/JavaScriptCore/runtime/ArrayIteratorPrototype.h: * Source/JavaScriptCore/runtime/AsyncGeneratorFunctionPrototype.h: * Source/JavaScriptCore/runtime/IntlLocaleConstructor.h: * Source/JavaScriptCore/runtime/JSModuleLoader.h: * Source/JavaScriptCore/runtime/MapConstructor.cpp: * Source/JavaScriptCore/runtime/MapPrototype.h: * Source/JavaScriptCore/runtime/RegExpStringIteratorPrototype.h: * Source/JavaScriptCore/runtime/SetPrototype.h: * Source/JavaScriptCore/runtime/StringIteratorPrototype.h: * Source/JavaScriptCore/runtime/Structure.cpp: (JSC::Structure::validateFlags): * Source/JavaScriptCore/tools/JSDollarVM.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyArrayConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyArrayConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyArrayPrototype.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyArrayPrototype.h: * Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorPrototype.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorPrototype.h: * Source/JavaScriptCore/wasm/js/WebAssemblyExceptionConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyExceptionConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.h: * Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorPrototype.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorPrototype.h: * Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyModulePrototype.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyModulePrototype.h: * Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorPrototype.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorPrototype.h: * Source/JavaScriptCore/wasm/js/WebAssemblyStructConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyStructConstructor.h: * Source/JavaScriptCore/wasm/js/WebAssemblyStructPrototype.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyStructPrototype.h: * Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp: * Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h: * Source/WebCore/bindings/scripts/CodeGeneratorJS.pm: (GeneratePrototypeDeclaration): * Source/WebCore/bindings/scripts/test/JS/*: Updated. Canonical link: https://commits.webkit.org/276069@main
1 parent 942b7ee commit ed9f215

53 files changed

Lines changed: 66 additions & 172 deletions

File tree

Some content is hidden

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

‎Source/JavaScriptCore/runtime/ArrayIteratorPrototype.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace JSC {
3232
class ArrayIteratorPrototype final : public JSNonFinalObject {
3333
public:
3434
using Base = JSNonFinalObject;
35-
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
35+
static constexpr unsigned StructureFlags = Base::StructureFlags;
3636

3737
template<typename CellType, SubspaceAccess>
3838
static GCClient::IsoSubspace* subspaceFor(VM& vm)

‎Source/JavaScriptCore/runtime/AsyncGeneratorFunctionPrototype.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace JSC {
3232
class AsyncGeneratorFunctionPrototype final : public JSNonFinalObject {
3333
public:
3434
using Base = JSNonFinalObject;
35-
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
35+
static constexpr unsigned StructureFlags = Base::StructureFlags;
3636

3737
template<typename CellType, SubspaceAccess>
3838
static GCClient::IsoSubspace* subspaceFor(VM& vm)

‎Source/JavaScriptCore/runtime/IntlLocaleConstructor.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class IntlLocalePrototype;
3535
class IntlLocaleConstructor final : public InternalFunction {
3636
public:
3737
using Base = InternalFunction;
38-
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
38+
static constexpr unsigned StructureFlags = Base::StructureFlags;
3939

4040
static IntlLocaleConstructor* create(VM&, Structure*, IntlLocalePrototype*);
4141
static Structure* createStructure(VM&, JSGlobalObject*, JSValue);

‎Source/JavaScriptCore/runtime/JSModuleLoader.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SourceCode;
3838
class JSModuleLoader final : public JSNonFinalObject {
3939
public:
4040
using Base = JSNonFinalObject;
41-
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
41+
static constexpr unsigned StructureFlags = Base::StructureFlags;
4242

4343
template<typename CellType, SubspaceAccess>
4444
static GCClient::IsoSubspace* subspaceFor(VM& vm)

‎Source/JavaScriptCore/runtime/MapConstructor.cpp‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,9 @@
3434
#include "MapPrototype.h"
3535
#include "VMInlines.h"
3636

37-
#include "MapConstructor.lut.h"
38-
3937
namespace JSC {
4038

41-
const ClassInfo MapConstructor::s_info = { "Function"_s, &Base::s_info, &mapConstructorTable, nullptr, CREATE_METHOD_TABLE(MapConstructor) };
42-
43-
/* Source for MapConstructor.lut.h
44-
@begin mapConstructorTable
45-
@end
46-
*/
39+
const ClassInfo MapConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(MapConstructor) };
4740

4841
void MapConstructor::finishCreation(VM& vm, MapPrototype* mapPrototype)
4942
{

‎Source/JavaScriptCore/runtime/MapPrototype.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MapPrototype final : public JSNonFinalObject {
4040
return &vm.plainObjectSpace();
4141
}
4242

43-
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
43+
static constexpr unsigned StructureFlags = Base::StructureFlags;
4444

4545
static MapPrototype* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
4646
{

‎Source/JavaScriptCore/runtime/RegExpStringIteratorPrototype.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace JSC {
3333
class RegExpStringIteratorPrototype final : public JSNonFinalObject {
3434
public:
3535
using Base = JSNonFinalObject;
36-
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
36+
static constexpr unsigned StructureFlags = Base::StructureFlags;
3737

3838
template<typename CellType, SubspaceAccess>
3939
static GCClient::IsoSubspace* subspaceFor(VM& vm)

‎Source/JavaScriptCore/runtime/SetPrototype.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class SetPrototype final : public JSNonFinalObject {
4040
return &vm.plainObjectSpace();
4141
}
4242

43-
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
43+
static constexpr unsigned StructureFlags = Base::StructureFlags;
4444

4545
static SetPrototype* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
4646
{

‎Source/JavaScriptCore/runtime/StringIteratorPrototype.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace JSC {
3333
class StringIteratorPrototype final : public JSNonFinalObject {
3434
public:
3535
using Base = JSNonFinalObject;
36-
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
36+
static constexpr unsigned StructureFlags = Base::StructureFlags;
3737

3838
template<typename CellType, SubspaceAccess>
3939
static GCClient::IsoSubspace* subspaceFor(VM& vm)

‎Source/JavaScriptCore/runtime/Structure.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ void Structure::dumpStatistics()
130130
#if ASSERT_ENABLED
131131
void Structure::validateFlags()
132132
{
133+
bool hasStaticPropertyTable = false;
134+
for (const ClassInfo* ci = classInfoForCells(); ci; ci = ci->parentClass) {
135+
if (ci->staticPropHashTable)
136+
hasStaticPropertyTable = true;
137+
}
138+
RELEASE_ASSERT(hasStaticPropertyTable == typeInfo().hasStaticPropertyTable());
139+
133140
const MethodTable& methodTable = m_classInfo->methodTable;
134141

135142
bool overridesGetCallData = methodTable.getCallData != JSCell::getCallData;

0 commit comments

Comments
 (0)