Revert arguments access support for inlined functions (r11109,r11118).
authorvegorov@chromium.org <vegorov@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 23 Mar 2012 15:39:34 +0000 (15:39 +0000)
committervegorov@chromium.org <vegorov@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 23 Mar 2012 15:39:34 +0000 (15:39 +0000)
We are inserting HPushArgument instructions after HEnterInlined based on the environment at the point of the first arguments access. Which might create use before def if there are redundant phis in the environment.
Review URL: https://chromiumcodereview.appspot.com/9837041

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

18 files changed:
src/arm/lithium-arm.cc
src/arm/lithium-arm.h
src/arm/lithium-codegen-arm.cc
src/hydrogen-instructions.cc
src/hydrogen-instructions.h
src/hydrogen.cc
src/hydrogen.h
src/ia32/lithium-codegen-ia32.cc
src/ia32/lithium-ia32.cc
src/ia32/lithium-ia32.h
src/mips/lithium-codegen-mips.cc
src/mips/lithium-mips.cc
src/mips/lithium-mips.h
src/runtime.cc
src/x64/lithium-codegen-x64.cc
src/x64/lithium-x64.cc
src/x64/lithium-x64.h
test/mjsunit/compiler/inline-arguments.js

index f48e08e..cdc1947 100644 (file)
@@ -1077,8 +1077,7 @@ LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* instr) {
 
 
 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
-  return DefineAsRegister(new(zone()) LArgumentsElements(
-      current_block_->last_environment()->outer() != NULL));
+  return DefineAsRegister(new(zone()) LArgumentsElements);
 }
 
 
@@ -2272,9 +2271,6 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
                                                undefined,
                                                instr->call_kind(),
                                                instr->is_construct());
-  if (instr->materializes_arguments()) {
-    inner->Bind(instr->arguments(), graph()->GetArgumentsObject());
-  }
   current_block_->UpdateEnvironment(inner);
   chunk_->AddInlinedClosure(instr->closure());
   return NULL;
@@ -2282,21 +2278,10 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
 
 
 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
-  LInstruction* pop = NULL;
-
-  HEnvironment* env = current_block_->last_environment();
-
-  if (instr->arguments_pushed()) {
-    int argument_count = env->arguments_environment()->parameter_count();
-    pop = new(zone()) LPop(argument_count);
-    argument_count_ -= argument_count;
-  }
-
   HEnvironment* outer = current_block_->last_environment()->
       DiscardInlined(false);
   current_block_->UpdateEnvironment(outer);
-
-  return pop;
+  return NULL;
 }
 
 
index 6d799ca..62cde6e 100644 (file)
@@ -179,8 +179,7 @@ class LCodeGen;
   V(CheckMapValue)                              \
   V(LoadFieldByIndex)                           \
   V(DateField)                                  \
-  V(WrapReceiver)                               \
-  V(Pop)
+  V(WrapReceiver)
 
 
 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)              \
@@ -535,15 +534,9 @@ class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
 
 class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
  public:
-  explicit LArgumentsElements(bool from_inlined)
-      : from_inlined_(from_inlined) { }
-
-  bool from_inlined() const { return from_inlined_; }
+  LArgumentsElements() { }
 
   DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
-
- private:
-  bool from_inlined_;
 };
 
 
@@ -1385,19 +1378,6 @@ class LPushArgument: public LTemplateInstruction<0, 1, 0> {
 };
 
 
-class LPop: public LTemplateInstruction<0, 0, 0> {
- public:
-  explicit LPop(int count) : count_(count) { }
-
-  int count() const { return count_; }
-
-  DECLARE_CONCRETE_INSTRUCTION(Pop, "pop")
-
- private:
-  int count_;
-};
-
-
 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
  public:
   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
index c8f1e17..82b80a2 100644 (file)
@@ -2764,20 +2764,16 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
   Register scratch = scratch0();
   Register result = ToRegister(instr->result());
 
