Title: [254416] trunk/Source
Revision
254416
Author
[email protected]
Date
2020-01-12 14:42:53 -0800 (Sun, 12 Jan 2020)

Log Message

[WebCore] Reorganize JSType in WebCore to offer more bits to JSC
https://bugs.webkit.org/show_bug.cgi?id=206141

Reviewed by Keith Miller.

Source/_javascript_Core:

* runtime/JSType.h:

Source/WebCore:

This patch reorganize JSType a bit to offer more bits to JSC. Then JSC can use JSType for types easily.

* bindings/js/JSDOMWrapper.h:
* bindings/js/JSElementCustom.h:
(JSC::JSCastingHelpers::InheritsTraits<WebCore::JSElement>::inherits):
* domjit/DOMJITHelpers.h:
(WebCore::DOMJIT::branchIfElement):
(WebCore::DOMJIT::branchIfNotElement):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (254415 => 254416)


--- trunk/Source/_javascript_Core/ChangeLog	2020-01-12 21:30:19 UTC (rev 254415)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-01-12 22:42:53 UTC (rev 254416)
@@ -1,3 +1,12 @@
+2020-01-12  Yusuke Suzuki  <[email protected]>
+
+        [WebCore] Reorganize JSType in WebCore to offer more bits to JSC
+        https://bugs.webkit.org/show_bug.cgi?id=206141
+
+        Reviewed by Keith Miller.
+
+        * runtime/JSType.h:
+
 2020-01-11  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, suppress warnings in GCC, part 2

Modified: trunk/Source/_javascript_Core/runtime/JSType.h (254415 => 254416)


--- trunk/Source/_javascript_Core/runtime/JSType.h	2020-01-12 21:30:19 UTC (rev 254415)
+++ trunk/Source/_javascript_Core/runtime/JSType.h	2020-01-12 22:42:53 UTC (rev 254416)
@@ -137,7 +137,7 @@
 static constexpr uint32_t NumberOfTypedArrayTypesExcludingDataView = NumberOfTypedArrayTypes - 1;
 
 static_assert(sizeof(JSType) == sizeof(uint8_t), "sizeof(JSType) is one byte.");
