Simplify the processing of deferred code in the code generator. Our

deferred code snippets are highly stylized.  They always make a call
to a stub or the runtime and then return.  This change takes advantage
of that.

Creating a deferred code object now captures a snapshot of the
registers in the virtual frame.  The registers are automatically saved
on entry to the deferred code and restored on exit.

The clients of deferred code must ensure that there is no change to
the registers in the virtual frame (eg, by allocating which can cause
spilling) or to the stack pointer.  That is currently the case.

As a separate change, I will add either code to verify this constraint
or else code to forbid any frame effect.

The deferred code itself does not use the virtual frame or register
allocator (or even the code generator).  It is raw macro assembler
code.
Review URL: http://codereview.chromium.org/118226

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2112 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1e55c821
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_ARM_CODEGEN_ARM_INL_H_
#define V8_ARM_CODEGEN_ARM_INL_H_
namespace v8 {
namespace internal {
#define __ ACCESS_MASM(masm_)
// Platform-specific inline functions.
void DeferredCode::Jump() { __ jmp(&entry_label_); }
void DeferredCode::Branch(Condition cc) { __ b(cc, &entry_label_); }
#undef __
} } // namespace v8::internal
#endif // V8_ARM_CODEGEN_ARM_INL_H_
...@@ -41,6 +41,34 @@ namespace internal { ...@@ -41,6 +41,34 @@ namespace internal {
#define __ ACCESS_MASM(masm_) #define __ ACCESS_MASM(masm_)
// -------------------------------------------------------------------------
// Platform-specific DeferredCode functions.
void DeferredCode::SaveRegisters() {
for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
int action = registers_[i];
if (action == kPush) {
__ push(RegisterAllocator::ToRegister(i));
} else if (action != kIgnore && (action & kSyncedFlag) == 0) {
__ str(RegisterAllocator::ToRegister(i), MemOperand(fp, action));
}
}
}
void DeferredCode::RestoreRegisters() {
// Restore registers in reverse order due to the stack.
for (int i = RegisterAllocator::kNumRegisters - 1; i >= 0; i--) {
int action = registers_[i];
if (action == kPush) {
__ pop(RegisterAllocator::ToRegister(i));
} else if (action != kIgnore) {
action &= ~kSyncedFlag;
__ ldr(RegisterAllocator::ToRegister(i), MemOperand(fp, action));
}
}
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// CodeGenState implementation. // CodeGenState implementation.
...@@ -776,23 +804,14 @@ class DeferredInlineSmiOperation: public DeferredCode { ...@@ -776,23 +804,14 @@ class DeferredInlineSmiOperation: public DeferredCode {
}; };
#undef __
#define __ ACCESS_MASM(masm)
void DeferredInlineSmiOperation::Generate() { void DeferredInlineSmiOperation::Generate() {
MacroAssembler* masm = cgen()->masm();
enter()->Bind();
VirtualFrame::SpilledScope spilled_scope;
switch (op_) { switch (op_) {
case Token::ADD: { case Token::ADD: {
// Revert optimistic add.
if (reversed_) { if (reversed_) {
// revert optimistic add
__ sub(r0, r0, Operand(Smi::FromInt(value_))); __ sub(r0, r0, Operand(Smi::FromInt(value_)));
__ mov(r1, Operand(Smi::FromInt(value_))); __ mov(r1, Operand(Smi::FromInt(value_)));
} else { } else {
// revert optimistic add
__ sub(r1, r0, Operand(Smi::FromInt(value_))); __ sub(r1, r0, Operand(Smi::FromInt(value_)));
__ mov(r0, Operand(Smi::FromInt(value_))); __ mov(r0, Operand(Smi::FromInt(value_)));
} }
...@@ -800,8 +819,8 @@ void DeferredInlineSmiOperation::Generate() { ...@@ -800,8 +819,8 @@ void DeferredInlineSmiOperation::Generate() {
} }
case Token::SUB: { case Token::SUB: {
// Revert optimistic sub.
if (reversed_) { if (reversed_) {
// revert optimistic sub
__ rsb(r0, r0, Operand(Smi::FromInt(value_))); __ rsb(r0, r0, Operand(Smi::FromInt(value_)));
__ mov(r1, Operand(Smi::FromInt(value_))); __ mov(r1, Operand(Smi::FromInt(value_)));
} else { } else {
...@@ -830,31 +849,22 @@ void DeferredInlineSmiOperation::Generate() { ...@@ -830,31 +849,22 @@ void DeferredInlineSmiOperation::Generate() {
__ mov(r1, Operand(r0)); __ mov(r1, Operand(r0));
__ mov(r0, Operand(Smi::FromInt(value_))); __ mov(r0, Operand(Smi::FromInt(value_)));
} else { } else {
UNREACHABLE(); // should have been handled in SmiOperation UNREACHABLE(); // Should have been handled in SmiOperation.
} }
break; break;
} }
default: default:
// other cases should have been handled before this point. // Other cases should have been handled before this point.
UNREACHABLE(); UNREACHABLE();
break; break;
} }
GenericBinaryOpStub igostub(op_, overwrite_mode_); GenericBinaryOpStub stub(op_, overwrite_mode_);
Result arg0 = cgen()->allocator()->Allocate(r1); __ CallStub(&stub);
ASSERT(arg0.is_valid());
Result arg1 = cgen()->allocator()->Allocate(r0);
ASSERT(arg1.is_valid());
cgen()->frame()->CallStub(&igostub, &arg0, &arg1);
exit_.Jump();
} }
#undef __
#define __ ACCESS_MASM(masm_)
void CodeGenerator::SmiOperation(Token::Value op, void CodeGenerator::SmiOperation(Token::Value op,
Handle<Object> value, Handle<Object> value,
bool reversed, bool reversed,
...@@ -877,28 +887,28 @@ void CodeGenerator::SmiOperation(Token::Value op, ...@@ -877,28 +887,28 @@ void CodeGenerator::SmiOperation(Token::Value op,
switch (op) { switch (op) {
case Token::ADD: { case Token::ADD: {
DeferredCode* deferred = DeferredCode* deferred =
new DeferredInlineSmiOperation(op, int_value, reversed, mode); new DeferredInlineSmiOperation(op, int_value, reversed, mode);
__ add(r0, r0, Operand(value), SetCC); __ add(r0, r0, Operand(value), SetCC);
deferred->enter()->Branch(vs); deferred->Branch(vs);
__ tst(r0, Operand(kSmiTagMask)); __ tst(r0, Operand(kSmiTagMask));
deferred->enter()->Branch(ne); deferred->Branch(ne);
deferred->BindExit(); deferred->BindExit();
break; break;
} }
case Token::SUB: { case Token::SUB: {
DeferredCode* deferred = DeferredCode* deferred =
new DeferredInlineSmiOperation(op, int_value, reversed, mode); new DeferredInlineSmiOperation(op, int_value, reversed, mode);
if (!reversed) { if (reversed) {
__ sub(r0, r0, Operand(value), SetCC);
} else {
__ rsb(r0, r0, Operand(value), SetCC); __ rsb(r0, r0, Operand(value), SetCC);
} else {
__ sub(r0, r0, Operand(value), SetCC);
} }
deferred->enter()->Branch(vs); deferred->Branch(vs);
__ tst(r0, Operand(kSmiTagMask)); __ tst(r0, Operand(kSmiTagMask));
deferred->enter()->Branch(ne); deferred->Branch(ne);
deferred->BindExit(); deferred->BindExit();
break; break;
} }
...@@ -909,7 +919,7 @@ void CodeGenerator::SmiOperation(Token::Value op, ...@@ -909,7 +919,7 @@ void CodeGenerator::SmiOperation(Token::Value op,
DeferredCode* deferred = DeferredCode* deferred =
new DeferredInlineSmiOperation(op, int_value, reversed, mode); new DeferredInlineSmiOperation(op, int_value, reversed, mode);
__ tst(r0, Operand(kSmiTagMask)); __ tst(r0, Operand(kSmiTagMask));
deferred->enter()->Branch(ne); deferred->Branch(ne);
switch (op) { switch (op) {
case Token::BIT_OR: __ orr(r0, r0, Operand(value)); break; case Token::BIT_OR: __ orr(r0, r0, Operand(value)); break;
case Token::BIT_XOR: __ eor(r0, r0, Operand(value)); break; case Token::BIT_XOR: __ eor(r0, r0, Operand(value)); break;
...@@ -934,14 +944,14 @@ void CodeGenerator::SmiOperation(Token::Value op, ...@@ -934,14 +944,14 @@ void CodeGenerator::SmiOperation(Token::Value op,
DeferredCode* deferred = DeferredCode* deferred =
new DeferredInlineSmiOperation(op, shift_value, false, mode); new DeferredInlineSmiOperation(op, shift_value, false, mode);
__ tst(r0, Operand(kSmiTagMask)); __ tst(r0, Operand(kSmiTagMask));
deferred->enter()->Branch(ne); deferred->Branch(ne);
__ mov(r2, Operand(r0, ASR, kSmiTagSize)); // remove tags __ mov(r2, Operand(r0, ASR, kSmiTagSize)); // remove tags
switch (op) { switch (op) {
case Token::SHL: { case Token::SHL: {
__ mov(r2, Operand(r2, LSL, shift_value)); __ mov(r2, Operand(r2, LSL, shift_value));
// check that the *unsigned* result fits in a smi // check that the *unsigned* result fits in a smi
__ add(r3, r2, Operand(0x40000000), SetCC); __ add(r3, r2, Operand(0x40000000), SetCC);
deferred->enter()->Branch(mi); deferred->Branch(mi);
break; break;
} }
case Token::SHR: { case Token::SHR: {
...@@ -956,7 +966,7 @@ void CodeGenerator::SmiOperation(Token::Value op, ...@@ -956,7 +966,7 @@ void CodeGenerator::SmiOperation(Token::Value op,
// smi tagging these two cases can only happen with shifts // smi tagging these two cases can only happen with shifts
// by 0 or 1 when handed a valid smi // by 0 or 1 when handed a valid smi
__ and_(r3, r2, Operand(0xc0000000), SetCC); __ and_(r3, r2, Operand(0xc0000000), SetCC);
deferred->enter()->Branch(ne); deferred->Branch(ne);
break; break;
} }
case Token::SAR: { case Token::SAR: {
...@@ -2670,40 +2680,25 @@ class DeferredObjectLiteral: public DeferredCode { ...@@ -2670,40 +2680,25 @@ class DeferredObjectLiteral: public DeferredCode {
}; };
#undef __
#define __ ACCESS_MASM(masm)
void DeferredObjectLiteral::Generate() { void DeferredObjectLiteral::Generate() {
MacroAssembler* masm = cgen()->masm();
// Argument is passed in r1. // Argument is passed in r1.
enter()->Bind();
VirtualFrame::SpilledScope spilled_scope;
// If the entry is undefined we call the runtime system to compute // If the entry is undefined we call the runtime system to compute
// the literal. // the literal.
VirtualFrame* frame = cgen()->frame();
// Literal array (0). // Literal array (0).
frame->EmitPush(r1); __ push(r1);
// Literal index (1). // Literal index (1).
__ mov(r0, Operand(Smi::FromInt(node_->literal_index()))); __ mov(r0, Operand(Smi::FromInt(node_->literal_index())));
frame->EmitPush(r0); __ push(r0);
// Constant properties (2). // Constant properties (2).
__ mov(r0, Operand(node_->constant_properties())); __ mov(r0, Operand(node_->constant_properties()));
frame->EmitPush(r0); __ push(r0);
Result boilerplate = __ CallRuntime(Runtime::kCreateObjectLiteralBoilerplate, 3);
frame->CallRuntime(Runtime::kCreateObjectLiteralBoilerplate, 3); __ mov(r2, Operand(r0));
__ mov(r2, Operand(boilerplate.reg()));
// Result is returned in r2. // Result is returned in r2.
exit_.Jump();
} }
#undef __
#define __ ACCESS_MASM(masm_)
void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) {
#ifdef DEBUG #ifdef DEBUG
int original_height = frame_->height(); int original_height = frame_->height();
...@@ -2729,7 +2724,7 @@ void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { ...@@ -2729,7 +2724,7 @@ void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) {
// Check whether we need to materialize the object literal boilerplate. // Check whether we need to materialize the object literal boilerplate.
// If so, jump to the deferred code. // If so, jump to the deferred code.
__ cmp(r2, Operand(Factory::undefined_value())); __ cmp(r2, Operand(Factory::undefined_value()));
deferred->enter()->Branch(eq); deferred->Branch(eq);
deferred->BindExit(); deferred->BindExit();
// Push the object literal boilerplate. // Push the object literal boilerplate.
...@@ -2807,40 +2802,25 @@ class DeferredArrayLiteral: public DeferredCode { ...@@ -2807,40 +2802,25 @@ class DeferredArrayLiteral: public DeferredCode {
}; };
#undef __
#define __ ACCESS_MASM(masm)
void DeferredArrayLiteral::Generate() { void DeferredArrayLiteral::Generate() {
MacroAssembler* masm = cgen()->masm();
// Argument is passed in r1. // Argument is passed in r1.
enter()->Bind();
VirtualFrame::SpilledScope spilled_scope;
// If the entry is undefined we call the runtime system to computed // If the entry is undefined we call the runtime system to computed
// the literal. // the literal.
VirtualFrame* frame = cgen()->frame();
// Literal array (0). // Literal array (0).
frame->EmitPush(r1); __ push(r1);
// Literal index (1). // Literal index (1).
__ mov(r0, Operand(Smi::FromInt(node_->literal_index()))); __ mov(r0, Operand(Smi::FromInt(node_->literal_index())));
frame->EmitPush(r0); __ push(r0);
// Constant properties (2). // Constant properties (2).
__ mov(r0, Operand(node_->literals())); __ mov(r0, Operand(node_->literals()));
frame->EmitPush(r0); __ push(r0);
Result boilerplate = __ CallRuntime(Runtime::kCreateArrayLiteralBoilerplate, 3);
frame->CallRuntime(Runtime::kCreateArrayLiteralBoilerplate, 3); __ mov(r2, Operand(r0));
__ mov(r2, Operand(boilerplate.reg()));
// Result is returned in r2. // Result is returned in r2.
exit_.Jump();
} }
#undef __
#define __ ACCESS_MASM(masm_)
void CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) { void CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) {
#ifdef DEBUG #ifdef DEBUG
int original_height = frame_->height(); int original_height = frame_->height();
...@@ -2866,7 +2846,7 @@ void CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) { ...@@ -2866,7 +2846,7 @@ void CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) {
// Check whether we need to materialize the object literal boilerplate. // Check whether we need to materialize the object literal boilerplate.
// If so, jump to the deferred code. // If so, jump to the deferred code.
__ cmp(r2, Operand(Factory::undefined_value())); __ cmp(r2, Operand(Factory::undefined_value()));
deferred->enter()->Branch(eq); deferred->Branch(eq);
deferred->BindExit(); deferred->BindExit();
// Push the object literal boilerplate. // Push the object literal boilerplate.
......
...@@ -525,6 +525,8 @@ class VirtualFrame : public ZoneObject { ...@@ -525,6 +525,8 @@ class VirtualFrame : public ZoneObject {
bool Equals(VirtualFrame* other); bool Equals(VirtualFrame* other);
// Classes that need raw access to the elements_ array.
friend class DeferredCode;
friend class JumpTarget; friend class JumpTarget;
}; };
......
...@@ -32,27 +32,21 @@ ...@@ -32,27 +32,21 @@
#include "codegen.h" #include "codegen.h"
#include "register-allocator-inl.h" #include "register-allocator-inl.h"
namespace v8 { #if V8_TARGET_ARCH_IA32
namespace internal { #include "ia32/codegen-ia32-inl.h"
#elif V8_TARGET_ARCH_X64
#include "x64/codegen-x64-inl.h"
void DeferredCode::SetEntryFrame(Result* arg) { #elif V8_TARGET_ARCH_ARM
ASSERT(cgen()->has_valid_frame()); #include "arm/codegen-arm-inl.h"
cgen()->frame()->Push(arg); #else
enter()->set_entry_frame(new VirtualFrame(cgen()->frame())); #error Unsupported target architecture.
*arg = cgen()->frame()->Pop(); #endif
}
void DeferredCode::SetEntryFrame(Result* arg0, Result* arg1) { namespace v8 {
ASSERT(cgen()->has_valid_frame()); namespace internal {
cgen()->frame()->Push(arg0);
cgen()->frame()->Push(arg1);
enter()->set_entry_frame(new VirtualFrame(cgen()->frame()));
*arg1 = cgen()->frame()->Pop();
*arg0 = cgen()->frame()->Pop();
}
#define __ ACCESS_MASM(masm_)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Support for "structured" code comments. // Support for "structured" code comments.
...@@ -64,15 +58,12 @@ void DeferredCode::SetEntryFrame(Result* arg0, Result* arg1) { ...@@ -64,15 +58,12 @@ void DeferredCode::SetEntryFrame(Result* arg0, Result* arg1) {
class Comment BASE_EMBEDDED { class Comment BASE_EMBEDDED {
public: public:
Comment(MacroAssembler* masm, const char* msg) Comment(MacroAssembler* masm, const char* msg) : masm_(masm), msg_(msg) {
: masm_(masm), __ RecordComment(msg);
msg_(msg) {
masm_->RecordComment(msg);
} }
~Comment() { ~Comment() {
if (msg_[0] == '[') if (msg_[0] == '[') __ RecordComment("]");
masm_->RecordComment("]");
} }
private: private:
...@@ -89,6 +80,8 @@ class Comment BASE_EMBEDDED { ...@@ -89,6 +80,8 @@ class Comment BASE_EMBEDDED {
#endif // DEBUG #endif // DEBUG
#undef __
} } // namespace v8::internal } } // namespace v8::internal
......
...@@ -45,33 +45,54 @@ namespace internal { ...@@ -45,33 +45,54 @@ namespace internal {
CodeGenerator* CodeGeneratorScope::top_ = NULL; CodeGenerator* CodeGeneratorScope::top_ = NULL;
DeferredCode::DeferredCode() : exit_(JumpTarget::BIDIRECTIONAL) { DeferredCode::DeferredCode()
MacroAssembler* masm = cgen()->masm(); : masm_(CodeGeneratorScope::Current()->masm()),
statement_position_ = masm->current_statement_position(); statement_position_(masm_->current_statement_position()),
position_ = masm->current_position(); position_(masm_->current_position()) {
ASSERT(statement_position_ != RelocInfo::kNoPosition); ASSERT(statement_position_ != RelocInfo::kNoPosition);
ASSERT(position_ != RelocInfo::kNoPosition); ASSERT(position_ != RelocInfo::kNoPosition);
cgen()->AddDeferred(this); CodeGeneratorScope::Current()->AddDeferred(this);
#ifdef DEBUG #ifdef DEBUG
comment_ = ""; comment_ = "";
#endif #endif
// Copy the register locations from the code generator's frame.
// These are the registers that will be spilled on entry to the
// deferred code and restored on exit.
VirtualFrame* frame = CodeGeneratorScope::Current()->frame();
int sp_offset = frame->fp_relative(frame->stack_pointer_);
for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
int loc = frame->register_location(i);
if (loc == VirtualFrame::kIllegalIndex) {
registers_[i] = kIgnore;
} else if (frame->elements_[loc].is_synced()) {
// Needs to be restored on exit but not saved on entry.
registers_[i] = frame->fp_relative(loc) | kSyncedFlag;
} else {
int offset = frame->fp_relative(loc);
registers_[i] = (offset < sp_offset) ? kPush : offset;
}
}
} }
void CodeGenerator::ProcessDeferred() { void CodeGenerator::ProcessDeferred() {
while (!deferred_.is_empty()) { while (!deferred_.is_empty()) {
DeferredCode* code = deferred_.RemoveLast(); DeferredCode* code = deferred_.RemoveLast();
MacroAssembler* masm = code->cgen()->masm(); ASSERT(masm_ == code->masm());
// Record position of deferred code stub. // Record position of deferred code stub.
masm->RecordStatementPosition(code->statement_position()); masm_->RecordStatementPosition(code->statement_position());
if (code->position() != RelocInfo::kNoPosition) { if (code->position() != RelocInfo::kNoPosition) {
masm->RecordPosition(code->position()); masm_->RecordPosition(code->position());
} }
// Generate the code. // Generate the code.
Comment cmnt(masm, code->comment()); Comment cmnt(masm_, code->comment());
masm_->bind(code->entry_label());
code->SaveRegisters();
code->Generate(); code->Generate();
ASSERT(code->enter()->is_bound()); code->RestoreRegisters();
masm_->jmp(code->exit_label());
} }
} }
......
...@@ -125,29 +125,14 @@ class DeferredCode: public ZoneObject { ...@@ -125,29 +125,14 @@ class DeferredCode: public ZoneObject {
virtual void Generate() = 0; virtual void Generate() = 0;
CodeGenerator* cgen() const { return CodeGeneratorScope::Current(); } MacroAssembler* masm() { return masm_; }
// Set the virtual frame for entry to the deferred code as a
// snapshot of the code generator's current frame (plus additional
// results). This is optional, but should be done before branching
// or jumping to the deferred code.
inline void SetEntryFrame(Result* arg);
inline void SetEntryFrame(Result* arg0, Result* arg1);
JumpTarget* enter() { return &enter_; }
void BindExit() { exit_.Bind(0); }
void BindExit(Result* result) { exit_.Bind(result, 1); }
void BindExit(Result* result0, Result* result1) {
exit_.Bind(result0, result1, 2);
}
void BindExit(Result* result0, Result* result1, Result* result2) {
exit_.Bind(result0, result1, result2, 3);
}
int statement_position() const { return statement_position_; } int statement_position() const { return statement_position_; }
int position() const { return position_; } int position() const { return position_; }
Label* entry_label() { return &entry_label_; }
Label* exit_label() { return &exit_label_; }
#ifdef DEBUG #ifdef DEBUG
void set_comment(const char* comment) { comment_ = comment; } void set_comment(const char* comment) { comment_ = comment; }
const char* comment() const { return comment_; } const char* comment() const { return comment_; }
...@@ -156,13 +141,35 @@ class DeferredCode: public ZoneObject { ...@@ -156,13 +141,35 @@ class DeferredCode: public ZoneObject {
const char* comment() const { return ""; } const char* comment() const { return ""; }
#endif #endif
inline void Jump();
inline void Branch(Condition cc);
void BindExit() { masm_->bind(&exit_label_); }
void SaveRegisters();
void RestoreRegisters();
protected: protected:
JumpTarget enter_; MacroAssembler* masm_;
JumpTarget exit_;
private: private:
// Constants indicating special actions. They should not be multiples
// of kPointerSize so they will not collide with valid offsets from
// the frame pointer.
static const int kIgnore = -1;
static const int kPush = 1;
// This flag is ored with a valid offset from the frame pointer, so
// it should fit in the low zero bits of a valid offset.
static const int kSyncedFlag = 2;
int statement_position_; int statement_position_;
int position_; int position_;
Label entry_label_;
Label exit_label_;
int registers_[RegisterAllocator::kNumRegisters];
#ifdef DEBUG #ifdef DEBUG
const char* comment_; const char* comment_;
#endif #endif
......
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_IA32_CODEGEN_IA32_INL_H_
#define V8_IA32_CODEGEN_IA32_INL_H_
namespace v8 {
namespace internal {
#define __ ACCESS_MASM(masm_)
// Platform-specific inline functions.
void DeferredCode::Jump() { __ jmp(&entry_label_); }
void DeferredCode::Branch(Condition cc) { __ j(cc, &entry_label_); }
#undef __
} } // namespace v8::internal
#endif // V8_IA32_CODEGEN_IA32_INL_H_
This diff is collapsed.
...@@ -545,6 +545,8 @@ class VirtualFrame : public ZoneObject { ...@@ -545,6 +545,8 @@ class VirtualFrame : public ZoneObject {
bool Equals(VirtualFrame* other); bool Equals(VirtualFrame* other);
// Classes that need raw access to the elements_ array.
friend class DeferredCode;
friend class JumpTarget; friend class JumpTarget;
}; };
......
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_X64_CODEGEN_X64_INL_H_
#define V8_X64_CODEGEN_X64_INL_H_
namespace v8 {
namespace internal {
// Platform-specific inline functions.
void DeferredCode::Jump() { UNIMPLEMENTED(); }
void DeferredCode::Branch(Condition cc) { UNIMPLEMENTED(); }
} } // namespace v8::internal
#endif // V8_X64_CODEGEN_X64_INL_H_
...@@ -545,6 +545,8 @@ class VirtualFrame : public ZoneObject { ...@@ -545,6 +545,8 @@ class VirtualFrame : public ZoneObject {
bool Equals(VirtualFrame* other); bool Equals(VirtualFrame* other);
// Classes that need raw access to the elements_ array.
friend class DeferredCode;
friend class JumpTarget; friend class JumpTarget;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment