Revision: 7682
Author:   [email protected]
Date:     Tue Apr 26 08:22:44 2011
Log:      Crankshaft support for IN.

In JavaScriptFrame::Print avoid printing optimized frame as if it is unoptimized.

Review URL: http://codereview.chromium.org/6894043
http://code.google.com/p/v8/source/detail?r=7682

Modified:
 /branches/bleeding_edge/src/arm/lithium-arm.cc
 /branches/bleeding_edge/src/arm/lithium-arm.h
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/frames.cc
 /branches/bleeding_edge/src/hydrogen-instructions.cc
 /branches/bleeding_edge/src/hydrogen-instructions.h
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-ia32.h
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
 /branches/bleeding_edge/src/x64/lithium-x64.cc
 /branches/bleeding_edge/src/x64/lithium-x64.h

=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc      Thu Apr 21 00:15:43 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc      Tue Apr 26 08:22:44 2011
@@ -2140,6 +2140,14 @@
   current_block_->UpdateEnvironment(outer);
   return NULL;
 }
+
+
+LInstruction* LChunkBuilder::DoIn(HIn* instr) {
+  LOperand* key = UseRegisterAtStart(instr->key());
+  LOperand* object = UseRegisterAtStart(instr->object());
+  LIn* result = new LIn(key, object);
+  return MarkAsCall(DefineFixed(result, r0), instr);
+}


 } }  // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h       Wed Apr 20 02:08:26 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.h       Tue Apr 26 08:22:44 2011
@@ -102,6 +102,7 @@
   V(HasCachedArrayIndexAndBranch)               \
   V(HasInstanceType)                            \
   V(HasInstanceTypeAndBranch)                   \
+  V(In)                                         \
   V(InstanceOf)                                 \
   V(InstanceOfAndBranch)                        \
   V(InstanceOfKnownGlobal)                      \
@@ -1992,6 +1993,20 @@
 };


+class LIn: public LTemplateInstruction<1, 2, 0> {
+ public:
+  LIn(LOperand* key, LOperand* object) {
+    inputs_[0] = key;
+    inputs_[1] = object;
+  }
+
+  LOperand* key() { return inputs_[0]; }
+  LOperand* object() { return inputs_[1]; }
+
+  DECLARE_CONCRETE_INSTRUCTION(In, "in")
+};
+
+
 class LChunkBuilder;
 class LChunk: public ZoneObject {
  public:
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Apr 21 00:15:43 2011 +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Apr 26 08:22:44 2011
@@ -4255,6 +4255,22 @@
                                          env->deoptimization_index());
   __ InvokeBuiltin(Builtins::DELETE, CALL_JS, &safepoint_generator);
 }
+
+
+void LCodeGen::DoIn(LIn* instr) {
+  Register obj = ToRegister(instr->object());
+  Register key = ToRegister(instr->key());
+  __ Push(key, obj);
+  ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
+  LPointerMap* pointers = instr->pointer_map();
+  LEnvironment* env = instr->deoptimization_environment();
+  RecordPosition(pointers->position());
+  RegisterEnvironmentForDeoptimization(env);
+  SafepointGenerator safepoint_generator(this,
+                                         pointers,
+                                         env->deoptimization_index());
+  __ InvokeBuiltin(Builtins::IN, CALL_JS, &safepoint_generator);
+}


 void LCodeGen::DoStackCheck(LStackCheck* instr) {
@@ -4284,6 +4300,8 @@
   ASSERT(osr_pc_offset_ == -1);
   osr_pc_offset_ = masm()->pc_offset();
 }
+
+


 #undef __
=======================================
--- /branches/bleeding_edge/src/frames.cc       Wed Apr  6 07:23:27 2011
+++ /branches/bleeding_edge/src/frames.cc       Tue Apr 26 08:22:44 2011
@@ -938,6 +938,10 @@
     accumulator->Add("\n");
     return;
   }
