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(literal, 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 function get_standard_literal() { | 84 function get_standard_literal() { |
85 var literal = [1, 2, 3]; | 85 var literal = [1, 2, 3]; |
86 return literal; | 86 return literal; |
87 } | 87 } |
88 | 88 |
89 // Case: [1,2,3] as allocation site | 89 // Case: [1,2,3] as allocation site |
90 obj = fastliteralcase(get_standard_literal(), 1); | 90 obj = fastliteralcase(get_standard_literal(), 1); |
91 assertKind(elements_kind.fast_smi_only, obj); | 91 assertKind(elements_kind.fast_smi_only, obj); |
92 obj = fastliteralcase(get_standard_literal(), 1.5); | 92 obj = fastliteralcase(get_standard_literal(), 1.5); |
93 assertKind(elements_kind.fast_double, obj); | 93 assertKind(elements_kind.fast_double, obj); |
94 obj = fastliteralcase(get_standard_literal(), 2); | 94 obj = fastliteralcase(get_standard_literal(), 2); |
95 assertKind(elements_kind.fast_double, obj); | 95 assertKind(elements_kind.fast_double, obj); |
96 | 96 |
97 obj = fastliteralcase([5, 3, 2], 1.5); | 97 obj = fastliteralcase([5, 3, 2], 1.5); |
98 assertKind(elements_kind.fast_double, obj); | 98 assertKind(elements_kind.fast_double, obj); |
99 obj = fastliteralcase([3, 6, 2], 1.5); | 99 obj = fastliteralcase([3, 6, 2], 1.5); |
100 assertKind(elements_kind.fast_double, obj); | 100 assertKind(elements_kind.fast_double, obj); |
101 obj = fastliteralcase([2, 6, 3], 2); | 101 obj = fastliteralcase([2, 6, 3], 2); |
102 assertKind(elements_kind.fast_double, obj); | 102 assertKind(elements_kind.fast_smi_only, obj); |
103 | 103 |
104 // Verify that we will not pretransition the double->fast path. | 104 // Verify that we will not pretransition the double->fast path. |
105 obj = fastliteralcase(get_standard_literal(), "elliot"); | 105 obj = fastliteralcase(get_standard_literal(), "elliot"); |
106 assertKind(elements_kind.fast, obj); | 106 assertKind(elements_kind.fast, obj); |
107 | 107 |
108 // This fails until we turn off optimistic transitions to the | 108 // This fails until we turn off optimistic transitions to the |
109 // most general elements kind seen on keyed stores. It's a goal | 109 // most general elements kind seen on keyed stores. It's a goal |
110 // to turn it off, but for now we need it. | 110 // to turn it off, but for now we need it. |
111 // obj = fastliteralcase(3); | 111 // obj = fastliteralcase(3); |
112 // assertKind(elements_kind.fast_double, obj); | 112 // assertKind(elements_kind.fast_double, obj); |
113 | 113 |
114 function fastliteralcase_smifast(value) { | 114 function fastliteralcase_smifast(value) { |
115 var literal = [1, 2, 3, 4]; | 115 var literal = [1, 2, 3, 4]; |
116 literal[0] = value; | 116 literal[0] = value; |
117 return literal; | 117 return literal; |
118 } | 118 } |
119 | 119 |
120 obj = fastliteralcase_smifast(1); | 120 obj = fastliteralcase_smifast(1); |
121 assertKind(elements_kind.fast_smi_only, obj); | 121 assertKind(elements_kind.fast_smi_only, obj); |
122 obj = fastliteralcase_smifast("carter"); | 122 obj = fastliteralcase_smifast("carter"); |
123 assertKind(elements_kind.fast, obj); | 123 assertKind(elements_kind.fast, obj); |
124 obj = fastliteralcase_smifast(2); | 124 obj = fastliteralcase_smifast(2); |
125 assertKind(elements_kind.fast, obj); | 125 assertKind(elements_kind.fast, obj); |
126 } | 126 } |
OLD | NEW |