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