Title: [203911] trunk/Source/WTF
Revision
203911
Author
[email protected]
Date
2016-07-29 11:52:53 -0700 (Fri, 29 Jul 2016)

Log Message

Make StringView capable of being passed or returned in only 2 registers.
https://bugs.webkit.org/show_bug.cgi?id=160344

Reviewed by Geoffrey Garen.

We just need to #if out copy and move constructors and assignment operators.

After this change, the following test code:

    JS_EXPORT_PRIVATE StringView returnStringView(StringView sv)
    {
        return sv;
    }

... compiles to the following for x86_64:

    __ZN3JSC16returnStringViewEN3WTF10StringViewE:
    000000000093fb20        pushq   %rbp
    000000000093fb21        movq    %rsp, %rbp
    000000000093fb24        movq    %rdi, %rax // Copy from arg word 0 to ret word 0.
    000000000093fb27        movq    %rsi, %rdx // Copy from arg word 1 to ret word 1.
    000000000093fb2a        popq    %rbp
    000000000093fb2b        retq

... and this for arm64:

    __ZN3JSC16returnStringViewEN3WTF10StringViewE:
    0000000000818504        ret // arg word 0 and 1 are in the same regs as ret word 0 and 1.

* wtf/text/StringView.h:
(WTF::StringView::StringView):
(WTF::StringView::~StringView):
(WTF::StringView::operator=):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (203910 => 203911)


--- trunk/Source/WTF/ChangeLog	2016-07-29 18:47:52 UTC (rev 203910)
+++ trunk/Source/WTF/ChangeLog	2016-07-29 18:52:53 UTC (rev 203911)
@@ -1,3 +1,39 @@
+2016-07-29  Mark Lam  <[email protected]>
+
+        Make StringView capable of being passed or returned in only 2 registers.
+        https://bugs.webkit.org/show_bug.cgi?id=160344
+
+        Reviewed by Geoffrey Garen.
+
+        We just need to #if out copy and move constructors and assignment operators.
+
+        After this change, the following test code:
+
+            JS_EXPORT_PRIVATE StringView returnStringView(StringView sv)
+            {
+                return sv;
+            }
+
+        ... compiles to the following for x86_64:
+
+            __ZN3JSC16returnStringViewEN3WTF10StringViewE:
+            000000000093fb20        pushq   %rbp
+            000000000093fb21        movq    %rsp, %rbp
+            000000000093fb24        movq    %rdi, %rax // Copy from arg word 0 to ret word 0.
+            000000000093fb27        movq    %rsi, %rdx // Copy from arg word 1 to ret word 1.
+            000000000093fb2a        popq    %rbp
+            000000000093fb2b        retq
+
+        ... and this for arm64:
+
+            __ZN3JSC16returnStringViewEN3WTF10StringViewE:
+            0000000000818504        ret // arg word 0 and 1 are in the same regs as ret word 0 and 1.
+
+        * wtf/text/StringView.h:
+        (WTF::StringView::StringView):
+        (WTF::StringView::~StringView):
+        (WTF::StringView::operator=):
+
 2016-07-29  Csaba Osztrogonác  <[email protected]>
 
         Remove PassRef.h after r177259

Modified: trunk/Source/WTF/wtf/text/StringView.h (203910 => 203911)


--- trunk/Source/WTF/wtf/text/StringView.h	2016-07-29 18:47:52 UTC (rev 203910)
+++ trunk/Source/WTF/wtf/text/StringView.h	2016-07-29 18:52:53 UTC (rev 203911)
@@ -48,17 +48,17 @@
 using CharacterMatchFunction = bool (*)(UChar);
 
 // StringView is a non-owning reference to a string, similar to the proposed std::string_view.
-// Whether the string is 8-bit or 16-bit is encoded in the upper bit of the length member.
-// This means that strings longer than 2 gigacharacters cannot be represented.
 
 class StringView {
 public:
     StringView();
+#if CHECK_STRINGVIEW_LIFETIME
     ~StringView();
     StringView(StringView&&);
     StringView(const StringView&);
     StringView& operator=(StringView&&);
     StringView& operator=(const StringView&);
+#endif
 
     StringView(const String&);
     StringView(const StringImpl&);
@@ -202,6 +202,7 @@
     // FIXME: It's peculiar that null strings are 16-bit and empty strings return 8-bit (according to the is8Bit function).
 }
 
+#if CHECK_STRINGVIEW_LIFETIME
 inline StringView::~StringView()
 {
     setUnderlyingString(nullptr);
@@ -258,6 +259,7 @@
 
     return *this;
 }
+#endif // CHECK_STRINGVIEW_LIFETIME
 
 inline void StringView::initialize(const LChar* characters, unsigned length)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to