Changeset 266251 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Aug 27, 2020, 1:11:57 PM (5 years ago)
Author:
[email protected]
Message:

structureOrNull should take VM instead of getting it from the marked block
https://bugs.webkit.org/show_bug.cgi?id=215899

Reviewed by Yusuke Suzuki.

It's slightly faster use an existing VM over recomputing the address. It probably doesn't
happen to matter here for performance but it's good hygiene.

  • API/tests/JSWrapperMapTests.mm:

(+[JSWrapperMapTests testStructureIdentity]):

  • jit/JITOperations.cpp:
  • runtime/JSCJSValue.h:
  • runtime/JSCJSValueInlines.h:

(JSC::JSValue::structureOrNull const):
(JSC::JSValue::structureOrUndefined const): Deleted.

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/tests/JSWrapperMapTests.mm

    r251425 r266251  
    5858    JSGlobalContextRef contextRef = JSGlobalContextRetain(context.JSGlobalContextRef);
    5959    JSC::JSGlobalObject* globalObject = toJS(contextRef);
     60    JSC::VM& vm = globalObject->vm();
    6061
    6162    context[@"TestClass"] = [TestClass class];
     
    6465    JSC::JSValue aValue = toJS(globalObject, aWrapper.JSValueRef);
    6566    JSC::JSValue bValue = toJS(globalObject, bWrapper.JSValueRef);
    66     JSC::Structure* aStructure = aValue.structureOrNull();
    67     JSC::Structure* bStructure = bValue.structureOrNull();
     67    JSC::Structure* aStructure = aValue.structureOrNull(vm);
     68    JSC::Structure* bStructure = bValue.structureOrNull(vm);
    6869    checkResult(@"structure should not be null", !!aStructure);
    6970    checkResult(@"both wrappers should share the same structure", aStructure == bStructure);
  • trunk/Source/JavaScriptCore/ChangeLog

    r266250 r266251  
     12020-08-27  Keith Miller  <[email protected]>
     2
     3        structureOrNull should take VM instead of getting it from the marked block
     4        https://bugs.webkit.org/show_bug.cgi?id=215899
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        It's slightly faster use an existing VM over recomputing the address. It probably doesn't
     9        happen to matter here for performance but it's good hygiene.
     10
     11        * API/tests/JSWrapperMapTests.mm:
     12        (+[JSWrapperMapTests testStructureIdentity]):
     13        * jit/JITOperations.cpp:
     14        * runtime/JSCJSValue.h:
     15        * runtime/JSCJSValueInlines.h:
     16        (JSC::JSValue::structureOrNull const):
     17        (JSC::JSValue::structureOrUndefined const): Deleted.
     18
    1192020-08-27  Yusuke Suzuki  <[email protected]>
    220
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r265600 r266251  
    213213
    214214    CodeBlock* codeBlock = callFrame->codeBlock();
    215     if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier) && !slot.isTaintedByOpaqueObject() && (slot.isCacheableValue() || slot.isCacheableGetter() || slot.isUnset()))
     215    if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier) && !slot.isTaintedByOpaqueObject() && (slot.isCacheableValue() || slot.isCacheableGetter() || slot.isUnset()))
    216216        repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::Try);
    217217
     
    272272
    273273    CodeBlock* codeBlock = callFrame->codeBlock();
    274     if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
     274    if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
    275275        repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::Direct);
    276276
     
    335335       
    336336        CodeBlock* codeBlock = callFrame->codeBlock();
    337         if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
     337        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
    338338            repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::Normal);
    339339        return found ? slot.getValue(globalObject, ident) : jsUndefined();
     
    395395       
    396396        CodeBlock* codeBlock = callFrame->codeBlock();
    397         if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
     397        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
    398398            repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::WithThis);
    399399        return found ? slot.getValue(globalObject, ident) : jsUndefined();
     
    21472147               
    21482148                CacheableIdentifier identifier = CacheableIdentifier::createFromCell(subscript.asCell());
    2149                 if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
     2149                if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
    21502150                    repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::NormalByVal);
    21512151                return found ? slot.getValue(globalObject, propertyName) : jsUndefined();
     
    22442244
    22452245        CacheableIdentifier identifier = CacheableIdentifier::createFromCell(fieldNameValue.asCell());
    2246         if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
     2246        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
    22472247            repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::PrivateName);
    22482248        return JSValue::encode(slot.getValue(globalObject, fieldName));
     
    23592359
    23602360    DeletePropertySlot slot;
    2361     Structure* oldStructure = baseValue.structureOrNull();
     2361    Structure* oldStructure = baseValue.structureOrNull(vm);
    23622362
    23632363    CacheableIdentifier identifier = CacheableIdentifier::createFromRawBits(rawCacheableIdentifier);
     
    23702370        if (!parseIndex(ident)) {
    23712371            CodeBlock* codeBlock = callFrame->codeBlock();
    2372             if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
     2372            if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
    23732373                repatchDeleteBy(globalObject, codeBlock, slot, baseValue, oldStructure, identifier, *stubInfo, DelByKind::Normal, ecmaMode);
    23742374        }
     
    24232423
    24242424    DeletePropertySlot slot;
    2425     Structure* oldStructure = baseValue.structureOrNull();
     2425    Structure* oldStructure = baseValue.structureOrNull(vm);
    24262426
    24272427    bool result = deleteByVal(globalObject, vm, slot, baseValue, subscript, ecmaMode);
     
    24352435            CodeBlock* codeBlock = callFrame->codeBlock();
    24362436            CacheableIdentifier identifier = CacheableIdentifier::createFromCell(subscript.asCell());
    2437             if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
     2437            if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
    24382438                repatchDeleteBy(globalObject, codeBlock, slot, baseValue, oldStructure, identifier, *stubInfo, DelByKind::NormalByVal, ecmaMode);
    24392439        }
     
    25152515   
    25162516    CodeBlock* codeBlock = callFrame->codeBlock();
    2517     if (stubInfo->considerCachingGeneric(vm, codeBlock, value.structureOrNull()))
     2517    if (stubInfo->considerCachingGeneric(vm, codeBlock, value.structureOrNull(vm)))
    25182518        repatchInstanceOf(globalObject, codeBlock, value, proto, *stubInfo, result);
    25192519   
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.h

    r266107 r266251  
    339339    JS_EXPORT_PRIVATE bool isValidCallee();
    340340
    341     Structure* structureOrNull() const;
    342     JSValue structureOrUndefined() const;
     341    Structure* structureOrNull(VM&) const;
    343342
    344343    JS_EXPORT_PRIVATE void dump(PrintStream&) const;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r266107 r266251  
    11061106}
    11071107
    1108 inline Structure* JSValue::structureOrNull() const
     1108inline Structure* JSValue::structureOrNull(VM& vm) const
    11091109{
    11101110    if (isCell())
    1111         return asCell()->structure();
     1111        return asCell()->structure(vm);
    11121112    return nullptr;
    1113 }
    1114 
    1115 inline JSValue JSValue::structureOrUndefined() const
    1116 {
    1117     if (isCell())
    1118         return JSValue(asCell()->structure());
    1119     return jsUndefined();
    11201113}
    11211114
Note: See TracChangeset for help on using the changeset viewer.