Title: [186649] trunk/Source
Revision
186649
Author
achristen...@apple.com
Date
2015-07-09 16:33:25 -0700 (Thu, 09 Jul 2015)

Log Message

[Content Extensions] Add 3 byte jump size.
https://bugs.webkit.org/show_bug.cgi?id=146425

Reviewed by Darin Adler.

Source/WebCore:

* contentextensions/DFABytecode.h:
(WebCore::ContentExtensions::smallestPossibleJumpSize):
* contentextensions/DFABytecodeCompiler.cpp:
(WebCore::ContentExtensions::appendZeroes):
(WebCore::ContentExtensions::DFABytecodeCompiler::compile):
* contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::jumpSizeInBytes):
(WebCore::ContentExtensions::getJumpSize):
(WebCore::ContentExtensions::getJumpDistance):
Added DFABytecodeJumpSize::Int24.

Source/WebKit2:

* UIProcess/API/APIUserContentExtensionStore.h:
Increment CurrentContentExtensionFileVersion because of change in the bytecode.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (186648 => 186649)


--- trunk/Source/WebCore/ChangeLog	2015-07-09 23:32:15 UTC (rev 186648)
+++ trunk/Source/WebCore/ChangeLog	2015-07-09 23:33:25 UTC (rev 186649)
@@ -1,3 +1,21 @@
+2015-07-09  Alex Christensen  <achristen...@webkit.org>
+
+        [Content Extensions] Add 3 byte jump size.
+        https://bugs.webkit.org/show_bug.cgi?id=146425
+
+        Reviewed by Darin Adler.
+
+        * contentextensions/DFABytecode.h:
+        (WebCore::ContentExtensions::smallestPossibleJumpSize):
+        * contentextensions/DFABytecodeCompiler.cpp:
+        (WebCore::ContentExtensions::appendZeroes):
+        (WebCore::ContentExtensions::DFABytecodeCompiler::compile):
+        * contentextensions/DFABytecodeInterpreter.cpp:
+        (WebCore::ContentExtensions::jumpSizeInBytes):
+        (WebCore::ContentExtensions::getJumpSize):
+        (WebCore::ContentExtensions::getJumpDistance):
+        Added DFABytecodeJumpSize::Int24.
+
 2015-07-09  Brady Eidson  <beid...@apple.com>
 
         Add better ASSERTs to learn more about what is going wrong in DocumentLoader::detachFromFrame()

Modified: trunk/Source/WebCore/contentextensions/DFABytecode.h (186648 => 186649)


--- trunk/Source/WebCore/contentextensions/DFABytecode.h	2015-07-09 23:32:15 UTC (rev 186648)
+++ trunk/Source/WebCore/contentextensions/DFABytecode.h	2015-07-09 23:33:25 UTC (rev 186649)
@@ -83,8 +83,11 @@
 enum DFABytecodeJumpSize {
     Int8 = 0x10,
     Int16 = 0x20,
-    Int32 = 0x30,
+    Int24 = 0x30,
+    Int32 = 0x40,
 };
+const int32_t Int24Max = (1 << 23) - 1;
+const int32_t Int24Min = -(1 << 23);
 
 static inline DFABytecodeJumpSize smallestPossibleJumpSize(int32_t longestPossibleJump)
 {
@@ -92,6 +95,8 @@
         return Int8;
     if (longestPossibleJump <= std::numeric_limits<int16_t>::max() && longestPossibleJump >= std::numeric_limits<int16_t>::min())
         return Int16;
+    if (longestPossibleJump <= Int24Max && longestPossibleJump >= Int24Min)
+        return Int24;
     return Int32;
 }
     

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp (186648 => 186649)


--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp	2015-07-09 23:32:15 UTC (rev 186648)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp	2015-07-09 23:33:25 UTC (rev 186649)
@@ -52,6 +52,10 @@
     case DFABytecodeJumpSize::Int16:
         append<int16_t>(bytecode, 0); // This value will be set when linking.
         break;
+    case DFABytecodeJumpSize::Int24:
+        append<uint16_t>(bytecode, 0);
+        append<int8_t>(bytecode, 0); // These values will be set when linking.
+        break;
     case DFABytecodeJumpSize::Int32:
         append<int32_t>(bytecode, 0); // This value will be set when linking.
         break;
