Changeset 39675 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jan 7, 2009, 12:16:52 AM (16 years ago)
Author:
[email protected]
Message:

2009-01-06 Gavin Barraclough <[email protected]>

Reviewed by Maciej Stachowiak.

Replace accidentally removed references in BytecodeGenerator, deleting these
will be hindering the sharing of constant numbers and strings.

The code to add a new constant (either number or string) to their respective
map works by attempting to add a null entry, then checking the result of the
add for null. The first time, this should return the null (or noValue).
The code checks for null (to see if this is the initial add), and then allocates
a new number / string object. This code relies on the result returned from
the add to the map being stored as a reference, such that the allocated object
will be stored in the map, and will be resused if the same constant is encountered
again. By failing to use a reference we will be leaking GC object for each
additional entry added to the map. As GC objects they should be clollected,
be we should no be allocatin them in the first place.

https://bugs.webkit.org/show_bug.cgi?id=23158

  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitLoad):
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r39673 r39675  
     12009-01-06  Gavin Barraclough  <[email protected]>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Replace accidentally removed references in BytecodeGenerator, deleting these
     6        will be hindering the sharing of constant numbers and strings.
     7
     8        The code to add a new constant (either number or string) to their respective
     9        map works by attempting to add a null entry, then checking the result of the
     10        add for null.  The first time, this should return the null (or noValue).
     11        The code checks for null (to see if this is the initial add), and then allocates
     12        a new number / string object.  This code relies on the result returned from
     13        the add to the map being stored as a reference, such that the allocated object
     14        will be stored in the map, and will be resused if the same constant is encountered
     15        again.  By failing to use a reference we will be leaking GC object for each
     16        additional entry added to the map.  As GC objects they should be clollected,
     17        be we should no be allocatin them in the first place.
     18
     19        https://bugs.webkit.org/show_bug.cgi?id=23158
     20
     21        * bytecompiler/BytecodeGenerator.cpp:
     22        (JSC::BytecodeGenerator::emitLoad):
     23
    1242009-01-06  Oliver Hunt  <[email protected]>
    225
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r39670 r39675  
    868868    if (number == HashTraits<double>::emptyValue() || HashTraits<double>::isDeletedValue(number))
    869869        return emitLoad(dst, jsNumber(globalData(), number));
    870     JSValuePtr valueInMap = m_numberMap.add(number, noValue()).first->second;
     870    JSValuePtr& valueInMap = m_numberMap.add(number, noValue()).first->second;
    871871    if (!valueInMap)
    872872        valueInMap = jsNumber(globalData(), number);
     
    876876RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, const Identifier& identifier)
    877877{
    878     JSValuePtr valueInMap = m_stringMap.add(identifier.ustring().rep(), 0).first->second;
    879     if (!valueInMap)
    880         valueInMap = jsOwnedString(globalData(), identifier.ustring());
    881     return emitLoad(dst, valueInMap);
     878    JSString*& stringInMap = m_stringMap.add(identifier.ustring().rep(), 0).first->second;
     879    if (!stringInMap)
     880        stringInMap = jsOwnedString(globalData(), identifier.ustring());
     881    return emitLoad(dst, JSValuePtr(stringInMap));
    882882}
    883883
Note: See TracChangeset for help on using the changeset viewer.