OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 for (var i = 0; i < 10000; i++) a.push(new_space_string); | 33 for (var i = 0; i < 10000; i++) a.push(new_space_string); |
34 | 34 |
35 // At some point during the first stringify, allocation causes a GC and | 35 // At some point during the first stringify, allocation causes a GC and |
36 // new_space_string is moved to old space. Make sure that this does not | 36 // new_space_string is moved to old space. Make sure that this does not |
37 // screw up reading from the correct location. | 37 // screw up reading from the correct location. |
38 json1 = JSON.stringify(a); | 38 json1 = JSON.stringify(a); |
39 json2 = JSON.stringify(a); | 39 json2 = JSON.stringify(a); |
40 assertTrue(json1 == json2, "GC caused JSON.stringify to fail."); | 40 assertTrue(json1 == json2, "GC caused JSON.stringify to fail."); |
41 | 41 |
| 42 // Check that the slow path of JSON.stringify works correctly wrt GC. |
| 43 for (var i = 0; i < 100000; i++) { |
| 44 var s = i.toString(); |
| 45 assertEquals('"' + s + '"', JSON.stringify(s, null, 0)); |
| 46 } |
| 47 |
| 48 for (var i = 0; i < 100000; i++) { |
| 49 var s = i.toString() + "\u2603"; |
| 50 assertEquals('"' + s + '"', JSON.stringify(s, null, 0)); |
| 51 } |
OLD | NEW |