Commit 218e1012 authored by danno's avatar danno Committed by Commit bot

Generalize builtins inlining flag to allow forced inlining of any function

Review URL: https://codereview.chromium.org/1140743004

Cr-Commit-Position: refs/heads/master@{#28510}
parent 8af3c3a1
......@@ -18,7 +18,7 @@ function HashToEntry(table, hash, numBuckets) {
var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets);
return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket);
}
%SetInlineBuiltinFlag(HashToEntry);
%SetForceInlineFlag(HashToEntry);
function SetFindEntry(table, numBuckets, key, hash) {
......@@ -36,7 +36,7 @@ function SetFindEntry(table, numBuckets, key, hash) {
}
return NOT_FOUND;
}
%SetInlineBuiltinFlag(SetFindEntry);
%SetForceInlineFlag(SetFindEntry);
function MapFindEntry(table, numBuckets, key, hash) {
......@@ -54,7 +54,7 @@ function MapFindEntry(table, numBuckets, key, hash) {
}
return NOT_FOUND;
}
%SetInlineBuiltinFlag(MapFindEntry);
%SetForceInlineFlag(MapFindEntry);
function ComputeIntegerHash(key, seed) {
......@@ -68,7 +68,7 @@ function ComputeIntegerHash(key, seed) {
hash = hash ^ (hash >>> 16);
return hash;
}
%SetInlineBuiltinFlag(ComputeIntegerHash);
%SetForceInlineFlag(ComputeIntegerHash);
function GetHash(key) {
......@@ -83,7 +83,7 @@ function GetHash(key) {
}
return %GenericHash(key);
}
%SetInlineBuiltinFlag(GetHash);
%SetForceInlineFlag(GetHash);
// -------------------------------------------------------------------
......
......@@ -114,7 +114,6 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info)
if (isolate_->debug()->is_active()) MarkAsDebug();
if (FLAG_context_specialization) MarkAsContextSpecializing();
if (FLAG_turbo_builtin_inlining) MarkAsBuiltinInliningEnabled();
if (FLAG_turbo_deoptimization) MarkAsDeoptimizationEnabled();
if (FLAG_turbo_inlining) MarkAsInliningEnabled();
if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled();
......
......@@ -125,10 +125,9 @@ class CompilationInfo {
kTypingEnabled = 1 << 11,
kDisableFutureOptimization = 1 << 12,
kSplittingEnabled = 1 << 13,
kBuiltinInliningEnabled = 1 << 14,
kTypeFeedbackEnabled = 1 << 15,
kDeoptimizationEnabled = 1 << 16,
kSourcePositionsEnabled = 1 << 17
kTypeFeedbackEnabled = 1 << 14,
kDeoptimizationEnabled = 1 << 15,
kSourcePositionsEnabled = 1 << 16
};
explicit CompilationInfo(ParseInfo* parse_info);
......@@ -238,12 +237,6 @@ class CompilationInfo {
bool is_inlining_enabled() const { return GetFlag(kInliningEnabled); }
void MarkAsBuiltinInliningEnabled() { SetFlag(kBuiltinInliningEnabled); }
bool is_builtin_inlining_enabled() const {
return GetFlag(kBuiltinInliningEnabled);
}
void MarkAsTypingEnabled() { SetFlag(kTypingEnabled); }
bool is_typing_enabled() const { return GetFlag(kTypingEnabled); }
......
......@@ -295,7 +295,7 @@ Reduction JSInliner::Reduce(Node* node) {
Handle<JSFunction> function = match.Value().handle();
if (!function->IsJSFunction()) return NoChange();
if (mode_ == kBuiltinsInlining && !function->shared()->inline_builtin()) {
if (mode_ == kRestrictedInlining && !function->shared()->force_inline()) {
return NoChange();
}
......
......@@ -17,7 +17,7 @@ struct Inlinee;
class JSInliner final : public AdvancedReducer {
public:
enum Mode { kBuiltinsInlining, kGeneralInlining };
enum Mode { kRestrictedInlining, kGeneralInlining };
JSInliner(Editor* editor, Mode mode, Zone* local_zone, CompilationInfo* info,
JSGraph* jsgraph)
......
......@@ -503,7 +503,7 @@ struct InliningPhase {
GraphReducer graph_reducer(data->graph(), temp_zone);
JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled()
? JSInliner::kGeneralInlining
: JSInliner::kBuiltinsInlining,
: JSInliner::kRestrictedInlining,
temp_zone, data->info(), data->jsgraph());
AddReducer(data, &graph_reducer, &inliner);
graph_reducer.ReduceGraph();
......@@ -1010,10 +1010,8 @@ Handle<Code> Pipeline::GenerateCode() {
RunPrintAndVerify("Context specialized", true);
}
if (info()->is_builtin_inlining_enabled() || info()->is_inlining_enabled()) {
Run<InliningPhase>();
RunPrintAndVerify("Inlined", true);
}
Run<InliningPhase>();
RunPrintAndVerify("Inlined", true);
if (FLAG_print_turbo_replay) {
// Print a replay of the initial graph.
......
......@@ -410,7 +410,6 @@ DEFINE_BOOL(context_specialization, false,
"enable context specialization in TurboFan")
DEFINE_BOOL(turbo_deoptimization, false, "enable deoptimization in TurboFan")
DEFINE_BOOL(turbo_inlining, false, "enable inlining in TurboFan")
DEFINE_BOOL(turbo_builtin_inlining, true, "enable builtin inlining in TurboFan")
DEFINE_BOOL(trace_turbo_inlining, false, "trace TurboFan inlining")
DEFINE_BOOL(loop_assignment_analysis, true, "perform loop assignment analysis")
DEFINE_BOOL(turbo_profiling, false, "enable profiling in TurboFan")
......
......@@ -7951,9 +7951,12 @@ int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) {
Handle<JSFunction> caller = current_info()->closure();
Handle<SharedFunctionInfo> target_shared(target->shared());
// Always inline builtins marked for inlining.
// Always inline functions that force inlining.
if (target_shared->force_inline()) {
return 0;
}
if (target->IsBuiltin()) {
return target_shared->inline_builtin() ? 0 : kNotInlinable;
return kNotInlinable;
}
if (target_shared->IsApiFunction()) {
......
......@@ -344,18 +344,18 @@ $installFunctions(Math, DONT_ENUM, [
"cbrt", MathCbrt
]);
%SetInlineBuiltinFlag(MathAbs);
%SetInlineBuiltinFlag(MathAcosJS);
%SetInlineBuiltinFlag(MathAsinJS);
%SetInlineBuiltinFlag(MathAtanJS);
%SetInlineBuiltinFlag(MathAtan2JS);
%SetInlineBuiltinFlag(MathCeil);
%SetInlineBuiltinFlag(MathClz32JS);
%SetInlineBuiltinFlag(MathFloorJS);
%SetInlineBuiltinFlag(MathRandom);
%SetInlineBuiltinFlag(MathSign);
%SetInlineBuiltinFlag(MathSqrtJS);
%SetInlineBuiltinFlag(MathTrunc);
%SetForceInlineFlag(MathAbs);
%SetForceInlineFlag(MathAcosJS);
%SetForceInlineFlag(MathAsinJS);
%SetForceInlineFlag(MathAtanJS);
%SetForceInlineFlag(MathAtan2JS);
%SetForceInlineFlag(MathCeil);
%SetForceInlineFlag(MathClz32JS);
%SetForceInlineFlag(MathFloorJS);
%SetForceInlineFlag(MathRandom);
%SetForceInlineFlag(MathSign);
%SetForceInlineFlag(MathSqrtJS);
%SetForceInlineFlag(MathTrunc);
// Expose to the global scope.
$abs = MathAbs;
......
......@@ -5785,8 +5785,7 @@ void SharedFunctionInfo::set_kind(FunctionKind kind) {
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_super_property,
kUsesSuperProperty)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin,
kInlineBuiltin)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
name_should_print_as_anonymous,
kNameShouldPrintAsAnonymous)
......
......@@ -7093,8 +7093,8 @@ class SharedFunctionInfo: public HeapObject {
// global object.
DECL_BOOLEAN_ACCESSORS(native)
// Indicate that this builtin needs to be inlined in crankshaft.
DECL_BOOLEAN_ACCESSORS(inline_builtin)
// Indicate that this function should always be inlined in optimized code.
DECL_BOOLEAN_ACCESSORS(force_inline)
// Indicates that the function was created by the Function function.
// Though it's anonymous, toString should treat it as if it had the name
......@@ -7372,7 +7372,7 @@ class SharedFunctionInfo: public HeapObject {
kUsesSuperProperty,
kHasDuplicateParameters,
kNative,
kInlineBuiltin,
kForceInline,
kBoundFunction,
kIsAnonymous,
kNameShouldPrintAsAnonymous,
......
......@@ -311,14 +311,14 @@ RUNTIME_FUNCTION(Runtime_IsConstructor) {
}
RUNTIME_FUNCTION(Runtime_SetInlineBuiltinFlag) {
RUNTIME_FUNCTION(Runtime_SetForceInlineFlag) {
SealHandleScope shs(isolate);
RUNTIME_ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
if (object->IsJSFunction()) {
JSFunction* func = JSFunction::cast(*object);
func->shared()->set_inline_builtin(true);
func->shared()->set_force_inline(true);
}
return isolate->heap()->undefined_value();
}
......
......@@ -210,7 +210,7 @@ namespace internal {
F(SetNativeFlag, 1, 1) \
F(ThrowStrongModeTooFewArguments, 0, 1) \
F(IsConstructor, 1, 1) \
F(SetInlineBuiltinFlag, 1, 1) \
F(SetForceInlineFlag, 1, 1) \
F(FunctionBindArguments, 4, 1) \
F(BoundFunctionGetBindings, 1, 1) \
F(NewObjectFromBound, 1, 1) \
......
......@@ -1024,7 +1024,7 @@ $installFunctions(GlobalMath, DONT_ENUM, [
"expm1", MathExpm1
]);
%SetInlineBuiltinFlag(MathSin);
%SetInlineBuiltinFlag(MathCos);
%SetForceInlineFlag(MathSin);
%SetForceInlineFlag(MathCos);
})
......@@ -1753,7 +1753,7 @@ InstallFunctions(GlobalNumber, DONT_ENUM, [
"parseFloat", GlobalParseFloat
]);
%SetInlineBuiltinFlag(NumberIsNaN);
%SetForceInlineFlag(NumberIsNaN);
// ----------------------------------------------------------------------------
......
......@@ -34,7 +34,6 @@ class FunctionTester : public InitializedHandleScope {
flags_(flags) {
Compile(function);
const uint32_t supported_flags = CompilationInfo::kContextSpecializing |
CompilationInfo::kBuiltinInliningEnabled |
CompilationInfo::kInliningEnabled |
CompilationInfo::kTypingEnabled;
CHECK_EQ(0u, flags_ & ~supported_flags);
......
......@@ -40,9 +40,8 @@ void InstallAssertInlineCountHelper(v8::Isolate* isolate) {
}
const uint32_t kBuiltinInlineFlags = CompilationInfo::kBuiltinInliningEnabled |
CompilationInfo::kContextSpecializing |
CompilationInfo::kTypingEnabled;
const uint32_t kRestrictedInliningFlags =
CompilationInfo::kContextSpecializing | CompilationInfo::kTypingEnabled;
const uint32_t kInlineFlags = CompilationInfo::kInliningEnabled |
CompilationInfo::kContextSpecializing |
......@@ -499,10 +498,10 @@ TEST(InlineBuiltin) {
"(function () {"
" function foo(s,t,u) { AssertInlineCount(2); return true; }"
" function bar() { return foo(); };"
" %SetInlineBuiltinFlag(foo);"
" %SetForceInlineFlag(foo);"
" return bar;"
"})();",
kBuiltinInlineFlags);
kRestrictedInliningFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
T.CheckCall(T.true_value());
......@@ -516,11 +515,11 @@ TEST(InlineNestedBuiltin) {
" function foo(s,t,u) { AssertInlineCount(3); return true; }"
" function baz(s,t,u) { return foo(s,t,u); }"
" function bar() { return baz(); };"
" %SetInlineBuiltinFlag(foo);"
" %SetInlineBuiltinFlag(baz);"
" %SetForceInlineFlag(foo);"
" %SetForceInlineFlag(baz);"
" return bar;"
"})();",
kBuiltinInlineFlags);
kRestrictedInliningFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
T.CheckCall(T.true_value());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment