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

Unified Diff: test/mjsunit/keyed-named-access.js

Issue 585433002: Turn keyed loads with string-based (non-convertible to array-index) key into named loads (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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/hydrogen.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/keyed-named-access.js
diff --git a/test/mjsunit/keyed-named-access.js b/test/mjsunit/keyed-named-access.js
new file mode 100644
index 0000000000000000000000000000000000000000..f9541e8e0aa9c2cd9a96faab478270964104f2a4
--- /dev/null
+++ b/test/mjsunit/keyed-named-access.js
@@ -0,0 +1,36 @@
+// Copyright 2014 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
+
+var k = "x";
+var o1 = {x: 10};
+var o2 = {x: 11, y: 20};
+var o3 = {x: 12, y: 20, z: 100};
+
+function f(o) {
+ var result = 0;
+ for (var i = 0; i < 100; i++) {
+ result += o[k];
+ }
+ return result;
+}
+
+f(o1);
+f(o1);
+f(o1);
+%OptimizeFunctionOnNextCall(f);
+assertEquals(1000, f(o1));
+
+f(o2);
+f(o2);
+f(o2);
+%OptimizeFunctionOnNextCall(f);
+assertEquals(1100, f(o2));
+
+f(o3);
+f(o3);
+f(o3);
+%OptimizeFunctionOnNextCall(f);
+assertEquals(1200, f(o3));
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698