Index: test/mjsunit/string-natives.js |
diff --git a/test/mjsunit/regress/regress-2250.js b/test/mjsunit/string-natives.js |
similarity index 60% |
copy from test/mjsunit/regress/regress-2250.js |
copy to test/mjsunit/string-natives.js |
index b3b0db3fc386fdd469f580f57dcc77bd40a5f930..ce1a71ae8ea21ac504d862c09b7238bdc4e5200b 100644 |
--- a/test/mjsunit/regress/regress-2250.js |
+++ b/test/mjsunit/string-natives.js |
@@ -25,44 +25,50 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Flags: --allow-natives-syntax |
+// Flags: --expose-gc --allow-natives-syntax |
-// The original problem from the bug: In the example below SMI check for b |
-// generated for inlining of equals invocation (marked with (*)) will be hoisted |
-// out of the loop across the typeof b === "object" condition and cause an |
-// immediate deopt. Another problem here is that no matter how many time we |
-// deopt and reopt we will continue to produce the wrong code. |
-// |
-// The fix is to notice when a deopt and subsequent reopt doesn't find |
-// additional type information, indicating that optimistic LICM should be |
-// disabled during compilation. |
+function test() { |
+ var s1 = %NewString(26, true); |
+ for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, i+65); |
+ assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s1); |
+ %TruncateString(s1, 13); |
+ assertEquals("ABCDEFGHIJKLM", s1); |
+ assertThrows(function() { %TruncateString(s1, 14) }); |
+ assertThrows(function() { %TruncateString(s1, 0) }); |
+ |
+ var s2 = %NewString(26, false); |
+ for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, i+65); |
+ assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s2); |
+ %TruncateString(s2, 13); |
+ assertEquals("ABCDEFGHIJKLM", s2); |
-function eq(a, b) { |
- if (typeof b === "object") { |
- return b.equals(a); // (*) |
+ var s3 = %NewString(26, false); |
+ for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s3, i, i+1000); |
+ for (i = 0; i < 26; i++) assertEquals(s3[i], String.fromCharCode(i+1000)); |
+ |
+ var a = []; |
+ for (var i = 0; i < 1000; i++) { |
+ var s = %NewString(10000, i % 2 == 1); |
+ a.push(s); |
} |
- return a === b; |
-} |
-Object.prototype.equals = function (other) { |
- return (this === other); |
-}; |
+ gc(); |
-function test() { |
- for (var i = 0; !eq(i, 10); i++) |
- ; |
+ for (var i = 0; i < 1000; i++) { |
+ assertEquals(10000, a[i].length); |
+ %TruncateString(a[i], 5000); |
+ } |
+ |
+ gc(); |
+ |
+ for (var i = 0; i < 1000; i++) { |
+ assertEquals(5000, a[i].length); |
+ } |
} |
-eq({}, {}); |
-eq({}, {}); |
-eq(1, 1); |
-eq(1, 1); |
+ |
test(); |
-%OptimizeFunctionOnNextCall(test); |
test(); |
%OptimizeFunctionOnNextCall(test); |
-// Second compilation should have noticed that LICM wasn't a good idea, and now |
-// function should no longer deopt when called. |
test(); |
-assertTrue(2 != %GetOptimizationStatus(test)); |