Revert "Initial shot at deoptimizing JSCallFunction in Turbofan."
authorjarin@chromium.org <jarin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 11 Aug 2014 07:33:58 +0000 (07:33 +0000)
committerjarin@chromium.org <jarin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 11 Aug 2014 07:33:58 +0000 (07:33 +0000)
This reverts commit r23020.

BUG=
TBR=bmeurer@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23022 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

18 files changed:
src/compiler/arm/linkage-arm.cc
src/compiler/arm64/linkage-arm64.cc
src/compiler/ast-graph-builder.cc
src/compiler/code-generator.cc
src/compiler/ia32/linkage-ia32.cc
src/compiler/js-generic-lowering.cc
src/compiler/js-operator.h
src/compiler/linkage-impl.h
src/compiler/linkage.cc
src/compiler/linkage.h
src/compiler/operator-properties-inl.h
src/compiler/register-allocator.cc
src/compiler/register-allocator.h
src/compiler/x64/linkage-x64.cc
src/objects.cc
test/cctest/cctest.status
test/cctest/compiler/test-scheduler.cc
test/cctest/test-deoptimization.cc

index 6bea210ec5f077111c5d6655f4e22c00cb7c761f..489a0c61234a75fbf256dd4f9eeb2a31ae59396b 100644 (file)
@@ -49,10 +49,9 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
-    CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
+    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count) {
   return LinkageHelper::GetStubCallDescriptor<LinkageHelperTraits>(
-      zone, descriptor, stack_parameter_count, can_deoptimize);
+      this->info_->zone(), descriptor, stack_parameter_count);
 }
 
 
index e44c5d86fda34fbaf6c9aa2b1490403519106d5e..240cef1e330e4ed5cf9cb567a59f151ac932f023 100644 (file)
@@ -49,10 +49,9 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
-    CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
+    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count) {
   return LinkageHelper::GetStubCallDescriptor<LinkageHelperTraits>(
-      zone, descriptor, stack_parameter_count, can_deoptimize);
+      this->info_->zone(), descriptor, stack_parameter_count);
 }
 
 
index 21f92b1d82d84c630a983a1252e6cb46013c76f5..2c242cbe1434c28cf76f0ef8bfb583fa277fa69e 100644 (file)
@@ -722,13 +722,8 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
           environment()->Push(value);
           // result is either the string key or Smi(0) indicating the property
           // is gone.
-          // TODO(jarin) Insert lazy deoptimization support here - the call
-          // actually
-          // can deoptimize.
           Node* res = ProcessArguments(
-              javascript()->Call(3, NO_CALL_FUNCTION_FLAGS,
-                                 CallDescriptor::kCannotDeoptimize),
-              3);
+              javascript()->Call(3, NO_CALL_FUNCTION_FLAGS), 3);
           Node* property_missing = NewNode(javascript()->StrictEqual(), res,
                                            jsgraph()->ZeroConstant());
           {
@@ -1251,12 +1246,9 @@ void AstGraphBuilder::VisitCall(Call* expr) {
   }
 
   // Create node to perform the function call.
-  Operator* call = javascript()->Call(args->length() + 2, flags,
-                                      CallDescriptor::kCanDeoptimize);
+  Operator* call = javascript()->Call(args->length() + 2, flags);
   Node* value = ProcessArguments(call, args->length() + 2);
   ast_context()->ProduceValue(value);
-
-  BuildLazyBailout(value, expr->id());
 }
 
 
@@ -1291,12 +1283,9 @@ void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
   VisitForValues(args);
 
   // Create node to perform the JS runtime call.
-  Operator* call = javascript()->Call(args->length() + 2, flags,
-                                      CallDescriptor::kCanDeoptimize);
+  Operator* call = javascript()->Call(args->length() + 2, flags);
   Node* value = ProcessArguments(call, args->length() + 2);
   ast_context()->ProduceValue(value);
-
-  BuildLazyBailout(value, expr->id());
 }
 
 
