Rename the Location type tags to be consistent with our current naming

scheme for enumerations (eg, EFFECT => kEffect).

Remove the ability to move from one Location to another, which should
never be necessary.

Review URL: http://codereview.chromium.org/340034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3175 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent be769f6a
......@@ -119,11 +119,11 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
void FastCodeGenerator::Move(Location destination, Slot* source) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
break;
case Location::VALUE:
case Location::kValue:
__ ldr(ip, MemOperand(fp, SlotOffset(source)));
__ push(ip);
break;
......@@ -133,11 +133,11 @@ void FastCodeGenerator::Move(Location destination, Slot* source) {
void FastCodeGenerator::Move(Location destination, Literal* expr) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
break;
case Location::VALUE:
case Location::kValue:
__ mov(ip, Operand(expr->handle()));
__ push(ip);
break;
......@@ -147,10 +147,10 @@ void FastCodeGenerator::Move(Location destination, Literal* expr) {
void FastCodeGenerator::Move(Slot* destination, Location source) {
switch (source.type()) {
case Location::UNINITIALIZED: // Fall through.
case Location::EFFECT:
case Location::kUninitialized: // Fall through.
case Location::kEffect:
UNREACHABLE();
case Location::VALUE:
case Location::kValue:
__ pop(ip);
__ str(ip, MemOperand(fp, SlotOffset(destination)));
break;
......@@ -160,12 +160,12 @@ void FastCodeGenerator::Move(Slot* destination, Location source) {
void FastCodeGenerator::DropAndMove(Location destination, Register source) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
__ pop();
break;
case Location::VALUE:
case Location::kValue:
__ str(source, MemOperand(sp));
break;
}
......@@ -362,12 +362,12 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
}
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
if (result_saved) __ pop();
break;
case Location::VALUE:
case Location::kValue:
if (!result_saved) __ push(r0);
break;
}
......@@ -439,12 +439,12 @@ void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
if (result_saved) __ pop();
break;
case Location::VALUE:
case Location::kValue:
if (!result_saved) __ push(r0);
break;
}
......@@ -497,13 +497,13 @@ void FastCodeGenerator::VisitAssignment(Assignment* expr) {
Visit(rhs);
// Load right-hand side into ip.
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
// Case 'var = temp'. Discard right-hand-side temporary.
__ pop(ip);
break;
case Location::VALUE:
case Location::kValue:
// Case 'temp1 <- (var = temp0)'. Preserve right-hand-side
// temporary on the stack.
__ ldr(ip, MemOperand(sp));
......@@ -549,12 +549,12 @@ void FastCodeGenerator::VisitProperty(Property* expr) {
__ pop();
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::VALUE:
case Location::kValue:
__ str(r0, MemOperand(sp));
break;
case Location::EFFECT:
case Location::kEffect:
__ pop();
}
}
......@@ -734,12 +734,8 @@ void FastCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) {
// Discard the left-hand value if present on the stack.
if (destination.is_value()) __ pop();
// Save or discard the right-hand value as needed.
if (right->AsLiteral() != NULL) {
Move(destination, right->AsLiteral());
} else {
Visit(right);
Move(destination, right->location());
}
Visit(right);
ASSERT_EQ(destination.type(), right->location().type());
__ bind(&done);
}
......
......@@ -71,36 +71,15 @@ int FastCodeGenerator::SlotOffset(Slot* slot) {
}
void FastCodeGenerator::Move(Location destination, Location source) {
switch (destination.type()) {
case Location::UNINITIALIZED:
UNREACHABLE();
case Location::EFFECT:
break;
case Location::VALUE:
switch (source.type()) {
case Location::UNINITIALIZED: // Fall through.
case Location::EFFECT:
UNREACHABLE();
case Location::VALUE:
break;
}
break;
}
}
// All platform macro assemblers in {ia32,x64,arm} have a push(Register)
// function.
void FastCodeGenerator::Move(Location destination, Register source) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
break;
case Location::VALUE:
case Location::kValue:
masm_->push(source);
break;
}
......@@ -111,10 +90,10 @@ void FastCodeGenerator::Move(Location destination, Register source) {
// function.
void FastCodeGenerator::Move(Register destination, Location source) {
switch (source.type()) {
case Location::UNINITIALIZED: // Fall through.
case Location::EFFECT:
case Location::kUninitialized: // Fall through.
case Location::kEffect:
UNREACHABLE();
case Location::VALUE:
case Location::kValue:
masm_->pop(destination);
}
}
......
......@@ -51,8 +51,6 @@ class FastCodeGenerator: public AstVisitor {
private:
int SlotOffset(Slot* slot);
void Move(Location destination, Location source);
void Move(Location destination, Register source);
void Move(Location destination, Slot* source);
void Move(Location destination, Literal* source);
......
......@@ -110,11 +110,11 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
void FastCodeGenerator::Move(Location destination, Slot* source) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
break;
case Location::VALUE:
case Location::kValue:
__ push(Operand(ebp, SlotOffset(source)));
break;
}
......@@ -123,11 +123,11 @@ void FastCodeGenerator::Move(Location destination, Slot* source) {
void FastCodeGenerator::Move(Location destination, Literal* expr) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
break;
case Location::VALUE:
case Location::kValue:
__ push(Immediate(expr->handle()));
break;
}
......@@ -136,10 +136,10 @@ void FastCodeGenerator::Move(Location destination, Literal* expr) {
void FastCodeGenerator::Move(Slot* destination, Location source) {
switch (source.type()) {
case Location::UNINITIALIZED: // Fall through.
case Location::EFFECT:
case Location::kUninitialized: // Fall through.
case Location::kEffect:
UNREACHABLE();
case Location::VALUE:
case Location::kValue:
__ pop(Operand(ebp, SlotOffset(destination)));
break;
}
......@@ -148,12 +148,12 @@ void FastCodeGenerator::Move(Slot* destination, Location source) {
void FastCodeGenerator::DropAndMove(Location destination, Register source) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
__ add(Operand(esp), Immediate(kPointerSize));
break;
case Location::VALUE:
case Location::kValue:
__ mov(Operand(esp, 0), source);
break;
}
......@@ -352,12 +352,12 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
}
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
if (result_saved) __ add(Operand(esp), Immediate(kPointerSize));
break;
case Location::VALUE:
case Location::kValue:
if (!result_saved) __ push(eax);
break;
}
......@@ -426,12 +426,12 @@ void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
if (result_saved) __ add(Operand(esp), Immediate(kPointerSize));
break;
case Location::VALUE:
case Location::kValue:
if (!result_saved) __ push(eax);
break;
}
......@@ -481,13 +481,13 @@ void FastCodeGenerator::VisitAssignment(Assignment* expr) {
ASSERT(rhs->location().is_value());
Visit(rhs);
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
// Case 'var = temp'. Discard right-hand-side temporary.
Move(var->slot(), rhs->location());
break;
case Location::VALUE:
case Location::kValue:
// Case 'temp1 <- (var = temp0)'. Preserve right-hand-side
// temporary on the stack.
__ mov(eax, Operand(esp, 0));
......@@ -532,12 +532,12 @@ void FastCodeGenerator::VisitProperty(Property* expr) {
__ add(Operand(esp), Immediate(kPointerSize));
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::VALUE:
case Location::kValue:
__ mov(Operand(esp, 0), eax);
break;
case Location::EFFECT:
case Location::kEffect:
__ add(Operand(esp), Immediate(kPointerSize));
break;
}
......@@ -706,14 +706,14 @@ void FastCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) {
Visit(left);
ASSERT(left->location().is_value());
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
// Pop the left-hand value into eax because we will not need it as the
// final result.
__ pop(eax);
break;
case Location::VALUE:
case Location::kValue:
// Copy the left-hand value into eax because we may need it as the
// final result.
__ mov(eax, Operand(esp, 0));
......@@ -753,12 +753,8 @@ void FastCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) {
__ add(Operand(esp), Immediate(kPointerSize));
}
// Save or discard the right-hand value as needed.
if (right->AsLiteral() != NULL) {
Move(destination, right->AsLiteral());
} else {
Visit(right);
Move(destination, right->location());
}
Visit(right);
ASSERT_EQ(destination.type(), right->location().type());
__ bind(&done);
}
......
......@@ -35,14 +35,18 @@ namespace internal {
class Location BASE_EMBEDDED {
public:
enum Type { UNINITIALIZED, EFFECT, VALUE };
static Location Uninitialized() { return Location(UNINITIALIZED); }
static Location Effect() { return Location(EFFECT); }
static Location Value() { return Location(VALUE); }
bool is_effect() { return type_ == EFFECT; }
bool is_value() { return type_ == VALUE; }
enum Type {
kUninitialized,
kEffect,
kValue
};
static Location Uninitialized() { return Location(kUninitialized); }
static Location Effect() { return Location(kEffect); }
static Location Value() { return Location(kValue); }
bool is_effect() { return type_ == kEffect; }
bool is_value() { return type_ == kValue; }
Type type() { return type_; }
......
......@@ -118,11 +118,11 @@ void FastCodeGenerator::Generate(FunctionLiteral* fun) {
void FastCodeGenerator::Move(Location destination, Slot* source) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
break;
case Location::VALUE:
case Location::kValue:
__ push(Operand(rbp, SlotOffset(source)));
break;
}
......@@ -131,11 +131,11 @@ void FastCodeGenerator::Move(Location destination, Slot* source) {
void FastCodeGenerator::Move(Location destination, Literal* expr) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
break;
case Location::VALUE:
case Location::kValue:
__ Push(expr->handle());
break;
}
......@@ -144,10 +144,10 @@ void FastCodeGenerator::Move(Location destination, Literal* expr) {
void FastCodeGenerator::Move(Slot* destination, Location source) {
switch (source.type()) {
case Location::UNINITIALIZED: // Fall through.
case Location::EFFECT:
case Location::kUninitialized: // Fall through.
case Location::kEffect:
UNREACHABLE();
case Location::VALUE:
case Location::kValue:
__ pop(Operand(rbp, SlotOffset(destination)));
break;
}
......@@ -156,12 +156,12 @@ void FastCodeGenerator::Move(Slot* destination, Location source) {
void FastCodeGenerator::DropAndMove(Location destination, Register source) {
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
__ addq(rsp, Immediate(kPointerSize));
break;
case Location::VALUE:
case Location::kValue:
__ movq(Operand(rsp, 0), source);
break;
}
......@@ -364,12 +364,12 @@ void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
}
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
if (result_saved) __ addq(rsp, Immediate(kPointerSize));
break;
case Location::VALUE:
case Location::kValue:
if (!result_saved) __ push(rax);
break;
}
......@@ -438,12 +438,12 @@ void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
if (result_saved) __ addq(rsp, Immediate(kPointerSize));
break;
case Location::VALUE:
case Location::kValue:
if (!result_saved) __ push(rax);
break;
}
......@@ -494,13 +494,13 @@ void FastCodeGenerator::VisitAssignment(Assignment* expr) {
ASSERT(rhs->location().is_value());
Visit(rhs);
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
// Case 'var = temp'. Discard right-hand-side temporary.
Move(var->slot(), rhs->location());
break;
case Location::VALUE:
case Location::kValue:
// Case 'temp1 <- (var = temp0)'. Preserve right-hand-side
// temporary on the stack.
__ movq(kScratchRegister, Operand(rsp, 0));
......@@ -545,12 +545,12 @@ void FastCodeGenerator::VisitProperty(Property* expr) {
__ addq(rsp, Immediate(kPointerSize));
}
switch (expr->location().type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::VALUE:
case Location::kValue:
__ movq(Operand(rsp, 0), rax);
break;
case Location::EFFECT:
case Location::kEffect:
__ addq(rsp, Immediate(kPointerSize));
break;
}
......@@ -722,14 +722,14 @@ void FastCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) {
Visit(left);
ASSERT(left->location().is_value());
switch (destination.type()) {
case Location::UNINITIALIZED:
case Location::kUninitialized:
UNREACHABLE();
case Location::EFFECT:
case Location::kEffect:
// Pop the left-hand value into rax because we will not need it as the
// final result.
__ pop(rax);
break;
case Location::VALUE:
case Location::kValue:
// Copy the left-hand value into rax because we may need it as the
// final result.
__ movq(rax, Operand(rsp, 0));
......@@ -770,12 +770,8 @@ void FastCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) {
__ addq(rsp, Immediate(kPointerSize));
}
// Save or discard the right-hand value as needed.
if (right->AsLiteral() != NULL) {
Move(destination, right->AsLiteral());
} else {
Visit(right);
Move(destination, right->location());
}
Visit(right);
ASSERT_EQ(destination.type(), right->location().type());
__ bind(&done);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment