From: kmillikin@chromium.org Date: Thu, 29 Oct 2009 13:58:04 +0000 (+0000) Subject: Rename the Location type tags to be consistent with our current naming X-Git-Tag: upstream/4.7.83~23046 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b1defd51cb9fa15f4476e83e715bb5440774af4c;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/arm/fast-codegen-arm.cc b/src/arm/fast-codegen-arm.cc index a50075384..6540d4016 100644 --- a/src/arm/fast-codegen-arm.cc +++ b/src/arm/fast-codegen-arm.cc @@ -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); } diff --git a/src/fast-codegen.cc b/src/fast-codegen.cc index 20c17b33c..2f6a27a5e 100644 --- a/src/fast-codegen.cc +++ b/src/fast-codegen.cc @@ -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); } } diff --git a/src/fast-codegen.h b/src/fast-codegen.h index 33e6b9b7a..31bb41c4d 100644 --- a/src/fast-codegen.h +++ b/src/fast-codegen.h @@ -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); diff --git a/src/ia32/fast-codegen-ia32.cc b/src/ia32/fast-codegen-ia32.cc index 9f7f623d9..247f12496 100644 --- a/src/ia32/fast-codegen-ia32.cc +++ b/src/ia32/fast-codegen-ia32.cc @@ -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); } diff --git a/src/location.h b/src/location.h index 7a11c4ab5..26b1a09e9 100644 --- a/src/location.h +++ b/src/location.h @@ -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_; } diff --git a/src/x64/fast-codegen-x64.cc b/src/x64/fast-codegen-x64.cc index 81d24c21a..b938119cd 100644 --- a/src/x64/fast-codegen-x64.cc +++ b/src/x64/fast-codegen-x64.cc @@ -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); }