summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/bound-construct-derived-class-ctor.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/cacheir/bound-construct-derived-class-ctor.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/src/jit-test/tests/cacheir/bound-construct-derived-class-ctor.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/cacheir/bound-construct-derived-class-ctor.js b/js/src/jit-test/tests/cacheir/bound-construct-derived-class-ctor.js
new file mode 100644
index 0000000000..321fbb47f6
--- /dev/null
+++ b/js/src/jit-test/tests/cacheir/bound-construct-derived-class-ctor.js
@@ -0,0 +1,46 @@
+class Base {
+ constructor(b) {
+ this.b = b;
+ }
+}
+class Derived extends Base {
+ constructor(a, b) {
+ super(b);
+ this.a = a;
+ }
+}
+
+function testSimple() {
+ var boundCtor = Derived.bind(null, 1);
+ for (var i = 0; i < 100; i++) {
+ var o = new boundCtor(2);
+ assertEq(o.a, 1);
+ assertEq(o.b, 2);
+
+ }
+}
+testSimple();
+
+function testMegamorphic() {
+ var ctors = [
+ function(a, b) { this.a = a; this.b = b; this.c = 1; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 2; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 3; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 4; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 5; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 6; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 7; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 8; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 9; }.bind(null, 1),
+ function(a, b) { this.a = a; this.b = b; this.c = 10; }.bind(null, 1),
+ Derived.bind(null, 1),
+ Derived.bind(null, 1),
+ ];
+ for (var i = 0; i < 100; i++) {
+ var ctor = ctors[i % ctors.length];
+ var o = new ctor(2);
+ assertEq(o.a, 1);
+ assertEq(o.b, 2);
+ }
+}
+testMegamorphic();