Revision: 3532
Author: [email protected]
Date: Tue Jan  5 01:11:10 2010
Log: Style cleanup of switches over Slot::Type in the nonoptimizing code
generator.

The Slot::Type enumeration has four values.  It should never be
necessary to use a default to handle the case of a value out of range
of the enumeration.  Doing so silences a useful warning when one of
the enumeration values is actually forgotten or when a new enumeration
value is added.

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

Modified:
  /branches/bleeding_edge/src/arm/fast-codegen-arm.cc
  /branches/bleeding_edge/src/fast-codegen.cc
  /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc
  /branches/bleeding_edge/src/x64/fast-codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Mon Jan  4 06:15:47  
2010
+++ /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Tue Jan  5 01:11:10  
2010
@@ -294,15 +294,12 @@
            function_->scope()->ContextChainLength(source->var()->scope());
        __ LoadContext(scratch, context_chain_length);
        return CodeGenerator::ContextOperand(scratch, source->index());
-      break;
      }
      case Slot::LOOKUP:
        UNIMPLEMENTED();
-      // Fall-through.
-    default:
-      UNREACHABLE();
-      return MemOperand(r0, 0);  // Dead code to make the compiler happy.
-  }
+  }
+  UNREACHABLE();
+  return MemOperand(r0, 0);
  }


@@ -322,9 +319,9 @@
        UNREACHABLE();
      case Expression::kEffect:
        break;
-    case Expression::kValue:  // Fall through.
-    case Expression::kTest:  // Fall through.
-    case Expression::kValueTest:  // Fall through.
+    case Expression::kValue:
+    case Expression::kTest:
+    case Expression::kValueTest:
      case Expression::kTestValue:
        Move(scratch, source);
        Move(context, scratch);
@@ -339,9 +336,9 @@
        UNREACHABLE();
      case Expression::kEffect:
        break;
-    case Expression::kValue:  // Fall through.
-    case Expression::kTest:  // Fall through.
-    case Expression::kValueTest:  // Fall through.
+    case Expression::kValue:
+    case Expression::kTest:
+    case Expression::kValueTest:
      case Expression::kTestValue:
        __ mov(ip, Operand(expr->handle()));
        Move(context, ip);
@@ -371,8 +368,6 @@
      }
      case Slot::LOOKUP:
        UNIMPLEMENTED();
-    default:
-      UNREACHABLE();
    }
  }

@@ -452,7 +447,7 @@

    if (slot != NULL) {
      switch (slot->type()) {
-      case Slot::PARAMETER:  // Fall through.
+      case Slot::PARAMETER:
        case Slot::LOCAL:
          if (decl->mode() == Variable::CONST) {
            __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
@@ -597,8 +592,8 @@
      Slot* slot = rewrite->AsSlot();
      if (FLAG_debug_code) {
        switch (slot->type()) {
-        case Slot::LOCAL:
-        case Slot::PARAMETER: {
+        case Slot::PARAMETER:
+        case Slot::LOCAL: {
            Comment cmnt(masm_, "Stack slot");
            break;
          }
@@ -609,8 +604,6 @@
          case Slot::LOOKUP:
            UNIMPLEMENTED();
            break;
-        default:
-          UNREACHABLE();
        }
      }
      Move(context, slot, r0);
@@ -738,7 +731,7 @@
          __ ldr(r0, MemOperand(sp));  // Restore result into r0.
          break;

-      case ObjectLiteral::Property::GETTER:  // Fall through.
+      case ObjectLiteral::Property::GETTER:
        case ObjectLiteral::Property::SETTER:
          __ push(r0);
          Visit(key);
@@ -1323,7 +1316,7 @@
            // Value is false so it's needed.
            __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
            __ push(ip);
-        case Expression::kTest:  // Fall through.
+        case Expression::kTest:
          case Expression::kValueTest:
            __ jmp(false_label_);
            break;
@@ -1487,9 +1480,9 @@
        case Expression::kEffect:
          // Do not save result.
          break;
-      case Expression::kValue:  // Fall through
-      case Expression::kTest:  // Fall through
-      case Expression::kTestValue:  // Fall through
+      case Expression::kValue:
+      case Expression::kTest:
+      case Expression::kTestValue:
        case Expression::kValueTest:
          // Save the result on the stack. If we have a named or keyed  
property
          // we store the result under the receiver that is currently on top
=======================================
--- /branches/bleeding_edge/src/fast-codegen.cc Mon Jan  4 05:56:31 2010
+++ /branches/bleeding_edge/src/fast-codegen.cc Tue Jan  5 01:11:10 2010
@@ -67,7 +67,8 @@
      case Slot::LOCAL:
        offset += JavaScriptFrameConstants::kLocal0Offset;
        break;
-    default:
+    case Slot::CONTEXT:
+    case Slot::LOOKUP:
        UNREACHABLE();
    }
    return offset;
@@ -162,7 +163,7 @@
    switch (expr->context()) {
      case Expression::kUninitialized:
        UNREACHABLE();
-    case Expression::kEffect:  // Fall through.
+    case Expression::kEffect:
      case Expression::kTest:
        // The value of the left subexpression is not needed.
        expected = Expression::kTest;
=======================================
--- /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc       Mon Jan  4  
05:56:31 2010
+++ /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc       Tue Jan  5  
01:11:10 2010
@@ -273,15 +273,12 @@
            function_->scope()->ContextChainLength(source->var()->scope());
        __ LoadContext(scratch, context_chain_length);
        return CodeGenerator::ContextOperand(scratch, source->index());
-      break;
      }
      case Slot::LOOKUP:
        UNIMPLEMENTED();
-      // Fall-through.
-    default:
-      UNREACHABLE();
-      return Operand(eax, 0);  // Dead code to make the compiler happy.
-  }
+  }
+  UNREACHABLE();
+  return Operand(eax, 0);
  }


