Fast codegen: Implement with.
Review URL: http://codereview.chromium.org/491077 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3473 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
bb0431b097
commit
482d434f4d
@ -1690,28 +1690,43 @@ void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
|
||||
|
||||
Register FastCodeGenerator::result_register() { return r0; }
|
||||
|
||||
|
||||
Register FastCodeGenerator::context_register() { return cp; }
|
||||
|
||||
|
||||
void FastCodeGenerator::StoreToFrameField(int frame_offset, Register value) {
|
||||
ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset);
|
||||
__ str(value, MemOperand(fp, frame_offset));
|
||||
}
|
||||
|
||||
|
||||
void FastCodeGenerator::LoadContextField(Register dst, int context_index) {
|
||||
__ ldr(dst, CodeGenerator::ContextOperand(cp, context_index));
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Non-local control flow support.
|
||||
|
||||
void FastCodeGenerator::EnterFinallyBlock() {
|
||||
ASSERT(!result_register().is(r1));
|
||||
// Store result register while executing finally block.
|
||||
__ push(result_register());
|
||||
// Cook return address in link register to stack (smi encoded Code* delta)
|
||||
__ sub(r1, lr, Operand(masm_->CodeObject()));
|
||||
ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize);
|
||||
ASSERT_EQ(0, kSmiTag);
|
||||
__ add(r1, r1, Operand(r1)); // Convert to smi.
|
||||
__ push(r1);
|
||||
// Store result register while executing finally block.
|
||||
__ push(result_register());
|
||||
}
|
||||
|
||||
|
||||
void FastCodeGenerator::ExitFinallyBlock() {
|
||||
ASSERT(!result_register().is(r1));
|
||||
// Restore result register from stack.
|
||||
__ pop(result_register());
|
||||
// Uncook return address and return.
|
||||
__ pop(r1);
|
||||
// Uncook return address and return.
|
||||
__ pop(result_register());
|
||||
ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize);
|
||||
__ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value.
|
||||
__ add(pc, r1, Operand(masm_->CodeObject()));
|
||||
|
@ -703,12 +703,12 @@ void CodeGenSelector::VisitReturnStatement(ReturnStatement* stmt) {
|
||||
|
||||
|
||||
void CodeGenSelector::VisitWithEnterStatement(WithEnterStatement* stmt) {
|
||||
BAILOUT("WithEnterStatement");
|
||||
ProcessExpression(stmt->expression(), Expression::kValue);
|
||||
}
|
||||
|
||||
|
||||
void CodeGenSelector::VisitWithExitStatement(WithExitStatement* stmt) {
|
||||
BAILOUT("WithExitStatement");
|
||||
// Supported.
|
||||
}
|
||||
|
||||
|
||||
|
@ -337,12 +337,31 @@ void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
|
||||
|
||||
|
||||
void FastCodeGenerator::VisitWithEnterStatement(WithEnterStatement* stmt) {
|
||||
UNREACHABLE();
|
||||
Comment cmnt(masm_, "[ WithEnterStatement");
|
||||
SetStatementPosition(stmt);
|
||||
|
||||
Visit(stmt->expression());
|
||||
if (stmt->is_catch_block()) {
|
||||
__ CallRuntime(Runtime::kPushCatchContext, 1);
|
||||
} else {
|
||||
__ CallRuntime(Runtime::kPushContext, 1);
|
||||
}
|
||||
// Both runtime calls return the new context in both the context and the
|
||||
// result registers.
|
||||
|
||||
// Update local stack frame context field.
|
||||
StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
|
||||
}
|
||||
|
||||
|
||||
void FastCodeGenerator::VisitWithExitStatement(WithExitStatement* stmt) {
|
||||
UNREACHABLE();
|
||||
Comment cmnt(masm_, "[ WithExitStatement");
|
||||
SetStatementPosition(stmt);
|
||||
|
||||
// Pop context.
|
||||
LoadContextField(context_register(), Context::PREVIOUS_INDEX);
|
||||
// Update local stack frame context field.
|
||||
StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,6 +291,15 @@ class FastCodeGenerator: public AstVisitor {
|
||||
|
||||
MacroAssembler* masm() { return masm_; }
|
||||
static Register result_register();
|
||||
static Register context_register();
|
||||
|
||||
// Set fields in the stack frame. Offsets are the frame pointer relative
|
||||
// offsets defined in, e.g., StandardFrameConstants.
|
||||
void StoreToFrameField(int frame_offset, Register value);
|
||||
|
||||
// Load a value from the current context. Indices are defined as an enum
|
||||
// in v8::internal::Context.
|
||||
void LoadContextField(Register dst, int context_index);
|
||||
|
||||
// AST node visit functions.
|
||||
#define DECLARE_VISIT(type) virtual void Visit##type(type* node);
|
||||
|
@ -1665,6 +1665,21 @@ void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
|
||||
|
||||
Register FastCodeGenerator::result_register() { return eax; }
|
||||
|
||||
|
||||
Register FastCodeGenerator::context_register() { return esi; }
|
||||
|
||||
|
||||
void FastCodeGenerator::StoreToFrameField(int frame_offset, Register value) {
|
||||
ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset);
|
||||
__ mov(Operand(ebp, frame_offset), value);
|
||||
}
|
||||
|
||||
|
||||
void FastCodeGenerator::LoadContextField(Register dst, int context_index) {
|
||||
__ mov(dst, CodeGenerator::ContextOperand(esi, context_index));
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Non-local control flow support.
|
||||
|
||||
|
@ -1671,6 +1671,22 @@ void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
|
||||
|
||||
Register FastCodeGenerator::result_register() { return rax; }
|
||||
|
||||
|
||||
Register FastCodeGenerator::context_register() { return rsi; }
|
||||
|
||||
|
||||
void FastCodeGenerator::StoreToFrameField(int frame_offset, Register value) {
|
||||
ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset),
|
||||
static_cast<intptr_t>(frame_offset));
|
||||
__ movq(Operand(rbp, frame_offset), value);
|
||||
}
|
||||
|
||||
|
||||
void FastCodeGenerator::LoadContextField(Register dst, int context_index) {
|
||||
__ movq(dst, CodeGenerator::ContextOperand(rsi, context_index));
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Non-local control flow support.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user