@@ -374,6 +378,11 @@
             RELEASE_ASSERT(distance == static_cast<int16_t>(distance));
             setBits<int16_t>(m_bytecode, linkRecord.jumpLocation, static_cast<int16_t>(distance));
             break;
+        case Int24:
+            RELEASE_ASSERT(distance >= Int24Min && distance <= Int24Max);
+            setBits<uint16_t>(m_bytecode, linkRecord.jumpLocation, static_cast<uint16_t>(distance));
+            setBits<int8_t>(m_bytecode, linkRecord.jumpLocation + sizeof(int16_t), static_cast<int8_t>(distance >> 16));
+            break;
         case Int32:
             setBits<int32_t>(m_bytecode, linkRecord.jumpLocation, distance);
             break;

Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (186648 => 186649)


--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp	2015-07-09 23:32:15 UTC (rev 186648)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp	2015-07-09 23:33:25 UTC (rev 186649)
@@ -54,6 +54,8 @@
         return sizeof(int8_t);
     case Int16:
         return sizeof(int16_t);
+    case Int24:
+        return sizeof(uint16_t) + sizeof(int8_t);
     case Int32:
         return sizeof(int32_t);
     default:
@@ -64,7 +66,7 @@
 static inline DFABytecodeJumpSize getJumpSize(const DFABytecode* bytecode, uint32_t bytecodeLength, uint32_t index)
 {
     DFABytecodeJumpSize jumpSize = static_cast<DFABytecodeJumpSize>(getBits<uint8_t>(bytecode, bytecodeLength, index) & DFABytecodeJumpSizeMask);
-    ASSERT(jumpSize == DFABytecodeJumpSize::Int32 || jumpSize == DFABytecodeJumpSize::Int16 || jumpSize == DFABytecodeJumpSize::Int8);
+    ASSERT(jumpSize == DFABytecodeJumpSize::Int32 || jumpSize == DFABytecodeJumpSize::Int24 || jumpSize == DFABytecodeJumpSize::Int16 || jumpSize == DFABytecodeJumpSize::Int8);
     return jumpSize;
 }
 
@@ -75,6 +77,8 @@
         return getBits<int8_t>(bytecode, bytecodeLength, index);
     case Int16:
         return getBits<int16_t>(bytecode, bytecodeLength, index);
+    case Int24:
+        return getBits<uint16_t>(bytecode, bytecodeLength, index) | (static_cast<int32_t>(getBits<int8_t>(bytecode, bytecodeLength, index + sizeof(uint16_t))) << 16);
     case Int32:
         return getBits<int32_t>(bytecode, bytecodeLength, index);
     default:

Modified: trunk/Source/WebKit2/ChangeLog (186648 => 186649)


--- trunk/Source/WebKit2/ChangeLog	2015-07-09 23:32:15 UTC (rev 186648)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-09 23:33:25 UTC (rev 186649)
@@ -1,3 +1,13 @@
+2015-07-09  Alex Christensen  <achristen...@webkit.org>
+
+        [Content Extensions] Add 3 byte jump size.
+        https://bugs.webkit.org/show_bug.cgi?id=146425
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/API/APIUserContentExtensionStore.h:
+        Increment CurrentContentExtensionFileVersion because of change in the bytecode.
+
 2015-07-09  Anders Carlsson  <ander...@apple.com>
 
         SafariViewController loads partial webpage or entirely blank webpage

Modified: trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h (186648 => 186649)


--- trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h	2015-07-09 23:32:15 UTC (rev 186648)
+++ trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h	2015-07-09 23:33:25 UTC (rev 186649)
@@ -51,7 +51,7 @@
     
     // This should be incremented every time a functional change is made to the bytecode, file format, etc.
     // to prevent crashing while loading old data.
-    const static uint32_t CurrentContentExtensionFileVersion = 4;
+    const static uint32_t CurrentContentExtensionFileVersion = 5;
 
     static UserContentExtensionStore& defaultStore();
     static Ref<UserContentExtensionStore> storeWithPath(const WTF::String& storePath);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to