+  if (is_optimized()) {
+    accumulator->Add(" {\n// optimized frame\n}\n");
+    return;
+  }
   accumulator->Add(" {\n");

   // Compute the number of locals and expression stack elements.
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Apr 21 00:15:43 2011 +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Apr 26 08:22:44 2011
@@ -1609,6 +1609,13 @@
   }
   return NULL;
 }
+
+
+void HIn::PrintDataTo(StringStream* stream) {
+  key()->PrintNameTo(stream);
+  stream->Add(" ");
+  object()->PrintNameTo(stream);
+}


 // Node-specific verification code is only included in debug mode.
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Thu Apr 21 00:15:43 2011 +++ /branches/bleeding_edge/src/hydrogen-instructions.h Tue Apr 26 08:22:44 2011
@@ -104,6 +104,7 @@
   V(Goto)                                      \
   V(HasInstanceType)                           \
   V(HasCachedArrayIndex)                       \
+  V(In)                                        \
   V(InstanceOf)                                \
   V(InstanceOfKnownGlobal)                     \
   V(InvokeFunction)                            \
@@ -3780,6 +3781,32 @@
   HValue* key() { return right(); }
 };

+
+class HIn: public HTemplateInstruction<2> {
+ public:
+  HIn(HValue* key, HValue* object) {
+    SetOperandAt(0, key);
+    SetOperandAt(1, object);
+    set_representation(Representation::Tagged());
+    SetAllSideEffects();
+  }
+
+  HValue* key() { return OperandAt(0); }
+  HValue* object() { return OperandAt(1); }
+
+  virtual Representation RequiredInputRepresentation(int index) const {
+    return Representation::Tagged();
+  }
+
+  virtual HType CalculateInferredType() {
+    return HType::Boolean();
+  }
+
+  virtual void PrintDataTo(StringStream* stream);
+
+  DECLARE_CONCRETE_INSTRUCTION(In)
+};
+
 #undef DECLARE_INSTRUCTION
 #undef DECLARE_CONCRETE_INSTRUCTION

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Wed Apr 20 03:38:08 2011
+++ /branches/bleeding_edge/src/hydrogen.cc     Tue Apr 26 08:22:44 2011
@@ -5105,7 +5105,7 @@
       instr = new(zone()) HInstanceOfKnownGlobal(left, target);
     }
   } else if (op == Token::IN) {
-    return Bailout("Unsupported comparison: in");
+    instr = new(zone()) HIn(left, right);
   } else if (type_info.IsNonPrimitive()) {
     switch (op) {
       case Token::EQ:
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Apr 21 00:15:43 2011 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Apr 26 08:22:44 2011
@@ -4216,6 +4216,35 @@
   ASSERT(osr_pc_offset_ == -1);
   osr_pc_offset_ = masm()->pc_offset();
 }
+
+
+void LCodeGen::DoIn(LIn* instr) {
+  LOperand* obj = instr->object();
+  LOperand* key = instr->key();
+  if (key->IsConstantOperand()) {
+    __ push(ToImmediate(key));
+  } else {
+    __ push(ToOperand(key));
+  }
+  if (obj->IsConstantOperand()) {
+    __ push(ToImmediate(obj));
+  } else {
+    __ push(ToOperand(obj));
+  }
+  ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
+  LPointerMap* pointers = instr->pointer_map();
+  LEnvironment* env = instr->deoptimization_environment();
+  RecordPosition(pointers->position());
+  RegisterEnvironmentForDeoptimization(env);
+  // Create safepoint generator that will also ensure enough space in the
+  // reloc info for patching in deoptimization (since this is invoking a
+  // builtin)
+  SafepointGenerator safepoint_generator(this,
+                                         pointers,
+                                         env->deoptimization_index());
+  __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
+  __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, &safepoint_generator);
+}


 #undef __
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu Apr 21 00:15:43 2011 +++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue Apr 26 08:22:44 2011
@@ -2203,6 +2203,14 @@
   current_block_->UpdateEnvironment(outer);
   return NULL;
 }
