Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Unified Diff: test/mjsunit/string-indexof-1.js

Issue 2638393002: [builtins] Add String.prototype.indexOf fast path in TF (Closed)
Patch Set: hardcode paramater massaging Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interface-descriptors.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/string-indexof-1.js
diff --git a/test/mjsunit/string-indexof-1.js b/test/mjsunit/string-indexof-1.js
index e403ec4dad524dad47199ab404ec2cb4cbbc9322..61473255fbfa88173a584a0a7e3fcfa18e41cb21 100644
--- a/test/mjsunit/string-indexof-1.js
+++ b/test/mjsunit/string-indexof-1.js
@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Flags: --allow-natives-syntax
+
var s = "test test test";
assertEquals(0, s.indexOf("t"));
@@ -205,3 +207,79 @@ for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
assertEquals(2, "aba".indexOf("a", "2.00000"));
assertEquals(-1, "aba".indexOf("a", "3.00000"));
})();
+
+(function optimize() {
+ function f() {
+ return 'abc'.indexOf('a');
+ }
+ assertEquals(0, f());
+ assertEquals(0, f());
+ assertEquals(0, f());
+ % OptimizeFunctionOnNextCall(f);
+ assertEquals(0, f());
+
+ function f2() {
+ return 'abc'.indexOf('a', 1);
+ }
+ assertEquals(-1, f2());
+ assertEquals(-1, f2());
+ assertEquals(-1, f2());
+ % OptimizeFunctionOnNextCall(f2);
+ assertEquals(-1, f2());
+
+ function f3() {
+ return 'abc'.indexOf('a');
+ }
+ assertEquals(0, f3());
+ assertEquals(0, f3());
+ assertEquals(0, f3());
+ % OptimizeFunctionOnNextCall(f3);
+ assertEquals(0, f3());
+
+ function f4() {
+ return 'abcbc'.indexOf('bc', 2);
+ }
+ assertEquals(3, f4());
+ assertEquals(3, f4());
+ assertEquals(3, f4());
+ % OptimizeFunctionOnNextCall(f4);
+ assertEquals(3, f4());
+})();
+
+(function optimizeOSR() {
+ function f() {
+ var result;
+ for (var i = 0; i < 100000; i++) {
+ result = 'abc'.indexOf('a');
+ }
+ return result;
+ }
+ assertEquals(0, f());
+
+ function f2() {
+ var result;
+ for (var i = 0; i < 100000; i++) {
+ result = 'abc'.indexOf('a', 1);
+ }
+ return result;
+ }
+ assertEquals(-1, f2());
+
+ function f3() {
+ var result;
+ for (var i = 0; i < 100000; i++) {
+ result = 'abc'.indexOf('a');
+ }
+ return result;
+ }
+ assertEquals(0, f3());
+
+ function f4() {
+ var result;
+ for (var i = 0; i < 100000; i++) {
+ result = 'abcbc'.indexOf('bc', 2);
+ }
+ return result;
+ }
+ assertEquals(3, f4());
+})();
« no previous file with comments | « src/interface-descriptors.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698