Revision: 8503
Author:   [email protected]
Date:     Fri Jul  1 00:50:46 2011
Log:      Simplify UnaryOpStub a little bit.

Only a single constructor is really needed. Make UnaryOp_Patch's arguments
simpler, avoiding encoding/decoding things in a cryptic way.
Review URL: http://codereview.chromium.org/7248063
http://code.google.com/p/v8/source/detail?r=8503

Modified:
 /branches/bleeding_edge/src/arm/code-stubs-arm.cc
 /branches/bleeding_edge/src/arm/code-stubs-arm.h
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.h
 /branches/bleeding_edge/src/ic.cc
 /branches/bleeding_edge/src/mips/code-stubs-mips.cc
 /branches/bleeding_edge/src/mips/code-stubs-mips.h
 /branches/bleeding_edge/src/x64/code-stubs-x64.cc
 /branches/bleeding_edge/src/x64/code-stubs-x64.h

=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Thu Jun 30 04:26:15 2011 +++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Fri Jul 1 00:50:46 2011
@@ -1731,22 +1731,14 @@


 void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
-  // Prepare to push argument.
-  __ mov(r3, Operand(r0));
-
-  // Push this stub's key. Although the operation and the type info are
-  // encoded into the key, the encoding is opaque, so push them too.
-  __ mov(r2, Operand(Smi::FromInt(MinorKey())));
-  __ mov(r1, Operand(Smi::FromInt(op_)));
+  __ mov(r3, Operand(r0));  // the operand
+  __ mov(r2, Operand(Smi::FromInt(op_)));
+  __ mov(r1, Operand(Smi::FromInt(mode_)));
   __ mov(r0, Operand(Smi::FromInt(operand_type_)));
-
   __ Push(r3, r2, r1, r0);

   __ TailCallExternalReference(
-      ExternalReference(IC_Utility(IC::kUnaryOp_Patch),
-                        masm->isolate()),
-      4,
-      1);
+ ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1);
 }


