Reviewers: Michael Starzinger,

Message:
PTAL

Description:
Tail call from TurboFan into select runtime calls

Please review this at https://codereview.chromium.org/1254073003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+33, -0 lines):
  M src/compiler/js-context-relaxation.cc
  M src/compiler/linkage-impl.h
  M src/runtime/runtime.h
  M src/runtime/runtime.cc


Index: src/compiler/js-context-relaxation.cc
diff --git a/src/compiler/js-context-relaxation.cc b/src/compiler/js-context-relaxation.cc index 0ca3c0c9d3ccb7fd6872afd161f601324b6be247..4072ae82ef0c668949aaba9cdf76af0c31a26331 100644
--- a/src/compiler/js-context-relaxation.cc
+++ b/src/compiler/js-context-relaxation.cc
@@ -14,6 +14,20 @@ namespace compiler {

 Reduction JSContextRelaxation::Reduce(Node* node) {
   switch (node->opcode()) {
+    case IrOpcode::kJSCallRuntime: {
+      const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
+      const Runtime::Function* fun = Runtime::FunctionForId(p.id());
+      switch (fun->function_id) {
+#define IC_CASE(name, number_of_args, result_size) \
+  case Runtime::k##name:                           \
+    break;
+        FOR_EACH_INTRINSIC_IC(IC_CASE)
+#undef IC_CASE
+        default:
+          return NoChange();
+      }
+    }
+    // Fall through
     case IrOpcode::kJSCallFunction:
     case IrOpcode::kJSToNumber: {
       Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
Index: src/compiler/linkage-impl.h
diff --git a/src/compiler/linkage-impl.h b/src/compiler/linkage-impl.h
index 6641ef130982cc39de530c23d4243179ec6904d4..4694dd7dbd0baf514b195cf22cb5c2fb714b409c 100644
--- a/src/compiler/linkage-impl.h
+++ b/src/compiler/linkage-impl.h
@@ -7,6 +7,7 @@

 #include "src/code-stubs.h"
 #include "src/compiler/osr.h"
+#include "src/runtime/runtime.h"

 namespace v8 {
 namespace internal {
@@ -119,6 +120,9 @@ class LinkageHelper {
CallDescriptor::Flags flags = Linkage::FrameStateInputCount(function_id) > 0
                                       ? CallDescriptor::kNeedsFrameState
                                       : CallDescriptor::kNoFlags;
+    if (Runtime::SupportsTailCall(function_id)) {
+      flags |= CallDescriptor::kSupportsTailCalls;
+    }

     // The target for runtime calls is a code object.
     MachineType target_type = kMachAnyTagged;
Index: src/runtime/runtime.cc
diff --git a/src/runtime/runtime.cc b/src/runtime/runtime.cc
index 674f1173a789446cd138c8fa3c17c7c7baa06285..0d6b708391d468449eb2a3416298f6c92bcae2cf 100644
--- a/src/runtime/runtime.cc
+++ b/src/runtime/runtime.cc
@@ -90,6 +90,18 @@ const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
 }


+bool Runtime::SupportsTailCall(FunctionId id) {
+  switch (id) {
+#define RUNTIME_FUNCTION_SWITCH(name, a, b) case k##name:
+    FOR_EACH_INTRINSIC_IC(RUNTIME_FUNCTION_SWITCH)
+#undef RUNTIME_FUNCTION_SWITCH
+    return true;
+    default:
+      return false;
+  }
+}
+
+
 std::ostream& operator<<(std::ostream& os, Runtime::FunctionId id) {
   return os << Runtime::FunctionForId(id)->name;
 }
Index: src/runtime/runtime.h
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index 1e2471cf95287f12ffe4c8132630e5d039fa8c66..2c2f4d3acce1bf3243e9c366e45e599cb420dc50 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -874,6 +874,9 @@ class Runtime : public AllStatic {
   // Get the intrinsic function with the given function entry address.
   static const Function* FunctionForEntry(Address ref);

+  // Returns whether a runtime call supports being invoked via tail call.
+  static bool SupportsTailCall(FunctionId id);
+
   MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
       Isolate* isolate, Handle<JSReceiver> receiver, Handle<Object> key,
       LanguageMode language_mode);


--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to