Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/mjsunit/regress/regress-1493017.js

Issue 43004: Simplify the map collection regression test. This test is the minimal... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2009 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Test for collection of abandoned maps 28 // Test collection of abandoned maps. Tests that deleted map
29 29 // transitions do not show up as properties in for in.
30 // This test makes a wide, shallow tree of map transitions and maps
31 // by adding the properties "a" through "j" in a pseudorandom order
32 // to a new A() object. This should create map transitions forming
33 // a partial denary tree. These objects only stick around for about
34 // 1000 iterations, with each iteration creating a new object. Therefore,
35 // some of the maps going to leaves will become abandoned.
36 // There are still map transitions going to them though, so
37 // only the new map-collection code will remove them.
38
39 // Every 101 object creations, the object is created again, and tested
40 // after each property addition to make sure that no map transitions
41 // are visible as properties. This is a regression test for a bug.
42 30
43 // Flags: --expose-gc --collect-maps 31 // Flags: --expose-gc --collect-maps
44 32
45 function dotest() { 33 function C() {}
46 function A() {
47 }
48 34
49 function B() {
50 this.x = 3;
51 }
52 35
53 var a_B = new B(); 36 // Create an instance of C. Add a property to the instance and then
54 var r = 1; 37 // remove all references to instances of C.
55 var i = 0; 38 var o = new C();
56 var holder = new Array(); 39 o.x = 42;
57 while (i++ < 2001) { 40 o = null;
58 if (i == 1400) { 41
59 gc(); 42 // Force a global GC. This will collect the maps starting from C and
60 } 43 // delete map transitions.
61 var s = r % 100000000; 44 gc();
62 var obj = new A(); 45
63 holder[i % 1000] = obj; 46 // Create a new instance of C.
64 while (s > 0) { 47 o = new C();
65 var property_name = String.fromCharCode(s % 10 + 97); 48
66 obj[property_name] = a_B; 49 // Test that the deleted map transitions do not show up in for in.
67 s = s / 10; 50 for (var p in o) {
68 } 51 assertTrue(false);
69 if (i % 101 == 0) {
70 // Check that all object maps have no undefined properties
71 s = r % 100000000;
72 obj = new A();
73 while (s > 0) {
74 for (var p in obj) {
75 assertEquals(a_B, obj[p] );
76 }
77 property_name = String.fromCharCode(s % 10 + 97);
78 obj[property_name] = a_B;
79 s = s / 10;
80 }
81 }
82 r = r * 7 % 100000000;
83 }
84 } 52 }
85
86 dotest();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698