| Index: test/mjsunit/array-feedback.js
|
| diff --git a/test/mjsunit/array-constructor-feedback.js b/test/mjsunit/array-feedback.js
|
| similarity index 56%
|
| copy from test/mjsunit/array-constructor-feedback.js
|
| copy to test/mjsunit/array-feedback.js
|
| index d723121eef4ac6ea5c4410f98660a0d8deaadc6c..9c5b69cb563f39d91f2fe4c805f3cc317f08cfc0 100644
|
| --- a/test/mjsunit/array-constructor-feedback.js
|
| +++ b/test/mjsunit/array-feedback.js
|
| @@ -88,19 +88,133 @@ function assertKind(expected, obj, name_opt) {
|
| }
|
|
|
| if (support_smi_only_arrays && optimize_constructed_arrays) {
|
| - function bar0(t) {
|
| - return new t();
|
| - }
|
|
|
| - 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));
|
| + // Verify that basic elements kind feedback works for non-constructor
|
| + // array calls (as long as the call is made through an IC, and not
|
| + // a CallStub).
|
| + (function (){
|
| + function create0() {
|
| + return Array();
|
| + }
|
| +
|
| + // Calls through ICs need warm up through uninitialized, then
|
| + // premonomorphic first.
|
| + create0();
|
| + create0();
|
| + a = create0();
|
| + assertKind(elements_kind.fast_smi_only, a);
|
| + a[0] = 3.5;
|
| + b = create0();
|
| + assertKind(elements_kind.fast_double, b);
|
| +
|
| + function create1(arg) {
|
| + return Array(arg);
|
| + }
|
| +
|
| + create1(0);
|
| + create1(0);
|
| + a = create1(0);
|
| + assertFalse(isHoley(a));
|
| + assertKind(elements_kind.fast_smi_only, a);
|
| + a[0] = "hello";
|
| + b = create1(10);
|
| + assertTrue(isHoley(b));
|
| + assertKind(elements_kind.fast, b);
|
| +
|
| + a = create1(100000);
|
| + assertKind(elements_kind.dictionary, a);
|
| +
|
| + function create3(arg1, arg2, arg3) {
|
| + return Array(arg1, arg2, arg3);
|
| + }
|
| +
|
| + create3();
|
| + create3();
|
| + a = create3(1,2,3);
|
| + a[0] = 3.5;
|
| + b = create3(1,2,3);
|
| + assertKind(elements_kind.fast_double, b);
|
| + assertFalse(isHoley(b));
|
| + })();
|
| +
|
| +
|
| + // Verify that keyed calls work
|
| + (function (){
|
| + function create0(name) {
|
| + return this[name]();
|
| + }
|
| +
|
| + name = "Array";
|
| + create0(name);
|
| + create0(name);
|
| + a = create0(name);
|
| + a[0] = 3.5;
|
| + b = create0(name);
|
| + assertKind(elements_kind.fast_double, b);
|
| + })();
|
| +
|
| +
|
| + // Verify that the IC can't be spoofed by patching
|
| + (function (){
|
| + function create0() {
|
| + return Array();
|
| + }
|
| +
|
| + create0();
|
| + create0();
|
| + a = create0();
|
| + assertKind(elements_kind.fast_smi_only, a);
|
| + var oldArray = this.Array;
|
| + this.Array = function() { return ["hi"]; };
|
| + b = create0();
|
| + assertEquals(["hi"], b);
|
| + this.Array = oldArray;
|
| + })();
|
| +
|
| + // Verify that calls are still made through an IC after crankshaft,
|
| + // though the type information is reset.
|
| + // TODO(mvstanton): instead, consume the type feedback gathered up
|
| + // until crankshaft time.
|
| + (function (){
|
| + function create0() {
|
| + return Array();
|
| + }
|
| +
|
| + create0();
|
| + create0();
|
| + a = create0();
|
| + a[0] = 3.5;
|
| + %OptimizeFunctionOnNextCall(create0);
|
| + create0();
|
| + create0();
|
| + b = create0();
|
| + assertKind(elements_kind.fast_smi_only, b);
|
| + b[0] = 3.5;
|
| + c = create0();
|
| + assertKind(elements_kind.fast_double, c);
|
| + assertTrue(2 != %GetOptimizationStatus(create0));
|
| + })();
|
| +
|
| +
|
| + // Verify that cross context calls work
|
| + (function (){
|
| + var realmA = Realm.current();
|
| + var realmB = Realm.create();
|
| + assertEquals(0, realmA);
|
| + assertEquals(1, realmB);
|
| +
|
| + function instanceof_check(type) {
|
| + assertTrue(type() instanceof type);
|
| + assertTrue(type(5) instanceof type);
|
| + assertTrue(type(1,2,3) instanceof type);
|
| + }
|
| +
|
| + var realmBArray = Realm.eval(realmB, "Array");
|
| + instanceof_check(Array);
|
| + instanceof_check(Array);
|
| + instanceof_check(Array);
|
| + instanceof_check(realmBArray);
|
| + instanceof_check(realmBArray);
|
| + instanceof_check(realmBArray);
|
| + })();
|
| }
|
|
|