]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/invalidation-point.js
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / tests / stress / invalidation-point.js
diff --git a/tests/stress/invalidation-point.js b/tests/stress/invalidation-point.js
new file mode 100644 (file)
index 0000000..6f8b55c
--- /dev/null
@@ -0,0 +1,24 @@
+function foo(o, p) {
+    possiblyDoBadThings(p);
+    return o.f();
+}
+noInline(foo);
+
+function Thingy() { }
+Thingy.prototype.f = function() { return 42; }
+
+function possiblyDoBadThings(p) {
+    if (p)
+        Thingy.prototype.f = function() { return 24; }
+}
+noInline(possiblyDoBadThings);
+
+for (var i = 0; i < 100000; ++i) {
+    var result = foo(new Thingy(), false);
+    if (result != 42)
+        throw "Error: bad result: " + result;
+}
+
+var result = foo(new Thingy(), true);
+if (result != 24)
+    throw "Error: bad result: " + result;