Ignore:
Timestamp:
Sep 21, 2008, 1:35:20 PM (17 years ago)
Author:
Darin Adler
Message:

2008-09-21 Judit Jasz <[email protected]>

Reviewed and tweaked by Darin Adler.

Seems to be a wash on SunSpider.

  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitLoad): Use m_numberMap and m_stringMap to guarantee we emit the same JSValue* for identical numbers and strings.
  • VM/CodeGenerator.h: Added overload of emitLoad for const Identifier&. Add NumberMap and IdentifierStringMap types and m_numberMap and m_stringMap.
  • kjs/nodes.cpp: (JSC::StringNode::emitCode): Call the new emitLoad and let it do the JSString creation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CodeGenerator.cpp

    r36695 r36741  
    731731}
    732732
    733 RegisterID* CodeGenerator::emitLoad(RegisterID* dst, double d)
    734 {
    735     return emitLoad(dst, jsNumber(globalExec(), d));
     733RegisterID* CodeGenerator::emitLoad(RegisterID* dst, double number)
     734{
     735    pair<NumberMap::iterator, bool> addResult = m_numberMap.add(number, 0);
     736    if (addResult.second)
     737        addResult.first->second = jsNumber(globalExec(), number);
     738    return emitLoad(dst, addResult.first->second);
     739}
     740
     741RegisterID* CodeGenerator::emitLoad(RegisterID* dst, const Identifier& identifier)
     742{
     743    pair<IdentifierStringMap::iterator, bool> addResult = m_stringMap.add(identifier.ustring().rep(), 0);
     744    if (addResult.second)
     745        addResult.first->second = jsOwnedString(globalExec(), identifier.ustring());
     746    return emitLoad(dst, addResult.first->second);
    736747}
    737748
Note: See TracChangeset for help on using the changeset viewer.