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

Side by Side Diff: test/webkit/dfg-constant-fold-misprediction.js

Issue 18068003: Migrated several tests from blink to V8 repository. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions
6 // are met:
7 // 1. Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // 2. Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 //
13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24 description(
25 "This tests that a constant folding on a node that has obviously mispredicted ty pe doesn't send the compiler into an infinite loop."
26 );
27
28 // A function with an argument correctly predicted double.
29 function foo(x) {
30 // Two variables holding constants such that the bytecode generation constan t folder
31 // will not constant fold the division below, but the DFG constant folder wi ll.
32 var a = 1;
33 var b = 4000;
34 // A division that is going to be predicted integer on the first compilation . The
35 // compilation will be triggered from the loop below so the slow case counte r of the
36 // division will be 1, which is too low for the division to be predicted dou ble.
37 // If we constant fold this division, we'll have a constant node that is pre dicted
38 // integer but that contains a double. The subsequent addition to x, which i s
39 // predicted double, will lead the Fixup phase to inject an Int32ToDouble no de on
40 // the constant-that-was-a-division; subsequent fases in the fixpoint will c onstant
41 // fold that Int32ToDouble. And hence we will have an infinite loop. The cor rect fix
42 // is to disable constant folding of mispredicted nodes; that allows the nor mal
43 // process of correcting predictions (OSR exit profiling, exiting to profile d code,
44 // and recompilation with exponential backoff) to take effect so that the ne xt
45 // compilation does not make this same mistake.
46 var c = (a / b) + x;
47 // A pointless loop to force the first compilation to occur before the divis ion got
48 // hot. If this loop was not here then the division would be known to produc e doubles
49 // on the first compilation.
50 var d = 0;
51 for (var i = 0; i < 1000; ++i)
52 d++;
53 return c + d;
54 }
55
56 // Call foo() enough times to make totally sure that we optimize.
57 for (var i = 0; i < 5; ++i)
58 shouldBe("foo(0.5)", "1000.50025");
59
60
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698