@@ -304,8 +301,8 @@
        __ push(location);
        break;
      }
-    case Expression::kTest:  // Fall through.
-    case Expression::kValueTest:  // Fall through.
+    case Expression::kTest:
+    case Expression::kValueTest:
      case Expression::kTestValue:
        Move(scratch, source);
        Move(context, scratch);
@@ -323,8 +320,8 @@
      case Expression::kValue:
        __ push(Immediate(expr->handle()));
        break;
-    case Expression::kTest:  // Fall through.
-    case Expression::kValueTest:  // Fall through.
+    case Expression::kTest:
+    case Expression::kValueTest:
      case Expression::kTestValue:
        __ mov(eax, expr->handle());
        Move(context, eax);
@@ -356,8 +353,6 @@
      }
      case Slot::LOOKUP:
        UNIMPLEMENTED();
-    default:
-      UNREACHABLE();
    }
  }

@@ -450,7 +445,7 @@

    if (slot != NULL) {
      switch (slot->type()) {
-      case Slot::PARAMETER:  // Fall through.
+      case Slot::PARAMETER:
        case Slot::LOCAL:
          if (decl->mode() == Variable::CONST) {
            __ mov(Operand(ebp, SlotOffset(var->slot())),
@@ -595,8 +590,8 @@
      Slot* slot = rewrite->AsSlot();
      if (FLAG_debug_code) {
        switch (slot->type()) {
-        case Slot::LOCAL:
-        case Slot::PARAMETER: {
+        case Slot::PARAMETER:
+        case Slot::LOCAL: {
            Comment cmnt(masm_, "Stack slot");
            break;
          }
@@ -607,8 +602,6 @@
          case Slot::LOOKUP:
            UNIMPLEMENTED();
            break;
-        default:
-          UNREACHABLE();
        }
      }
      Move(context, slot, eax);
@@ -706,7 +699,7 @@
        result_saved = true;
      }
      switch (property->kind()) {
-      case ObjectLiteral::Property::MATERIALIZED_LITERAL:  // fall through
+      case ObjectLiteral::Property::MATERIALIZED_LITERAL:  // Fall through.
          ASSERT(!CompileTimeValue::IsCompileTimeValue(value));
        case ObjectLiteral::Property::COMPUTED:
          if (key->handle()->IsSymbol()) {
@@ -720,7 +713,7 @@
            __ mov(eax, Operand(esp, 0));  // Restore result into eax.
            break;
          }
-        // fall through
+        // Fall through.
        case ObjectLiteral::Property::PROTOTYPE:
          __ push(eax);
          Visit(key);
@@ -730,7 +723,7 @@
          __ CallRuntime(Runtime::kSetProperty, 3);
          __ mov(eax, Operand(esp, 0));  // Restore result into eax.
          break;
-      case ObjectLiteral::Property::SETTER:  // fall through
+      case ObjectLiteral::Property::SETTER:
        case ObjectLiteral::Property::GETTER:
          __ push(eax);
          Visit(key);
@@ -1303,7 +1296,7 @@
            // Value is false so it's needed.
            __ push(Immediate(Factory::undefined_value()));
            // Fall through.
-        case Expression::kTest:  // Fall through.
+        case Expression::kTest:
          case Expression::kValueTest:
            __ jmp(false_label_);
            break;
@@ -1461,9 +1454,9 @@
        case Expression::kEffect:
          // Do not save result.
          break;
-      case Expression::kValue:  // Fall through
-      case Expression::kTest:  // Fall through
-      case Expression::kTestValue:  // Fall through
+      case Expression::kValue:
+      case Expression::kTest:
+      case Expression::kTestValue:
        case Expression::kValueTest:
          // Save the result on the stack. If we have a named or keyed  
property
          // we store the result under the receiver that is currently on top
=======================================
--- /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Mon Jan  4 05:56:31  
2010
+++ /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Tue Jan  5 01:11:10  
2010
@@ -282,15 +282,12 @@
            function_->scope()->ContextChainLength(source->var()->scope());
        __ LoadContext(scratch, context_chain_length);
        return CodeGenerator::ContextOperand(scratch, source->index());
-      break;
      }
      case Slot::LOOKUP:
        UNIMPLEMENTED();
-      // Fall-through.
-    default:
-      UNREACHABLE();
-      return Operand(rax, 0);  // Dead code to make the compiler happy.
-  }
+  }
+  UNREACHABLE();
+  return Operand(rax, 0);
  }


@@ -313,8 +310,8 @@
        __ push(location);
        break;
      }
