Changeset 201645 in webkit


Ignore:
Timestamp:
Jun 3, 2016 9:43:10 AM (8 years ago)
Author:
akling@apple.com
Message:

Eliminate two large sources of temporary StringImpl objects.
<https://webkit.org/b/158336>

Reviewed by Anders Carlsson.

We were jumping through some inefficient hoops when creating Identifiers due to the
convenience of our String(const char*) constructor.

This patch avoids just over 1 million temporary StringImpl objects on the PLUM benchmark.

  • runtime/JSObject.h:

(JSC::makeIdentifier): Add an overload for string literals so we can stop creating a temporary
String just for passing to Identifier::fromString().

  • runtime/Lookup.h:

(JSC::reifyStaticProperties): Use the Identifier::fromString() that takes an LChar* and a length
instead of creating a temporary String.

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r201641 r201645  
     12016-06-03  Andreas Kling  <akling@apple.com>
     2
     3        Eliminate two large sources of temporary StringImpl objects.
     4        <https://webkit.org/b/158336>
     5
     6        Reviewed by Anders Carlsson.
     7
     8        We were jumping through some inefficient hoops when creating Identifiers due to the
     9        convenience of our String(const char*) constructor.
     10
     11        This patch avoids just over 1 million temporary StringImpl objects on the PLUM benchmark.
     12
     13        * runtime/JSObject.h:
     14        (JSC::makeIdentifier): Add an overload for string literals so we can stop creating a temporary
     15        String just for passing to Identifier::fromString().
     16
     17        * runtime/Lookup.h:
     18        (JSC::reifyStaticProperties): Use the Identifier::fromString() that takes an LChar* and a length
     19        instead of creating a temporary String.
     20
    1212016-06-03  Mark Lam  <mark.lam@apple.com>
    222
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r201562 r201645  
    16251625COMPILE_ASSERT(!(sizeof(JSObject) % sizeof(WriteBarrierBase<Unknown>)), JSObject_inline_storage_has_correct_alignment);
    16261626
     1627template<unsigned charactersCount>
     1628ALWAYS_INLINE Identifier makeIdentifier(VM& vm, const char (&characters)[charactersCount])
     1629{
     1630    return Identifier::fromString(&vm, characters);
     1631}
     1632
    16271633ALWAYS_INLINE Identifier makeIdentifier(VM& vm, const char* name)
    16281634{
  • trunk/Source/JavaScriptCore/runtime/Lookup.h

    r201448 r201645  
    429429        if (!value.m_key)
    430430            continue;
    431         auto key = Identifier::fromString(&vm, value.m_key);
     431        auto key = Identifier::fromString(&vm, reinterpret_cast<const LChar*>(value.m_key), strlen(value.m_key));
    432432        reifyStaticProperty(vm, key, value, thisObj);
    433433    }
Note: See TracChangeset for help on using the changeset viewer.