-  if (instr->from_inlined()) {
-    __ add(result, sp, Operand(-2 * kPointerSize));
-  } else {
-    // Check if the calling frame is an arguments adaptor frame.
-    Label done, adapted;
-    __ ldr(scratch, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
-    __ ldr(result, MemOperand(scratch, StandardFrameConstants::kContextOffset));
-    __ cmp(result, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
+  // Check if the calling frame is an arguments adaptor frame.
+  Label done, adapted;
+  __ ldr(scratch, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
+  __ ldr(result, MemOperand(scratch, StandardFrameConstants::kContextOffset));
+  __ cmp(result, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
 
-    // Result is the frame pointer for the frame if not adapted and for the real
-    // frame below the adaptor frame if adapted.
-    __ mov(result, fp, LeaveCC, ne);
-    __ mov(result, scratch, LeaveCC, eq);
-  }
+  // Result is the frame pointer for the frame if not adapted and for the real
+  // frame below the adaptor frame if adapted.
+  __ mov(result, fp, LeaveCC, ne);
+  __ mov(result, scratch, LeaveCC, eq);
 }
 
 
@@ -2911,11 +2907,6 @@ void LCodeGen::DoPushArgument(LPushArgument* instr) {
 }
 
 
-void LCodeGen::DoPop(LPop* instr) {
-  __ Drop(instr->count());
-}
-
-
 void LCodeGen::DoThisFunction(LThisFunction* instr) {
   Register result = ToRegister(instr->result());
   __ LoadHeapObject(result, instr->hydrogen()->closure());
index 3231704..f698da4 100644 (file)
@@ -599,9 +599,6 @@ void HInstruction::InsertAfter(HInstruction* previous) {
   SetBlock(block);
   previous->next_ = this;
   if (next != NULL) next->previous_ = this;
-  if (block->last() == previous) {
-    block->set_last(this);
-  }
 }
 
 
index 93e14be..fb5879f 100644 (file)
@@ -1353,15 +1353,12 @@ class HEnterInlined: public HTemplateInstruction<0> {
                 int arguments_count,
                 FunctionLiteral* function,
                 CallKind call_kind,
-                bool is_construct,
-                Variable* arguments)
+                bool is_construct)
       : closure_(closure),
         arguments_count_(arguments_count),
         function_(function),
         call_kind_(call_kind),
-        is_construct_(is_construct),
-        arguments_(arguments),
-        materializes_arguments_(false) {
+        is_construct_(is_construct) {
   }
 
   virtual void PrintDataTo(StringStream* stream);
@@ -1376,13 +1373,6 @@ class HEnterInlined: public HTemplateInstruction<0> {
     return Representation::None();
   }
 
-  bool materializes_arguments() { return materializes_arguments_; }
-  void set_materializes_arguments(bool materializes_arguments) {
-    materializes_arguments_ = materializes_arguments;
-  }
-
-  Variable* arguments() { return arguments_; }
-
   DECLARE_CONCRETE_INSTRUCTION(EnterInlined)
 
  private:
@@ -1391,28 +1381,18 @@ class HEnterInlined: public HTemplateInstruction<0> {
   FunctionLiteral* function_;
   CallKind call_kind_;
   bool is_construct_;
-  Variable* arguments_;
-  bool materializes_arguments_;
 };
 
 
 class HLeaveInlined: public HTemplateInstruction<0> {
  public:
-  explicit HLeaveInlined(bool arguments_pushed)
-      : arguments_pushed_(arguments_pushed) { }
+  HLeaveInlined() {}
 
   virtual Representation RequiredInputRepresentation(int index) {
     return Representation::None();
   }
 
-  bool arguments_pushed() {
-    return arguments_pushed_;
-  }
-
   DECLARE_CONCRETE_INSTRUCTION(LeaveInlined)
-
- private:
-  bool arguments_pushed_;
 };
 
 
index 838ff32..9b77408 100644 (file)
@@ -113,6 +113,7 @@ void HBasicBlock::AddInstruction(HInstruction* instr) {
     first_ = last_ = entry;
   }
   instr->InsertAfter(last_);
+  last_ = instr;
 }
 
 
@@ -164,15 +165,11 @@ void HBasicBlock::Finish(HControlInstruction* end) {
 }
 
 
-void HBasicBlock::Goto(HBasicBlock* block, FunctionState* state) {
-  bool drop_extra = state != NULL && state->drop_extra();
-  bool arguments_pushed = state != NULL && state->arguments_pushed();
-
+void HBasicBlock::Goto(HBasicBlock* block, bool drop_extra) {
   if (block->IsInlineReturnTarget()) {
-    AddInstruction(new(zone()) HLeaveInlined(arguments_pushed));
+    AddInstruction(new(zone()) HLeaveInlined);
     last_environment_ = last_environment()->DiscardInlined(drop_extra);
   }
-
   AddSimulate(AstNode::kNoNumber);
   HGoto* instr = new(zone()) HGoto(block);
   Finish(instr);
@@ -181,13 +178,10 @@ void HBasicBlock::Goto(HBasicBlock* block, FunctionState* state) {
 
 void HBasicBlock::AddLeaveInlined(HValue* return_value,
                                   HBasicBlock* target,
-                                  FunctionState* state) {
-  bool drop_extra = state != NULL && state->drop_extra();
-  bool arguments_pushed = state != NULL && state->arguments_pushed();
-
+                                  bool drop_extra) {
   ASSERT(target->IsInlineReturnTarget());
   ASSERT(return_value != NULL);
-  AddInstruction(new(zone()) HLeaveInlined(arguments_pushed));
+  AddInstruction(new(zone()) HLeaveInlined);
   last_environment_ = last_environment()->DiscardInlined(drop_extra);
   last_environment()->Push(return_value);
   AddSimulate(AstNode::kNoNumber);
@@ -2184,8 +2178,6 @@ FunctionState::FunctionState(HGraphBuilder* owner,
       return_handling_(return_handling),
       function_return_(NULL),
       test_context_(NULL),
-      entry_(NULL),
-      arguments_elements_(NULL),
       outer_(owner->function_state()) {
   if (outer_ != NULL) {
     // State for an inline function.
@@ -2345,8 +2337,8 @@ void TestContext::ReturnControl(HControlInstruction* instr, int ast_id) {
   instr->SetSuccessorAt(0, empty_true);
   instr->SetSuccessorAt(1, empty_false);
   owner()->current_block()->Finish(instr);
-  empty_true->Goto(if_true(), owner()->function_state());
-  empty_false->Goto(if_false(), owner()->function_state());
+  empty_true->Goto(if_true(), owner()->function_state()->drop_extra());
+  empty_false->Goto(if_false(), owner()->function_state()->drop_extra());
   owner()->set_current_block(NULL);
 }
 
@@ -2367,8 +2359,8 @@ void TestContext::BuildBranch(HValue* value) {
   HBranch* test = new(zone()) HBranch(value, empty_true, empty_false, expected);
   builder->current_block()->Finish(test);
 
-  empty_true->Goto(if_true(), owner()->function_state());
-  empty_false->Goto(if_false(), owner()->function_state());
+  empty_true->Goto(if_true(), owner()->function_state()->drop_extra());
+  empty_false->Goto(if_false(), owner()->function_state()->drop_extra());
   builder->set_current_block(NULL);
 }
 
@@ -2859,10 +2851,10 @@ void HGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) {
     if (context->IsTest()) {
       TestContext* test = TestContext::cast(context);
       CHECK_ALIVE(VisitForEffect(stmt->expression()));
-      current_block()->Goto(test->if_true(), function_state());
+      current_block()->Goto(test->if_true(), function_state()->drop_extra());
     } else if (context->IsEffect()) {
       CHECK_ALIVE(VisitForEffect(stmt->expression()));
-      current_block()->Goto(function_return(), function_state());
+      current_block()->Goto(function_return(), function_state()->drop_extra());
     } else {
       ASSERT(context->IsValue());
       CHECK_ALIVE(VisitForValue(stmt->expression()));
@@ -2879,10 +2871,10 @@ void HGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) {
       current_block()->Finish(typecheck);
       if_spec_object->AddLeaveInlined(return_value,
                                       function_return(),
-                                      function_state());
+                                      function_state()->drop_extra());
       not_spec_object->AddLeaveInlined(receiver,
                                        function_return(),
-                                       function_state());
+                                       function_state()->drop_extra());
     }
   } else {
     // Return from an inlined function, visit the subexpression in the
@@ -2894,14 +2886,14 @@ void HGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) {
                       test->if_false());
     } else if (context->IsEffect()) {
       CHECK_ALIVE(VisitForEffect(stmt->expression()));
-      current_block()->Goto(function_return(), function_state());
+      current_block()->Goto(function_return(), function_state()->drop_extra());
     } else {
       ASSERT(context->IsValue());
       CHECK_ALIVE(VisitForValue(stmt->expression()));
       HValue* return_value = Pop();
       current_block()->AddLeaveInlined(return_value,
                                        function_return(),
-                                       function_state());
+                                       function_state()->drop_extra());
     }
   }
   set_current_block(NULL);
@@ -4945,70 +4937,31 @@ bool HGraphBuilder::TryArgumentsAccess(Property* expr) {
     return false;
   }
 
+  // Our implementation of arguments (based on this stack frame or an
+  // adapter below it) does not work for inlined functions.
   if (function_state()->outer() != NULL) {
-    // Push arguments when entering inlined function.
-    if (!function_state()->arguments_pushed()) {
-      HEnvironment* arguments_env = environment()->arguments_environment();
-
-      HInstruction* insert_after = function_state()->entry();
-      ASSERT(insert_after->IsEnterInlined());
-      HEnterInlined::cast(insert_after)->set_materializes_arguments(true);
-
-      for (int i = 0; i < arguments_env->parameter_count(); i++) {
-        HValue* argument = arguments_env->Lookup(i);
-        HInstruction* push_argument = new(zone()) HPushArgument(argument);
-        push_argument->InsertAfter(insert_after);
-        insert_after = push_argument;
-      }
-
-      HInstruction* arguments_elements = new(zone()) HArgumentsElements();
-      arguments_elements->ClearFlag(HValue::kUseGVN);
-      arguments_elements->InsertAfter(insert_after);
-      function_state()->set_arguments_elements(arguments_elements);
-    }
+    Bailout("arguments access in inlined function");
+    return true;
   }
 
   HInstruction* result = NULL;
   if (expr->key()->IsPropertyName()) {
     Handle<String> name = expr->key()->AsLiteral()->AsPropertyName();
     if (!name->IsEqualTo(CStrVector("length"))) return false;
-
-    if (function_state()->outer() == NULL) {
-      HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
-      result = new(zone()) HArgumentsLength(elements);
-    } else {
-      // Number of arguments without receiver.
-      int argument_count = environment()->
-          arguments_environment()->parameter_count() - 1;
-      result = new(zone()) HConstant(
-        Handle<Object>(Smi::FromInt(argument_count)),
-        Representation::Integer32());
-    }
+    HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
+    result = new(zone()) HArgumentsLength(elements);
   } else {
     Push(graph()->GetArgumentsObject());
     VisitForValue(expr->key());
     if (HasStackOverflow() || current_block() == NULL) return true;
     HValue* key = Pop();
     Drop(1);  // Arguments object.
-    if (function_state()->outer() == NULL) {
-      HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
-      HInstruction* length = AddInstruction(
-          new(zone()) HArgumentsLength(elements));
-      HInstruction* checked_key =
-          AddInstruction(new(zone()) HBoundsCheck(key, length));
-      result = new(zone()) HAccessArgumentsAt(elements, length, checked_key);
-    } else {
-      // Number of arguments without receiver.
-      HInstruction* elements = function_state()->arguments_elements();
-      int argument_count = environment()->
-          arguments_environment()->parameter_count() - 1;
-      HInstruction* length = AddInstruction(new(zone()) HConstant(
-        Handle<Object>(Smi::FromInt(argument_count)),
-        Representation::Integer32()));
-      HInstruction* checked_key =
-          AddInstruction(new(zone()) HBoundsCheck(key, length));
-      result = new(zone()) HAccessArgumentsAt(elements, length, checked_key);
-    }
+    HInstruction* elements = AddInstruction(new(zone()) HArgumentsElements);
+    HInstruction* length = AddInstruction(
+        new(zone()) HArgumentsLength(elements));
+    HInstruction* checked_key =
+        AddInstruction(new(zone()) HBoundsCheck(key, length));
+    result = new(zone()) HAccessArgumentsAt(elements, length, checked_key);
   }
   ast_context()->ReturnInstruction(result, expr->id());
   return true;
@@ -5416,24 +5369,19 @@ bool HGraphBuilder::TryInline(CallKind call_kind,
   AddInstruction(context);
   inner_env->BindContext(context);
 #endif
+  AddSimulate(return_id);
+  current_block()->UpdateEnvironment(inner_env);
+  AddInstruction(new(zone()) HEnterInlined(target,
+                                           arguments->length(),
+                                           function,
+                                           call_kind,
+                                           function_state()->is_construct()));
   // If the function uses arguments object create and bind one.
   if (function->scope()->arguments() != NULL) {
     ASSERT(function->scope()->arguments()->IsStackAllocated());
-    inner_env->Bind(function->scope()->arguments(),
-                    graph()->GetArgumentsObject());
+    environment()->Bind(function->scope()->arguments(),
+                        graph()->GetArgumentsObject());
   }
-
-  AddSimulate(return_id);
-  current_block()->UpdateEnvironment(inner_env);
-
-  HInstruction* enter_inlined =
-      AddInstruction(new(zone()) HEnterInlined(target,
-                                               arguments->length(),
-                                               function,
-                                               call_kind,
-                                               function_state()->is_construct(),
-                                               function->scope()->arguments()));
-  function_state()->set_entry(enter_inlined);
   VisitDeclarations(target_info.scope()->declarations());
   VisitStatements(function->body());
   if (HasStackOverflow()) {
@@ -5462,17 +5410,17 @@ bool HGraphBuilder::TryInline(CallKind call_kind,
           : undefined;
       current_block()->AddLeaveInlined(return_value,
                                        function_return(),
-                                       function_state());
+                                       function_state()->drop_extra());
     } else if (call_context()->IsEffect()) {
       ASSERT(function_return() != NULL);
-      current_block()->Goto(function_return(), function_state());
+      current_block()->Goto(function_return(), function_state()->drop_extra());
     } else {
       ASSERT(call_context()->IsTest());
       ASSERT(inlined_test_context() != NULL);
       HBasicBlock* target = function_state()->is_construct()
           ? inlined_test_context()->if_true()
           : inlined_test_context()->if_false();
-      current_block()->Goto(target, function_state());
+      current_block()->Goto(target, function_state()->drop_extra());
     }
   }
 
@@ -5490,12 +5438,12 @@ bool HGraphBuilder::TryInline(CallKind call_kind,
     if (if_true->HasPredecessor()) {
       if_true->SetJoinId(ast_id);
       HBasicBlock* true_target = TestContext::cast(ast_context())->if_true();
-      if_true->Goto(true_target, function_state());
+      if_true->Goto(true_target, function_state()->drop_extra());
     }
     if (if_false->HasPredecessor()) {
       if_false->SetJoinId(ast_id);
       HBasicBlock* false_target = TestContext::cast(ast_context())->if_false();
-      if_false->Goto(false_target, function_state());
+      if_false->Goto(false_target, function_state()->drop_extra());
     }
     set_current_block(NULL);
     return true;
index 82e3119..e2779bb 100644 (file)
@@ -42,7 +42,6 @@ namespace internal {
 
 // Forward declarations.
 class BitVector;
-class FunctionState;
 class HEnvironment;
 class HGraph;
 class HLoopInformation;
@@ -122,7 +121,7 @@ class HBasicBlock: public ZoneObject {
 
   void Finish(HControlInstruction* last);
   void FinishExit(HControlInstruction* instruction);
-  void Goto(HBasicBlock* block, FunctionState* state = NULL);
+  void Goto(HBasicBlock* block, bool drop_extra = false);
 
   int PredecessorIndexOf(HBasicBlock* predecessor) const;
   void AddSimulate(int ast_id) { AddInstruction(CreateSimulate(ast_id)); }
@@ -137,7 +136,7 @@ class HBasicBlock: public ZoneObject {
   // instruction and updating the bailout environment.
   void AddLeaveInlined(HValue* return_value,
                        HBasicBlock* target,
-                       FunctionState* state = NULL);
+                       bool drop_extra = false);
 
   // If a target block is tagged as an inline function return, all
   // predecessors should contain the inlined exit sequence:
@@ -716,16 +715,6 @@ class FunctionState {
 
   FunctionState* outer() { return outer_; }
 
-  HInstruction* entry() { return entry_; }
-  void set_entry(HInstruction* entry) { entry_ = entry; }
-
-  HInstruction* arguments_elements() { return arguments_elements_; }
-  void set_arguments_elements(HInstruction* arguments_elements) {
-    arguments_elements_ = arguments_elements;
-  }
-
-  bool arguments_pushed() { return arguments_elements() != NULL; }
-
  private:
   HGraphBuilder* owner_;
 
@@ -752,12 +741,6 @@ class FunctionState {
   // return blocks.  NULL in all other cases.
   TestContext* test_context_;
 
-  // When inlining HEnterInlined instruction corresponding to the function
-  // entry.
-  HInstruction* entry_;
-
-  HInstruction* arguments_elements_;
-
   FunctionState* outer_;
 };
 
index 2c5a167..8fb4c79 100644 (file)
@@ -2543,29 +2543,25 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
   Register result = ToRegister(instr->result());
 
-  if (instr->from_inlined()) {
-    __ lea(result, Operand(esp, -2 * kPointerSize));
-  } else {
-    // Check for arguments adapter frame.
-    Label done, adapted;
-    __ mov(result, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
-    __ mov(result, Operand(result, StandardFrameConstants::kContextOffset));
-    __ cmp(Operand(result),
-           Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
-    __ j(equal, &adapted, Label::kNear);
-
-    // No arguments adaptor frame.
-    __ mov(result, Operand(ebp));
-    __ jmp(&done, Label::kNear);
+  // Check for arguments adapter frame.
+  Label done, adapted;
+  __ mov(result, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
+  __ mov(result, Operand(result, StandardFrameConstants::kContextOffset));
+  __ cmp(Operand(result),
+         Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
+  __ j(equal, &adapted, Label::kNear);
 
-    // Arguments adaptor frame present.
-    __ bind(&adapted);
-    __ mov(result, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
+  // No arguments adaptor frame.
+  __ mov(result, Operand(ebp));
+  __ jmp(&done, Label::kNear);
 
-    // Result is the frame pointer for the frame if not adapted and for the real
-    // frame below the adaptor frame if adapted.
-    __ bind(&done);
-  }
+  // Arguments adaptor frame present.
+  __ bind(&adapted);
+  __ mov(result, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
+
+  // Result is the frame pointer for the frame if not adapted and for the real
+  // frame below the adaptor frame if adapted.
+  __ bind(&done);
 }
 
 
@@ -2687,11 +2683,6 @@ void LCodeGen::DoPushArgument(LPushArgument* instr) {
 }
 
 
-void LCodeGen::DoPop(LPop* instr) {
-  __ Drop(instr->count());
-}
-
-
 void LCodeGen::DoThisFunction(LThisFunction* instr) {
   Register result = ToRegister(instr->result());
   __ LoadHeapObject(result, instr->hydrogen()->closure());
index 10131d4..2bfbb67 100644 (file)
@@ -1083,8 +1083,7 @@ LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) {
 
 
 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
-  return DefineAsRegister(new(zone()) LArgumentsElements(
-      current_block_->last_environment()->outer() != NULL));
+  return DefineAsRegister(new(zone()) LArgumentsElements);
 }
 
 
@@ -2381,9 +2380,6 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
                                                undefined,
                                                instr->call_kind(),
                                                instr->is_construct());
-  if (instr->materializes_arguments()) {
-    inner->Bind(instr->arguments(), graph()->GetArgumentsObject());
-  }
   current_block_->UpdateEnvironment(inner);
   chunk_->AddInlinedClosure(instr->closure());
   return NULL;
@@ -2391,20 +2387,10 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
 
 
 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
-  LInstruction* pop = NULL;
-
-  HEnvironment* env = current_block_->last_environment();
-
-  if (instr->arguments_pushed()) {
-    int argument_count = env->arguments_environment()->parameter_count();
-    pop = new(zone()) LPop(argument_count);
-    argument_count_ -= argument_count;
-  }
-
   HEnvironment* outer = current_block_->last_environment()->
       DiscardInlined(false);
   current_block_->UpdateEnvironment(outer);
-  return pop;
+  return NULL;
 }
 
 
index 3fa21f9..4ecce96 100644 (file)
@@ -174,8 +174,7 @@ class LCodeGen;
   V(CheckMapValue)                              \
   V(LoadFieldByIndex)                           \
   V(DateField)                                  \
-  V(WrapReceiver)                               \
-  V(Pop)
+  V(WrapReceiver)
 
 
 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)              \
@@ -526,15 +525,9 @@ class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
 
 class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
  public:
-  explicit LArgumentsElements(bool from_inlined)
-      : from_inlined_(from_inlined) { }
-
-  bool from_inlined() const { return from_inlined_; }
+  LArgumentsElements() { }
 
   DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
-
- private:
-  bool from_inlined_;
 };
 
 
@@ -1408,19 +1401,6 @@ class LPushArgument: public LTemplateInstruction<0, 1, 0> {
 };
 
 
-class LPop: public LTemplateInstruction<0, 0, 0> {
- public:
-  explicit LPop(int count) : count_(count) { }
-
-  int count() const { return count_; }
-
-  DECLARE_CONCRETE_INSTRUCTION(Pop, "pop")
-
- private:
-  int count_;
-};
-
-
 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
  public:
   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
index f6f0c94..94e8979 100644 (file)
@@ -2651,20 +2651,16 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
   Register temp = scratch1();
   Register result = ToRegister(instr->result());
 
-  if (instr->from_inlined()) {
-    __ Subu(result, sp, 2 * kPointerSize);
-  } else {
-    // Check if the calling frame is an arguments adaptor frame.
-    Label done, adapted;
-    __ lw(scratch, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
-    __ lw(result, MemOperand(scratch, StandardFrameConstants::kContextOffset));
-    __ Xor(temp, result, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
-
-    // Result is the frame pointer for the frame if not adapted and for the real
-    // frame below the adaptor frame if adapted.
-    __ Movn(result, fp, temp);  // Move only if temp is not equal to zero (ne).
-    __ Movz(result, scratch, temp);  // Move only if temp is equal to zero (eq).
-  }
+  // Check if the calling frame is an arguments adaptor frame.
+  Label done, adapted;
+  __ lw(scratch, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
+  __ lw(result, MemOperand(scratch, StandardFrameConstants::kContextOffset));
+  __ Xor(temp, result, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
+
+  // Result is the frame pointer for the frame if not adapted and for the real
+  // frame below the adaptor frame if adapted.
+  __ Movn(result, fp, temp);  // Move only if temp is not equal to zero (ne).
+  __ Movz(result, scratch, temp);  // Move only if temp is equal to zero (eq).
 }
 
 
@@ -2797,11 +2793,6 @@ void LCodeGen::DoPushArgument(LPushArgument* instr) {
 }
 
 
-void LCodeGen::DoPop(LPop* instr) {
-  __ Drop(instr->count());
-}
-
-
 void LCodeGen::DoThisFunction(LThisFunction* instr) {
   Register result = ToRegister(instr->result());
   __ LoadHeapObject(result, instr->hydrogen()->closure());
index dca90a1..1e0c216 100644 (file)
@@ -1076,8 +1076,7 @@ LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) {
 
 
 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
-  return DefineAsRegister(new(zone()) LArgumentsElements(
-      current_block_->last_environment()->outer() != NULL));
+  return DefineAsRegister(new(zone()) LArgumentsElements);
 }
 
 
@@ -2278,9 +2277,6 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
                                                undefined,
                                                instr->call_kind(),
                                                instr->is_construct());
-  if (instr->materializes_arguments()) {
-    inner->Bind(instr->arguments(), graph()->GetArgumentsObject());
-  }
   current_block_->UpdateEnvironment(inner);
   chunk_->AddInlinedClosure(instr->closure());
   return NULL;
@@ -2288,21 +2284,10 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
 
 
 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
-  LInstruction* pop = NULL;
-
-  HEnvironment* env = current_block_->last_environment();
-
-  if (instr->arguments_pushed()) {
-    int argument_count = env->arguments_environment()->parameter_count();
-    pop = new(zone()) LPop(argument_count);
-    argument_count_ -= argument_count;
-  }
-
   HEnvironment* outer = current_block_->last_environment()->
       DiscardInlined(false);
   current_block_->UpdateEnvironment(outer);
-
-  return pop;
+  return NULL;
 }
 
 
index 8fb80b6..5a7bf4d 100644 (file)
@@ -179,8 +179,7 @@ class LCodeGen;
   V(CheckMapValue)                              \
   V(LoadFieldByIndex)                           \
   V(DateField)                                  \
-  V(WrapReceiver)                               \
-  V(Pop)
+  V(WrapReceiver)
 
 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)              \
   virtual Opcode opcode() const { return LInstruction::k##type; } \
@@ -534,15 +533,9 @@ class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
 
 class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
  public:
-  explicit LArgumentsElements(bool from_inlined)
-      : from_inlined_(from_inlined) { }
-
-  bool from_inlined() const { return from_inlined_; }
+  LArgumentsElements() { }
 
   DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
-
- private:
-  bool from_inlined_;
 };
 
 
@@ -1365,19 +1358,6 @@ class LPushArgument: public LTemplateInstruction<0, 1, 0> {
 };
 
 
-class LPop: public LTemplateInstruction<0, 0, 0> {
- public:
-  explicit LPop(int count) : count_(count) { }
-
-  int count() const { return count_; }
-
-  DECLARE_CONCRETE_INSTRUCTION(Pop, "pop")
-
- private:
-  int count_;
-};
-
-
 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
  public:
   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
index a1e1633..20a9090 100644 (file)
@@ -8123,14 +8123,6 @@ static void MaterializeArgumentsObjectInFrame(Isolate* isolate,
         ASSERT(*arguments != isolate->heap()->undefined_value());
       }
       frame->SetExpression(i, *arguments);
-      if (FLAG_trace_deopt) {
-        PrintF("Materializing arguments object for frame %p - %p: %p ",
-               reinterpret_cast<void*>(frame->sp()),
-               reinterpret_cast<void*>(frame->fp()),
-               reinterpret_cast<void*>(*arguments));
-        arguments->ShortPrint();
-        PrintF("\n");
-      }
     }
   }
 }
index 0555aeb..2ba2c57 100644 (file)
@@ -2497,28 +2497,24 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
   Register result = ToRegister(instr->result());
 
-  if (instr->from_inlined()) {
-    __ lea(result, Operand(rsp, -2 * kPointerSize));
-  } else {
-    // Check for arguments adapter frame.
-    Label done, adapted;
-    __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
-    __ Cmp(Operand(result, StandardFrameConstants::kContextOffset),
-           Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
-    __ j(equal, &adapted, Label::kNear);
-
-    // No arguments adaptor frame.
-    __ movq(result, rbp);
-    __ jmp(&done, Label::kNear);
+  // Check for arguments adapter frame.
+  Label done, adapted;
+  __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
+  __ Cmp(Operand(result, StandardFrameConstants::kContextOffset),
+         Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
+  __ j(equal, &adapted, Label::kNear);
 
-    // Arguments adaptor frame present.
-    __ bind(&adapted);
-    __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
+  // No arguments adaptor frame.
+  __ movq(result, rbp);
+  __ jmp(&done, Label::kNear);
 
-    // Result is the frame pointer for the frame if not adapted and for the real
-    // frame below the adaptor frame if adapted.
-    __ bind(&done);
-  }
+  // Arguments adaptor frame present.
+  __ bind(&adapted);
+  __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
+
+  // Result is the frame pointer for the frame if not adapted and for the real
+  // frame below the adaptor frame if adapted.
+  __ bind(&done);
 }
 
 
@@ -2644,11 +2640,6 @@ void LCodeGen::DoPushArgument(LPushArgument* instr) {
 }
 
 
-void LCodeGen::DoPop(LPop* instr) {
-  __ Drop(instr->count());
-}
-
-
 void LCodeGen::DoThisFunction(LThisFunction* instr) {
   Register result = ToRegister(instr->result());
   __ LoadHeapObject(result, instr->hydrogen()->closure());
index baff1bd..d3e4cdd 100644 (file)
@@ -1071,8 +1071,7 @@ LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) {
 
 
 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
-  return DefineAsRegister(new(zone()) LArgumentsElements(
-      current_block_->last_environment()->outer() != NULL));
+  return DefineAsRegister(new(zone()) LArgumentsElements);
 }
 
 
@@ -2271,9 +2270,6 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
                                                undefined,
                                                instr->call_kind(),
                                                instr->is_construct());
-  if (instr->materializes_arguments()) {
-    inner->Bind(instr->arguments(), graph()->GetArgumentsObject());
-  }
   current_block_->UpdateEnvironment(inner);
   chunk_->AddInlinedClosure(instr->closure());
   return NULL;
@@ -2281,21 +2277,10 @@ LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
 
 
 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
-  LInstruction* pop = NULL;
-
-  HEnvironment* env = current_block_->last_environment();
-
-  if (instr->arguments_pushed()) {
-    int argument_count = env->arguments_environment()->parameter_count();
-    pop = new(zone()) LPop(argument_count);
-    argument_count_ -= argument_count;
-  }
-
   HEnvironment* outer = current_block_->last_environment()->
       DiscardInlined(false);
   current_block_->UpdateEnvironment(outer);
-
-  return pop;
+  return NULL;
 }
 
 
index b9e390e..2d8fd2e 100644 (file)
@@ -179,8 +179,7 @@ class LCodeGen;
   V(CheckMapValue)                              \
   V(LoadFieldByIndex)                           \
   V(DateField)                                  \
-  V(WrapReceiver)                               \
-  V(Pop)
+  V(WrapReceiver)
 
 
 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)              \
@@ -536,15 +535,9 @@ class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
 
 class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
  public:
-  explicit LArgumentsElements(bool from_inlined)
-      : from_inlined_(from_inlined) { }
-
-  bool from_inlined() const { return from_inlined_; }
+  LArgumentsElements() { }
 
   DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
-
- private:
-  bool from_inlined_;
 };
 
 
@@ -1365,19 +1358,6 @@ class LPushArgument: public LTemplateInstruction<0, 1, 0> {
 };
 
 
-class LPop: public LTemplateInstruction<0, 0, 0> {
- public:
-  explicit LPop(int count) : count_(count) { }
-
-  int count() const { return count_; }
-
-  DECLARE_CONCRETE_INSTRUCTION(Pop, "pop")
-
- private:
-  int count_;
-};
-
-
 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
  public:
   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
index 48f6019..b6adf7f 100644 (file)
@@ -113,46 +113,3 @@ F4(1);
   %OptimizeFunctionOnNextCall(test_adaptation);
   test_adaptation();
 })();
-
-// Test arguments access from the inlined function.
-function uninlinable(v) {
-  assertEquals(0, v);
-  try { } catch (e) { }
-  return 0;
-}
-
-function toarr_inner() {
-  var a = arguments;
-  var marker = a[0];
-  uninlinable(uninlinable(0, 0), marker.x);
-
-  var r = new Array();
-  for (var i = a.length - 1; i >= 1; i--) {
-    r.push(a[i]);
-  }
-
-  return r;
-}
-
-function toarr1(marker, a, b, c) {
-  return toarr_inner(marker, a / 2, b / 2, c / 2);
-}
-
-function toarr2(marker, a, b, c) {
-  var x = 0;
-  return uninlinable(uninlinable(0, 0),
-                    x = toarr_inner(marker, a / 2, b / 2, c / 2)), x;
-}
-
-function test_toarr(toarr) {
-  var marker = { x: 0 };
-  assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6));
-  assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6));
-  %OptimizeFunctionOnNextCall(toarr);
-  assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6));
-  delete marker.x;
-  assertArrayEquals([3, 2, 1], toarr(marker, 2, 4, 6));
-}
-
-test_toarr(toarr1);
-test_toarr(toarr2);