2014-08-20 13:05:03 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "src/v8.h"
|
|
|
|
|
|
|
|
#include "test/cctest/compiler/function-tester.h"
|
|
|
|
|
|
|
|
#if V8_TURBOFAN_TARGET
|
|
|
|
|
|
|
|
using namespace v8::internal;
|
|
|
|
using namespace v8::internal::compiler;
|
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
// Helper to determine inline count via JavaScriptFrame::GetInlineCount.
|
|
|
|
// Note that a count of 1 indicates that no inlining has occured.
|
|
|
|
static void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
|
|
StackTraceFrameIterator it(CcTest::i_isolate());
|
|
|
|
int frames_seen = 0;
|
|
|
|
JavaScriptFrame* topmost = it.frame();
|
|
|
|
while (!it.done()) {
|
|
|
|
JavaScriptFrame* frame = it.frame();
|
|
|
|
PrintF("%d %s, inline count: %d\n", frames_seen,
|
|
|
|
frame->function()->shared()->DebugName()->ToCString().get(),
|
|
|
|
frame->GetInlineCount());
|
|
|
|
frames_seen++;
|
|
|
|
it.Advance();
|
|
|
|
}
|
|
|
|
CHECK_EQ(args[0]->ToInt32()->Value(), topmost->GetInlineCount());
|
2014-08-20 13:05:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
static void InstallAssertInlineCountHelper(v8::Isolate* isolate) {
|
2014-08-20 13:05:03 +00:00
|
|
|
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
|
|
v8::Local<v8::FunctionTemplate> t =
|
2014-09-18 08:56:52 +00:00
|
|
|
v8::FunctionTemplate::New(isolate, AssertInlineCount);
|
|
|
|
context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction());
|
2014-08-20 13:05:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(SimpleInlining) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function(){"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function foo(s) { AssertInlineCount(2); return s; };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"function bar(s, t) { return foo(s); };"
|
2014-08-28 08:39:24 +00:00
|
|
|
"return bar;})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
|
|
|
T.CheckCall(T.Val(1), T.Val(1), T.Val(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(SimpleInliningDeopt) {
|
|
|
|
FLAG_turbo_deoptimization = true;
|
|
|
|
FunctionTester T(
|
|
|
|
"(function(){"
|
|
|
|
"function foo(s) { %DeoptimizeFunction(bar); return "
|
|
|
|
"s; };"
|
|
|
|
"function bar(s, t) { return foo(s); };"
|
|
|
|
"return bar;})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-20 13:05:03 +00:00
|
|
|
T.CheckCall(T.Val(1), T.Val(1), T.Val(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(SimpleInliningContext) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function foo(s) { AssertInlineCount(2); var x = 12; return s + x; };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"function bar(s, t) { return foo(s); };"
|
|
|
|
"return bar;"
|
2014-08-28 08:39:24 +00:00
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
|
|
|
T.CheckCall(T.Val(13), T.Val(1), T.Val(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(SimpleInliningContextDeopt) {
|
|
|
|
FLAG_turbo_deoptimization = true;
|
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"function foo(s) { "
|
|
|
|
" AssertInlineCount(2); %DeoptimizeFunction(bar); var x = 12;"
|
|
|
|
" return s + x;"
|
|
|
|
"};"
|
|
|
|
"function bar(s, t) { return foo(s); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-20 13:05:03 +00:00
|
|
|
T.CheckCall(T.Val(13), T.Val(1), T.Val(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(CaptureContext) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"var f = (function () {"
|
|
|
|
"var x = 42;"
|
|
|
|
"function bar(s) { return x + s; };"
|
|
|
|
"return (function (s) { return bar(s); });"
|
|
|
|
"})();"
|
2014-08-28 08:39:24 +00:00
|
|
|
"(function (s) { return f(s)})",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-20 13:05:03 +00:00
|
|
|
T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO(sigurds) For now we do not inline any native functions. If we do at
|
|
|
|
// some point, change this test.
|
|
|
|
TEST(DontInlineEval) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"var x = 42;"
|
|
|
|
"(function () {"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function bar(s, t) { return eval(\"AssertInlineCount(1); x\") };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"return bar;"
|
2014-08-28 08:39:24 +00:00
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-20 13:05:03 +00:00
|
|
|
T.CheckCall(T.Val(42), T.Val("x"), T.undefined());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(InlineOmitArguments) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 42;"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"return (function (s,t) { return bar(s); });"
|
2014-08-28 08:39:24 +00:00
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-20 13:05:03 +00:00
|
|
|
T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
TEST(InlineOmitArgumentsDeopt) {
|
|
|
|
FLAG_turbo_deoptimization = true;
|
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"function foo(s,t,u,v) { AssertInlineCount(2); %DeoptimizeFunction(bar); "
|
|
|
|
"return baz(); };"
|
|
|
|
"function bar() { return foo(11); };"
|
|
|
|
"function baz() { return foo.arguments.length == 1 && "
|
|
|
|
" foo.arguments[0] == 11 ; }"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
|
|
|
T.CheckCall(T.true_value(), T.Val(12), T.Val(14));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-20 13:05:03 +00:00
|
|
|
TEST(InlineSurplusArguments) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 42;"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function foo(s) { AssertInlineCount(2); return x + s; };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"function bar(s,t) { return foo(s,t,13); };"
|
|
|
|
"return bar;"
|
2014-08-28 08:39:24 +00:00
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-20 13:05:03 +00:00
|
|
|
T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
TEST(InlineSurplusArgumentsDeopt) {
|
|
|
|
FLAG_turbo_deoptimization = true;
|
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar); "
|
|
|
|
"return baz(); };"
|
|
|
|
"function bar() { return foo(13, 14, 15); };"
|
|
|
|
"function baz() { return foo.arguments.length == 3 && "
|
|
|
|
" foo.arguments[0] == 13 && "
|
|
|
|
" foo.arguments[1] == 14 && "
|
|
|
|
" foo.arguments[2] == 15; }"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
|
|
|
T.CheckCall(T.true_value(), T.Val(12), T.Val(14));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-20 13:05:03 +00:00
|
|
|
TEST(InlineTwice) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 42;"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function bar(s) { AssertInlineCount(2); return x + s; };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"return (function (s,t) { return bar(s) + bar(t); });"
|
2014-08-28 08:39:24 +00:00
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-20 13:05:03 +00:00
|
|
|
T.CheckCall(T.Val(2 * 42 + 12 + 4), T.Val(12), T.Val(4));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(InlineTwiceDependent) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 42;"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function foo(s) { AssertInlineCount(2); return x + s; };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"function bar(s,t) { return foo(foo(s)); };"
|
|
|
|
"return bar;"
|
2014-08-28 08:39:24 +00:00
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-20 13:05:03 +00:00
|
|
|
T.CheckCall(T.Val(42 + 42 + 12), T.Val(12), T.Val(4));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(InlineTwiceDependentDiamond) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
2014-08-28 12:18:25 +00:00
|
|
|
"var x = 41;"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function foo(s) { AssertInlineCount(2); if (s % 2 == 0) {"
|
2014-08-28 12:18:25 +00:00
|
|
|
" return x - s } else { return x + s; } };"
|
|
|
|
"function bar(s,t) { return foo(foo(s)); };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"return bar;"
|
2014-08-28 08:39:24 +00:00
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-28 12:18:25 +00:00
|
|
|
T.CheckCall(T.Val(-11), T.Val(11), T.Val(4));
|
2014-08-20 13:05:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-28 12:18:25 +00:00
|
|
|
TEST(InlineTwiceDependentDiamondDifferent) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-20 13:05:03 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 41;"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function foo(s,t) { AssertInlineCount(2); if (s % 2 == 0) {"
|
2014-08-28 12:18:25 +00:00
|
|
|
" return x - s * t } else { return x + s * t; } };"
|
|
|
|
"function bar(s,t) { return foo(foo(s, 3), 5); };"
|
2014-08-20 13:05:03 +00:00
|
|
|
"return bar;"
|
2014-08-28 08:39:24 +00:00
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-20 13:05:03 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-28 12:18:25 +00:00
|
|
|
T.CheckCall(T.Val(-329), T.Val(11), T.Val(4));
|
2014-08-20 13:05:03 +00:00
|
|
|
}
|
|
|
|
|
2014-08-29 08:58:51 +00:00
|
|
|
|
|
|
|
TEST(InlineLoop) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-29 08:58:51 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 41;"
|
2014-09-18 08:56:52 +00:00
|
|
|
"function foo(s) { AssertInlineCount(2); while (s > 0) {"
|
2014-08-29 08:58:51 +00:00
|
|
|
" s = s - 1; }; return s; };"
|
|
|
|
"function bar(s,t) { return foo(foo(s)); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-29 08:58:51 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-29 08:58:51 +00:00
|
|
|
T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(InlineStrictIntoNonStrict) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-29 08:58:51 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = Object.create({}, { y: { value:42, writable:false } });"
|
|
|
|
"function foo(s) { 'use strict';"
|
|
|
|
" x.y = 9; };"
|
|
|
|
"function bar(s,t) { return foo(s); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-29 08:58:51 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-29 08:58:51 +00:00
|
|
|
T.CheckThrows(T.undefined(), T.undefined());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(InlineNonStrictIntoStrict) {
|
2014-09-18 08:56:52 +00:00
|
|
|
FLAG_turbo_deoptimization = true;
|
2014-08-29 08:58:51 +00:00
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = Object.create({}, { y: { value:42, writable:false } });"
|
|
|
|
"function foo(s) { x.y = 9; return x.y; };"
|
|
|
|
"function bar(s,t) { \'use strict\'; return foo(s); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
2014-09-10 09:48:03 +00:00
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
2014-08-29 08:58:51 +00:00
|
|
|
|
2014-09-18 08:56:52 +00:00
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
2014-08-29 08:58:51 +00:00
|
|
|
T.CheckCall(T.Val(42), T.undefined(), T.undefined());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-20 07:56:50 +00:00
|
|
|
TEST(InlineIntrinsicIsSmi) {
|
|
|
|
FLAG_turbo_deoptimization = true;
|
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 42;"
|
|
|
|
"function bar(s,t) { return %_IsSmi(x); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
|
|
|
T.CheckCall(T.true_value(), T.Val(12), T.Val(4));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(InlineIntrinsicIsNonNegativeSmi) {
|
|
|
|
FLAG_turbo_deoptimization = true;
|
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 42;"
|
|
|
|
"function bar(s,t) { return %_IsNonNegativeSmi(x); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
|
|
|
T.CheckCall(T.true_value(), T.Val(12), T.Val(4));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(InlineIntrinsicIsArray) {
|
|
|
|
FLAG_turbo_deoptimization = true;
|
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
"var x = [1,2,3];"
|
|
|
|
"function bar(s,t) { return %_IsArray(x); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
|
|
|
T.CheckCall(T.true_value(), T.Val(12), T.Val(4));
|
|
|
|
|
|
|
|
FunctionTester T2(
|
|
|
|
"(function () {"
|
|
|
|
"var x = 32;"
|
|
|
|
"function bar(s,t) { return %_IsArray(x); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
T2.CheckCall(T.false_value(), T.Val(12), T.Val(4));
|
|
|
|
|
|
|
|
FunctionTester T3(
|
|
|
|
"(function () {"
|
|
|
|
"var x = bar;"
|
|
|
|
"function bar(s,t) { return %_IsArray(x); };"
|
|
|
|
"return bar;"
|
|
|
|
"})();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
T3.CheckCall(T.false_value(), T.Val(12), T.Val(4));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(InlineWithArguments) {
|
|
|
|
FLAG_turbo_deoptimization = true;
|
|
|
|
FunctionTester T(
|
|
|
|
"(function () {"
|
|
|
|
" function foo(s,t,u) { AssertInlineCount(2); "
|
|
|
|
" return foo.arguments.length == 3 && "
|
|
|
|
" foo.arguments[0] == 13 && "
|
|
|
|
" foo.arguments[1] == 14 && "
|
|
|
|
" foo.arguments[2] == 15; "
|
|
|
|
" }"
|
|
|
|
" function bar() { return foo(13, 14, 15); };"
|
|
|
|
" return bar;"
|
|
|
|
"}"
|
|
|
|
")();",
|
|
|
|
CompilationInfo::kInliningEnabled |
|
|
|
|
CompilationInfo::kContextSpecializing |
|
|
|
|
CompilationInfo::kTypingEnabled);
|
|
|
|
|
|
|
|
InstallAssertInlineCountHelper(CcTest::isolate());
|
|
|
|
T.CheckCall(T.true_value(), T.Val(12), T.Val(14));
|
|
|
|
}
|
|
|
|
|
2014-08-20 13:05:03 +00:00
|
|
|
#endif // V8_TURBOFAN_TARGET
|