Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Unified Diff: src/ia32/cfg-ia32.cc

Issue 160584: Add support to the CFG builder for non-short-circuited binary... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cfg.cc ('k') | src/ia32/codegen-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/cfg-ia32.cc
===================================================================
--- src/ia32/cfg-ia32.cc (revision 2620)
+++ src/ia32/cfg-ia32.cc (working copy)
@@ -29,6 +29,7 @@
#include "cfg.h"
#include "codegen-inl.h"
+#include "codegen-ia32.h"
#include "macro-assembler-ia32.h"
namespace v8 {
@@ -42,6 +43,14 @@
{
Comment cmt(masm, "[ InstructionBlock");
for (int i = 0, len = instructions_.length(); i < len; i++) {
+ // If the location of the current instruction is a temp, then the
+ // instruction cannot be in tail position in the block. Allocate the
+ // temp based on peeking ahead to the next instruction.
+ Instruction* instr = instructions_[i];
+ Location* loc = instr->location();
+ if (loc->is_temporary()) {
+ instructions_[i+1]->FastAllocate(TempLocation::cast(loc));
+ }
instructions_[i]->Compile(masm);
}
}
@@ -103,35 +112,123 @@
}
+void BinaryOpInstr::Compile(MacroAssembler* masm) {
+ // The right value should not be on the stack---if it is a
+ // compiler-generated temporary it is in the accumulator.
+ ASSERT(!val1_->is_on_stack());
+
+ // We can overwrite one of the operands if it is a temporary.
+ OverwriteMode mode = NO_OVERWRITE;
+ if (val0_->is_temporary()) {
+ mode = OVERWRITE_LEFT;
+ } else if (val1_->is_temporary()) {
+ mode = OVERWRITE_RIGHT;
+ }
+
+ // Push both operands and call the specialized stub.
+ if (!val0_->is_on_stack()) {
+ val0_->Push(masm);
+ }
+ val1_->Push(masm);
+ GenericBinaryOpStub stub(op_, mode, SMI_CODE_IN_STUB);
+ __ CallStub(&stub);
+ loc_->Set(masm, eax);
+}
+
+
void ReturnInstr::Compile(MacroAssembler* masm) {
+ // The location should be 'Effect'. As a side effect, move the value to
+ // the accumulator.
Comment cmnt(masm, "[ ReturnInstr");
- value_->ToRegister(masm, eax);
+ value_->Get(masm, eax);
}
-void Constant::ToRegister(MacroAssembler* masm, Register reg) {
+void Constant::Get(MacroAssembler* masm, Register reg) {
__ mov(reg, Immediate(handle_));
}
-void SlotLocation::ToRegister(MacroAssembler* masm, Register reg) {
- switch (type_) {
+void Constant::Push(MacroAssembler* masm) {
+ __ push(Immediate(handle_));
+}
+
+
+static Operand ToOperand(SlotLocation* loc) {
+ switch (loc->type()) {
case Slot::PARAMETER: {
int count = CfgGlobals::current()->fun()->scope()->num_parameters();
- __ mov(reg, Operand(ebp, (1 + count - index_) * kPointerSize));
- break;
+ return Operand(ebp, (1 + count - loc->index()) * kPointerSize);
}
case Slot::LOCAL: {
const int kOffset = JavaScriptFrameConstants::kLocal0Offset;
- __ mov(reg, Operand(ebp, kOffset - index_ * kPointerSize));
- break;
+ return Operand(ebp, kOffset - loc->index() * kPointerSize);
}
default:
UNREACHABLE();
+ return Operand(eax);
}
}
+void SlotLocation::Get(MacroAssembler* masm, Register reg) {
+ __ mov(reg, ToOperand(this));
+}
+
+
+void SlotLocation::Set(MacroAssembler* masm, Register reg) {
+ __ mov(ToOperand(this), reg);
+}
+
+
+void SlotLocation::Push(MacroAssembler* masm) {
+ __ push(ToOperand(this));
+}
+
+
+void TempLocation::Get(MacroAssembler* masm, Register reg) {
+ switch (where_) {
+ case ACCUMULATOR:
+ if (!reg.is(eax)) __ mov(reg, eax);
+ break;
+ case STACK:
+ __ pop(reg);
+ break;
+ case NOWHERE:
+ UNREACHABLE();
+ break;
+ }
+}
+
+
+void TempLocation::Set(MacroAssembler* masm, Register reg) {
+ switch (where_) {
+ case ACCUMULATOR:
+ if (!reg.is(eax)) __ mov(eax, reg);
+ break;
+ case STACK:
+ __ push(reg);
+ break;
+ case NOWHERE:
+ UNREACHABLE();
+ break;
+ }
+}
+
+
+void TempLocation::Push(MacroAssembler* masm) {
+ switch (where_) {
+ case ACCUMULATOR:
+ __ push(eax);
+ break;
+ case STACK:
+ case NOWHERE:
+ UNREACHABLE();
+ break;
+ }
+}
+
+
#undef __
} } // namespace v8::internal
« no previous file with comments | « src/cfg.cc ('k') | src/ia32/codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698