Revision: 23605
Author:   [email protected]
Date:     Tue Sep  2 11:51:25 2014 UTC
Log:      Minor-key-ify four stubs.

- ICCompareStub
- BinaryOpICStub
- CompareNilICStub
- VectorLoadStub

[email protected]

Review URL: https://codereview.chromium.org/529773002
https://code.google.com/p/v8/source/detail?r=23605

Modified:
 /branches/bleeding_edge/src/arm/code-stubs-arm.cc
 /branches/bleeding_edge/src/arm/macro-assembler-arm.cc
 /branches/bleeding_edge/src/arm64/code-stubs-arm64.cc
 /branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc
 /branches/bleeding_edge/src/code-stubs.cc
 /branches/bleeding_edge/src/code-stubs.h
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.h
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc
 /branches/bleeding_edge/src/ic/ic.cc
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/x64/code-stubs-x64.cc
 /branches/bleeding_edge/src/x64/macro-assembler-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Mon Sep 1 09:18:39 2014 UTC +++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Tue Sep 2 11:51:25 2014 UTC
@@ -704,8 +704,8 @@
   Condition cc = GetCondition();

   Label miss;
-  ICCompareStub_CheckInputType(masm, lhs, r2, left_, &miss);
-  ICCompareStub_CheckInputType(masm, rhs, r3, right_, &miss);
+  ICCompareStub_CheckInputType(masm, lhs, r2, left(), &miss);
+  ICCompareStub_CheckInputType(masm, rhs, r3, right(), &miss);

   Label slow;  // Call builtin.
   Label not_smis, both_loaded_as_doubles, lhs_not_nan;
@@ -3472,7 +3472,7 @@


 void ICCompareStub::GenerateSmis(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::SMI);
+  DCHECK(state() == CompareIC::SMI);
   Label miss;
   __ orr(r2, r1, r0);
   __ JumpIfNotSmi(r2, &miss);
@@ -3493,16 +3493,16 @@


 void ICCompareStub::GenerateNumbers(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::NUMBER);
+  DCHECK(state() == CompareIC::NUMBER);

   Label generic_stub;
   Label unordered, maybe_undefined1, maybe_undefined2;
   Label miss;