-static_assert(LastJSCObjectType < 128, "The highest bit is reserved for embedder's extension.");
+static_assert(LastJSCObjectType < 0b11100000, "Embedder can use 0b11100000 or upper.");
 
 inline constexpr bool isTypedArrayType(JSType type)
 {

Modified: trunk/Source/WebCore/ChangeLog (254415 => 254416)


--- trunk/Source/WebCore/ChangeLog	2020-01-12 21:30:19 UTC (rev 254415)
+++ trunk/Source/WebCore/ChangeLog	2020-01-12 22:42:53 UTC (rev 254416)
@@ -1,3 +1,19 @@
+2020-01-12  Yusuke Suzuki  <[email protected]>
+
+        [WebCore] Reorganize JSType in WebCore to offer more bits to JSC
+        https://bugs.webkit.org/show_bug.cgi?id=206141
+
+        Reviewed by Keith Miller.
+
+        This patch reorganize JSType a bit to offer more bits to JSC. Then JSC can use JSType for types easily.
+
+        * bindings/js/JSDOMWrapper.h:
+        * bindings/js/JSElementCustom.h:
+        (JSC::JSCastingHelpers::InheritsTraits<WebCore::JSElement>::inherits):
+        * domjit/DOMJITHelpers.h:
+        (WebCore::DOMJIT::branchIfElement):
+        (WebCore::DOMJIT::branchIfNotElement):
+
 2019-12-20  Darin Adler  <[email protected]>
 
         Remove unneeded MemoryIDBBackingStore::create

Modified: trunk/Source/WebCore/bindings/js/JSDOMWrapper.h (254415 => 254416)


--- trunk/Source/WebCore/bindings/js/JSDOMWrapper.h	2020-01-12 21:30:19 UTC (rev 254415)
+++ trunk/Source/WebCore/bindings/js/JSDOMWrapper.h	2020-01-12 22:42:53 UTC (rev 254416)
@@ -29,18 +29,18 @@
 
 class ScriptExecutionContext;
 
-// JSC allows us to extend JSType. If the highest bit is set, we can add any Object types and they are
+// JSC allows us to extend JSType. If the highest 3 bits are set, we can add any Object types and they are
 // recognized as OtherObj in JSC. And we encode Node type into JSType if the given JSType is subclass of Node.
-// offset | 7 | 6 | 5   4 | 3   2   1   0  |
-// value  | 1 | 0 |  Non-node DOM types    |
+// offset | 7 | 6 | 5 | 4   3   2   1   0  |
+// value  | 1 | 1 | 1 | Non-node DOM types |
 // If the given JSType is a subclass of Node, the format is the following.
-// offset | 7 | 6 | 5   4 | 3   2   1   0  |
-// value  | 1 | 1 |  Kind |       NodeType |
+// offset | 7 | 6 | 5 | 4 | 3   2   1   0  |
+// value  | 1 | 1 | 1 | 1 |    NodeType    |
+
+static const uint8_t JSDOMWrapperType                = 0b11101110;
+static const uint8_t JSEventType                     = 0b11101111;
+static const uint8_t JSNodeType                      = 0b11110000;
 static const uint8_t JSNodeTypeMask                  = 0b00001111;
-
-static const uint8_t JSDOMWrapperType                = 0b10000000;
-static const uint8_t JSEventType                     = 0b10000001;
-static const uint8_t JSNodeType                      = 0b11000000;
 static const uint8_t JSTextNodeType                  = JSNodeType | NodeConstants::TEXT_NODE;
 static const uint8_t JSProcessingInstructionNodeType = JSNodeType | NodeConstants::PROCESSING_INSTRUCTION_NODE;
 static const uint8_t JSDocumentTypeNodeType          = JSNodeType | NodeConstants::DOCUMENT_TYPE_NODE;
@@ -49,7 +49,7 @@
 static const uint8_t JSCommentNodeType               = JSNodeType | NodeConstants::COMMENT_NODE;
 static const uint8_t JSCDATASectionNodeType          = JSNodeType | NodeConstants::CDATA_SECTION_NODE;
 static const uint8_t JSAttrNodeType                  = JSNodeType | NodeConstants::ATTRIBUTE_NODE;
-static const uint8_t JSElementType                   = 0b11010000 | NodeConstants::ELEMENT_NODE;
+static const uint8_t JSElementType                   = 0b11110000 | NodeConstants::ELEMENT_NODE;
 
 static_assert(JSDOMWrapperType > JSC::LastJSCObjectType, "JSC::JSType offers the highest bit.");
 static_assert(NodeConstants::LastNodeType <= JSNodeTypeMask, "NodeType should be represented in 4bit.");

Modified: trunk/Source/WebCore/bindings/js/JSElementCustom.h (254415 => 254416)


--- trunk/Source/WebCore/bindings/js/JSElementCustom.h	2020-01-12 21:30:19 UTC (rev 254415)
+++ trunk/Source/WebCore/bindings/js/JSElementCustom.h	2020-01-12 22:42:53 UTC (rev 254416)
@@ -37,7 +37,7 @@
     template<typename From>
     static inline bool inherits(VM&, From* from)
     {
-        return from->type() >= WebCore::JSElementType;
+        return from->type() == WebCore::JSElementType;
     }
 };
 

Modified: trunk/Source/WebCore/domjit/DOMJITHelpers.h (254415 => 254416)


--- trunk/Source/WebCore/domjit/DOMJITHelpers.h	2020-01-12 21:30:19 UTC (rev 254415)
+++ trunk/Source/WebCore/domjit/DOMJITHelpers.h	2020-01-12 22:42:53 UTC (rev 254416)
@@ -141,7 +141,7 @@
 inline CCallHelpers::Jump branchIfElement(CCallHelpers& jit, GPRReg target)
 {
     return jit.branch8(
-        CCallHelpers::AboveOrEqual,
+        CCallHelpers::Equal,
         CCallHelpers::Address(target, JSC::JSCell::typeInfoTypeOffset()),
         CCallHelpers::TrustedImm32(JSC::JSType(JSElementType)));
 }
@@ -149,7 +149,7 @@
 inline CCallHelpers::Jump branchIfNotElement(CCallHelpers& jit, GPRReg target)
 {
     return jit.branch8(
-        CCallHelpers::Below,
+        CCallHelpers::NotEqual,
         CCallHelpers::Address(target, JSC::JSCell::typeInfoTypeOffset()),
         CCallHelpers::TrustedImm32(JSC::JSType(JSElementType)));
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to