=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.h Wed Jun 22 01:28:35 2011 +++ /branches/bleeding_edge/src/arm/code-stubs-arm.h Fri Jul 1 00:50:46 2011
@@ -60,18 +60,11 @@

 class UnaryOpStub: public CodeStub {
  public:
-  UnaryOpStub(Token::Value op, UnaryOverwriteMode mode)
+  UnaryOpStub(Token::Value op,
+              UnaryOverwriteMode mode,
+              UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED)
       : op_(op),
         mode_(mode),
-        operand_type_(UnaryOpIC::UNINITIALIZED),
-        name_(NULL) {
-  }
-
-  UnaryOpStub(
-      int key,
-      UnaryOpIC::TypeInfo operand_type)
-      : op_(OpBits::decode(key)),
-        mode_(ModeBits::decode(key)),
         operand_type_(operand_type),
         name_(NULL) {
   }
@@ -89,8 +82,7 @@

 #ifdef DEBUG
   void Print() {
-    PrintF("UnaryOpStub %d (op %s), "
-           "(mode %d, runtime_type_info %s)\n",
+    PrintF("UnaryOpStub %d (op %s), (mode %d, runtime_type_info %s)\n",
            MinorKey(),
            Token::String(op_),
            static_cast<int>(mode_),
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Jun 28 08:22:08 2011 +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Fri Jul 1 00:50:46 2011
@@ -554,12 +554,10 @@

 void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
   __ pop(ecx);  // Save return address.
-  __ push(eax);
-  // the argument is now on top.
-  // Push this stub's key. Although the operation and the type info are
-  // encoded into the key, the encoding is opaque, so push them too.
-  __ push(Immediate(Smi::FromInt(MinorKey())));
+
+  __ push(eax);  // the operand
   __ push(Immediate(Smi::FromInt(op_)));
+  __ push(Immediate(Smi::FromInt(mode_)));
   __ push(Immediate(Smi::FromInt(operand_type_)));

   __ push(ecx);  // Push return address.
@@ -567,8 +565,7 @@
   // Patch the caller to an appropriate specialized stub and return the
   // operation result to the caller of the stub.
   __ TailCallExternalReference(
-      ExternalReference(IC_Utility(IC::kUnaryOp_Patch),
-                        masm->isolate()), 4, 1);
+ ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1);
 }


=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.h Wed Jun 22 01:28:35 2011 +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.h Fri Jul 1 00:50:46 2011
@@ -62,16 +62,11 @@

 class UnaryOpStub: public CodeStub {
  public:
-  UnaryOpStub(Token::Value op, UnaryOverwriteMode mode)
+  UnaryOpStub(Token::Value op,
+              UnaryOverwriteMode mode,
+              UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED)
       : op_(op),
         mode_(mode),
-        operand_type_(UnaryOpIC::UNINITIALIZED),
-        name_(NULL) {
-  }
-
-  UnaryOpStub(int key, UnaryOpIC::TypeInfo operand_type)
-      : op_(OpBits::decode(key)),
-        mode_(ModeBits::decode(key)),
         operand_type_(operand_type),
         name_(NULL) {
   }
@@ -89,8 +84,7 @@

 #ifdef DEBUG
   void Print() {
-    PrintF("TypeRecordingUnaryOpStub %d (op %s), "
-           "(mode %d, runtime_type_info %s)\n",
+    PrintF("UnaryOpStub %d (op %s), (mode %d, runtime_type_info %s)\n",
            MinorKey(),
            Token::String(op_),
            static_cast<int>(mode_),
=======================================
--- /branches/bleeding_edge/src/ic.cc   Thu Jun 30 01:40:31 2011
+++ /branches/bleeding_edge/src/ic.cc   Fri Jul  1 00:50:46 2011
@@ -2332,15 +2332,15 @@

   HandleScope scope(isolate);
   Handle<Object> operand = args.at<Object>(0);
-  int key = args.smi_at(1);
-  Token::Value op = static_cast<Token::Value>(args.smi_at(2));
+  Token::Value op = static_cast<Token::Value>(args.smi_at(1));
+ UnaryOverwriteMode mode = static_cast<UnaryOverwriteMode>(args.smi_at(2));
   UnaryOpIC::TypeInfo previous_type =
       static_cast<UnaryOpIC::TypeInfo>(args.smi_at(3));

   UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand);
   type = UnaryOpIC::ComputeNewType(type, previous_type);

-  UnaryOpStub stub(key, type);
+  UnaryOpStub stub(op, mode, type);
   Handle<Code> code = stub.GetCode();
   if (!code.is_null()) {
     if (FLAG_trace_ic) {
=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.cc Thu Jun 30 01:32:59 2011 +++ /branches/bleeding_edge/src/mips/code-stubs-mips.cc Fri Jul 1 00:50:46 2011
@@ -1846,19 +1846,13 @@

 void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
   // Argument is in a0 and v0 at this point, so we can overwrite a0.
-  // Push this stub's key. Although the operation and the type info are
-  // encoded into the key, the encoding is opaque, so push them too.
-  __ li(a2, Operand(Smi::FromInt(MinorKey())));
-  __ li(a1, Operand(Smi::FromInt(op_)));
+  __ li(a2, Operand(Smi::FromInt(op_)));
+  __ li(a1, Operand(Smi::FromInt(mode_)));
   __ li(a0, Operand(Smi::FromInt(operand_type_)));
-
   __ Push(v0, a2, a1, a0);

   __ TailCallExternalReference(
-      ExternalReference(IC_Utility(IC::kUnaryOp_Patch),
-                        masm->isolate()),
-      4,
-      1);
+ ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1);
 }


=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.h Wed Jun 22 01:28:35 2011 +++ /branches/bleeding_edge/src/mips/code-stubs-mips.h Fri Jul 1 00:50:46 2011
@@ -61,18 +61,11 @@

 class UnaryOpStub: public CodeStub {
  public:
-  UnaryOpStub(Token::Value op, UnaryOverwriteMode mode)
+  UnaryOpStub(Token::Value op,
+              UnaryOverwriteMode mode,
+              UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED)
       : op_(op),
         mode_(mode),
-        operand_type_(UnaryOpIC::UNINITIALIZED),
-        name_(NULL) {
-  }
-
-  UnaryOpStub(
-      int key,
-      UnaryOpIC::TypeInfo operand_type)
-      : op_(OpBits::decode(key)),
-        mode_(ModeBits::decode(key)),
         operand_type_(operand_type),
         name_(NULL) {
   }
@@ -90,8 +83,7 @@

 #ifdef DEBUG
   void Print() {
-    PrintF("UnaryOpStub %d (op %s), "
-           "(mode %d, runtime_type_info %s)\n",
+    PrintF("UnaryOpStub %d (op %s), (mode %d, runtime_type_info %s)\n",
            MinorKey(),
            Token::String(op_),
            static_cast<int>(mode_),
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Tue Jun 28 08:22:08 2011 +++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Fri Jul 1 00:50:46 2011
@@ -424,12 +424,10 @@

 void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
   __ pop(rcx);  // Save return address.
-  __ push(rax);
-  // Left and right arguments are now on top.
-  // Push this stub's key. Although the operation and the type info are
-  // encoded into the key, the encoding is opaque, so push them too.
-  __ Push(Smi::FromInt(MinorKey()));
+
+  __ push(rax);  // the operand
   __ Push(Smi::FromInt(op_));
+  __ Push(Smi::FromInt(mode_));
   __ Push(Smi::FromInt(operand_type_));

   __ push(rcx);  // Push return address.
@@ -437,10 +435,7 @@
   // Patch the caller to an appropriate specialized stub and return the
   // operation result to the caller of the stub.
   __ TailCallExternalReference(
-      ExternalReference(IC_Utility(IC::kUnaryOp_Patch),
-                        masm->isolate()),
-      4,
-      1);
+ ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1);
 }


=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.h Wed Jun 22 01:28:35 2011 +++ /branches/bleeding_edge/src/x64/code-stubs-x64.h Fri Jul 1 00:50:46 2011
@@ -61,18 +61,11 @@

 class UnaryOpStub: public CodeStub {
  public:
-  UnaryOpStub(Token::Value op, UnaryOverwriteMode mode)
+  UnaryOpStub(Token::Value op,
+              UnaryOverwriteMode mode,
+              UnaryOpIC::TypeInfo operand_type = UnaryOpIC::UNINITIALIZED)
       : op_(op),
         mode_(mode),
-        operand_type_(UnaryOpIC::UNINITIALIZED),
-        name_(NULL) {
-  }
-
-  UnaryOpStub(
-      int key,
-      UnaryOpIC::TypeInfo operand_type)
-      : op_(OpBits::decode(key)),
-        mode_(ModeBits::decode(key)),
         operand_type_(operand_type),
         name_(NULL) {
   }
@@ -90,8 +83,7 @@

 #ifdef DEBUG
   void Print() {
-    PrintF("UnaryOpStub %d (op %s), "
-           "(mode %d, runtime_type_info %s)\n",
+    PrintF("UnaryOpStub %d (op %s), (mode %d, runtime_type_info %s)\n",
            MinorKey(),
            Token::String(op_),
            static_cast<int>(mode_),

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

Reply via email to