-  if (left_ == CompareIC::SMI) {
+  if (left() == CompareIC::SMI) {
     __ JumpIfNotSmi(r1, &miss);
   }
-  if (right_ == CompareIC::SMI) {
+  if (right() == CompareIC::SMI) {
     __ JumpIfNotSmi(r0, &miss);
   }

@@ -3544,12 +3544,12 @@

   __ bind(&unordered);
   __ bind(&generic_stub);
- ICCompareStub stub(isolate(), op_, CompareIC::GENERIC, CompareIC::GENERIC, + ICCompareStub stub(isolate(), op(), CompareIC::GENERIC, CompareIC::GENERIC,
                      CompareIC::GENERIC);
   __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);

   __ bind(&maybe_undefined1);
-  if (Token::IsOrderedRelationalCompareOp(op_)) {
+  if (Token::IsOrderedRelationalCompareOp(op())) {
     __ CompareRoot(r0, Heap::kUndefinedValueRootIndex);
     __ b(ne, &miss);
     __ JumpIfSmi(r1, &unordered);
@@ -3559,7 +3559,7 @@
   }

   __ bind(&maybe_undefined2);
-  if (Token::IsOrderedRelationalCompareOp(op_)) {
+  if (Token::IsOrderedRelationalCompareOp(op())) {
     __ CompareRoot(r1, Heap::kUndefinedValueRootIndex);
     __ b(eq, &unordered);
   }
@@ -3570,7 +3570,7 @@


 void ICCompareStub::GenerateInternalizedStrings(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::INTERNALIZED_STRING);
+  DCHECK(state() == CompareIC::INTERNALIZED_STRING);
   Label miss;

   // Registers containing left and right operands respectively.
@@ -3608,7 +3608,7 @@


 void ICCompareStub::GenerateUniqueNames(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::UNIQUE_NAME);
+  DCHECK(state() == CompareIC::UNIQUE_NAME);
   DCHECK(GetCondition() == eq);
   Label miss;

@@ -3647,10 +3647,10 @@


 void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::STRING);
+  DCHECK(state() == CompareIC::STRING);
   Label miss;

-  bool equality = Token::IsEqualityOp(op_);
+  bool equality = Token::IsEqualityOp(op());

   // Registers containing left and right operands respectively.
   Register left = r1;
@@ -3726,7 +3726,7 @@


 void ICCompareStub::GenerateObjects(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::OBJECT);
+  DCHECK(state() == CompareIC::OBJECT);
   Label miss;
   __ and_(r2, r1, Operand(r0));
   __ JumpIfSmi(r2, &miss);
@@ -3774,7 +3774,7 @@
     FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
     __ Push(r1, r0);
     __ Push(lr, r1, r0);
-    __ mov(ip, Operand(Smi::FromInt(op_)));
+    __ mov(ip, Operand(Smi::FromInt(op())));
     __ push(ip);
     __ CallExternalReference(miss, 3);
     // Compute the entry point of the rewritten stub.
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Mon Aug 4 11:34:54 2014 UTC +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Tue Sep 2 11:51:25 2014 UTC
@@ -677,8 +677,7 @@
     Ret(eq);
   }
   push(lr);
-  StoreBufferOverflowStub store_buffer_overflow =
-      StoreBufferOverflowStub(isolate(), fp_mode);
+  StoreBufferOverflowStub store_buffer_overflow(isolate(), fp_mode);
   CallStub(&store_buffer_overflow);
   pop(lr);
   bind(&done);
=======================================
--- /branches/bleeding_edge/src/arm64/code-stubs-arm64.cc Mon Sep 1 09:18:39 2014 UTC +++ /branches/bleeding_edge/src/arm64/code-stubs-arm64.cc Tue Sep 2 11:51:25 2014 UTC
@@ -513,8 +513,8 @@
   Condition cond = GetCondition();

   Label miss;
-  ICCompareStub_CheckInputType(masm, lhs, x2, left_, &miss);
-  ICCompareStub_CheckInputType(masm, rhs, x3, right_, &miss);
+  ICCompareStub_CheckInputType(masm, lhs, x2, left(), &miss);
+  ICCompareStub_CheckInputType(masm, rhs, x3, right(), &miss);

   Label slow;  // Call builtin.
   Label not_smis, both_loaded_as_doubles;
@@ -3204,7 +3204,7 @@

 void ICCompareStub::GenerateSmis(MacroAssembler* masm) {
   // Inputs are in x0 (lhs) and x1 (rhs).
-  DCHECK(state_ == CompareIC::SMI);
+  DCHECK(state() == CompareIC::SMI);
   ASM_LOCATION("ICCompareStub[Smis]");
   Label miss;
   // Bail out (to 'miss') unless both x0 and x1 are smis.
@@ -3226,7 +3226,7 @@


 void ICCompareStub::GenerateNumbers(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::NUMBER);
+  DCHECK(state() == CompareIC::NUMBER);
   ASM_LOCATION("ICCompareStub[HeapNumbers]");

   Label unordered, maybe_undefined1, maybe_undefined2;
@@ -3239,10 +3239,10 @@
   FPRegister rhs_d = d0;
   FPRegister lhs_d = d1;

-  if (left_ == CompareIC::SMI) {
+  if (left() == CompareIC::SMI) {
     __ JumpIfNotSmi(lhs, &miss);
   }
-  if (right_ == CompareIC::SMI) {
+  if (right() == CompareIC::SMI) {
     __ JumpIfNotSmi(rhs, &miss);
   }

@@ -3271,12 +3271,12 @@
   __ Ret();

   __ Bind(&unordered);
- ICCompareStub stub(isolate(), op_, CompareIC::GENERIC, CompareIC::GENERIC, + ICCompareStub stub(isolate(), op(), CompareIC::GENERIC, CompareIC::GENERIC,
                      CompareIC::GENERIC);
   __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);

   __ Bind(&maybe_undefined1);
-  if (Token::IsOrderedRelationalCompareOp(op_)) {
+  if (Token::IsOrderedRelationalCompareOp(op())) {
     __ JumpIfNotRoot(rhs, Heap::kUndefinedValueRootIndex, &miss);
     __ JumpIfSmi(lhs, &unordered);
__ JumpIfNotObjectType(lhs, x10, x10, HEAP_NUMBER_TYPE, &maybe_undefined2);
@@ -3284,7 +3284,7 @@
   }

   __ Bind(&maybe_undefined2);
-  if (Token::IsOrderedRelationalCompareOp(op_)) {
+  if (Token::IsOrderedRelationalCompareOp(op())) {
     __ JumpIfRoot(lhs, Heap::kUndefinedValueRootIndex, &unordered);
   }

@@ -3294,7 +3294,7 @@


 void ICCompareStub::GenerateInternalizedStrings(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::INTERNALIZED_STRING);
+  DCHECK(state() == CompareIC::INTERNALIZED_STRING);
   ASM_LOCATION("ICCompareStub[InternalizedStrings]");
   Label miss;

@@ -3332,7 +3332,7 @@


 void ICCompareStub::GenerateUniqueNames(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::UNIQUE_NAME);
+  DCHECK(state() == CompareIC::UNIQUE_NAME);
   ASM_LOCATION("ICCompareStub[UniqueNames]");
   DCHECK(GetCondition() == eq);
   Label miss;
@@ -3371,12 +3371,12 @@


 void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::STRING);
+  DCHECK(state() == CompareIC::STRING);
   ASM_LOCATION("ICCompareStub[Strings]");

   Label miss;

-  bool equality = Token::IsEqualityOp(op_);
+  bool equality = Token::IsEqualityOp(op());

   Register result = x0;
   Register rhs = x0;
@@ -3452,7 +3452,7 @@


 void ICCompareStub::GenerateObjects(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::OBJECT);
+  DCHECK(state() == CompareIC::OBJECT);
   ASM_LOCATION("ICCompareStub[Objects]");

   Label miss;
@@ -3522,7 +3522,7 @@
     // Preserve some caller-saved registers.
     __ Push(x1, x0, lr);
     // Push the arguments.
-    __ Mov(op, Smi::FromInt(op_));
+    __ Mov(op, Smi::FromInt(this->op()));
     __ Push(left, right, op);

     // Call the miss handler. This also pops the arguments.
=======================================
--- /branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc Fri Aug 29 18:46:30 2014 UTC +++ /branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc Tue Sep 2 11:51:25 2014 UTC
@@ -4301,8 +4301,7 @@

   Bind(&store_buffer_overflow);
   Push(lr);
-  StoreBufferOverflowStub store_buffer_overflow_stub =
-      StoreBufferOverflowStub(isolate(), fp_mode);
+  StoreBufferOverflowStub store_buffer_overflow_stub(isolate(), fp_mode);
   CallStub(&store_buffer_overflow_stub);
   Pop(lr);

=======================================
--- /branches/bleeding_edge/src/code-stubs.cc   Mon Sep  1 09:18:39 2014 UTC
+++ /branches/bleeding_edge/src/code-stubs.cc   Tue Sep  2 11:51:25 2014 UTC
@@ -219,7 +219,7 @@


 void BinaryOpICStub::PrintState(OStream& os) const {  // NOLINT
-  os << state_;
+  os << state();
 }


@@ -270,7 +270,7 @@


 InlineCacheState ICCompareStub::GetICState() const {
-  CompareIC::State state = Max(left_, right_);
+  CompareIC::State state = Max(left(), right());
   switch (state) {
     case CompareIC::UNINITIALIZED:
       return ::v8::internal::UNINITIALIZED;
@@ -307,7 +307,7 @@
   Code::Flags flags = Code::ComputeFlags(
       GetCodeKind(),
       UNINITIALIZED);
-  DCHECK(op_ == Token::EQ || op_ == Token::EQ_STRICT);
+  DCHECK(op() == Token::EQ || op() == Token::EQ_STRICT);
   Handle<Object> probe(
       known_map_->FindInCodeCache(
         strict() ?
@@ -318,50 +318,20 @@
   if (probe->IsCode()) {
     *code_out = Code::cast(*probe);
 #ifdef DEBUG
-    Token::Value cached_op;
-    ICCompareStub::DecodeKey((*code_out)->stub_key(), NULL, NULL, NULL,
-                             &cached_op);
-    DCHECK(op_ == cached_op);
+    ICCompareStub decode((*code_out)->stub_key());
+    DCHECK(op() == decode.op());
+    DCHECK(left() == decode.left());
+    DCHECK(right() == decode.right());
+    DCHECK(state() == decode.state());
 #endif
     return true;
   }
   return false;
 }
-
-
-uint32_t ICCompareStub::MinorKey() const {
-  return OpField::encode(op_ - Token::EQ) |
-         LeftStateField::encode(left_) |
-         RightStateField::encode(right_) |
-         HandlerStateField::encode(state_);
-}
-
-
-void ICCompareStub::DecodeKey(uint32_t stub_key, CompareIC::State* left_state,
-                              CompareIC::State* right_state,
-                              CompareIC::State* handler_state,
-                              Token::Value* op) {
-  int minor_key = MinorKeyFromKey(stub_key);
-  if (left_state) {
-    *left_state =
-        static_cast<CompareIC::State>(LeftStateField::decode(minor_key));
-  }
-  if (right_state) {
-    *right_state =
-        static_cast<CompareIC::State>(RightStateField::decode(minor_key));
-  }
-  if (handler_state) {
-    *handler_state =
- static_cast<CompareIC::State>(HandlerStateField::decode(minor_key));
-  }
-  if (op) {
- *op = static_cast<Token::Value>(OpField::decode(minor_key) + Token::EQ);
-  }
-}


 void ICCompareStub::Generate(MacroAssembler* masm) {
-  switch (state_) {
+  switch (state()) {
     case CompareIC::UNINITIALIZED:
       GenerateMiss(masm);
       break;
@@ -395,24 +365,26 @@


 void CompareNilICStub::UpdateStatus(Handle<Object> object) {
-  DCHECK(!state_.Contains(GENERIC));
-  State old_state(state_);
+  State state = this->state();
+  DCHECK(!state.Contains(GENERIC));
+  State old_state = state;
   if (object->IsNull()) {
-    state_.Add(NULL_TYPE);
+    state.Add(NULL_TYPE);
   } else if (object->IsUndefined()) {
-    state_.Add(UNDEFINED);
+    state.Add(UNDEFINED);
   } else if (object->IsUndetectableObject() ||
              object->IsOddball() ||
              !object->IsHeapObject()) {
-    state_.RemoveAll();
-    state_.Add(GENERIC);
+    state.RemoveAll();
+    state.Add(GENERIC);
   } else if (IsMonomorphic()) {
-    state_.RemoveAll();
-    state_.Add(GENERIC);
+    state.RemoveAll();
+    state.Add(GENERIC);
   } else {
-    state_.Add(MONOMORPHIC_MAP);
+    state.Add(MONOMORPHIC_MAP);
   }
-  TraceTransition(old_state, state_);
+  TraceTransition(old_state, state);
+ set_sub_minor_key(TypesBits::update(sub_minor_key(), state.ToIntegral()));
 }


@@ -431,12 +403,12 @@

 void CompareNilICStub::PrintBaseName(OStream& os) const {  // NOLINT
   CodeStub::PrintBaseName(os);
-  os << ((nil_value_ == kNullValue) ? "(NullValue)" : "(UndefinedValue)");
+  os << ((nil_value() == kNullValue) ? "(NullValue)" : "(UndefinedValue)");
 }


 void CompareNilICStub::PrintState(OStream& os) const {  // NOLINT
-  os << state_;
+  os << state();
 }


@@ -473,18 +445,17 @@


 Type* CompareNilICStub::GetType(Zone* zone, Handle<Map> map) {
-  if (state_.Contains(CompareNilICStub::GENERIC)) {
-    return Type::Any(zone);
-  }
+  State state = this->state();
+  if (state.Contains(CompareNilICStub::GENERIC)) return Type::Any(zone);

   Type* result = Type::None(zone);
-  if (state_.Contains(CompareNilICStub::UNDEFINED)) {
+  if (state.Contains(CompareNilICStub::UNDEFINED)) {
     result = Type::Union(result, Type::Undefined(zone), zone);
   }
-  if (state_.Contains(CompareNilICStub::NULL_TYPE)) {
+  if (state.Contains(CompareNilICStub::NULL_TYPE)) {
     result = Type::Union(result, Type::Null(zone), zone);
   }
-  if (state_.Contains(CompareNilICStub::MONOMORPHIC_MAP)) {
+  if (state.Contains(CompareNilICStub::MONOMORPHIC_MAP)) {
     Type* type =
         map.is_null() ? Type::Detectable(zone) : Type::Class(map, zone);
     result = Type::Union(result, type, zone);
@@ -497,7 +468,7 @@
 Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) {
   Type* output_type = GetType(zone, map);
   Type* nil_type =
-      nil_value_ == kNullValue ? Type::Null(zone) : Type::Undefined(zone);
+      nil_value() == kNullValue ? Type::Null(zone) : Type::Undefined(zone);
   return Type::Union(output_type, nil_type, zone);
 }

=======================================
--- /branches/bleeding_edge/src/code-stubs.h    Tue Sep  2 07:07:52 2014 UTC
+++ /branches/bleeding_edge/src/code-stubs.h    Tue Sep  2 11:51:25 2014 UTC
@@ -204,6 +204,8 @@
   Isolate* isolate() const { return isolate_; }

  protected:
+  explicit CodeStub(uint32_t key) : minor_key_(MinorKeyFromKey(key)) {}
+
   // Generates the assembler code for the stub.
   virtual Handle<Code> GenerateCode() = 0;

@@ -274,6 +276,11 @@
  protected:
   // Generates the assembler code for the stub.
   virtual void Generate(MacroAssembler* masm) = 0;
+
+  explicit PlatformCodeStub(uint32_t key) : CodeStub(key) {}
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(PlatformCodeStub);
 };


@@ -415,14 +422,6 @@
   virtual Handle<Code> GenerateCode() = 0;

   bool IsUninitialized() const { return IsMissBits::decode(minor_key_); }
-
-  // TODO(yangguo): we use this temporarily to construct the minor key.
-  //   We want to remove NotMissMinorKey methods one by one and eventually
-  //   remove HydrogenStub::MinorKey and turn CodeStub::MinorKey into a
-  //   non-virtual method that directly returns minor_key_.
-  virtual int NotMissMinorKey() const {
-    return SubMinorKeyBits::decode(minor_key_);
-  }

   Handle<Code> GenerateLightweightMissCode();

@@ -438,16 +437,13 @@

   static const int kSubMinorKeyBits = kStubMinorKeyBits - 1;

-  class SubMinorKeyBits : public BitField<int, 0, kSubMinorKeyBits> {};
-
  private:
   class IsMissBits : public BitField<bool, kSubMinorKeyBits, 1> {};
+  class SubMinorKeyBits : public BitField<int, 0, kSubMinorKeyBits> {};

   void GenerateLightweightMiss(MacroAssembler* masm);
-  virtual uint32_t MinorKey() const {
-    return IsMissBits::encode(IsUninitialized()) |
-           SubMinorKeyBits::encode(NotMissMinorKey());
-  }
+
+  DISALLOW_COPY_AND_ASSIGN(HydrogenCodeStub);
 };


@@ -1123,10 +1119,15 @@
  public:
   BinaryOpICStub(Isolate* isolate, Token::Value op,
                  OverwriteMode mode = NO_OVERWRITE)
- : HydrogenCodeStub(isolate, UNINITIALIZED), state_(isolate, op, mode) {}
+      : HydrogenCodeStub(isolate, UNINITIALIZED) {
+    BinaryOpIC::State state(isolate, op, mode);
+    set_sub_minor_key(state.GetExtraICState());
+  }

   explicit BinaryOpICStub(Isolate* isolate, const BinaryOpIC::State& state)
-      : HydrogenCodeStub(isolate), state_(state) {}
+      : HydrogenCodeStub(isolate) {
+    set_sub_minor_key(state.GetExtraICState());
+  }

   static void GenerateAheadOfTime(Isolate* isolate);

@@ -1140,34 +1141,31 @@
   }

   virtual InlineCacheState GetICState() const FINAL OVERRIDE {
-    return state_.GetICState();
+    return state().GetICState();
   }

   virtual ExtraICState GetExtraICState() const FINAL OVERRIDE {
-    return state_.GetExtraICState();
+    return static_cast<ExtraICState>(sub_minor_key());
   }

   virtual Handle<Code> GenerateCode() OVERRIDE;

-  const BinaryOpIC::State& state() const { return state_; }
+  BinaryOpIC::State state() const {
+    return BinaryOpIC::State(isolate(), GetExtraICState());
+  }

   virtual void PrintState(OStream& os) const FINAL OVERRIDE;  // NOLINT
-
-  virtual Major MajorKey() const OVERRIDE { return BinaryOpIC; }
-  virtual int NotMissMinorKey() const FINAL OVERRIDE {
-    return GetExtraICState();
-  }

   // Parameters accessed via CodeStubGraphBuilder::GetParameter()
   static const int kLeft = 0;
   static const int kRight = 1;

  private:
+  virtual Major MajorKey() const OVERRIDE { return BinaryOpIC; }
+
   static void GenerateAheadOfTime(Isolate* isolate,
                                   const BinaryOpIC::State& state);

-  BinaryOpIC::State state_;
-
   DISALLOW_COPY_AND_ASSIGN(BinaryOpICStub);
 };

@@ -1309,37 +1307,34 @@

 class ICCompareStub: public PlatformCodeStub {
  public:
-  ICCompareStub(Isolate* isolate,
-                Token::Value op,
-                CompareIC::State left,
-                CompareIC::State right,
-                CompareIC::State handler)
-      : PlatformCodeStub(isolate),
-        op_(op),
-        left_(left),
-        right_(right),
-        state_(handler) {
+  ICCompareStub(Isolate* isolate, Token::Value op, CompareIC::State left,
+                CompareIC::State right, CompareIC::State state)
+      : PlatformCodeStub(isolate) {
     DCHECK(Token::IsCompareOp(op));
+ minor_key_ = OpBits::encode(op - Token::EQ) | LeftStateBits::encode(left) |
+                 RightStateBits::encode(right) | StateBits::encode(state);
   }

   virtual void Generate(MacroAssembler* masm);

   void set_known_map(Handle<Map> map) { known_map_ = map; }

-  static void DecodeKey(uint32_t stub_key, CompareIC::State* left_state,
-                        CompareIC::State* right_state,
-                        CompareIC::State* handler_state, Token::Value* op);
+  explicit ICCompareStub(uint32_t stub_key) : PlatformCodeStub(stub_key) {
+    DCHECK_EQ(MajorKeyFromKey(stub_key), MajorKey());
+  }

   virtual InlineCacheState GetICState() const;

+  Token::Value op() const {
+ return static_cast<Token::Value>(Token::EQ + OpBits::decode(minor_key_));
+  }
+
+ CompareIC::State left() const { return LeftStateBits::decode(minor_key_); } + CompareIC::State right() const { return RightStateBits::decode(minor_key_); }
+  CompareIC::State state() const { return StateBits::decode(minor_key_); }
+
  private:
-  class OpField: public BitField<int, 0, 3> { };
-  class LeftStateField: public BitField<int, 3, 4> { };
-  class RightStateField: public BitField<int, 7, 4> { };
-  class HandlerStateField: public BitField<int, 11, 4> { };
-
   virtual Major MajorKey() const OVERRIDE { return CompareIC; }
-  virtual uint32_t MinorKey() const;

   virtual Code::Kind GetCodeKind() const { return Code::COMPARE_IC; }

@@ -1353,18 +1348,21 @@
   void GenerateKnownObjects(MacroAssembler* masm);
   void GenerateGeneric(MacroAssembler* masm);

-  bool strict() const { return op_ == Token::EQ_STRICT; }
- Condition GetCondition() const { return CompareIC::ComputeCondition(op_); }
+  bool strict() const { return op() == Token::EQ_STRICT; }
+ Condition GetCondition() const { return CompareIC::ComputeCondition(op()); }

   virtual void AddToSpecialCache(Handle<Code> new_object);
   virtual bool FindCodeInSpecialCache(Code** code_out);
- virtual bool UseSpecialCache() { return state_ == CompareIC::KNOWN_OBJECT; } + virtual bool UseSpecialCache() { return state() == CompareIC::KNOWN_OBJECT; }

-  Token::Value op_;
-  CompareIC::State left_;
-  CompareIC::State right_;
-  CompareIC::State state_;
+  class OpBits : public BitField<int, 0, 3> {};
+  class LeftStateBits : public BitField<CompareIC::State, 3, 4> {};
+  class RightStateBits : public BitField<CompareIC::State, 7, 4> {};
+  class StateBits : public BitField<CompareIC::State, 11, 4> {};
+
   Handle<Map> known_map_;
+
+  DISALLOW_COPY_AND_ASSIGN(ICCompareStub);
 };


@@ -1373,16 +1371,15 @@
   Type* GetType(Zone* zone, Handle<Map> map = Handle<Map>());
   Type* GetInputType(Zone* zone, Handle<Map> map);

-  CompareNilICStub(Isolate* isolate, NilValue nil)
-      : HydrogenCodeStub(isolate), nil_value_(nil) { }
+ CompareNilICStub(Isolate* isolate, NilValue nil) : HydrogenCodeStub(isolate) {
+    set_sub_minor_key(NilValueBits::encode(nil));
+  }

-  CompareNilICStub(Isolate* isolate,
-                   ExtraICState ic_state,
+  CompareNilICStub(Isolate* isolate, ExtraICState ic_state,
                    InitializationState init_state = INITIALIZED)
-      : HydrogenCodeStub(isolate, init_state),
-        nil_value_(NilValueField::decode(ic_state)),
-        state_(State(TypesField::decode(ic_state))) {
-      }
+      : HydrogenCodeStub(isolate, init_state) {
+    set_sub_minor_key(ic_state);
+  }

   static Handle<Code> GetUninitialized(Isolate* isolate,
                                        NilValue nil) {
@@ -1399,9 +1396,10 @@
   }

   virtual InlineCacheState GetICState() const {
-    if (state_.Contains(GENERIC)) {
+    State state = this->state();
+    if (state.Contains(GENERIC)) {
       return MEGAMORPHIC;
-    } else if (state_.Contains(MONOMORPHIC_MAP)) {
+    } else if (state.Contains(MONOMORPHIC_MAP)) {
       return MONOMORPHIC;
     } else {
       return PREMONOMORPHIC;
@@ -1412,22 +1410,29 @@

   virtual Handle<Code> GenerateCode() OVERRIDE;

-  virtual ExtraICState GetExtraICState() const {
-    return NilValueField::encode(nil_value_) |
-           TypesField::encode(state_.ToIntegral());
-  }
+  virtual ExtraICState GetExtraICState() const { return sub_minor_key(); }

   void UpdateStatus(Handle<Object> object);

-  bool IsMonomorphic() const { return state_.Contains(MONOMORPHIC_MAP); }
-  NilValue GetNilValue() const { return nil_value_; }
-  void ClearState() { state_.RemoveAll(); }
+  bool IsMonomorphic() const { return state().Contains(MONOMORPHIC_MAP); }
+
+ NilValue nil_value() const { return NilValueBits::decode(sub_minor_key()); }
+
+  void ClearState() {
+    set_sub_minor_key(TypesBits::update(sub_minor_key(), 0));
+  }

   virtual void PrintState(OStream& os) const OVERRIDE;     // NOLINT
   virtual void PrintBaseName(OStream& os) const OVERRIDE;  // NOLINT

  private:
-  friend class CompareNilIC;
+  CompareNilICStub(Isolate* isolate, NilValue nil,
+                   InitializationState init_state)
+      : HydrogenCodeStub(isolate, init_state) {
+    set_sub_minor_key(NilValueBits::encode(nil));
+  }
+
+  virtual Major MajorKey() const OVERRIDE { return CompareNilIC; }

   enum CompareNilType {
     UNDEFINED,
@@ -1449,19 +1454,12 @@
   };
   friend OStream& operator<<(OStream& os, const State& s);

-  CompareNilICStub(Isolate* isolate,
-                   NilValue nil,
-                   InitializationState init_state)
-      : HydrogenCodeStub(isolate, init_state), nil_value_(nil) { }
+  State state() const { return State(TypesBits::decode(sub_minor_key())); }

-  class NilValueField : public BitField<NilValue, 0, 1> {};
-  class TypesField    : public BitField<byte,     1, NUMBER_OF_TYPES> {};
+  class NilValueBits : public BitField<NilValue, 0, 1> {};
+  class TypesBits : public BitField<byte, 1, NUMBER_OF_TYPES> {};

-  virtual Major MajorKey() const OVERRIDE { return CompareNilIC; }
-  virtual int NotMissMinorKey() const { return GetExtraICState(); }
-
-  NilValue nil_value_;
-  State state_;
+  friend class CompareNilIC;

   DISALLOW_COPY_AND_ASSIGN(CompareNilICStub);
 };
@@ -1967,7 +1965,9 @@
 class VectorLoadStub : public HydrogenCodeStub {
  public:
   explicit VectorLoadStub(Isolate* isolate, const LoadIC::State& state)
-      : HydrogenCodeStub(isolate), state_(state) {}
+      : HydrogenCodeStub(isolate) {
+    set_sub_minor_key(state.GetExtraICState());
+  }

   virtual Handle<Code> GenerateCode() OVERRIDE;

@@ -1983,15 +1983,13 @@
   }

   virtual ExtraICState GetExtraICState() const FINAL OVERRIDE {
-    return state_.GetExtraICState();
+    return static_cast<ExtraICState>(sub_minor_key());
   }
-
-  virtual Major MajorKey() const OVERRIDE { return VectorLoad; }

  private:
-  int NotMissMinorKey() const { return state_.GetExtraICState(); }
+  virtual Major MajorKey() const OVERRIDE { return VectorLoad; }

-  const LoadIC::State state_;
+  LoadIC::State state() const { return LoadIC::State(GetExtraICState()); }

   DISALLOW_COPY_AND_ASSIGN(VectorLoadStub);
 };
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Mon Sep 1 09:18:39 2014 UTC +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Sep 2 11:51:25 2014 UTC
@@ -1576,8 +1576,8 @@
   Condition cc = GetCondition();

   Label miss;
-  CheckInputType(masm, edx, left_, &miss);
-  CheckInputType(masm, eax, right_, &miss);
+  CheckInputType(masm, edx, left(), &miss);
+  CheckInputType(masm, eax, right(), &miss);

   // Compare two smis.
   Label non_smi, smi_done;
@@ -3395,7 +3395,7 @@


 void ICCompareStub::GenerateSmis(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::SMI);
+  DCHECK(state() == CompareIC::SMI);
   Label miss;
   __ mov(ecx, edx);
   __ or_(ecx, eax);
@@ -3421,16 +3421,16 @@


 void ICCompareStub::GenerateNumbers(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::NUMBER);
+  DCHECK(state() == CompareIC::NUMBER);

   Label generic_stub;
   Label unordered, maybe_undefined1, maybe_undefined2;
   Label miss;

-  if (left_ == CompareIC::SMI) {
+  if (left() == CompareIC::SMI) {
     __ JumpIfNotSmi(edx, &miss);
   }
-  if (right_ == CompareIC::SMI) {
+  if (right() == CompareIC::SMI) {
     __ JumpIfNotSmi(eax, &miss);
   }

@@ -3477,12 +3477,12 @@

   __ bind(&unordered);
   __ bind(&generic_stub);
- ICCompareStub stub(isolate(), op_, CompareIC::GENERIC, CompareIC::GENERIC, + ICCompareStub stub(isolate(), op(), CompareIC::GENERIC, CompareIC::GENERIC,
                      CompareIC::GENERIC);
   __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);

   __ bind(&maybe_undefined1);
-  if (Token::IsOrderedRelationalCompareOp(op_)) {
+  if (Token::IsOrderedRelationalCompareOp(op())) {
     __ cmp(eax, Immediate(isolate()->factory()->undefined_value()));
     __ j(not_equal, &miss);
     __ JumpIfSmi(edx, &unordered);
@@ -3492,7 +3492,7 @@
   }

   __ bind(&maybe_undefined2);
-  if (Token::IsOrderedRelationalCompareOp(op_)) {
+  if (Token::IsOrderedRelationalCompareOp(op())) {
     __ cmp(edx, Immediate(isolate()->factory()->undefined_value()));
     __ j(equal, &unordered);
   }
@@ -3503,7 +3503,7 @@


 void ICCompareStub::GenerateInternalizedStrings(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::INTERNALIZED_STRING);
+  DCHECK(state() == CompareIC::INTERNALIZED_STRING);
   DCHECK(GetCondition() == equal);

   // Registers containing left and right operands respectively.
@@ -3548,7 +3548,7 @@


 void ICCompareStub::GenerateUniqueNames(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::UNIQUE_NAME);
+  DCHECK(state() == CompareIC::UNIQUE_NAME);
   DCHECK(GetCondition() == equal);

   // Registers containing left and right operands respectively.
@@ -3593,10 +3593,10 @@


 void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::STRING);
+  DCHECK(state() == CompareIC::STRING);
   Label miss;

-  bool equality = Token::IsEqualityOp(op_);
+  bool equality = Token::IsEqualityOp(op());

   // Registers containing left and right operands respectively.
   Register left = edx;
@@ -3683,7 +3683,7 @@


 void ICCompareStub::GenerateObjects(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::OBJECT);
+  DCHECK(state() == CompareIC::OBJECT);
   Label miss;
   __ mov(ecx, edx);
   __ and_(ecx, eax);
@@ -3734,7 +3734,7 @@
     __ push(eax);
     __ push(edx);  // And also use them as the arguments.
     __ push(eax);
-    __ push(Immediate(Smi::FromInt(op_)));
+    __ push(Immediate(Smi::FromInt(op())));
     __ CallExternalReference(miss, 3);
     // Compute the entry point of the rewritten stub.
     __ lea(edi, FieldOperand(eax, Code::kHeaderSize));
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.h Mon Aug 25 13:09:02 2014 UTC +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.h Tue Sep 2 11:51:25 2014 UTC
@@ -16,7 +16,7 @@
                      Label* call_generic_code);


-class StoreBufferOverflowStub: public PlatformCodeStub {
+class StoreBufferOverflowStub : public PlatformCodeStub {
  public:
   StoreBufferOverflowStub(Isolate* isolate, SaveFPRegsMode save_fp)
       : PlatformCodeStub(isolate), save_doubles_(save_fp) { }
=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Wed Aug 6 07:20:14 2014 UTC +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Tue Sep 2 11:51:25 2014 UTC
@@ -179,8 +179,7 @@
     DCHECK(and_then == kFallThroughAtEnd);
     j(equal, &done, Label::kNear);
   }
-  StoreBufferOverflowStub store_buffer_overflow =
-      StoreBufferOverflowStub(isolate(), save_fp);
+  StoreBufferOverflowStub store_buffer_overflow(isolate(), save_fp);
   CallStub(&store_buffer_overflow);
   if (and_then == kReturnAtEnd) {
     ret(0);
=======================================
--- /branches/bleeding_edge/src/ic/ic.cc        Mon Sep  1 09:11:44 2014 UTC
+++ /branches/bleeding_edge/src/ic/ic.cc        Tue Sep  2 11:51:25 2014 UTC
@@ -547,12 +547,11 @@
 void CompareIC::Clear(Isolate* isolate, Address address, Code* target,
                       ConstantPoolArray* constant_pool) {
   DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC);
-  CompareIC::State handler_state;
-  Token::Value op;
- ICCompareStub::DecodeKey(target->stub_key(), NULL, NULL, &handler_state, &op);
+  ICCompareStub stub(target->stub_key());
   // Only clear CompareICs that can retain objects.
-  if (handler_state != KNOWN_OBJECT) return;
- SetTargetAtAddress(address, GetRawUninitialized(isolate, op), constant_pool);
+  if (stub.state() != KNOWN_OBJECT) return;
+  SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()),
+                     constant_pool);
   PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK);
 }

@@ -2744,12 +2743,10 @@
 void CompareIC::StubInfoToType(uint32_t stub_key, Type** left_type,
                                Type** right_type, Type** overall_type,
                                Handle<Map> map, Zone* zone) {
-  State left_state, right_state, handler_state;
- ICCompareStub::DecodeKey(stub_key, &left_state, &right_state, &handler_state,
-                           NULL);
-  *left_type = StateToType(zone, left_state);
-  *right_type = StateToType(zone, right_state);
-  *overall_type = StateToType(zone, handler_state, map);
+  ICCompareStub stub(stub_key);
+  *left_type = StateToType(zone, stub.left());
+  *right_type = StateToType(zone, stub.right());
+  *overall_type = StateToType(zone, stub.state(), map);
 }


@@ -2859,12 +2856,10 @@

 Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) {
   HandleScope scope(isolate());
-  State previous_left, previous_right, previous_state;
-  ICCompareStub::DecodeKey(target()->stub_key(), &previous_left,
-                           &previous_right, &previous_state, NULL);
-  State new_left = NewInputState(previous_left, x);
-  State new_right = NewInputState(previous_right, y);
-  State state = TargetState(previous_state, previous_left, previous_right,
+  ICCompareStub old_stub(target()->stub_key());
+  State new_left = NewInputState(old_stub.left(), x);
+  State new_right = NewInputState(old_stub.right(), y);
+ State state = TargetState(old_stub.state(), old_stub.left(), old_stub.right(),
                             HasInlinedSmiCode(address()), x, y);
   ICCompareStub stub(isolate(), op_, new_left, new_right, state);
   if (state == KNOWN_OBJECT) {
@@ -2877,14 +2872,15 @@
   if (FLAG_trace_ic) {
     PrintF("[CompareIC in ");
     JavaScriptFrame::PrintTop(isolate(), stdout, false, true);
- PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n", GetStateName(previous_left),
-           GetStateName(previous_right), GetStateName(previous_state),
- GetStateName(new_left), GetStateName(new_right), GetStateName(state),
-           Token::Name(op_), static_cast<void*>(*stub.GetCode()));
+    PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n",
+           GetStateName(old_stub.left()), GetStateName(old_stub.right()),
+           GetStateName(old_stub.state()), GetStateName(new_left),
+           GetStateName(new_right), GetStateName(state), Token::Name(op_),
+           static_cast<void*>(*stub.GetCode()));
   }

   // Activate inlined smi code.
-  if (previous_state == UNINITIALIZED) {
+  if (old_stub.state() == UNINITIALIZED) {
     PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK);
   }

@@ -2938,7 +2934,7 @@

   stub.UpdateStatus(object);

-  NilValue nil = stub.GetNilValue();
+  NilValue nil = stub.nil_value();

   // Find or create the specialized stub to support the new set of types.
   Handle<Code> code;
=======================================
--- /branches/bleeding_edge/src/objects.cc      Tue Sep  2 07:07:52 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc      Tue Sep  2 11:51:25 2014 UTC
@@ -10901,14 +10901,11 @@
     }
     if (is_compare_ic_stub()) {
       DCHECK(CodeStub::GetMajorKey(this) == CodeStub::CompareIC);
-      CompareIC::State left_state, right_state, handler_state;
-      Token::Value op;
-      ICCompareStub::DecodeKey(stub_key(), &left_state, &right_state,
-                               &handler_state, &op);
- os << "compare_state = " << CompareIC::GetStateName(left_state) << "*"
-         << CompareIC::GetStateName(right_state) << " -> "
-         << CompareIC::GetStateName(handler_state) << "\n";
-      os << "compare_operation = " << Token::Name(op) << "\n";
+      ICCompareStub stub(stub_key());
+ os << "compare_state = " << CompareIC::GetStateName(stub.left()) << "*"
+         << CompareIC::GetStateName(stub.right()) << " -> "
+         << CompareIC::GetStateName(stub.state()) << "\n";
+      os << "compare_operation = " << Token::Name(stub.op()) << "\n";
     }
   }
   if ((name != NULL) && (name[0] != '\0')) {
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Mon Sep 1 09:18:39 2014 UTC +++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Tue Sep 2 11:51:25 2014 UTC
@@ -1446,8 +1446,8 @@
   Factory* factory = isolate()->factory();

   Label miss;
-  CheckInputType(masm, rdx, left_, &miss);
-  CheckInputType(masm, rax, right_, &miss);
+  CheckInputType(masm, rdx, left(), &miss);
+  CheckInputType(masm, rax, right(), &miss);

   // Compare two smis.
   Label non_smi, smi_done;
@@ -3358,7 +3358,7 @@


 void ICCompareStub::GenerateSmis(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::SMI);
+  DCHECK(state() == CompareIC::SMI);
   Label miss;
   __ JumpIfNotBothSmi(rdx, rax, &miss, Label::kNear);

@@ -3382,16 +3382,16 @@


 void ICCompareStub::GenerateNumbers(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::NUMBER);
+  DCHECK(state() == CompareIC::NUMBER);

   Label generic_stub;
   Label unordered, maybe_undefined1, maybe_undefined2;
   Label miss;

-  if (left_ == CompareIC::SMI) {
+  if (left() == CompareIC::SMI) {
     __ JumpIfNotSmi(rdx, &miss);
   }
-  if (right_ == CompareIC::SMI) {
+  if (right() == CompareIC::SMI) {
     __ JumpIfNotSmi(rax, &miss);
   }

@@ -3433,12 +3433,12 @@

   __ bind(&unordered);
   __ bind(&generic_stub);
- ICCompareStub stub(isolate(), op_, CompareIC::GENERIC, CompareIC::GENERIC, + ICCompareStub stub(isolate(), op(), CompareIC::GENERIC, CompareIC::GENERIC,
                      CompareIC::GENERIC);
   __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);

   __ bind(&maybe_undefined1);
-  if (Token::IsOrderedRelationalCompareOp(op_)) {
+  if (Token::IsOrderedRelationalCompareOp(op())) {
     __ Cmp(rax, isolate()->factory()->undefined_value());
     __ j(not_equal, &miss);
     __ JumpIfSmi(rdx, &unordered);
@@ -3448,7 +3448,7 @@
   }

   __ bind(&maybe_undefined2);
-  if (Token::IsOrderedRelationalCompareOp(op_)) {
+  if (Token::IsOrderedRelationalCompareOp(op())) {
     __ Cmp(rdx, isolate()->factory()->undefined_value());
     __ j(equal, &unordered);
   }
@@ -3459,7 +3459,7 @@


 void ICCompareStub::GenerateInternalizedStrings(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::INTERNALIZED_STRING);
+  DCHECK(state() == CompareIC::INTERNALIZED_STRING);
   DCHECK(GetCondition() == equal);

   // Registers containing left and right operands respectively.
@@ -3502,7 +3502,7 @@


 void ICCompareStub::GenerateUniqueNames(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::UNIQUE_NAME);
+  DCHECK(state() == CompareIC::UNIQUE_NAME);
   DCHECK(GetCondition() == equal);

   // Registers containing left and right operands respectively.
@@ -3545,10 +3545,10 @@


 void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::STRING);
+  DCHECK(state() == CompareIC::STRING);
   Label miss;

-  bool equality = Token::IsEqualityOp(op_);
+  bool equality = Token::IsEqualityOp(op());

   // Registers containing left and right operands respectively.
   Register left = rdx;
@@ -3632,7 +3632,7 @@


 void ICCompareStub::GenerateObjects(MacroAssembler* masm) {
-  DCHECK(state_ == CompareIC::OBJECT);
+  DCHECK(state() == CompareIC::OBJECT);
   Label miss;
   Condition either_smi = masm->CheckEitherSmi(rdx, rax);
   __ j(either_smi, &miss, Label::kNear);
@@ -3682,7 +3682,7 @@
     __ Push(rax);
     __ Push(rdx);
     __ Push(rax);
-    __ Push(Smi::FromInt(op_));
+    __ Push(Smi::FromInt(op()));
     __ CallExternalReference(miss, 3);

     // Compute the entry point of the rewritten stub.
=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Tue Aug 5 08:18:22 2014 UTC +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Tue Sep 2 11:51:25 2014 UTC
@@ -235,8 +235,7 @@
     DCHECK(and_then == kFallThroughAtEnd);
     j(equal, &done, Label::kNear);
   }
-  StoreBufferOverflowStub store_buffer_overflow =
-      StoreBufferOverflowStub(isolate(), save_fp);
+  StoreBufferOverflowStub store_buffer_overflow(isolate(), save_fp);
   CallStub(&store_buffer_overflow);
   if (and_then == kReturnAtEnd) {
     ret(0);

--
--
v8-dev mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to