| OLD | NEW | 
|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/v8.h" | 5 #include "src/v8.h" | 
| 6 | 6 | 
| 7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" | 
| 8 #include "test/cctest/compiler/function-tester.h" | 8 #include "test/cctest/compiler/function-tester.h" | 
| 9 | 9 | 
| 10 using namespace v8::internal; | 10 using namespace v8::internal; | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 154   InstallAssertInlineCountHelper(CcTest::isolate()); | 154   InstallAssertInlineCountHelper(CcTest::isolate()); | 
| 155   T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); | 155   T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); | 
| 156 } | 156 } | 
| 157 | 157 | 
| 158 | 158 | 
| 159 TEST(InlineOmitArguments) { | 159 TEST(InlineOmitArguments) { | 
| 160   FunctionTester T( | 160   FunctionTester T( | 
| 161       "(function () {" | 161       "(function () {" | 
| 162       "  var x = 42;" | 162       "  var x = 42;" | 
| 163       "  function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };" | 163       "  function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };" | 
| 164       "  return (function (s,t) { return bar(s); });" | 164       "  function foo(s, t) { return bar(s); };" | 
|  | 165       "  return foo;" | 
| 165       "})();", | 166       "})();", | 
| 166       kInlineFlags); | 167       kInlineFlags); | 
| 167 | 168 | 
| 168   InstallAssertInlineCountHelper(CcTest::isolate()); | 169   InstallAssertInlineCountHelper(CcTest::isolate()); | 
| 169   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); | 170   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); | 
| 170 } | 171 } | 
| 171 | 172 | 
| 172 | 173 | 
|  | 174 TEST(InlineOmitArgumentsObject) { | 
|  | 175   FunctionTester T( | 
|  | 176       "(function () {" | 
|  | 177       "  function bar(s, t, u, v) { AssertInlineCount(2); return arguments; };" | 
|  | 178       "  function foo(s, t) { var args = bar(s);" | 
|  | 179       "                       return args.length == 1 &&" | 
|  | 180       "                              args[0] == 11; };" | 
|  | 181       "  return foo;" | 
|  | 182       "})();", | 
|  | 183       kInlineFlags); | 
|  | 184 | 
|  | 185   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  | 186   T.CheckCall(T.true_value(), T.Val(11), T.undefined()); | 
|  | 187 } | 
|  | 188 | 
|  | 189 | 
| 173 TEST(InlineOmitArgumentsDeopt) { | 190 TEST(InlineOmitArgumentsDeopt) { | 
| 174   FunctionTester T( | 191   FunctionTester T( | 
| 175       "(function () {" | 192       "(function () {" | 
| 176       "  function foo(s,t,u,v) { AssertInlineCount(2);" | 193       "  function foo(s,t,u,v) { AssertInlineCount(2);" | 
| 177       "                          %DeoptimizeFunction(bar); return baz(); };" | 194       "                          %DeoptimizeFunction(bar); return baz(); };" | 
| 178       "  function bar() { return foo(11); };" | 195       "  function bar() { return foo(11); };" | 
| 179       "  function baz() { return foo.arguments.length == 1 &&" | 196       "  function baz() { return foo.arguments.length == 1 &&" | 
| 180       "                          foo.arguments[0] == 11; }" | 197       "                          foo.arguments[0] == 11; }" | 
| 181       "  return bar;" | 198       "  return bar;" | 
| 182       "})();", | 199       "})();", | 
| 183       kInlineFlags); | 200       kInlineFlags); | 
| 184 | 201 | 
| 185   InstallAssertInlineCountHelper(CcTest::isolate()); | 202   InstallAssertInlineCountHelper(CcTest::isolate()); | 
| 186   T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); | 203   T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); | 
| 187 } | 204 } | 
| 188 | 205 | 
| 189 | 206 | 
| 190 TEST(InlineSurplusArguments) { | 207 TEST(InlineSurplusArguments) { | 
| 191   FunctionTester T( | 208   FunctionTester T( | 
| 192       "(function () {" | 209       "(function () {" | 
| 193       "  var x = 42;" | 210       "  var x = 42;" | 
| 194       "  function foo(s) { AssertInlineCount(2); return x + s; };" | 211       "  function foo(s) { AssertInlineCount(2); return x + s; };" | 
| 195       "  function bar(s,t) { return foo(s,t,13); };" | 212       "  function bar(s, t) { return foo(s, t, 13); };" | 
| 196       "  return bar;" | 213       "  return bar;" | 
| 197       "})();", | 214       "})();", | 
| 198       kInlineFlags); | 215       kInlineFlags); | 
| 199 | 216 | 
| 200   InstallAssertInlineCountHelper(CcTest::isolate()); | 217   InstallAssertInlineCountHelper(CcTest::isolate()); | 
| 201   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); | 218   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); | 
| 202 } | 219 } | 
| 203 | 220 | 
| 204 | 221 | 
|  | 222 TEST(InlineSurplusArgumentsObject) { | 
|  | 223   FunctionTester T( | 
|  | 224       "(function () {" | 
|  | 225       "  function foo(s) { AssertInlineCount(2); return arguments; };" | 
|  | 226       "  function bar(s, t) { var args = foo(s, t, 13);" | 
|  | 227       "                       return args.length == 3 &&" | 
|  | 228       "                              args[0] == 11 &&" | 
|  | 229       "                              args[1] == 12 &&" | 
|  | 230       "                              args[2] == 13; };" | 
|  | 231       "  return bar;" | 
|  | 232       "})();", | 
|  | 233       kInlineFlags); | 
|  | 234 | 
|  | 235   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  | 236   T.CheckCall(T.true_value(), T.Val(11), T.Val(12)); | 
|  | 237 } | 
|  | 238 | 
|  | 239 | 
| 205 TEST(InlineSurplusArgumentsDeopt) { | 240 TEST(InlineSurplusArgumentsDeopt) { | 
| 206   FunctionTester T( | 241   FunctionTester T( | 
| 207       "(function () {" | 242       "(function () {" | 
| 208       "  function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar);" | 243       "  function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar);" | 
| 209       "                    return baz(); };" | 244       "                    return baz(); };" | 
| 210       "  function bar() { return foo(13, 14, 15); };" | 245       "  function bar() { return foo(13, 14, 15); };" | 
| 211       "  function baz() { return foo.arguments.length == 3 &&" | 246       "  function baz() { return foo.arguments.length == 3 &&" | 
| 212       "                          foo.arguments[0] == 13 &&" | 247       "                          foo.arguments[0] == 13 &&" | 
| 213       "                          foo.arguments[1] == 14 &&" | 248       "                          foo.arguments[1] == 14 &&" | 
| 214       "                          foo.arguments[2] == 15; }" | 249       "                          foo.arguments[2] == 15; }" | 
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 552       "    if (x == 1) return bar(42);" | 587       "    if (x == 1) return bar(42);" | 
| 553       "    return x;" | 588       "    return x;" | 
| 554       "  }" | 589       "  }" | 
| 555       "  return foo;" | 590       "  return foo;" | 
| 556       "})();", | 591       "})();", | 
| 557       kInlineFlags); | 592       kInlineFlags); | 
| 558 | 593 | 
| 559   InstallAssertInlineCountHelper(CcTest::isolate()); | 594   InstallAssertInlineCountHelper(CcTest::isolate()); | 
| 560   T.CheckCall(T.Val(42), T.Val(1)); | 595   T.CheckCall(T.Val(42), T.Val(1)); | 
| 561 } | 596 } | 
| OLD | NEW | 
|---|