| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 function assertKind(expected, obj, name_opt) { | 103 function assertKind(expected, obj, name_opt) { |
| 104 if (!support_smi_only_arrays && | 104 if (!support_smi_only_arrays && |
| 105 expected == elements_kind.fast_smi_only) { | 105 expected == elements_kind.fast_smi_only) { |
| 106 expected = elements_kind.fast; | 106 expected = elements_kind.fast; |
| 107 } | 107 } |
| 108 assertEquals(expected, getKind(obj), name_opt); | 108 assertEquals(expected, getKind(obj), name_opt); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // long-running loop forces OSR. | 111 // long-running loop forces OSR. |
| 112 %NeverOptimizeFunction(construct_smis); |
| 113 %NeverOptimizeFunction(construct_doubles); |
| 114 %NeverOptimizeFunction(convert_mixed); |
| 112 for (var i = 0; i < 1000000; i++) { } | 115 for (var i = 0; i < 1000000; i++) { } |
| 113 | 116 |
| 114 if (support_smi_only_arrays) { | 117 if (support_smi_only_arrays) { |
| 115 function construct_smis() { | 118 function construct_smis() { |
| 116 %NeverOptimize(); | |
| 117 var a = [0, 0, 0]; | 119 var a = [0, 0, 0]; |
| 118 a[0] = 0; // Send the COW array map to the steak house. | 120 a[0] = 0; // Send the COW array map to the steak house. |
| 119 assertKind(elements_kind.fast_smi_only, a); | 121 assertKind(elements_kind.fast_smi_only, a); |
| 120 return a; | 122 return a; |
| 121 } | 123 } |
| 122 function construct_doubles() { | 124 function construct_doubles() { |
| 123 %NeverOptimize(); | |
| 124 var a = construct_smis(); | 125 var a = construct_smis(); |
| 125 a[0] = 1.5; | 126 a[0] = 1.5; |
| 126 assertKind(elements_kind.fast_double, a); | 127 assertKind(elements_kind.fast_double, a); |
| 127 return a; | 128 return a; |
| 128 } | 129 } |
| 129 | 130 |
| 130 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will | 131 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will |
| 131 // transition to FAST directly). | 132 // transition to FAST directly). |
| 132 function convert_mixed(array, value, kind) { | 133 function convert_mixed(array, value, kind) { |
| 133 %NeverOptimize(); | |
| 134 array[1] = value; | 134 array[1] = value; |
| 135 assertKind(kind, array); | 135 assertKind(kind, array); |
| 136 assertEquals(value, array[1]); | 136 assertEquals(value, array[1]); |
| 137 } | 137 } |
| 138 smis = construct_smis(); | 138 smis = construct_smis(); |
| 139 convert_mixed(smis, 1.5, elements_kind.fast_double); | 139 convert_mixed(smis, 1.5, elements_kind.fast_double); |
| 140 | 140 |
| 141 doubles = construct_doubles(); | 141 doubles = construct_doubles(); |
| 142 convert_mixed(doubles, "three", elements_kind.fast); | 142 convert_mixed(doubles, "three", elements_kind.fast); |
| 143 | 143 |
| 144 convert_mixed(construct_smis(), "three", elements_kind.fast); | 144 convert_mixed(construct_smis(), "three", elements_kind.fast); |
| 145 convert_mixed(construct_doubles(), "three", elements_kind.fast); | 145 convert_mixed(construct_doubles(), "three", elements_kind.fast); |
| 146 | 146 |
| 147 smis = construct_smis(); | 147 smis = construct_smis(); |
| 148 doubles = construct_doubles(); | 148 doubles = construct_doubles(); |
| 149 convert_mixed(smis, 1, elements_kind.fast); | 149 convert_mixed(smis, 1, elements_kind.fast); |
| 150 convert_mixed(doubles, 1, elements_kind.fast); | 150 convert_mixed(doubles, 1, elements_kind.fast); |
| 151 assertTrue(%HaveSameMap(smis, doubles)); | 151 assertTrue(%HaveSameMap(smis, doubles)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // Throw away type information in the ICs for next stress run. | 154 // Throw away type information in the ICs for next stress run. |
| 155 gc(); | 155 gc(); |
| OLD | NEW |