| 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 "test/cctest/compiler/function-tester.h" |    7 #include "test/cctest/compiler/function-tester.h" | 
|    8  |    8  | 
|    9 #if V8_TURBOFAN_TARGET |    9 #if V8_TURBOFAN_TARGET | 
|   10  |   10  | 
|   11 using namespace v8::internal; |   11 using namespace v8::internal; | 
|   12 using namespace v8::internal::compiler; |   12 using namespace v8::internal::compiler; | 
|   13  |   13  | 
|   14 // TODO(sigurds) At the moment we do not write optimization frames when |   14 // Helper to determine inline count via JavaScriptFrame::GetInlineCount. | 
|   15 // inlining, thus the reported stack depth changes depending on inlining. |   15 // Note that a count of 1 indicates that no inlining has occured. | 
|   16 // AssertStackDepth checks the stack depth actually changes as a simple way |   16 static void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { | 
|   17 // to ensure that inlining actually occurs. |   17   StackTraceFrameIterator it(CcTest::i_isolate()); | 
|   18 // Once inlining creates optimization frames, all these unit tests need to |   18   int frames_seen = 0; | 
|   19 // check that the optimization frame is there. |   19   JavaScriptFrame* topmost = it.frame(); | 
|   20  |   20   while (!it.done()) { | 
|   21  |   21     JavaScriptFrame* frame = it.frame(); | 
|   22 static void AssertStackDepth(const v8::FunctionCallbackInfo<v8::Value>& args) { |   22     PrintF("%d %s, inline count: %d\n", frames_seen, | 
|   23   v8::HandleScope scope(args.GetIsolate()); |   23            frame->function()->shared()->DebugName()->ToCString().get(), | 
|   24   v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |   24            frame->GetInlineCount()); | 
|   25       args.GetIsolate(), 10, v8::StackTrace::kDetailed); |   25     frames_seen++; | 
|   26   CHECK_EQ(args[0]->ToInt32()->Value(), stackTrace->GetFrameCount()); |   26     it.Advance(); | 
 |   27   } | 
 |   28   CHECK_EQ(args[0]->ToInt32()->Value(), topmost->GetInlineCount()); | 