-    case Expression::kTest:  // Fall through.
-    case Expression::kValueTest:  // Fall through.
+    case Expression::kTest:
+    case Expression::kValueTest:
      case Expression::kTestValue:
        Move(scratch, source);
        Move(context, scratch);
@@ -332,8 +329,8 @@
      case Expression::kValue:
        __ Push(expr->handle());
        break;
-    case Expression::kTest:  // Fall through.
-    case Expression::kValueTest:  // Fall through.
+    case Expression::kTest:
+    case Expression::kValueTest:
      case Expression::kTestValue:
        __ Move(rax, expr->handle());
        Move(context, rax);
@@ -365,8 +362,6 @@
      }
      case Slot::LOOKUP:
        UNIMPLEMENTED();
-    default:
-      UNREACHABLE();
    }
  }

@@ -458,7 +453,7 @@

    if (slot != NULL) {
      switch (slot->type()) {
-      case Slot::PARAMETER:  // Fall through.
+      case Slot::PARAMETER:
        case Slot::LOCAL:
          if (decl->mode() == Variable::CONST) {
            __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
@@ -617,8 +612,6 @@
          case Slot::LOOKUP:
            UNIMPLEMENTED();
            break;
-        default:
-          UNREACHABLE();
        }
      }
      Move(context, slot, rax);
@@ -715,7 +708,7 @@
        result_saved = true;
      }
      switch (property->kind()) {
-      case ObjectLiteral::Property::MATERIALIZED_LITERAL:  // fall through
+      case ObjectLiteral::Property::MATERIALIZED_LITERAL:
          ASSERT(!CompileTimeValue::IsCompileTimeValue(value));
        case ObjectLiteral::Property::COMPUTED:
          if (key->handle()->IsSymbol()) {
@@ -729,7 +722,7 @@
            __ movq(rax, Operand(rsp, 0));  // Restore result back into rax.
            break;
          }
-        // fall through
+        // Fall through.
        case ObjectLiteral::Property::PROTOTYPE:
          __ push(rax);
          Visit(key);
@@ -739,7 +732,7 @@
          __ CallRuntime(Runtime::kSetProperty, 3);
          __ movq(rax, Operand(rsp, 0));  // Restore result into rax.
          break;
-      case ObjectLiteral::Property::SETTER:  // fall through
+      case ObjectLiteral::Property::SETTER:
        case ObjectLiteral::Property::GETTER:
          __ push(rax);
          Visit(key);
@@ -1320,7 +1313,7 @@
            // Value is false so it's needed.
            __ PushRoot(Heap::kUndefinedValueRootIndex);
            // Fall through.
-        case Expression::kTest:  // Fall through.
+        case Expression::kTest:
          case Expression::kValueTest:
            __ jmp(false_label_);
            break;
@@ -1672,7 +1665,7 @@
        switch (expr->op()) {
          case Token::EQ_STRICT:
            strict = true;
-          // Fall through
+          // Fall through.
          case Token::EQ:
            cc = equal;
            __ pop(rax);

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

Reply via email to