+
+
+LInstruction* LChunkBuilder::DoIn(HIn* instr) {
+  LOperand* key = UseOrConstantAtStart(instr->key());
+  LOperand* object = UseOrConstantAtStart(instr->object());
+  LIn* result = new LIn(key, object);
+  return MarkAsCall(DefineFixed(result, eax), instr);
+}


 } }  // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h     Wed Apr 20 02:08:26 2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h     Tue Apr 26 08:22:44 2011
@@ -103,6 +103,7 @@
   V(HasCachedArrayIndexAndBranch)               \
   V(HasInstanceType)                            \
   V(HasInstanceTypeAndBranch)                   \
+  V(In)                                         \
   V(InstanceOf)                                 \
   V(InstanceOfAndBranch)                        \
   V(InstanceOfKnownGlobal)                      \
@@ -2045,6 +2046,20 @@
 };


+class LIn: public LTemplateInstruction<1, 2, 0> {
+ public:
+  LIn(LOperand* key, LOperand* object) {
+    inputs_[0] = key;
+    inputs_[1] = object;
+  }
+
+  LOperand* key() { return inputs_[0]; }
+  LOperand* object() { return inputs_[1]; }
+
+  DECLARE_CONCRETE_INSTRUCTION(In, "in")
+};
+
+
 class LChunkBuilder;
 class LChunk: public ZoneObject {
  public:
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Apr 21 00:15:43 2011 +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Apr 26 08:22:44 2011
@@ -3996,6 +3996,26 @@
   __ Push(Smi::FromInt(strict_mode_flag()));
   __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator);
 }
+
+
+void LCodeGen::DoIn(LIn* instr) {
+  LOperand* obj = instr->object();
+  LOperand* key = instr->key();
+  EmitPushTaggedOperand(key);
+  EmitPushTaggedOperand(obj);
+  ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
+  LPointerMap* pointers = instr->pointer_map();
+  LEnvironment* env = instr->deoptimization_environment();
+  RecordPosition(pointers->position());
+  RegisterEnvironmentForDeoptimization(env);
+  // Create safepoint generator that will also ensure enough space in the
+  // reloc info for patching in deoptimization (since this is invoking a
+  // builtin)
+  SafepointGenerator safepoint_generator(this,
+                                         pointers,
+                                         env->deoptimization_index());
+  __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, &safepoint_generator);
+}


 void LCodeGen::DoStackCheck(LStackCheck* instr) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc      Thu Apr 21 00:15:43 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc      Tue Apr 26 08:22:44 2011
@@ -2135,6 +2135,15 @@
   current_block_->UpdateEnvironment(outer);
   return NULL;
 }
+
+
+LInstruction* LChunkBuilder::DoIn(HIn* instr) {
+  LOperand* key = UseOrConstantAtStart(instr->key());
+  LOperand* object = UseOrConstantAtStart(instr->object());
+  LIn* result = new LIn(key, object);
+  return MarkAsCall(DefineFixed(result, rax), instr);
+}
+

 } }  // namespace v8::internal

=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h       Wed Apr 20 02:08:26 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.h       Tue Apr 26 08:22:44 2011
@@ -102,6 +102,7 @@
   V(HasCachedArrayIndexAndBranch)               \
   V(HasInstanceType)                            \
   V(HasInstanceTypeAndBranch)                   \
+  V(In)                                         \
   V(InstanceOf)                                 \
   V(InstanceOfAndBranch)                        \
   V(InstanceOfKnownGlobal)                      \
@@ -830,6 +831,20 @@
 };


+class LIn: public LTemplateInstruction<1, 2, 0> {
+ public:
+  LIn(LOperand* key, LOperand* object) {
+    inputs_[0] = key;
+    inputs_[1] = object;
+  }
+
+  LOperand* key() { return inputs_[0]; }
+  LOperand* object() { return inputs_[1]; }
+
+  DECLARE_CONCRETE_INSTRUCTION(In, "in")
+};
+
+
 class LInstanceOf: public LTemplateInstruction<1, 2, 0> {
  public:
   LInstanceOf(LOperand* left, LOperand* right) {

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to