index 878ace3be1e631a75bc31ff5670852348ef581cc..5c831eb6ddce70b532923f9147e6399e5c49b6d7 100644 (file)
@@ -215,9 +215,7 @@ void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) {
   for (int i = 0; i < deopt_count; i++) {
     FrameStateDescriptor* descriptor = code()->GetDeoptimizationEntry(i);
     data->SetAstId(i, descriptor->bailout_id());
-    CHECK_NE(NULL, deoptimization_states_[i]);
-    data->SetTranslationIndex(
-        i, Smi::FromInt(deoptimization_states_[i]->translation_id_));
+    data->SetTranslationIndex(i, Smi::FromInt(0));
     data->SetArgumentsStackHeight(i, Smi::FromInt(0));
     data->SetPc(i, Smi::FromInt(-1));
   }
index 6ace8befa6b1023a441a89199b80f003f9e8c4eb..803d3f69f80f2652190cc270f28bceea6ba548de 100644 (file)
@@ -45,10 +45,9 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
-    CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
+    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count) {
   return LinkageHelper::GetStubCallDescriptor<LinkageHelperTraits>(
-      zone, descriptor, stack_parameter_count, can_deoptimize);
+      this->info_->zone(), descriptor, stack_parameter_count);
 }
 
 
index d777081d708b27c34c04e96f1c8866285cf60f58..699f7dd60569f8f6abe14767b1ca9325849ace9b 100644 (file)
@@ -349,22 +349,18 @@ void JSGenericLowering::ReplaceWithBuiltinCall(Node* node,
 }
 
 
