Changeset 203911 in webkit


Ignore:
Timestamp:
Jul 29, 2016 11:52:53 AM (8 years ago)
Author:
mark.lam@apple.com
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=):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r203907 r203911  
     12016-07-29  Mark Lam  <mark.lam@apple.com>
     2
     3        Make StringView capable of being passed or returned in only 2 registers.
     4        https://bugs.webkit.org/show_bug.cgi?id=160344
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        We just need to #if out copy and move constructors and assignment operators.
     9
     10        After this change, the following test code:
     11
     12            JS_EXPORT_PRIVATE StringView returnStringView(StringView sv)
     13            {
     14                return sv;
     15            }
     16
     17        ... compiles to the following for x86_64:
     18
     19            __ZN3JSC16returnStringViewEN3WTF10StringViewE:
     20            000000000093fb20        pushq   %rbp
     21            000000000093fb21        movq    %rsp, %rbp
     22            000000000093fb24        movq    %rdi, %rax // Copy from arg word 0 to ret word 0.
     23            000000000093fb27        movq    %rsi, %rdx // Copy from arg word 1 to ret word 1.
     24            000000000093fb2a        popq    %rbp
     25            000000000093fb2b        retq
     26
     27        ... and this for arm64:
     28
     29            __ZN3JSC16returnStringViewEN3WTF10StringViewE:
     30            0000000000818504        ret // arg word 0 and 1 are in the same regs as ret word 0 and 1.
     31
     32        * wtf/text/StringView.h:
     33        (WTF::StringView::StringView):
     34        (WTF::StringView::~StringView):
     35        (WTF::StringView::operator=):
     36
    1372016-07-29  Csaba Osztrogonác  <ossy@webkit.org>
    238
  • trunk/Source/WTF/wtf/text/StringView.h

    r203834 r203911  
    4949
    5050// StringView is a non-owning reference to a string, similar to the proposed std::string_view.
    51 // Whether the string is 8-bit or 16-bit is encoded in the upper bit of the length member.
    52 // This means that strings longer than 2 gigacharacters cannot be represented.
    5351
    5452class StringView {
    5553public:
    5654    StringView();
     55#if CHECK_STRINGVIEW_LIFETIME
    5756    ~StringView();
    5857    StringView(StringView&&);
     
    6059    StringView& operator=(StringView&&);
    6160    StringView& operator=(const StringView&);
     61#endif
    6262
    6363    StringView(const String&);
     
    203203}
    204204
     205#if CHECK_STRINGVIEW_LIFETIME
    205206inline StringView::~StringView()
    206207{
     
    259260    return *this;
    260261}
     262#endif // CHECK_STRINGVIEW_LIFETIME
    261263
    262264inline void StringView::initialize(const LChar* characters, unsigned length)
Note: See TracChangeset for help on using the changeset viewer.