|   27 } |   29 } | 
|   28  |   30  | 
|   29  |   31  | 
|   30 static void InstallAssertStackDepthHelper(v8::Isolate* isolate) { |   32 static void InstallAssertInlineCountHelper(v8::Isolate* isolate) { | 
|   31   v8::Local<v8::Context> context = isolate->GetCurrentContext(); |   33   v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 
|   32   v8::Local<v8::FunctionTemplate> t = |   34   v8::Local<v8::FunctionTemplate> t = | 
|   33       v8::FunctionTemplate::New(isolate, AssertStackDepth); |   35       v8::FunctionTemplate::New(isolate, AssertInlineCount); | 
|   34   context->Global()->Set(v8_str("AssertStackDepth"), t->GetFunction()); |   36   context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); | 
|   35 } |   37 } | 
|   36  |   38  | 
|   37  |   39  | 
|   38 TEST(SimpleInlining) { |   40 TEST(SimpleInlining) { | 
 |   41   FLAG_turbo_deoptimization = true; | 
|   39   FunctionTester T( |   42   FunctionTester T( | 
|   40       "(function(){" |   43       "(function(){" | 
|   41       "function foo(s) { AssertStackDepth(1); return s; };" |   44       "function foo(s) { AssertInlineCount(2); return s; };" | 
|   42       "function bar(s, t) { return foo(s); };" |   45       "function bar(s, t) { return foo(s); };" | 
|   43       "return bar;})();", |   46       "return bar;})();", | 
|   44       CompilationInfo::kInliningEnabled | |   47       CompilationInfo::kInliningEnabled | | 
|   45           CompilationInfo::kContextSpecializing | |   48           CompilationInfo::kContextSpecializing | | 
|   46           CompilationInfo::kTypingEnabled); |   49           CompilationInfo::kTypingEnabled); | 
|   47  |   50  | 
|   48   InstallAssertStackDepthHelper(CcTest::isolate()); |   51   InstallAssertInlineCountHelper(CcTest::isolate()); | 
 |   52   T.CheckCall(T.Val(1), T.Val(1), T.Val(2)); | 
 |   53 } | 
 |   54  | 
 |   55  | 
 |   56 TEST(SimpleInliningDeopt) { | 
 |   57   FLAG_turbo_deoptimization = true; | 
 |   58   FunctionTester T( | 
 |   59       "(function(){" | 
 |   60       "function foo(s) { %DeoptimizeFunction(bar); return " | 
 |   61       "s; };" | 
 |   62       "function bar(s, t) { return foo(s); };" | 
 |   63       "return bar;})();", | 
 |   64       CompilationInfo::kInliningEnabled | | 
 |   65           CompilationInfo::kContextSpecializing | | 
 |   66           CompilationInfo::kTypingEnabled); | 
 |   67  | 
 |   68   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|   49   T.CheckCall(T.Val(1), T.Val(1), T.Val(2)); |   69   T.CheckCall(T.Val(1), T.Val(1), T.Val(2)); | 
|   50 } |   70 } | 
|   51  |   71  | 
|   52  |   72  | 
|   53 TEST(SimpleInliningContext) { |   73 TEST(SimpleInliningContext) { | 
 |   74   FLAG_turbo_deoptimization = true; | 
|   54   FunctionTester T( |   75   FunctionTester T( | 
|   55       "(function () {" |   76       "(function () {" | 
|   56       "function foo(s) { AssertStackDepth(1); var x = 12; return s + x; };" |   77       "function foo(s) { AssertInlineCount(2); var x = 12; return s + x; };" | 
|   57       "function bar(s, t) { return foo(s); };" |   78       "function bar(s, t) { return foo(s); };" | 
|   58       "return bar;" |   79       "return bar;" | 
|   59       "})();", |   80       "})();", | 
|   60       CompilationInfo::kInliningEnabled | |   81       CompilationInfo::kInliningEnabled | | 
|   61           CompilationInfo::kContextSpecializing | |   82           CompilationInfo::kContextSpecializing | | 
|   62           CompilationInfo::kTypingEnabled); |   83           CompilationInfo::kTypingEnabled); | 
|   63  |   84  | 
|   64   InstallAssertStackDepthHelper(CcTest::isolate()); |   85   InstallAssertInlineCountHelper(CcTest::isolate()); | 
 |   86   T.CheckCall(T.Val(13), T.Val(1), T.Val(2)); | 
 |   87 } | 
 |   88  | 
 |   89  | 
 |   90 TEST(SimpleInliningContextDeopt) { | 
 |   91   FLAG_turbo_deoptimization = true; | 
 |   92   FunctionTester T( | 
 |   93       "(function () {" | 
 |   94       "function foo(s) { " | 
 |   95       "  AssertInlineCount(2); %DeoptimizeFunction(bar); var x = 12;" | 
 |   96       "  return s + x;" | 
 |   97       "};" | 
 |   98       "function bar(s, t) { return foo(s); };" | 
 |   99       "return bar;" | 
 |  100       "})();", | 
 |  101       CompilationInfo::kInliningEnabled | | 
 |  102           CompilationInfo::kContextSpecializing | | 
 |  103           CompilationInfo::kTypingEnabled); | 
 |  104  | 
 |  105   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|   65   T.CheckCall(T.Val(13), T.Val(1), T.Val(2)); |  106   T.CheckCall(T.Val(13), T.Val(1), T.Val(2)); | 
|   66 } |  107 } | 
|   67  |  108  | 
|   68  |  109  | 
|   69 TEST(CaptureContext) { |  110 TEST(CaptureContext) { | 
 |  111   FLAG_turbo_deoptimization = true; | 
|   70   FunctionTester T( |  112   FunctionTester T( | 
|   71       "var f = (function () {" |  113       "var f = (function () {" | 
|   72       "var x = 42;" |  114       "var x = 42;" | 
|   73       "function bar(s) { return x + s; };" |  115       "function bar(s) { return x + s; };" | 
|   74       "return (function (s) { return bar(s); });" |  116       "return (function (s) { return bar(s); });" | 
|   75       "})();" |  117       "})();" | 
|   76       "(function (s) { return f(s)})", |  118       "(function (s) { return f(s)})", | 
|   77       CompilationInfo::kInliningEnabled | |  119       CompilationInfo::kInliningEnabled | | 
|   78           CompilationInfo::kContextSpecializing | |  120           CompilationInfo::kContextSpecializing | | 
|   79           CompilationInfo::kTypingEnabled); |  121           CompilationInfo::kTypingEnabled); | 
|   80  |  122  | 
|   81   InstallAssertStackDepthHelper(CcTest::isolate()); |  123   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|   82   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); |  124   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); | 
|   83 } |  125 } | 
|   84  |  126  | 
|   85  |  127  | 
|   86 // TODO(sigurds) For now we do not inline any native functions. If we do at |  128 // TODO(sigurds) For now we do not inline any native functions. If we do at | 
|   87 // some point, change this test. |  129 // some point, change this test. | 
|   88 TEST(DontInlineEval) { |  130 TEST(DontInlineEval) { | 
 |  131   FLAG_turbo_deoptimization = true; | 
|   89   FunctionTester T( |  132   FunctionTester T( | 
|   90       "var x = 42;" |  133       "var x = 42;" | 
|   91       "(function () {" |  134       "(function () {" | 
|   92       "function bar(s, t) { return eval(\"AssertStackDepth(2); x\") };" |  135       "function bar(s, t) { return eval(\"AssertInlineCount(1); x\") };" | 
|   93       "return bar;" |  136       "return bar;" | 
|   94       "})();", |  137       "})();", | 
|   95       CompilationInfo::kInliningEnabled | |  138       CompilationInfo::kInliningEnabled | | 
|   96           CompilationInfo::kContextSpecializing | |  139           CompilationInfo::kContextSpecializing | | 
|   97           CompilationInfo::kTypingEnabled); |  140           CompilationInfo::kTypingEnabled); | 
|   98  |  141  | 
|   99   InstallAssertStackDepthHelper(CcTest::isolate()); |  142   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  100   T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); |  143   T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); | 
|  101 } |  144 } | 
|  102  |  145  | 
|  103  |  146  | 
|  104 TEST(InlineOmitArguments) { |  147 TEST(InlineOmitArguments) { | 
 |  148   FLAG_turbo_deoptimization = true; | 
|  105   FunctionTester T( |  149   FunctionTester T( | 
|  106       "(function () {" |  150       "(function () {" | 
|  107       "var x = 42;" |  151       "var x = 42;" | 
|  108       "function bar(s, t, u, v) { AssertStackDepth(1); return x + s; };" |  152       "function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };" | 
|  109       "return (function (s,t) { return bar(s); });" |  153       "return (function (s,t) { return bar(s); });" | 
|  110       "})();", |  154       "})();", | 
|  111       CompilationInfo::kInliningEnabled | |  155       CompilationInfo::kInliningEnabled | | 
|  112           CompilationInfo::kContextSpecializing | |  156           CompilationInfo::kContextSpecializing | | 
|  113           CompilationInfo::kTypingEnabled); |  157           CompilationInfo::kTypingEnabled); | 
|  114  |  158  | 
|  115   InstallAssertStackDepthHelper(CcTest::isolate()); |  159   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  116   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); |  160   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); | 
|  117 } |  161 } | 
|  118  |  162  | 
|  119  |  163  | 
 |  164 TEST(InlineOmitArgumentsDeopt) { | 
 |  165   FLAG_turbo_deoptimization = true; | 
 |  166   FunctionTester T( | 
 |  167       "(function () {" | 
 |  168       "function foo(s,t,u,v) { AssertInlineCount(2); %DeoptimizeFunction(bar); " | 
 |  169       "return baz(); };" | 
 |  170       "function bar() { return foo(11); };" | 
 |  171       "function baz() { return foo.arguments.length == 1 && " | 
 |  172       "                        foo.arguments[0] == 11 ; }" | 
 |  173       "return bar;" | 
 |  174       "})();", | 
 |  175       CompilationInfo::kInliningEnabled | | 
 |  176           CompilationInfo::kContextSpecializing | | 
 |  177           CompilationInfo::kTypingEnabled); | 
 |  178  | 
 |  179   InstallAssertInlineCountHelper(CcTest::isolate()); | 
 |  180   T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); | 
 |  181 } | 
 |  182  | 
 |  183  | 
