Changeset 250289 in webkit


Ignore:
Timestamp:
Sep 24, 2019 12:43:24 AM (5 years ago)
Author:
mark.lam@apple.com
Message:

Refactor cellSize() out of VMInspector::verifyCellSize().
https://bugs.webkit.org/show_bug.cgi?id=202132

Reviewed by Saam Barati.

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • runtime/CellSize.h: Added.

(JSC::isDynamicallySizedType):
(JSC::cellSize):

  • runtime/DirectArguments.h:
  • runtime/JSBigInt.h:
  • runtime/JSModuleNamespaceObject.h:
  • runtime/JSType.h:

(JSC::isDynamicallySizedType): Deleted.

  • tools/VMInspectorInlines.h:

(JSC::VMInspector::verifyCellSize):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r250285 r250289  
    768768    runtime/CallData.h
    769769    runtime/CatchScope.h
     770    runtime/CellSize.h
    770771    runtime/ClassInfo.h
    771772    runtime/CodeSpecializationKind.h
  • trunk/Source/JavaScriptCore/ChangeLog

    r250285 r250289  
     12019-09-24  Mark Lam  <mark.lam@apple.com>
     2
     3        Refactor cellSize() out of VMInspector::verifyCellSize().
     4        https://bugs.webkit.org/show_bug.cgi?id=202132
     5
     6        Reviewed by Saam Barati.
     7
     8        * CMakeLists.txt:
     9        * JavaScriptCore.xcodeproj/project.pbxproj:
     10        * runtime/CellSize.h: Added.
     11        (JSC::isDynamicallySizedType):
     12        (JSC::cellSize):
     13        * runtime/DirectArguments.h:
     14        * runtime/JSBigInt.h:
     15        * runtime/JSModuleNamespaceObject.h:
     16        * runtime/JSType.h:
     17        (JSC::isDynamicallySizedType): Deleted.
     18        * tools/VMInspectorInlines.h:
     19        (JSC::VMInspector::verifyCellSize):
     20
    1212019-09-23  Mark Lam  <mark.lam@apple.com>
    222
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r250285 r250289  
    19121912                FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEB51F6B1A97B688001F921C /* Regress141809.mm */; };
    19131913                FEB58C15187B8B160098EF0B /* ErrorHandlingScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FEB58C13187B8B160098EF0B /* ErrorHandlingScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1914                FEC160322339E9F900A04CB8 /* CellSize.h in Headers */ = {isa = PBXBuildFile; fileRef = FEC160312339E9F900A04CB8 /* CellSize.h */; };
    19141915                FEC5797323105B5100BCA83F /* VMInspectorInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEC5797223105B4800BCA83F /* VMInspectorInlines.h */; };
    19151916                FEC5797623105F4E00BCA83F /* Integrity.h in Headers */ = {isa = PBXBuildFile; fileRef = FEC5797523105F4300BCA83F /* Integrity.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    51395140                FEB58C12187B8B160098EF0B /* ErrorHandlingScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorHandlingScope.cpp; sourceTree = "<group>"; };
    51405141                FEB58C13187B8B160098EF0B /* ErrorHandlingScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorHandlingScope.h; sourceTree = "<group>"; };
     5142                FEC160312339E9F900A04CB8 /* CellSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CellSize.h; sourceTree = "<group>"; };
    51415143                FEC5797223105B4800BCA83F /* VMInspectorInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMInspectorInlines.h; sourceTree = "<group>"; };
    51425144                FEC5797423105F4200BCA83F /* Integrity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Integrity.cpp; sourceTree = "<group>"; };
     
    69506952                                FE80C1981D775FB4008510C0 /* CatchScope.cpp */,
    69516953                                FE80C1961D775B27008510C0 /* CatchScope.h */,
     6954                                FEC160312339E9F900A04CB8 /* CellSize.h */,
    69526955                                E326C4961ECBEF5700A9A905 /* ClassInfo.cpp */,
    69536956                                BC6AAAE40E1F426500AD87D8 /* ClassInfo.h */,
     
    90309033                                0F1C3DDA1BBCE09E00E523E4 /* CellState.h in Headers */,
    90319034                                BC6AAAE50E1F426500AD87D8 /* ClassInfo.h in Headers */,
     9035                                FEC160322339E9F900A04CB8 /* CellSize.h in Headers */,
    90329036                                0FE050261AA9095600D33B33 /* ClonedArguments.h in Headers */,
    90339037                                BC18C45E0E16F5CD00B34460 /* CLoopStack.h in Headers */,
  • trunk/Source/JavaScriptCore/runtime/DirectArguments.h

    r250285 r250289  
    186186    MappedArguments m_mappedArguments; // If non-null, it means that length, callee, and caller are fully materialized properties.
    187187
    188     friend class VMInspector;
     188    friend size_t cellSize(VM&, JSCell*);
    189189};
    190190
  • trunk/Source/JavaScriptCore/runtime/JSBigInt.h

    r250285 r250289  
    251251    bool m_sign { false };
    252252
    253     friend class VMInspector;
     253    friend size_t cellSize(VM&, JSCell*);
    254254};
    255255
  • trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h

    r250285 r250289  
    105105    WriteBarrier<AbstractModuleRecord> m_moduleRecord;
    106106
    107     friend class VMInspector;
     107    friend size_t cellSize(VM&, JSCell*);
    108108};
    109109
  • trunk/Source/JavaScriptCore/runtime/JSType.h

    r250285 r250289  
    141141}
    142142
    143 inline constexpr bool isDynamicallySizedType(JSType type)
    144 {
    145     if (type == BigIntType
    146         || type == DirectArgumentsType
    147         || type == FinalObjectType
    148         || type == LexicalEnvironmentType
    149         || type == ModuleEnvironmentType
    150         || type == ModuleNamespaceObjectType)
    151         return true;
    152     return false;
    153 }
    154 
    155143} // namespace JSC
    156144
  • trunk/Source/JavaScriptCore/tools/VMInspectorInlines.h

    r250285 r250289  
    2626#pragma once
    2727
    28 #include "DirectArguments.h"
    29 #include "JSBigInt.h"
    30 #include "JSLexicalEnvironment.h"
    31 #include "JSModuleEnvironment.h"
    32 #include "JSModuleNamespaceObject.h"
     28#include "CellSize.h"
    3329#include "VMInspector.h"
    3430#include <wtf/Assertions.h>
     
    5248    AUDIT_VERIFY(action, verifier, cellType == structure->m_blob.type(), cell, cellType, structure->m_blob.type());
    5349
    54     if (isDynamicallySizedType(cellType)) {
    55         size_t cellSize = 0;
    56         switch (cellType) {
    57         case BigIntType: {
    58             auto* bigInt = jsCast<JSBigInt*>(cell);
    59             cellSize = JSBigInt::allocationSize(bigInt->length());
    60             break;
    61         }
    62         case DirectArgumentsType: {
    63             auto* args = jsCast<DirectArguments*>(cell);
    64             cellSize = DirectArguments::allocationSize(args->m_minCapacity);
    65             break;
    66         }
    67         case FinalObjectType:
    68             cellSize = JSFinalObject::allocationSize(structure->inlineCapacity());
    69             break;
    70         case LexicalEnvironmentType: {
    71             auto* env = jsCast<JSLexicalEnvironment*>(cell);
    72             cellSize = JSLexicalEnvironment::allocationSize(env->symbolTable());
    73             break;
    74         }
    75         case ModuleEnvironmentType: {
    76             auto* env = jsCast<JSModuleEnvironment*>(cell);
    77             cellSize = JSModuleEnvironment::allocationSize(env->symbolTable());
    78             break;
    79         }
    80         case ModuleNamespaceObjectType: {
    81             auto* obj = jsCast<JSModuleNamespaceObject*>(cell);
    82             cellSize = JSModuleNamespaceObject::allocationSize(obj->m_names.capacity());
    83             break;
    84         }
    85         default:
    86             RELEASE_ASSERT_NOT_REACHED();
    87         }
    88         AUDIT_VERIFY(action, verifier, cellSize <= allocatorCellSize, cell, cellType, cellSize, allocatorCellSize);
    89         AUDIT_VERIFY(action, verifier, cellSize >= classInfo->staticClassSize, cell, cellType, cellSize, classInfo->staticClassSize);
    90     } else
    91         AUDIT_VERIFY(action, verifier, classInfo->staticClassSize <= allocatorCellSize, cell, cellType, classInfo->staticClassSize, allocatorCellSize);
     50    size_t size = cellSize(vm, cell);
     51    AUDIT_VERIFY(action, verifier, size <= allocatorCellSize, cell, cellType, size, allocatorCellSize, classInfo->staticClassSize);
     52    if (isDynamicallySizedType(cellType))
     53        AUDIT_VERIFY(action, verifier, size >= classInfo->staticClassSize, cell, cellType, size, classInfo->staticClassSize);
    9254
    9355    return true;
Note: See TracChangeset for help on using the changeset viewer.