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

Unified Diff: test/mjsunit/harmony/iteration-optimization.js

Issue 15740007: Add for-of Crankshaft support Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase onto master; fix AstTyper for ForOfStatement Created 7 years, 6 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/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/iteration-optimization.js
diff --git a/test/mjsunit/regress/readonly1.js b/test/mjsunit/harmony/iteration-optimization.js
similarity index 66%
copy from test/mjsunit/regress/readonly1.js
copy to test/mjsunit/harmony/iteration-optimization.js
index 366f432fbc4179e716834ca5622cd6bfba5ab7bd..4a0caba7181df32f3f914cabbba5eb172b5813d3 100644
--- a/test/mjsunit/regress/readonly1.js
+++ b/test/mjsunit/harmony/iteration-optimization.js
@@ -25,47 +25,36 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-function s(v) {
- v.x = 1;
-}
+// Flags: --harmony --allow-natives-syntax
-function s_strict(v) {
- "use strict";
- v.x = 1;
-}
+// Test Crankshaft for-of support.
-function c(p) {
- return {__proto__: p};
+function* integers_until(n) {
+ for (var i = 0; i < n; i++)
+ yield i;
}
-var p = {};
+function sum(iter) {
+ var sum = 0;
+ for (var x of iter) sum += x;
+ return sum;
+}
-var o1 = c(p);
-var o2 = c(p);
-var o3 = c(p);
-var o4 = c(p);
+assertEquals(45, sum(integers_until(10)));
-// Make p go slow.
-// Do this after using p as prototype, since using an object as prototype kicks
-// it back into fast mode.
-p.y = 1;
-delete p.y;
-p.x = 5;
+%OptimizeFunctionOnNextCall(sum);
-// Initialize the store IC.
-s(o1);
-s(o2);
-s_strict(o1);
-s_strict(o2);
+assertEquals(45, sum(integers_until(10)));
+assertTrue(%GetOptimizationStatus(sum) != 2);
-// Make x non-writable.
-Object.defineProperty(p, "x", { writable: false });
+assertEquals(4950, sum(integers_until(100)));
+assertTrue(%GetOptimizationStatus(sum) != 2);
-// Verify that direct setting fails.
-o3.x = 20;
-assertEquals(5, o3.x);
+// If iter is null or undefined, the loop gets skipped without deoptimization.
+assertEquals(0, sum(undefined));
+assertTrue(%GetOptimizationStatus(sum) != 2);
+assertEquals(0, sum(null));
+assertTrue(%GetOptimizationStatus(sum) != 2);
-// Verify that setting through the IC fails.
-s(o4);
-assertEquals(5, o4.x);
-assertThrows("s_strict(o4);", TypeError);
+assertEquals(45, sum(integers_until(10)));
+assertTrue(%GetOptimizationStatus(sum) != 2);
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698