| Index: test/mjsunit/osr-elements-kind.js
|
| diff --git a/test/mjsunit/array-constructor-feedback.js b/test/mjsunit/osr-elements-kind.js
|
| similarity index 57%
|
| copy from test/mjsunit/array-constructor-feedback.js
|
| copy to test/mjsunit/osr-elements-kind.js
|
| index 302239b79c173c9987fb0a2127278c6a57caa6c9..9b0f506b4841d9a334c54569e9a64dc1d282d5fc 100644
|
| --- a/test/mjsunit/array-constructor-feedback.js
|
| +++ b/test/mjsunit/osr-elements-kind.js
|
| @@ -26,7 +26,12 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
|
| -// Flags: --track-allocation-sites --noalways-opt
|
| +// Flags: --notrack_allocation_sites
|
| +
|
| +// Limit the number of stress runs to reduce polymorphism it defeats some of the
|
| +// assumptions made about how elements transitions work because transition stubs
|
| +// end up going generic.
|
| +// Flags: --stress-runs=2
|
|
|
| // Test element kind of objects.
|
| // Since --smi-only-arrays affects builtins, its default setting at compile
|
| @@ -35,8 +40,7 @@
|
| // in this test case. Depending on whether smi-only arrays are actually
|
| // enabled, this test takes the appropriate code path to check smi-only arrays.
|
|
|
| -// support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
|
| -support_smi_only_arrays = true;
|
| +support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
|
|
|
| if (support_smi_only_arrays) {
|
| print("Tests include smi-only arrays.");
|
| @@ -65,11 +69,35 @@ function getKind(obj) {
|
| if (%HasFastObjectElements(obj)) return elements_kind.fast;
|
| if (%HasFastDoubleElements(obj)) return elements_kind.fast_double;
|
| if (%HasDictionaryElements(obj)) return elements_kind.dictionary;
|
| -}
|
| -
|
| -function isHoley(obj) {
|
| - if (%HasFastHoleyElements(obj)) return true;
|
| - return false;
|
| + // Every external kind is also an external array.
|
| + assertTrue(%HasExternalArrayElements(obj));
|
| + if (%HasExternalByteElements(obj)) {
|
| + return elements_kind.external_byte;
|
| + }
|
| + if (%HasExternalUnsignedByteElements(obj)) {
|
| + return elements_kind.external_unsigned_byte;
|
| + }
|
| + if (%HasExternalShortElements(obj)) {
|
| + return elements_kind.external_short;
|
| + }
|
| + if (%HasExternalUnsignedShortElements(obj)) {
|
| + return elements_kind.external_unsigned_short;
|
| + }
|
| + if (%HasExternalIntElements(obj)) {
|
| + return elements_kind.external_int;
|
| + }
|
| + if (%HasExternalUnsignedIntElements(obj)) {
|
| + return elements_kind.external_unsigned_int;
|
| + }
|
| + if (%HasExternalFloatElements(obj)) {
|
| + return elements_kind.external_float;
|
| + }
|
| + if (%HasExternalDoubleElements(obj)) {
|
| + return elements_kind.external_double;
|
| + }
|
| + if (%HasExternalPixelElements(obj)) {
|
| + return elements_kind.external_pixel;
|
| + }
|
| }
|
|
|
| function assertKind(expected, obj, name_opt) {
|
| @@ -80,20 +108,48 @@ function assertKind(expected, obj, name_opt) {
|
| assertEquals(expected, getKind(obj), name_opt);
|
| }
|
|
|
| +// long-running loop forces OSR.
|
| +for (var i = 0; i < 1000000; i++) { }
|
| +
|
| if (support_smi_only_arrays) {
|
| - function bar0(t) {
|
| - return new t();
|
| + function construct_smis() {
|
| + try {} catch (e) {} // TODO(titzer): DisableOptimization
|
| + var a = [0, 0, 0];
|
| + a[0] = 0; // Send the COW array map to the steak house.
|
| + assertKind(elements_kind.fast_smi_only, a);
|
| + return a;
|
| + }
|
| + function construct_doubles() {
|
| + try {} catch (e) {} // TODO(titzer): DisableOptimization
|
| + var a = construct_smis();
|
| + a[0] = 1.5;
|
| + assertKind(elements_kind.fast_double, a);
|
| + return a;
|
| }
|
|
|
| - a = bar0(Array);
|
| - a[0] = 3.5;
|
| - b = bar0(Array);
|
| - assertKind(elements_kind.fast_double, b);
|
| - %OptimizeFunctionOnNextCall(bar0);
|
| - b = bar0(Array);
|
| - assertKind(elements_kind.fast_double, b);
|
| - assertTrue(2 != %GetOptimizationStatus(bar0));
|
| - // bar0 should deopt
|
| - b = bar0(Object);
|
| - assertTrue(1 != %GetOptimizationStatus(bar0));
|
| + // Test transition chain SMI->DOUBLE->FAST (crankshafted function will
|
| + // transition to FAST directly).
|
| + function convert_mixed(array, value, kind) {
|
| + try {} catch (e) {} // TODO(titzer): DisableOptimization
|
| + array[1] = value;
|
| + assertKind(kind, array);
|
| + assertEquals(value, array[1]);
|
| + }
|
| + smis = construct_smis();
|
| + convert_mixed(smis, 1.5, elements_kind.fast_double);
|
| +
|
| + doubles = construct_doubles();
|
| + convert_mixed(doubles, "three", elements_kind.fast);
|
| +
|
| + convert_mixed(construct_smis(), "three", elements_kind.fast);
|
| + convert_mixed(construct_doubles(), "three", elements_kind.fast);
|
| +
|
| + smis = construct_smis();
|
| + doubles = construct_doubles();
|
| + convert_mixed(smis, 1, elements_kind.fast);
|
| + convert_mixed(doubles, 1, elements_kind.fast);
|
| + assertTrue(%HaveSameMap(smis, doubles));
|
| }
|
| +
|
| +// Throw away type information in the ICs for next stress run.
|
| +gc();
|
|
|