|  120 TEST(InlineSurplusArguments) { |  184 TEST(InlineSurplusArguments) { | 
 |  185   FLAG_turbo_deoptimization = true; | 
|  121   FunctionTester T( |  186   FunctionTester T( | 
|  122       "(function () {" |  187       "(function () {" | 
|  123       "var x = 42;" |  188       "var x = 42;" | 
|  124       "function foo(s) { AssertStackDepth(1); return x + s; };" |  189       "function foo(s) { AssertInlineCount(2); return x + s; };" | 
|  125       "function bar(s,t) { return foo(s,t,13); };" |  190       "function bar(s,t) { return foo(s,t,13); };" | 
|  126       "return bar;" |  191       "return bar;" | 
|  127       "})();", |  192       "})();", | 
|  128       CompilationInfo::kInliningEnabled | |  193       CompilationInfo::kInliningEnabled | | 
|  129           CompilationInfo::kContextSpecializing | |  194           CompilationInfo::kContextSpecializing | | 
|  130           CompilationInfo::kTypingEnabled); |  195           CompilationInfo::kTypingEnabled); | 
|  131  |  196  | 
|  132   InstallAssertStackDepthHelper(CcTest::isolate()); |  197   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  133   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); |  198   T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); | 
|  134 } |  199 } | 
|  135  |  200  | 
|  136  |  201  | 
 |  202 TEST(InlineSurplusArgumentsDeopt) { | 
 |  203   FLAG_turbo_deoptimization = true; | 
 |  204   FunctionTester T( | 
 |  205       "(function () {" | 
 |  206       "function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar); " | 
 |  207       "return baz(); };" | 
 |  208       "function bar() { return foo(13, 14, 15); };" | 
 |  209       "function baz() { return foo.arguments.length == 3 && " | 
 |  210       "                        foo.arguments[0] == 13 && " | 
 |  211       "                        foo.arguments[1] == 14 && " | 
 |  212       "                        foo.arguments[2] == 15; }" | 
 |  213       "return bar;" | 
 |  214       "})();", | 
 |  215       CompilationInfo::kInliningEnabled | | 
 |  216           CompilationInfo::kContextSpecializing | | 
 |  217           CompilationInfo::kTypingEnabled); | 
 |  218  | 
 |  219   InstallAssertInlineCountHelper(CcTest::isolate()); | 
 |  220   T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); | 
 |  221 } | 
 |  222  | 
 |  223  | 
