Title: [266251] trunk/Source/_javascript_Core
Revision
266251
Author
[email protected]
Date
2020-08-27 13:11:57 -0700 (Thu, 27 Aug 2020)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/tests/JSWrapperMapTests.mm (266250 => 266251)


--- trunk/Source/_javascript_Core/API/tests/JSWrapperMapTests.mm	2020-08-27 20:01:04 UTC (rev 266250)
+++ trunk/Source/_javascript_Core/API/tests/JSWrapperMapTests.mm	2020-08-27 20:11:57 UTC (rev 266251)
@@ -57,6 +57,7 @@
     JSContext* context = [[JSContext alloc] init];
     JSGlobalContextRef contextRef = JSGlobalContextRetain(context.JSGlobalContextRef);
     JSC::JSGlobalObject* globalObject = toJS(contextRef);
+    JSC::VM& vm = globalObject->vm();
 
     context[@"TestClass"] = [TestClass class];
     JSValue* aWrapper = [context evaluateScript:@"new TestClass()"];
@@ -63,8 +64,8 @@
     JSValue* bWrapper = [context evaluateScript:@"new TestClass()"];
     JSC::JSValue aValue = toJS(globalObject, aWrapper.JSValueRef);
     JSC::JSValue bValue = toJS(globalObject, bWrapper.JSValueRef);
-    JSC::Structure* aStructure = aValue.structureOrNull();
-    JSC::Structure* bStructure = bValue.structureOrNull();
+    JSC::Structure* aStructure = aValue.structureOrNull(vm);
+    JSC::Structure* bStructure = bValue.structureOrNull(vm);
     checkResult(@"structure should not be null", !!aStructure);
     checkResult(@"both wrappers should share the same structure", aStructure == bStructure);
 }

Modified: trunk/Source/_javascript_Core/ChangeLog (266250 => 266251)


--- trunk/Source/_javascript_Core/ChangeLog	2020-08-27 20:01:04 UTC (rev 266250)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-08-27 20:11:57 UTC (rev 266251)
@@ -1,3 +1,21 @@
+2020-08-27  Keith Miller  <[email protected]>
+
+        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.
+
 2020-08-27  Yusuke Suzuki  <[email protected]>
 
         [JSC] Use auxiliary memory for JSBigInt storage

Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (266250 => 266251)


--- trunk/Source/_javascript_Core/jit/JITOperations.cpp	2020-08-27 20:01:04 UTC (rev 266250)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp	2020-08-27 20:11:57 UTC (rev 266251)
@@ -212,7 +212,7 @@
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     CodeBlock* codeBlock = callFrame->codeBlock();
-    if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier) && !slot.isTaintedByOpaqueObject() && (slot.isCacheableValue() || slot.isCacheableGetter() || slot.isUnset()))
+    if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier) && !slot.isTaintedByOpaqueObject() && (slot.isCacheableValue() || slot.isCacheableGetter() || slot.isUnset()))
         repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::Try);
 
     return JSValue::encode(slot.getPureResult());
@@ -271,7 +271,7 @@
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
 
     CodeBlock* codeBlock = callFrame->codeBlock();
-    if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
+    if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
         repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::Direct);
 
     RELEASE_AND_RETURN(scope, JSValue::encode(found ? slot.getValue(globalObject, ident) : jsUndefined()));
@@ -334,7 +334,7 @@
         LOG_IC((ICEvent::OperationGetByIdOptimize, baseValue.classInfoOrNull(vm), ident, baseValue == slot.slotBase()));
         
         CodeBlock* codeBlock = callFrame->codeBlock();
-        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
+        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
             repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::Normal);
         return found ? slot.getValue(globalObject, ident) : jsUndefined();
     }));
@@ -394,7 +394,7 @@
         LOG_IC((ICEvent::OperationGetByIdWithThisOptimize, baseValue.classInfoOrNull(vm), ident, baseValue == slot.slotBase()));
         
         CodeBlock* codeBlock = callFrame->codeBlock();
-        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
+        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
             repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::WithThis);
         return found ? slot.getValue(globalObject, ident) : jsUndefined();
     }));
@@ -2146,7 +2146,7 @@
                 LOG_IC((ICEvent::OperationGetByValOptimize, baseValue.classInfoOrNull(vm), propertyName, baseValue == slot.slotBase())); 
                 
                 CacheableIdentifier identifier = CacheableIdentifier::createFromCell(subscript.asCell());
-                if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
+                if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
                     repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::NormalByVal);
                 return found ? slot.getValue(globalObject, propertyName) : jsUndefined();
             }));
