Author: [email protected]
Date: Wed Feb 4 06:06:41 2009
New Revision: 1226
Modified:
branches/experimental/toiger/src/codegen-ia32.cc
branches/experimental/toiger/src/virtual-frame-ia32.cc
Log:
Remove spills from compound assignment statements
Modified: branches/experimental/toiger/src/codegen-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/codegen-ia32.cc (original)
+++ branches/experimental/toiger/src/codegen-ia32.cc Wed Feb 4 06:06:41
2009
@@ -3136,26 +3136,34 @@
frame_->Push(Smi::FromInt(0));
return;
}
+ Variable* var = node->target()->AsVariableProxy()->AsVariable();
if (node->op() == Token::ASSIGN ||
node->op() == Token::INIT_VAR ||
node->op() == Token::INIT_CONST) {
Load(node->value());
-
} else {
- VirtualFrame::SpilledScope spilled_scope(this);
- target.GetValueAndSpill(NOT_INSIDE_TYPEOF);
Literal* literal = node->value()->AsLiteral();
+ Variable* right_var = node->value()->AsVariableProxy()->AsVariable();
+ // There are two cases where the target is not read in the right hand
+ // side, that are easy to test for: the right hand side is a literal,
+ // or the right hand side is a different variable. TakeValue
invalidates
+ // the target, with an implicit promise that it will be written to
again
+ // before it is read.
+ if (literal != NULL || (right_var != NULL && right_var != var)) {
+ target.TakeValue(NOT_INSIDE_TYPEOF);
+ } else {
+ target.GetValue(NOT_INSIDE_TYPEOF);
+ }
if (IsInlineSmi(literal)) {
SmiOperation(node->binary_op(), node->type(), literal->handle(),
false,
NO_OVERWRITE);
} else {
- LoadAndSpill(node->value());
+ Load(node->value());
GenericBinaryOperation(node->binary_op(), node->type());
}
}
- Variable* var = node->target()->AsVariableProxy()->AsVariable();
if (var != NULL &&
var->mode() == Variable::CONST &&
node->op() != Token::INIT_VAR && node->op() != Token::INIT_CONST) {
Modified: branches/experimental/toiger/src/virtual-frame-ia32.cc
==============================================================================
--- branches/experimental/toiger/src/virtual-frame-ia32.cc (original)
+++ branches/experimental/toiger/src/virtual-frame-ia32.cc Wed Feb 4
06:06:41 2009
@@ -170,9 +170,11 @@
// Spill an element, making its type be MEMORY.
// Does not decrement usage counts, if element is a register.
void VirtualFrame::RawSpillElementAt(int index) {
- SyncElementAt(index);
- // The element is now in memory.
- elements_[index] = FrameElement::MemoryElement();
+ if (elements_[index].is_valid()) {
+ SyncElementAt(index);
+ // The element is now in memory.
+ elements_[index] = FrameElement::MemoryElement();
+ }
}
@@ -190,8 +192,7 @@
// element below the stack pointer (created by a single push).
void VirtualFrame::RawSyncElementAt(int index) {
FrameElement element = elements_[index];
-
- if (!element.is_synced()) {
+ if (element.is_valid() && !element.is_synced()) {
if (index <= stack_pointer_) {
// Write elements below the stack pointer to their (already
allocated)
// actual frame location.
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---