summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/watchtower/megamorphic-invalidate.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/watchtower/megamorphic-invalidate.js')
-rw-r--r--js/src/jit-test/tests/watchtower/megamorphic-invalidate.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/watchtower/megamorphic-invalidate.js b/js/src/jit-test/tests/watchtower/megamorphic-invalidate.js
new file mode 100644
index 0000000000..670da583b6
--- /dev/null
+++ b/js/src/jit-test/tests/watchtower/megamorphic-invalidate.js
@@ -0,0 +1,83 @@
+// |jit-test| --enable-watchtower
+
+setJitCompilerOption("ic.force-megamorphic", 1);
+
+function testAddToIntermediate() {
+ var C = Object.create(null);
+ var B = Object.create(C);
+ var A = Object.create(B);
+ C.x = 1;
+ for (var i = 0; i < 50; i++) {
+ assertEq(A.x, i <= 45 ? 1 : 0);
+ if (i === 45) {
+ B.x = 0;
+ }
+ }
+}
+for (var i = 0; i < 5; i++) {
+ testAddToIntermediate();
+}
+
+function testAddToReceiver() {
+ var C = Object.create(null);
+ var B = Object.create(C);
+ var A = Object.create(B);
+ C.x = 1;
+ for (var i = 0; i < 50; i++) {
+ assertEq(A.x, i <= 45 ? 1 : 0);
+ if (i === 45) {
+ A.x = 0;
+ }
+ }
+}
+for (var i = 0; i < 5; i++) {
+ testAddToReceiver();
+}
+
+function testDelete() {
+ var C = Object.create(null);
+ var B = Object.create(C);
+ var A = Object.create(B);
+ C.x = 1;
+ for (var i = 0; i < 50; i++) {
+ assertEq(A.x, i <= 45 ? 1 : undefined);
+ if (i === 45) {
+ delete C.x;
+ }
+ }
+}
+for (var i = 0; i < 5; i++) {
+ testDelete();
+}
+
+function testDataToAccessor() {
+ var C = Object.create(null);
+ var B = Object.create(C);
+ var A = Object.create(B);
+ C.x = 1;
+ for (var i = 0; i < 50; i++) {
+ assertEq(A.x, i <= 45 ? 1 : 7);
+ if (i === 45) {
+ Object.defineProperty(C, "x", {get: () => 7});
+ }
+ }
+}
+for (var i = 0; i < 5; i++) {
+ testDataToAccessor();
+}
+
+function testProtoChange() {
+ var C = Object.create(null);
+ var B = Object.create(C);
+ var A = Object.create(B);
+ C.x = 1;
+ for (var i = 0; i < 50; i++) {
+ assertEq(A.x, i <= 45 ? 1 : 8);
+ if (i === 45) {
+ Object.setPrototypeOf(B, {a: 0, b: 1, x: 8});
+ }
+ }
+}
+for (var i = 0; i < 5; i++) {
+ testProtoChange();
+}