@@ -2243,7 +2243,7 @@
         LOG_IC((ICEvent::OperationGetPrivateNameOptimize, baseValue.classInfoOrNull(vm), fieldName, true));
 
         CacheableIdentifier identifier = CacheableIdentifier::createFromCell(fieldNameValue.asCell());
-        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
+        if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
             repatchGetBy(globalObject, codeBlock, baseValue, identifier, slot, *stubInfo, GetByKind::PrivateName);
         return JSValue::encode(slot.getValue(globalObject, fieldName));
     }
@@ -2358,7 +2358,7 @@
     JSValue baseValue = JSValue::decode(encodedBase);
 
     DeletePropertySlot slot;
-    Structure* oldStructure = baseValue.structureOrNull();
+    Structure* oldStructure = baseValue.structureOrNull(vm);
 
     CacheableIdentifier identifier = CacheableIdentifier::createFromRawBits(rawCacheableIdentifier);
     Identifier ident = Identifier::fromUid(vm, identifier.uid());
@@ -2369,7 +2369,7 @@
     if (baseValue.isObject()) {
         if (!parseIndex(ident)) {
             CodeBlock* codeBlock = callFrame->codeBlock();
-            if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
+            if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
                 repatchDeleteBy(globalObject, codeBlock, slot, baseValue, oldStructure, identifier, *stubInfo, DelByKind::Normal, ecmaMode);
         }
     }
@@ -2422,7 +2422,7 @@
     JSValue subscript = JSValue::decode(encodedSubscript);
 
     DeletePropertySlot slot;
-    Structure* oldStructure = baseValue.structureOrNull();
+    Structure* oldStructure = baseValue.structureOrNull(vm);
 
     bool result = deleteByVal(globalObject, vm, slot, baseValue, subscript, ecmaMode);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
@@ -2434,7 +2434,7 @@
         if (subscript.isSymbol() || !parseIndex(propertyName)) {
             CodeBlock* codeBlock = callFrame->codeBlock();
             CacheableIdentifier identifier = CacheableIdentifier::createFromCell(subscript.asCell());
-            if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(), identifier))
+            if (stubInfo->considerCachingBy(vm, codeBlock, baseValue.structureOrNull(vm), identifier))
                 repatchDeleteBy(globalObject, codeBlock, slot, baseValue, oldStructure, identifier, *stubInfo, DelByKind::NormalByVal, ecmaMode);
         }
     }
@@ -2514,7 +2514,7 @@
     RETURN_IF_EXCEPTION(scope, JSValue::encode(jsUndefined()));
     
     CodeBlock* codeBlock = callFrame->codeBlock();
-    if (stubInfo->considerCachingGeneric(vm, codeBlock, value.structureOrNull()))
+    if (stubInfo->considerCachingGeneric(vm, codeBlock, value.structureOrNull(vm)))
         repatchInstanceOf(globalObject, codeBlock, value, proto, *stubInfo, result);
     
     return JSValue::encode(jsBoolean(result));

Modified: trunk/Source/_javascript_Core/runtime/JSCJSValue.h (266250 => 266251)


--- trunk/Source/_javascript_Core/runtime/JSCJSValue.h	2020-08-27 20:01:04 UTC (rev 266250)
+++ trunk/Source/_javascript_Core/runtime/JSCJSValue.h	2020-08-27 20:11:57 UTC (rev 266251)
@@ -338,8 +338,7 @@
     JSCell* asCell() const;
     JS_EXPORT_PRIVATE bool isValidCallee();
 
-    Structure* structureOrNull() const;
-    JSValue structureOrUndefined() const;
+    Structure* structureOrNull(VM&) const;
 
     JS_EXPORT_PRIVATE void dump(PrintStream&) const;
     void dumpInContext(PrintStream&, DumpContext*) const;

Modified: trunk/Source/_javascript_Core/runtime/JSCJSValueInlines.h (266250 => 266251)


--- trunk/Source/_javascript_Core/runtime/JSCJSValueInlines.h	2020-08-27 20:01:04 UTC (rev 266250)
+++ trunk/Source/_javascript_Core/runtime/JSCJSValueInlines.h	2020-08-27 20:11:57 UTC (rev 266251)
@@ -1105,20 +1105,13 @@
     return synthesizePrototype(globalObject);
 }
 
-inline Structure* JSValue::structureOrNull() const
+inline Structure* JSValue::structureOrNull(VM& vm) const
 {
     if (isCell())
-        return asCell()->structure();
+        return asCell()->structure(vm);
     return nullptr;
 }
 
-inline JSValue JSValue::structureOrUndefined() const
-{
-    if (isCell())
-        return JSValue(asCell()->structure());
-    return jsUndefined();
-}
-
 // ECMA 11.9.3
 inline bool JSValue::equal(JSGlobalObject* globalObject, JSValue v1, JSValue v2)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to