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