OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --allow-natives-syntax | 28 // Flags: --allow-natives-syntax |
29 | 29 |
30 (function OneByteSeqStringSetCharDeoptOsr() { | 30 (function DeoptimizeArgCallFunctionGeneric() { |
31 function deopt() { | 31 var a = []; |
32 %DeoptimizeFunction(f); | 32 |
| 33 function f1(method, array, elem, deopt) { |
| 34 assertEquals('push', method); |
33 } | 35 } |
34 | 36 |
35 function f(string, osr) { | 37 function f2() { } |
36 var world = " world"; | |
37 %_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48)); | |
38 | 38 |
39 if (osr) while (%GetOptimizationStatus(f) == 2) {} | 39 function bar(x, deopt, f) { |
40 | 40 f('push', a, [x], deopt + 0); |
41 return string + world; | |
42 } | 41 } |
43 | 42 |
44 assertEquals("Hello " + "world", f("hello", false)); | 43 function foo() { return bar(arguments[0], arguments[1], arguments[2]); } |
45 %OptimizeFunctionOnNextCall(f); | 44 function baz(f, deopt) { return foo("x", deopt, f); } |
46 assertEquals("Hello " + "world", f("hello", true)); | 45 |
| 46 baz(f1, 0); |
| 47 baz(f2, 0); |
| 48 %OptimizeFunctionOnNextCall(baz); |
| 49 baz(f1, "deopt"); |
47 })(); | 50 })(); |
48 | 51 |
49 | 52 |
50 (function OneByteSeqStringSetCharDeopt() { | 53 (function DeoptimizeArgGlobalFunctionGeneric() { |
51 function deopt() { | 54 var a = []; |
52 %DeoptimizeFunction(f); | 55 |
| 56 var f1; |
| 57 |
| 58 f1 = function(method, array, elem, deopt) { |
| 59 assertEquals('push', method); |
53 } | 60 } |
54 | 61 |
55 function g(x) { | 62 function bar(x, deopt, f) { |
| 63 f1('push', a, [x], deopt + 0); |
56 } | 64 } |
57 | 65 |
58 function f(string) { | 66 function foo() { return bar(arguments[0], arguments[1]); } |
59 g(%_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48))); | 67 function baz(deopt) { return foo("x", deopt); } |
60 return string; | |
61 } | |
62 | 68 |
63 assertEquals("Hell" + "o", f("hello")); | 69 baz(0); |
64 %OptimizeFunctionOnNextCall(f); | 70 baz(0); |
65 assertEquals("Hell" + "o", f("hello")); | 71 %OptimizeFunctionOnNextCall(baz); |
| 72 baz("deopt"); |
66 })(); | 73 })(); |
67 | 74 |
68 | 75 |
69 (function TwoByteSeqStringSetCharDeopt() { | 76 (function DeoptimizeArgCallFunctionRuntime() { |
70 function deopt() { | 77 var a = []; |
71 %DeoptimizeFunction(f); | 78 |
| 79 var f1; |
| 80 |
| 81 f1 = function(method, array, elem, deopt) { |
| 82 assertEquals('push', method); |
72 } | 83 } |
73 | 84 |
74 function g(x) { | 85 function bar(x, deopt) { |
| 86 %_CallFunction(null, 'push', [x][0], ((deopt + 0), 1), f1); |
75 } | 87 } |
76 | 88 |
77 function f(string) { | 89 function foo() { return bar(arguments[0], arguments[1]); } |
78 g(%_TwoByteSeqStringSetChar(string, 0, (deopt(), 0x48))); | 90 function baz(deopt) { return foo(0, deopt); } |
79 return string; | |
80 } | |
81 | 91 |
82 assertEquals("Hell" + "o", f("\u20ACello")); | 92 baz(0); |
83 %OptimizeFunctionOnNextCall(f); | 93 baz(0); |
84 assertEquals("Hell" + "o", f("\u20ACello")); | 94 %OptimizeFunctionOnNextCall(baz); |
| 95 baz("deopt"); |
85 })(); | 96 })(); |
OLD | NEW |