-static CallDescriptor::DeoptimizationSupport DeoptimizationSupportForNode(
-    Node* node) {
-  return OperatorProperties::CanLazilyDeoptimize(node->op())
-             ? CallDescriptor::kCanDeoptimize
-             : CallDescriptor::kCannotDeoptimize;
-}
-
-
 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
                                                Runtime::FunctionId f,
                                                int nargs_override) {
   Operator::Property props = node->op()->properties();
   const Runtime::Function* fun = Runtime::FunctionForId(f);
   int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
-  CallDescriptor* desc = linkage()->GetRuntimeCallDescriptor(
-      f, nargs, props, DeoptimizationSupportForNode(node));
+  CallDescriptor::DeoptimizationSupport deopt =
+      OperatorProperties::CanLazilyDeoptimize(node->op())
+          ? CallDescriptor::kCanDeoptimize
+          : CallDescriptor::kCannotDeoptimize;
+  CallDescriptor* desc =
+      linkage()->GetRuntimeCallDescriptor(f, nargs, props, deopt);
   Node* ref = ExternalConstant(ExternalReference(f, isolate()));
   Node* arity = Int32Constant(nargs);
   if (!centrystub_constant_.is_set()) {
@@ -528,8 +524,7 @@ Node* JSGenericLowering::LowerJSCallFunction(Node* node) {
   CallParameters p = OpParameter<CallParameters>(node);
   CallFunctionStub stub(isolate(), p.arity - 2, p.flags);
   CodeStubInterfaceDescriptor* d = GetInterfaceDescriptor(isolate(), &stub);
-  CallDescriptor* desc = linkage()->GetStubCallDescriptor(
-      d, p.arity - 1, DeoptimizationSupportForNode(node));
+  CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, p.arity - 1);
   Node* stub_code = CodeConstant(stub.GetCode());
   PatchInsertInput(node, 0, stub_code);
   PatchOperator(node, common()->Call(desc));
index 500db9d120e318c15a049de9f764f74936332141..d32eb5a39108b7ead2b7224be6c0d241cc42a432 100644 (file)
@@ -5,7 +5,6 @@
 #ifndef V8_COMPILER_JS_OPERATOR_H_
 #define V8_COMPILER_JS_OPERATOR_H_
 
-#include "src/compiler/linkage.h"
 #include "src/compiler/opcodes.h"
 #include "src/compiler/operator.h"
 #include "src/unique.h"
@@ -49,9 +48,6 @@ struct LoadNamedParameters {
 struct CallParameters {
   int arity;
   CallFunctionFlags flags;
-  // TODO(jarin) Remove the deopt flag once we can deoptimize all JavaScript
-  // calls (specifically the FILTER_KEY call in ForInStatement).
-  CallDescriptor::DeoptimizationSupport can_deoptimize;
 };
 
 // Interface for building JavaScript-level operators, e.g. directly from the
@@ -107,9 +103,8 @@ class JSOperatorBuilder {
 
   Operator* Create() { SIMPLE(JSCreate, Operator::kEliminatable, 0, 1); }
 
-  Operator* Call(int arguments, CallFunctionFlags flags,
-                 CallDescriptor::DeoptimizationSupport can_deoptimize) {
-    CallParameters parameters = {arguments, flags, can_deoptimize};
+  Operator* Call(int arguments, CallFunctionFlags flags) {
+    CallParameters parameters = {arguments, flags};
     OP1(JSCallFunction, CallParameters, parameters, Operator::kNoProperties,
         arguments, 1);
   }
index 36939cc6cc514167cba02e17a88af74b3cbc0d7c..212a622ac082e475db1befcf991896ce68778eb2 100644 (file)
@@ -128,8 +128,7 @@ class LinkageHelper {
   template <typename LinkageTraits>
   static CallDescriptor* GetStubCallDescriptor(
       Zone* zone, CodeStubInterfaceDescriptor* descriptor,
-      int stack_parameter_count,
-      CallDescriptor::DeoptimizationSupport can_deoptimize) {
+      int stack_parameter_count) {
     int register_parameter_count = descriptor->GetEnvironmentParameterCount();
     int parameter_count = register_parameter_count + stack_parameter_count;
     const int code_count = 1;
@@ -166,8 +165,9 @@ class LinkageHelper {
                        locations,                        // locations
                        Operator::kNoProperties,          // properties
                        kNoCalleeSaved,  // callee-saved registers
-                       can_deoptimize,  // deoptimization
+                       CallDescriptor::kCannotDeoptimize,  // deoptimization
                        CodeStub::MajorName(descriptor->MajorKey(), false));
+    // TODO(jarin) should deoptimize!
   }
 
 
index 7c3a9fb24b4bd115f910476f40b702253201d7f0..466f65c8ba8397552c82e7da14c648ab811847d5 100644 (file)
@@ -102,14 +102,6 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 }
 
 
-CallDescriptor* Linkage::GetStubCallDescriptor(
-    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
-    CallDescriptor::DeoptimizationSupport can_deoptimize) {
-  return GetStubCallDescriptor(descriptor, stack_parameter_count,
-                               can_deoptimize, this->info_->zone());
-}
-
-
 //==============================================================================
 // Provide unimplemented methods on unsupported architectures, to at least link.
 //==============================================================================
@@ -130,8 +122,7 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
-    CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
+    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count) {
   UNIMPLEMENTED();
   return NULL;
 }
index 7b19303fb04e51a3865f47404f94ff7d142e7715..310a87a9ca91f67eaab83ad7b8cbc331e0a62a9e 100644 (file)
@@ -147,13 +147,8 @@ class Linkage : public ZoneObject {
       Operator::Property properties,
       CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone);
 
-  CallDescriptor* GetStubCallDescriptor(
-      CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count = 0,
-      CallDescriptor::DeoptimizationSupport can_deoptimize =
-          CallDescriptor::kCannotDeoptimize);
-  static CallDescriptor* GetStubCallDescriptor(
-      CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
-      CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone);
+  CallDescriptor* GetStubCallDescriptor(CodeStubInterfaceDescriptor* descriptor,
+                                        int stack_parameter_count = 0);
 
   // Creates a call descriptor for simplified C calls that is appropriate
   // for the host platform. This simplified calling convention only supports
index 28d52e3cc5131a65dbb434ba1ada85a734cde633..fc9149dedb9c8f3a91c7ac27f33eadcf9f00d48d 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "src/v8.h"
 
-#include "src/compiler/js-operator.h"
 #include "src/compiler/opcodes.h"
 #include "src/compiler/operator-properties.h"
 
@@ -131,14 +130,6 @@ inline bool OperatorProperties::IsScheduleRoot(Operator* op) {
 }
 
 inline bool OperatorProperties::CanLazilyDeoptimize(Operator* op) {
-  // TODO(jarin) This function allows turning on lazy deoptimization
-  // incrementally. It will change as we turn on lazy deopt for
-  // more nodes.
-
-  if (!FLAG_turbo_deoptimization) {
-    return false;
-  }
-
   if (op->opcode() == IrOpcode::kCall) {
     CallOperator* call_op = reinterpret_cast<CallOperator*>(op);
     CallDescriptor* descriptor = call_op->parameter();
@@ -151,11 +142,6 @@ inline bool OperatorProperties::CanLazilyDeoptimize(Operator* op) {
         reinterpret_cast<Operator1<Runtime::FunctionId>*>(op)->parameter();
     return function == Runtime::kDeoptimizeFunction;
   }
-  if (op->opcode() == IrOpcode::kJSCallFunction) {
-    CallParameters p =
-        reinterpret_cast<Operator1<CallParameters>*>(op)->parameter();
-    return p.can_deoptimize == CallDescriptor::kCanDeoptimize;
-  }
   return false;
 }
 }
index 972a9045094a22ed2ceb355f0664e35b29201d6a..46446aa5622987aab52c395c6985b2b958b95630 100644 (file)
@@ -744,70 +744,6 @@ void RegisterAllocator::MeetRegisterConstraints(BasicBlock* block) {
       if (!AllocationOk()) return;
     }
   }
-
-  // Meet register constraints for the instruction in the end.
-  if (!code()->IsGapAt(end)) {
-    MeetRegisterConstraintsForLastInstructionInBlock(block);
-  }
-}
-
-
-void RegisterAllocator::MeetRegisterConstraintsForLastInstructionInBlock(
-    BasicBlock* block) {
-  int end = block->last_instruction_index();
-  Instruction* last_instruction = InstructionAt(end);
-  for (size_t i = 0; i < last_instruction->OutputCount(); i++) {
-    InstructionOperand* output_operand = last_instruction->OutputAt(i);
-    DCHECK(!output_operand->IsConstant());
-    UnallocatedOperand* output = UnallocatedOperand::cast(output_operand);
-    int output_vreg = output->virtual_register();
-    LiveRange* range = LiveRangeFor(output_vreg);
-    bool assigned = false;
-    if (output->HasFixedPolicy()) {
-      AllocateFixed(output, -1, false);
-      // This value is produced on the stack, we never need to spill it.
-      if (output->IsStackSlot()) {
-        range->SetSpillOperand(output);
-        range->SetSpillStartIndex(end);
-        assigned = true;
-      }
-
-      BasicBlock::Successors successors = block->successors();
-      for (BasicBlock::Successors::iterator succ = successors.begin();
-           succ != successors.end(); ++succ) {
-        DCHECK((*succ)->PredecessorCount() == 1);
-        int gap_index = (*succ)->first_instruction_index() + 1;
-        DCHECK(code()->IsGapAt(gap_index));
-
-        // Create an unconstrained operand for the same virtual register
-        // and insert a gap move from the fixed output to the operand.
-        UnallocatedOperand* output_copy =
-            new (code_zone()) UnallocatedOperand(UnallocatedOperand::ANY);
-        output_copy->set_virtual_register(output_vreg);
-
-        code()->AddGapMove(gap_index, output, output_copy);
-      }
-    }
-
-    if (!assigned) {
-      BasicBlock::Successors successors = block->successors();
-      for (BasicBlock::Successors::iterator succ = successors.begin();
-           succ != successors.end(); ++succ) {
-        DCHECK((*succ)->PredecessorCount() == 1);
-        int gap_index = (*succ)->first_instruction_index() + 1;
-        range->SetSpillStartIndex(gap_index);
-
-        // This move to spill operand is not a real use. Liveness analysis
-        // and splitting of live ranges do not account for it.
-        // Thus it should be inserted to a lifetime position corresponding to
-        // the instruction end.
-        GapInstruction* gap = code()->GapAt(gap_index);
-        ParallelMove* move =
-            gap->GetOrCreateParallelMove(GapInstruction::BEFORE, code_zone());
-        move->AddMove(output, range->GetSpillOperand(), code_zone());
-      }
-    }
-  }
 }
 
 
@@ -850,8 +786,6 @@ void RegisterAllocator::MeetConstraintsBetween(Instruction* first,
           code()->AddGapMove(gap_index, first_output, output_copy);
         }
 
-        // Make sure we add a gap move for spilling (if we have not done
-        // so already).
         if (!assigned) {
           range->SetSpillStartIndex(gap_index);
 
index 881ce37f7d590e2fc2983e4f5388397357797d73..8a99e6f6347851236526b52dc7f1c8e7265c63d3 100644 (file)
@@ -391,7 +391,6 @@ class RegisterAllocator BASE_EMBEDDED {
   void MeetRegisterConstraints(BasicBlock* block);
   void MeetConstraintsBetween(Instruction* first, Instruction* second,
                               int gap_index);
-  void MeetRegisterConstraintsForLastInstructionInBlock(BasicBlock* block);
   void ResolvePhis(BasicBlock* block);
 
   // Helper methods for building intervals.
index 9c8b9d044775d81df6d3669eb1c8be5668c5cfd3..30808e042ebd2c32bb28d3a34cc532ed42aefc45 100644 (file)
@@ -64,10 +64,9 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor(
 
 
 CallDescriptor* Linkage::GetStubCallDescriptor(
-    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count,
-    CallDescriptor::DeoptimizationSupport can_deoptimize, Zone* zone) {
+    CodeStubInterfaceDescriptor* descriptor, int stack_parameter_count) {
   return LinkageHelper::GetStubCallDescriptor<LinkageHelperTraits>(
-      zone, descriptor, stack_parameter_count, can_deoptimize);
+      this->info_->zone(), descriptor, stack_parameter_count);
 }
 
 
index 7cd79048dbc5bef6553a6da0d9dfc3d3d383bd64..645bb4a74e39f81272c0c9e3c4c4d913976224fc 100644 (file)
@@ -11128,7 +11128,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint(
   os << "Deoptimization Input Data (deopt points = " << deopt_count << ")\n";
   if (0 != deopt_count) {
     os << " index  ast id    argc     pc";
-    if (FLAG_print_code_verbose) os << "  commands";
+    if (FLAG_print_code_verbose) os << "commands";
     os << "\n";
   }
   for (int i = 0; i < deopt_count; i++) {
@@ -11158,7 +11158,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint(
            Translation::BEGIN !=
            (opcode = static_cast<Translation::Opcode>(iterator.Next()))) {
       Vector<char> buf2 = Vector<char>::New(128);
-      SNPrintF(buf2, "%27s    %s ", "", Translation::StringFor(opcode));
+      SNPrintF(buf2, "%24s    %s ", "", Translation::StringFor(opcode));
       os << buf2.start();
 
       switch (opcode) {
@@ -11284,11 +11284,11 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint(
   if (return_address_patch_count != 0) {
     os << "Return address patch data (count = " << return_address_patch_count
        << ")\n";
-    os << " index    pc  patched_pc\n";
+    os << "index pc    patched_pc\n";
   }
   for (int i = 0; i < return_address_patch_count; i++) {
     Vector<char> buf = Vector<char>::New(128);
-    SNPrintF(buf, "%6d  %6d  %12d\n", i, ReturnAddressPc(i)->value(),
+    SNPrintF(buf, "%6d  %6d  %10d", i, ReturnAddressPc(i)->value(),
              PatchedAddressPc(i)->value());
     os << buf.start();
   }
index 7b9d1cc5707316720dfee3f631e60e931b4f2c63..56616341f24d15d97c1e28a8cb6e273439ab26d4 100644 (file)
   'test-debug/DebugBreakLoop': [PASS, NO_VARIANTS],
 
   # Support for lazy deoptimization is missing.
+  'test-deoptimization/DeoptimizeSimple': [PASS, NO_VARIANTS],
+  'test-deoptimization/DeoptimizeSimpleNested': [PASS, NO_VARIANTS],
+  'test-deoptimization/DeoptimizeSimpleWithArguments': [PASS, NO_VARIANTS],
   'test-deoptimization/DeoptimizeBinaryOperation*': [PASS, NO_VARIANTS],
   'test-deoptimization/DeoptimizeCompare': [PASS, NO_VARIANTS],
   'test-deoptimization/DeoptimizeLoadICStoreIC': [PASS, NO_VARIANTS],
index 43c8ae646e4966b5f82ec89fb0fc41e1bf985d56..757f83a7109ac14c58618652220332bade49db9d 100644 (file)
@@ -1713,8 +1713,6 @@ static Handle<JSFunction> Compile(const char* source) {
 
 
 TEST(BuildScheduleTrivialLazyDeoptCall) {
-  FLAG_turbo_deoptimization = true;
-
   HandleAndZoneScope scope;
   Isolate* isolate = scope.main_isolate();
   Graph graph(scope.main_zone());
index 9192d87e8d5cf4169233f44e1279270b770b5715..a663007e95a0eae483c18d05d6f90f205680b784 100644 (file)
@@ -113,8 +113,6 @@ static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj,
 
 
 TEST(DeoptimizeSimple) {
-  i::FLAG_turbo_deoptimization = true;
-
   LocalContext env;
   v8::HandleScope scope(env->GetIsolate());
 
@@ -153,8 +151,6 @@ TEST(DeoptimizeSimple) {
 
 
 TEST(DeoptimizeSimpleWithArguments) {
-  i::FLAG_turbo_deoptimization = true;
-
   LocalContext env;
   v8::HandleScope scope(env->GetIsolate());
 
@@ -194,8 +190,6 @@ TEST(DeoptimizeSimpleWithArguments) {
 
 
 TEST(DeoptimizeSimpleNested) {
-  i::FLAG_turbo_deoptimization = true;
-
   LocalContext env;
   v8::HandleScope scope(env->GetIsolate());