-
barraclough@apple.com authored
https://bugs.webkit.org/show_bug.cgi?id=95815 Reviewed by Geoff Garen. Source/JavaScriptCore: There are two bugs here. (1) When the value being incremented is const, and the result is ignored, we assume this cannot be observed, and emit no code. However if the value being incremented is not a primitive & has a valueOf conversion, then this should be being called. (2) In the case of a pre-increment of a const value where the result is not ignored, we'll move +/-1 to the destination, then add the resolved const value being incremented to this. This is problematic if the destination is a local, and the const value being incremented has a valueOf conversion that throws - the destination will be modified erroneously. Instead, we need to use a temporary location. * bytecompiler/NodesCodegen.cpp: (JSC::PostfixResolveNode::emitBytecode): (JSC::PrefixResolveNode::emitBytecode): - always at least perform a toNumber conversion, use tempDestination when reducing inc/dec to an add +/-1. LayoutTests: Added test cases. * fast/js/inc-const-valueOf-expected.txt: Added. * fast/js/inc-const-valueOf.html: Added. * fast/js/script-tests/inc-const-valueOf.js: Added. (testPostIncConstVarWithIgnoredResult.const.a.valueOf): (testPostIncConstVarWithIgnoredResult): test that 'a++' results in a valueOf call, where 'a' is const. (testPreIncConstVarWithIgnoredResult.const.a.valueOf): (testPreIncConstVarWithIgnoredResult): test that '++a' results in a valueOf call, where 'a' is const. (testPreIncConstVarWithAssign.const.a.valueOf): (testPreIncConstVarWithAssign): test that 'b = ++a' does not erroneously update 'b', where 'a' is const. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127544 268f45cc-cd09-0410-ab3c-d52691b4dbfc
89f4b827