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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3532 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
kmillikin@chromium.org 2010-01-05 09:11:10 +00:00
parent 1902b76227
commit b74daccff0
4 changed files with 47 additions and 67 deletions

View File

@ -294,15 +294,12 @@ MemOperand FastCodeGenerator::CreateSlotOperand<MemOperand>(
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 @@ void FastCodeGenerator::Move(Expression::Context context,
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 @@ void FastCodeGenerator::Move(Expression::Context context, Literal* expr) {
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 @@ void FastCodeGenerator::Move(Slot* dst,
}
case Slot::LOOKUP:
UNIMPLEMENTED();
default:
UNREACHABLE();
}
}
@ -452,7 +447,7 @@ void FastCodeGenerator::VisitDeclaration(Declaration* decl) {
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 @@ void FastCodeGenerator::EmitVariableLoad(Variable* var,
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 @@ void FastCodeGenerator::EmitVariableLoad(Variable* var,
case Slot::LOOKUP:
UNIMPLEMENTED();
break;
default:
UNREACHABLE();
}
}
Move(context, slot, r0);
@ -738,7 +731,7 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ 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 @@ void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
// 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 @@ void FastCodeGenerator::VisitCountOperation(CountOperation* expr) {
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

View File

@ -67,7 +67,8 @@ int FastCodeGenerator::SlotOffset(Slot* slot) {
case Slot::LOCAL:
offset += JavaScriptFrameConstants::kLocal0Offset;
break;
default:
case Slot::CONTEXT:
case Slot::LOOKUP:
UNREACHABLE();
}
return offset;
@ -162,7 +163,7 @@ void FastCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) {
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;

View File

@ -273,15 +273,12 @@ Operand FastCodeGenerator::CreateSlotOperand<Operand>(Slot* source,
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 @@ void FastCodeGenerator::Move(Expression::Context context,
__ 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 @@ void FastCodeGenerator::Move(Expression::Context context, Literal* expr) {
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 @@ void FastCodeGenerator::Move(Slot* dst,
}
case Slot::LOOKUP:
UNIMPLEMENTED();
default:
UNREACHABLE();
}
}
@ -450,7 +445,7 @@ void FastCodeGenerator::VisitDeclaration(Declaration* decl) {
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 @@ void FastCodeGenerator::EmitVariableLoad(Variable* var,
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 @@ void FastCodeGenerator::EmitVariableLoad(Variable* var,
case Slot::LOOKUP:
UNIMPLEMENTED();
break;
default:
UNREACHABLE();
}
}
Move(context, slot, eax);
@ -706,7 +699,7 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
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 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ 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 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ 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 @@ void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
// 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 @@ void FastCodeGenerator::VisitCountOperation(CountOperation* expr) {
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

View File

@ -282,15 +282,12 @@ Operand FastCodeGenerator::CreateSlotOperand<Operand>(Slot* source,
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 @@ void FastCodeGenerator::Move(Expression::Context context,
__ 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 @@ void FastCodeGenerator::Move(Expression::Context context, Literal* expr) {
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 @@ void FastCodeGenerator::Move(Slot* dst,
}
case Slot::LOOKUP:
UNIMPLEMENTED();
default:
UNREACHABLE();
}
}
@ -458,7 +453,7 @@ void FastCodeGenerator::VisitDeclaration(Declaration* decl) {
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 @@ void FastCodeGenerator::EmitVariableLoad(Variable* var,
case Slot::LOOKUP:
UNIMPLEMENTED();
break;
default:
UNREACHABLE();
}
}
Move(context, slot, rax);
@ -715,7 +708,7 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
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 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ 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 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
__ 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 @@ void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
// 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 @@ void FastCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
switch (expr->op()) {
case Token::EQ_STRICT:
strict = true;
// Fall through
// Fall through.
case Token::EQ:
cc = equal;
__ pop(rax);