Revision: 3156
Author: [email protected]
Date: Wed Oct 28 02:56:14 2009
Log: Factor out a commonly used code sequence to DropAndMove(Location,
Register)
Review URL: http://codereview.chromium.org/337060
http://code.google.com/p/v8/source/detail?r=3156
Modified:
/branches/bleeding_edge/src/arm/fast-codegen-arm.cc
/branches/bleeding_edge/src/fast-codegen.h
/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 Tue Oct 27 09:11:12
2009
+++ /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Wed Oct 28 02:56:14
2009
@@ -151,6 +151,18 @@
break;
}
}
+
+
+void FastCodeGenerator::DropAndMove(Location destination, Register source)
{
+ switch (destination.type()) {
+ case Location::NOWHERE:
+ __ pop();
+ break;
+ case Location::TEMP:
+ __ str(source, MemOperand(sp));
+ break;
+ }
+}
void FastCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
@@ -219,16 +231,7 @@
__ mov(r2, Operand(expr->name()));
Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
__ Call(ic, RelocInfo::CODE_TARGET_CONTEXT);
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ pop();
- break;
- case Location::TEMP:
- // Replace the global object with the result.
- __ str(r0, MemOperand(sp));
- break;
- }
-
+ DropAndMove(expr->location(), r0);
} else {
Comment cmnt(masm_, "Stack slot");
Move(expr->location(), rewrite->AsSlot());
@@ -456,15 +459,7 @@
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
__ Call(ic, RelocInfo::CODE_TARGET);
// Overwrite the global object on the stack with the result if needed.
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ pop();
- break;
- case Location::TEMP:
- __ str(r0, MemOperand(sp));
- break;
- }
-
+ DropAndMove(expr->location(), r0);
} else {
// Local or parameter assignment.
@@ -561,14 +556,7 @@
__ Call(ic, RelocInfo::CODE_TARGET_CONTEXT);
// Restore context register.
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ pop();
- break;
- case Location::TEMP:
- __ str(r0, MemOperand(sp));
- break;
- }
+ DropAndMove(expr->location(), r0);
}
@@ -607,14 +595,7 @@
__ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
// Replace function on TOS with result in r0, or pop it.
- switch (node->location().type()) {
- case Location::TEMP:
- __ str(r0, MemOperand(sp, 0));
- break;
- case Location::NOWHERE:
- __ pop();
- break;
- }
+ DropAndMove(node->location(), r0);
}
=======================================
--- /branches/bleeding_edge/src/fast-codegen.h Tue Oct 27 06:38:57 2009
+++ /branches/bleeding_edge/src/fast-codegen.h Wed Oct 28 02:56:14 2009
@@ -60,6 +60,10 @@
void Move(Register destination, Location source);
void Move(Slot* destination, Location source);
+ // Drop the TOS, and store source to destination.
+ // If destination is TOS, just overwrite TOS with source.
+ void DropAndMove(Location destination, Register source);
+
void VisitDeclarations(ZoneList<Declaration*>* declarations);
Handle<JSFunction> BuildBoilerplate(FunctionLiteral* fun);
void DeclareGlobals(Handle<FixedArray> pairs);
=======================================
--- /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc Tue Oct 27
09:11:12 2009
+++ /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc Wed Oct 28
02:56:14 2009
@@ -139,6 +139,18 @@
break;
}
}
+
+
+void FastCodeGenerator::DropAndMove(Location destination, Register source)
{
+ switch (destination.type()) {
+ case Location::NOWHERE:
+ __ add(Operand(esp), Immediate(kPointerSize));
+ break;
+ case Location::TEMP:
+ __ mov(Operand(esp, 0), source);
+ break;
+ }
+}
void FastCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
@@ -211,16 +223,7 @@
// (eg, push/pop elimination).
__ nop();
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ add(Operand(esp), Immediate(kPointerSize));
- break;
- case Location::TEMP:
- // Replace the global object with the result.
- __ mov(Operand(esp, 0), eax);
- break;
- }
-
+ DropAndMove(expr->location(), eax);
} else {
Comment cmnt(masm_, "Stack slot");
Move(expr->location(), rewrite->AsSlot());
@@ -455,14 +458,7 @@
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
__ call(ic, RelocInfo::CODE_TARGET);
// Overwrite the global object on the stack with the result if needed.
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ add(Operand(esp), Immediate(kPointerSize));
- break;
- case Location::TEMP:
- __ mov(Operand(esp, 0), eax);
- break;
- }
+ DropAndMove(expr->location(), eax);
} else {
// Local or parameter assignment.
@@ -557,14 +553,7 @@
// Restore context register.
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
// Discard the function left on TOS.
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ add(Operand(esp), Immediate(kPointerSize));
- break;
- case Location::TEMP:
- __ mov(Operand(esp, 0), eax);
- break;
- }
+ DropAndMove(expr->location(), eax);
}
@@ -603,14 +592,7 @@
__ call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
// Replace function on TOS with result in eax, or pop it.
- switch (node->location().type()) {
- case Location::TEMP:
- __ mov(Operand(esp, 0), eax);
- break;
- case Location::NOWHERE:
- __ add(Operand(esp), Immediate(kPointerSize));
- break;
- }
+ DropAndMove(node->location(), eax);
}
=======================================
--- /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Tue Oct 27 09:11:12
2009
+++ /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Wed Oct 28 02:56:14
2009
@@ -147,6 +147,18 @@
break;
}
}
+
+
+void FastCodeGenerator::DropAndMove(Location destination, Register source)
{
+ switch (destination.type()) {
+ case Location::NOWHERE:
+ __ addq(rsp, Immediate(kPointerSize));
+ break;
+ case Location::TEMP:
+ __ movq(Operand(rsp, 0), source);
+ break;
+ }
+}
void FastCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
@@ -226,16 +238,7 @@
// A test rax instruction following the call is used by the IC to
// indicate that the inobject property case was inlined. Ensure there
// is no test rax instruction here.
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ addq(rsp, Immediate(kPointerSize));
- break;
- case Location::TEMP:
- // Replace the global object with the result.
- __ movq(Operand(rsp, 0), rax);
- break;
- }
-
+ DropAndMove(expr->location(), rax);
} else {
Comment cmnt(masm_, "Stack slot");
Move(expr->location(), rewrite->AsSlot());
@@ -468,14 +471,7 @@
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
__ Call(ic, RelocInfo::CODE_TARGET);
// Overwrite the global object on the stack with the result if needed.
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ addq(rsp, Immediate(kPointerSize));
- break;
- case Location::TEMP:
- __ movq(Operand(rsp, 0), rax);
- break;
- }
+ DropAndMove(expr->location(), rax);
} else {
// Local or parameter assignment.
@@ -570,14 +566,7 @@
// Restore context register.
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
// Discard the function left on TOS.
- switch (expr->location().type()) {
- case Location::NOWHERE:
- __ addq(rsp, Immediate(kPointerSize));
- break;
- case Location::TEMP:
- __ movq(Operand(rsp, 0), rax);
- break;
- }
+ DropAndMove(expr->location(), rax);
}
@@ -617,14 +606,7 @@
__ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
// Replace function on TOS with result in rax, or pop it.
- switch (node->location().type()) {
- case Location::TEMP:
- __ movq(Operand(rsp, 0), rax);
- break;
- case Location::NOWHERE:
- __ addq(rsp, Immediate(kPointerSize));
- break;
- }
+ DropAndMove(node->location(), rax);
}
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---