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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 function assertKind(expected, obj, name_opt) { | 69 function assertKind(expected, obj, name_opt) { |
70 if (!support_smi_only_arrays && | 70 if (!support_smi_only_arrays && |
71 expected == elements_kind.fast_smi_only) { | 71 expected == elements_kind.fast_smi_only) { |
72 expected = elements_kind.fast; | 72 expected = elements_kind.fast; |
73 } | 73 } |
74 assertEquals(expected, getKind(obj), name_opt); | 74 assertEquals(expected, getKind(obj), name_opt); |
75 } | 75 } |
76 | 76 |
77 if (support_smi_only_arrays) { | 77 if (support_smi_only_arrays) { |
78 function fastliteralcase(value) { | 78 function fastliteralcase(literal, value) { |
79 var literal = [1, 2, 3]; | 79 // var literal = [1, 2, 3]; |
80 literal[0] = value; | 80 literal[0] = value; |
81 return literal; | 81 return literal; |
82 } | 82 } |
83 | 83 |
84 // Case: [1,2,3] as allocation site | 84 function get_standard_literal() { |
85 obj = fastliteralcase(1); | 85 var literal = [1, 2, 3]; |
86 assertKind(elements_kind.fast_smi_only, obj); | 86 return literal; |
87 obj = fastliteralcase(1.5); | 87 } |
88 assertKind(elements_kind.fast_double, obj); | |
89 obj = fastliteralcase(2); | |
90 assertKind(elements_kind.fast_double, obj); | |
91 | 88 |
92 // Verify that we will not pretransition the double->fast path. | 89 // Case: [1,2,3] as allocation site |
93 obj = fastliteralcase("elliot"); | 90 obj = fastliteralcase(get_standard_literal(), 1); |
94 assertKind(elements_kind.fast, obj); | 91 assertKind(elements_kind.fast_smi_only, obj); |
| 92 obj = fastliteralcase(get_standard_literal(), 1.5); |
| 93 assertKind(elements_kind.fast_double, obj); |
| 94 obj = fastliteralcase(get_standard_literal(), 2); |
| 95 assertKind(elements_kind.fast_double, obj); |
95 | 96 |
96 // This fails until we turn off optimistic transitions to the | 97 obj = fastliteralcase([5, 3, 2], 1.5); |
97 // most general elements kind seen on keyed stores. It's a goal | 98 assertKind(elements_kind.fast_double, obj); |
98 // to turn it off, but for now we need it. | 99 obj = fastliteralcase([3, 6, 2], 1.5); |
99 // obj = fastliteralcase(3); | 100 assertKind(elements_kind.fast_double, obj); |
100 // assertKind(elements_kind.fast_double, obj); | 101 obj = fastliteralcase([2, 6, 3], 2); |
| 102 assertKind(elements_kind.fast_smi_only, obj); |
101 | 103 |
102 function fastliteralcase_smifast(value) { | 104 // Verify that we will not pretransition the double->fast path. |
103 var literal = [1, 2, 3, 4]; | 105 obj = fastliteralcase(get_standard_literal(), "elliot"); |
104 literal[0] = value; | 106 assertKind(elements_kind.fast, obj); |
105 return literal; | |
106 } | |
107 | 107 |
108 obj = fastliteralcase_smifast(1); | 108 // This fails until we turn off optimistic transitions to the |
109 assertKind(elements_kind.fast_smi_only, obj); | 109 // most general elements kind seen on keyed stores. It's a goal |
110 obj = fastliteralcase_smifast("carter"); | 110 // to turn it off, but for now we need it. |
111 assertKind(elements_kind.fast, obj); | 111 // obj = fastliteralcase(3); |
112 obj = fastliteralcase_smifast(2); | 112 // assertKind(elements_kind.fast_double, obj); |
113 assertKind(elements_kind.fast, obj); | 113 |
114 } | 114 function fastliteralcase_smifast(value) { |
| 115 var literal = [1, 2, 3, 4]; |
| 116 literal[0] = value; |
| 117 return literal; |
| 118 } |
| 119 |
| 120 obj = fastliteralcase_smifast(1); |
| 121 assertKind(elements_kind.fast_smi_only, obj); |
| 122 obj = fastliteralcase_smifast("carter"); |
| 123 assertKind(elements_kind.fast, obj); |
| 124 obj = fastliteralcase_smifast(2); |
| 125 assertKind(elements_kind.fast, obj); |
| 126 } |
OLD | NEW |