Changeset 39675 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jan 7, 2009, 12:16:52 AM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r39673 r39675 1 2009-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 1 24 2009-01-06 Oliver Hunt <[email protected]> 2 25 -
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r39670 r39675 868 868 if (number == HashTraits<double>::emptyValue() || HashTraits<double>::isDeletedValue(number)) 869 869 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; 871 871 if (!valueInMap) 872 872 valueInMap = jsNumber(globalData(), number); … … 876 876 RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, const Identifier& identifier) 877 877 { 878 JS ValuePtr 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)); 882 882 } 883 883
Note:
See TracChangeset
for help on using the changeset viewer.