Changeset 39675 in webkit for trunk/JavaScriptCore/bytecompiler


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):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.