|  137 TEST(InlineTwice) { |  224 TEST(InlineTwice) { | 
 |  225   FLAG_turbo_deoptimization = true; | 
|  138   FunctionTester T( |  226   FunctionTester T( | 
|  139       "(function () {" |  227       "(function () {" | 
|  140       "var x = 42;" |  228       "var x = 42;" | 
|  141       "function bar(s) { AssertStackDepth(1); return x + s; };" |  229       "function bar(s) { AssertInlineCount(2); return x + s; };" | 
|  142       "return (function (s,t) { return bar(s) + bar(t); });" |  230       "return (function (s,t) { return bar(s) + bar(t); });" | 
|  143       "})();", |  231       "})();", | 
|  144       CompilationInfo::kInliningEnabled | |  232       CompilationInfo::kInliningEnabled | | 
|  145           CompilationInfo::kContextSpecializing | |  233           CompilationInfo::kContextSpecializing | | 
|  146           CompilationInfo::kTypingEnabled); |  234           CompilationInfo::kTypingEnabled); | 
|  147  |  235  | 
|  148   InstallAssertStackDepthHelper(CcTest::isolate()); |  236   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  149   T.CheckCall(T.Val(2 * 42 + 12 + 4), T.Val(12), T.Val(4)); |  237   T.CheckCall(T.Val(2 * 42 + 12 + 4), T.Val(12), T.Val(4)); | 
|  150 } |  238 } | 
|  151  |  239  | 
|  152  |  240  | 
|  153 TEST(InlineTwiceDependent) { |  241 TEST(InlineTwiceDependent) { | 
 |  242   FLAG_turbo_deoptimization = true; | 
|  154   FunctionTester T( |  243   FunctionTester T( | 
|  155       "(function () {" |  244       "(function () {" | 
|  156       "var x = 42;" |  245       "var x = 42;" | 
|  157       "function foo(s) { AssertStackDepth(1); return x + s; };" |  246       "function foo(s) { AssertInlineCount(2); return x + s; };" | 
|  158       "function bar(s,t) { return foo(foo(s)); };" |  247       "function bar(s,t) { return foo(foo(s)); };" | 
|  159       "return bar;" |  248       "return bar;" | 
|  160       "})();", |  249       "})();", | 
|  161       CompilationInfo::kInliningEnabled | |  250       CompilationInfo::kInliningEnabled | | 
|  162           CompilationInfo::kContextSpecializing | |  251           CompilationInfo::kContextSpecializing | | 
|  163           CompilationInfo::kTypingEnabled); |  252           CompilationInfo::kTypingEnabled); | 
|  164  |  253  | 
|  165   InstallAssertStackDepthHelper(CcTest::isolate()); |  254   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  166   T.CheckCall(T.Val(42 + 42 + 12), T.Val(12), T.Val(4)); |  255   T.CheckCall(T.Val(42 + 42 + 12), T.Val(12), T.Val(4)); | 
|  167 } |  256 } | 
|  168  |  257  | 
|  169  |  258  | 
|  170 TEST(InlineTwiceDependentDiamond) { |  259 TEST(InlineTwiceDependentDiamond) { | 
 |  260   FLAG_turbo_deoptimization = true; | 
|  171   FunctionTester T( |  261   FunctionTester T( | 
|  172       "(function () {" |  262       "(function () {" | 
|  173       "var x = 41;" |  263       "var x = 41;" | 
|  174       "function foo(s) { AssertStackDepth(1); if (s % 2 == 0) {" |  264       "function foo(s) { AssertInlineCount(2); if (s % 2 == 0) {" | 
|  175       "                  return x - s } else { return x + s; } };" |  265       "                  return x - s } else { return x + s; } };" | 
|  176       "function bar(s,t) { return foo(foo(s)); };" |  266       "function bar(s,t) { return foo(foo(s)); };" | 
|  177       "return bar;" |  267       "return bar;" | 
|  178       "})();", |  268       "})();", | 
|  179       CompilationInfo::kInliningEnabled | |  269       CompilationInfo::kInliningEnabled | | 
|  180           CompilationInfo::kContextSpecializing | |  270           CompilationInfo::kContextSpecializing | | 
|  181           CompilationInfo::kTypingEnabled); |  271           CompilationInfo::kTypingEnabled); | 
|  182  |  272  | 
|  183   InstallAssertStackDepthHelper(CcTest::isolate()); |  273   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  184   T.CheckCall(T.Val(-11), T.Val(11), T.Val(4)); |  274   T.CheckCall(T.Val(-11), T.Val(11), T.Val(4)); | 
|  185 } |  275 } | 
|  186  |  276  | 
|  187  |  277  | 
|  188 TEST(InlineTwiceDependentDiamondDifferent) { |  278 TEST(InlineTwiceDependentDiamondDifferent) { | 
 |  279   FLAG_turbo_deoptimization = true; | 
|  189   FunctionTester T( |  280   FunctionTester T( | 
|  190       "(function () {" |  281       "(function () {" | 
|  191       "var x = 41;" |  282       "var x = 41;" | 
|  192       "function foo(s,t) { AssertStackDepth(1); if (s % 2 == 0) {" |  283       "function foo(s,t) { AssertInlineCount(2); if (s % 2 == 0) {" | 
|  193       "                    return x - s * t } else { return x + s * t; } };" |  284       "                    return x - s * t } else { return x + s * t; } };" | 
|  194       "function bar(s,t) { return foo(foo(s, 3), 5); };" |  285       "function bar(s,t) { return foo(foo(s, 3), 5); };" | 
|  195       "return bar;" |  286       "return bar;" | 
|  196       "})();", |  287       "})();", | 
|  197       CompilationInfo::kInliningEnabled | |  288       CompilationInfo::kInliningEnabled | | 
|  198           CompilationInfo::kContextSpecializing | |  289           CompilationInfo::kContextSpecializing | | 
|  199           CompilationInfo::kTypingEnabled); |  290           CompilationInfo::kTypingEnabled); | 
|  200  |  291  | 
|  201   InstallAssertStackDepthHelper(CcTest::isolate()); |  292   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  202   T.CheckCall(T.Val(-329), T.Val(11), T.Val(4)); |  293   T.CheckCall(T.Val(-329), T.Val(11), T.Val(4)); | 
|  203 } |  294 } | 
|  204  |  295  | 
|  205  |  296  | 
|  206 TEST(InlineLoop) { |  297 TEST(InlineLoop) { | 
 |  298   FLAG_turbo_deoptimization = true; | 
|  207   FunctionTester T( |  299   FunctionTester T( | 
|  208       "(function () {" |  300       "(function () {" | 
|  209       "var x = 41;" |  301       "var x = 41;" | 
|  210       "function foo(s) { AssertStackDepth(1); while (s > 0) {" |  302       "function foo(s) { AssertInlineCount(2); while (s > 0) {" | 
|  211       "                  s = s - 1; }; return s; };" |  303       "                  s = s - 1; }; return s; };" | 
|  212       "function bar(s,t) { return foo(foo(s)); };" |  304       "function bar(s,t) { return foo(foo(s)); };" | 
|  213       "return bar;" |  305       "return bar;" | 
|  214       "})();", |  306       "})();", | 
|  215       CompilationInfo::kInliningEnabled | |  307       CompilationInfo::kInliningEnabled | | 
|  216           CompilationInfo::kContextSpecializing | |  308           CompilationInfo::kContextSpecializing | | 
|  217           CompilationInfo::kTypingEnabled); |  309           CompilationInfo::kTypingEnabled); | 
|  218  |  310  | 
|  219   InstallAssertStackDepthHelper(CcTest::isolate()); |  311   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  220   T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4)); |  312   T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4)); | 
|  221 } |  313 } | 
|  222  |  314  | 
|  223  |  315  | 
|  224 TEST(InlineStrictIntoNonStrict) { |  316 TEST(InlineStrictIntoNonStrict) { | 
 |  317   FLAG_turbo_deoptimization = true; | 
|  225   FunctionTester T( |  318   FunctionTester T( | 
|  226       "(function () {" |  319       "(function () {" | 
|  227       "var x = Object.create({}, { y: { value:42, writable:false } });" |  320       "var x = Object.create({}, { y: { value:42, writable:false } });" | 
|  228       "function foo(s) { 'use strict';" |  321       "function foo(s) { 'use strict';" | 
|  229       "                   x.y = 9; };" |  322       "                   x.y = 9; };" | 
|  230       "function bar(s,t) { return foo(s); };" |  323       "function bar(s,t) { return foo(s); };" | 
|  231       "return bar;" |  324       "return bar;" | 
|  232       "})();", |  325       "})();", | 
|  233       CompilationInfo::kInliningEnabled | |  326       CompilationInfo::kInliningEnabled | | 
|  234           CompilationInfo::kContextSpecializing | |  327           CompilationInfo::kContextSpecializing | | 
|  235           CompilationInfo::kTypingEnabled); |  328           CompilationInfo::kTypingEnabled); | 
|  236  |  329  | 
|  237   InstallAssertStackDepthHelper(CcTest::isolate()); |  330   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  238   T.CheckThrows(T.undefined(), T.undefined()); |  331   T.CheckThrows(T.undefined(), T.undefined()); | 
|  239 } |  332 } | 
|  240  |  333  | 
|  241  |  334  | 
|  242 TEST(InlineNonStrictIntoStrict) { |  335 TEST(InlineNonStrictIntoStrict) { | 
 |  336   FLAG_turbo_deoptimization = true; | 
|  243   FunctionTester T( |  337   FunctionTester T( | 
|  244       "(function () {" |  338       "(function () {" | 
|  245       "var x = Object.create({}, { y: { value:42, writable:false } });" |  339       "var x = Object.create({}, { y: { value:42, writable:false } });" | 
|  246       "function foo(s) { x.y = 9; return x.y; };" |  340       "function foo(s) { x.y = 9; return x.y; };" | 
|  247       "function bar(s,t) { \'use strict\'; return foo(s); };" |  341       "function bar(s,t) { \'use strict\'; return foo(s); };" | 
|  248       "return bar;" |  342       "return bar;" | 
|  249       "})();", |  343       "})();", | 
|  250       CompilationInfo::kInliningEnabled | |  344       CompilationInfo::kInliningEnabled | | 
|  251           CompilationInfo::kContextSpecializing | |  345           CompilationInfo::kContextSpecializing | | 
|  252           CompilationInfo::kTypingEnabled); |  346           CompilationInfo::kTypingEnabled); | 
|  253  |  347  | 
|  254   InstallAssertStackDepthHelper(CcTest::isolate()); |  348   InstallAssertInlineCountHelper(CcTest::isolate()); | 
|  255   T.CheckCall(T.Val(42), T.undefined(), T.undefined()); |  349   T.CheckCall(T.Val(42), T.undefined(), T.undefined()); | 
|  256 } |  350 } | 
|  257  |  351  | 
|  258  |  352  | 
|  259 #endif  // V8_TURBOFAN_TARGET |  353 #endif  // V8_TURBOFAN_TARGET | 
| OLD | NEW |