v8/test/mjsunit/keyed-has-ic-module-import.js
Matt Gardner 803ad32414 Reland "Optimize in operator"
The original was reverted for breaking webkit layout tests:
https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8-Blink%20Linux%2064/30270

It also caused the following clusterfuzz failures:

chromium:935832
This was a correctness bug due to not properly handling the case of arrays with prototypes other
than Array.prototype. Accesses that were TheHole were not being handled property, both in bounds
holes in holey arrays and out of bounds on either holey or packed arrays. Handling was incorrect
both in access-assembler and in Turbofan.

chromium:935932
This bug was that there was no handling for Has checks on the global object. Turbofan was emitting
code for a store (the 'else' condition on 'access_mode == AccessMode::kLoad'). It hit a DCHECK in
debug builds but in release could show up in different places. This is the bug that caused the
webkit layout test failure that led to the revert.

Both bugs are fixed by in CL, and tests are added for those cases.

Bug: v8:8733, chromium:935932, chromium:935832
Change-Id: Iba0dfcfce6e15d2c0815a7670ece67bc13ba1925
Reviewed-on: https://chromium-review.googlesource.com/c/1493132
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Matt Gardner <magardn@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#59958}
2019-03-01 09:01:18 +00:00

71 lines
1.4 KiB
JavaScript

// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// MODULE
import * as mod from "keyed-has-ic-module-export.js";
function testIn(obj, key) {
return key in obj;
}
function expectTrue(obj, key) {
assertTrue(testIn(obj, key));
}
function expectFalse(obj, key) {
assertFalse(testIn(obj, key));
}
var tests = {
monomporphicTrue: function() {
expectTrue(mod, "a");
expectTrue(mod, "a");
expectTrue(mod, "a");
},
polymprohicKeyTrue: function() {
expectTrue(mod, "a");
expectTrue(mod, "b");
expectTrue(mod, "c");
},
monomorphicFalse: function() {
expectFalse(mod, "d");
expectFalse(mod, "d");
expectFalse(mod, "d");
},
polymorphicKeyFalse: function() {
expectFalse(mod, "d");
expectFalse(mod, "e");
expectFalse(mod, "f");
},
polymorphicTrue: function() {
var o = {a: "A"};
expectTrue(mod, "a");
expectTrue(o, "a");
expectTrue(mod, "a");
expectTrue(o, "a");
},
polymorphicFalse: function() {
var o = {a: "A"};
expectFalse(mod, "d");
expectFalse(o, "d");
expectFalse(mod, "d");
expectFalse(o, "d");
}
};
for (let test in tests) {
%DeoptimizeFunction(testIn);
%ClearFunctionFeedback(testIn);
tests[test]();
%OptimizeFunctionOnNextCall(testIn);
tests[test]();
}