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;
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;
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;
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;
}
}
}
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;
}
}
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;
}
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));
__ 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();
}
}
// 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);
}
}
-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;
}
// 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);
}
}
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);
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;
}
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;
}
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;
}
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;
}
}
}
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;
}
}
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;
}
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));
__ 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;
}
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));
__ 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);
}
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_; }
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;
}
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;
}
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;
}
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;
}
}
}
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;
}
}
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;
}
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));
__ 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;
}
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));
__ 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);
}