Generalize builtins inlining flag to allow forced inlining of any function
authordanno <danno@chromium.org>
Wed, 20 May 2015 12:48:02 +0000 (05:48 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 20 May 2015 12:47:43 +0000 (12:47 +0000)
Review URL: https://codereview.chromium.org/1140743004

Cr-Commit-Position: refs/heads/master@{#28510}

17 files changed:
src/collection.js
src/compiler.cc
src/compiler.h
src/compiler/js-inlining.cc
src/compiler/js-inlining.h
src/compiler/pipeline.cc
src/flag-definitions.h
src/hydrogen.cc
src/math.js
src/objects-inl.h
src/objects.h
src/runtime/runtime-function.cc
src/runtime/runtime.h
src/third_party/fdlibm/fdlibm.js
src/v8natives.js
test/cctest/compiler/function-tester.h
test/cctest/compiler/test-run-inlining.cc

index db30546..eddf0f3 100644 (file)
@@ -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);
 
 
 // -------------------------------------------------------------------
index 1517cdb..ca3dd31 100644 (file)
@@ -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();
index 4179894..56de2b6 100644 (file)
@@ -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); }
index 90c6eec..359eea5 100644 (file)
@@ -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();
   }
 
index 659315a..f35ea71 100644 (file)
@@ -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)
index 7387b46..d05b55a 100644 (file)
@@ -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.
index 7b464f6..d74200a 100644 (file)
@@ -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")
index 86bf763..5bf9f7b 100644 (file)
@@ -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()) {
index 633a5d0..427e329 100644 (file)
@@ -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;
index fbef269..bf970ce 100644 (file)
@@ -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)
index 9aec541..3ca4bb2 100644 (file)
@@ -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,
index 9c474a5..4213efb 100644 (file)
@@ -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();
 }
index b4de535..df616be 100644 (file)
@@ -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)                               \
index 82f50cc..eabaa19 100644 (file)
@@ -1024,7 +1024,7 @@ $installFunctions(GlobalMath, DONT_ENUM, [
   "expm1", MathExpm1
 ]);
 
-%SetInlineBuiltinFlag(MathSin);
-%SetInlineBuiltinFlag(MathCos);
+%SetForceInlineFlag(MathSin);
+%SetForceInlineFlag(MathCos);
 
 })
index 94133bf..47094e2 100644 (file)
@@ -1753,7 +1753,7 @@ InstallFunctions(GlobalNumber, DONT_ENUM, [
   "parseFloat", GlobalParseFloat
 ]);
 
-%SetInlineBuiltinFlag(NumberIsNaN);
+%SetForceInlineFlag(NumberIsNaN);
 
 
 // ----------------------------------------------------------------------------
index 20efd1e..771938c 100644 (file)
@@ -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);
index 61f3b62..6e9d8c7 100644 (file)
@@ -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());