Commit 7a25c43a authored by whesse@chromium.org's avatar whesse@chromium.org

Remove stack height tracking from ia32 non-optimizing code generator.

Review URL: http://codereview.chromium.org/8340023

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9857 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d418a11f
......@@ -430,7 +430,6 @@ DEFINE_bool(print_json_ast, false, "print source AST as JSON")
DEFINE_bool(print_builtin_json_ast, false,
"print source AST for builtins as JSON")
DEFINE_string(stop_at, "", "function name where to insert a breakpoint")
DEFINE_bool(verify_stack_height, false, "verify stack height tracing on ia32")
// compiler.cc
DEFINE_bool(print_builtin_scopes, false, "print scopes for builtins")
......
......@@ -410,7 +410,6 @@ void FullCodeGenerator::AccumulatorValueContext::Plug(Register reg) const {
void FullCodeGenerator::StackValueContext::Plug(Register reg) const {
__ push(reg);
codegen()->increment_stack_height();
}
......@@ -424,13 +423,11 @@ void FullCodeGenerator::TestContext::Plug(Register reg) const {
void FullCodeGenerator::EffectContext::PlugTOS() const {
__ Drop(1);
codegen()->decrement_stack_height();
}
void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const {
__ pop(result_register());
codegen()->decrement_stack_height();
}
......@@ -441,7 +438,6 @@ void FullCodeGenerator::StackValueContext::PlugTOS() const {
void FullCodeGenerator::TestContext::PlugTOS() const {
// For simplicity we always test the accumulator register.
__ pop(result_register());
codegen()->decrement_stack_height();
codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
codegen()->DoTest(this);
}
......@@ -979,7 +975,6 @@ void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) {
VisitForStackValue(stmt->expression());
PushFunctionArgumentForContextAllocation();
__ CallRuntime(Runtime::kPushWithContext, 2);
decrement_stack_height();
StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
{ WithOrCatch body(this);
......@@ -1149,13 +1144,10 @@ void FullCodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
// Try block code. Sets up the exception handler chain.
__ bind(&try_handler_setup);
{
const int delta = StackHandlerConstants::kSize / kPointerSize;
TryCatch try_block(this);
__ PushTryHandler(IN_JAVASCRIPT, TRY_CATCH_HANDLER);
increment_stack_height(delta);
Visit(stmt->try_block());
__ PopTryHandler();
decrement_stack_height(delta);
}
__ bind(&done);
}
......@@ -1187,7 +1179,6 @@ void FullCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
// cooked before GC.
Label finally_entry;
Label try_handler_setup;
const int original_stack_height = stack_height();
// Setup the try-handler chain. Use a call to
// Jump to try-handler setup and try-block code. Use call to put try-handler
......@@ -1209,7 +1200,6 @@ void FullCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
// Finally block implementation.
Finally finally_block(this);
EnterFinallyBlock();
set_stack_height(original_stack_height + Finally::kElementCount);
Visit(stmt->finally_block());
ExitFinallyBlock(); // Return to the calling code.
}
......@@ -1217,13 +1207,10 @@ void FullCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
__ bind(&try_handler_setup);
{
// Setup try handler (stack pointer registers).
const int delta = StackHandlerConstants::kSize / kPointerSize;
TryFinally try_block(this, &finally_entry);
__ PushTryHandler(IN_JAVASCRIPT, TRY_FINALLY_HANDLER);
set_stack_height(original_stack_height + delta);
Visit(stmt->try_block());
__ PopTryHandler();
set_stack_height(original_stack_height);
}
// Execute the finally block on the way out. Clobber the unpredictable
// value in the accumulator with one that's safe for GC. The finally
......@@ -1253,7 +1240,6 @@ void FullCodeGenerator::VisitConditional(Conditional* expr) {
__ bind(&true_case);
SetExpressionPosition(expr->then_expression(),
expr->then_expression_position());
int start_stack_height = stack_height();
if (context()->IsTest()) {
const TestContext* for_test = TestContext::cast(context());
VisitForControl(expr->then_expression(),
......@@ -1267,7 +1253,6 @@ void FullCodeGenerator::VisitConditional(Conditional* expr) {
PrepareForBailoutForId(expr->ElseId(), NO_REGISTERS);
__ bind(&false_case);
set_stack_height(start_stack_height);
if (context()->IsTest()) ForwardBailoutToChild(expr);
SetExpressionPosition(expr->else_expression(),
expr->else_expression_position());
......@@ -1308,11 +1293,8 @@ void FullCodeGenerator::VisitSharedFunctionInfoLiteral(
void FullCodeGenerator::VisitThrow(Throw* expr) {
Comment cmnt(masm_, "[ Throw");
// Throw has no effect on the stack height or the current expression context.
// Usually the expression context is null, because throw is a statement.
VisitForStackValue(expr->exception());
__ CallRuntime(Runtime::kThrow, 1);
decrement_stack_height();
// Never returns here.
}
......
......@@ -83,7 +83,6 @@ class FullCodeGenerator: public AstVisitor {
scope_(NULL),
nesting_stack_(NULL),
loop_depth_(0),
stack_height_(0),
context_(NULL),
bailout_entries_(0),
stack_checks_(2), // There's always at least one.
......@@ -534,35 +533,6 @@ class FullCodeGenerator: public AstVisitor {
loop_depth_--;
}
#if defined(V8_TARGET_ARCH_IA32)
int stack_height() { return stack_height_; }
void set_stack_height(int depth) { stack_height_ = depth; }
void increment_stack_height() { stack_height_++; }
void increment_stack_height(int delta) { stack_height_ += delta; }
void decrement_stack_height() {
if (FLAG_verify_stack_height) {
ASSERT(stack_height_ > 0);
}
stack_height_--;
}
void decrement_stack_height(int delta) {
stack_height_-= delta;
if (FLAG_verify_stack_height) {
ASSERT(stack_height_ >= 0);
}
}
// Call this function only if FLAG_verify_stack_height is true.
void verify_stack_height(); // Generates a runtime check of esp - ebp.
#else
int stack_height() { return 0; }
void set_stack_height(int depth) {}
void increment_stack_height() {}
void increment_stack_height(int delta) {}
void decrement_stack_height() {}
void decrement_stack_height(int delta) {}
void verify_stack_height() {}
#endif // V8_TARGET_ARCH_IA32
MacroAssembler* masm() { return masm_; }
class ExpressionContext;
......@@ -625,10 +595,6 @@ class FullCodeGenerator: public AstVisitor {
virtual ~ExpressionContext() {
codegen_->set_new_context(old_);
if (FLAG_verify_stack_height) {
ASSERT_EQ(expected_stack_height_, codegen()->stack_height());
codegen()->verify_stack_height();
}
}
Isolate* isolate() const { return codegen_->isolate(); }
......@@ -682,7 +648,6 @@ class FullCodeGenerator: public AstVisitor {
FullCodeGenerator* codegen() const { return codegen_; }
MacroAssembler* masm() const { return masm_; }
MacroAssembler* masm_;
int expected_stack_height_; // The expected stack height esp - ebp on exit.
private:
const ExpressionContext* old_;
......@@ -692,9 +657,7 @@ class FullCodeGenerator: public AstVisitor {
class AccumulatorValueContext : public ExpressionContext {
public:
explicit AccumulatorValueContext(FullCodeGenerator* codegen)
: ExpressionContext(codegen) {
expected_stack_height_ = codegen->stack_height();
}
: ExpressionContext(codegen) { }
virtual void Plug(bool flag) const;
virtual void Plug(Register reg) const;
......@@ -715,9 +678,7 @@ class FullCodeGenerator: public AstVisitor {
class StackValueContext : public ExpressionContext {
public:
explicit StackValueContext(FullCodeGenerator* codegen)
: ExpressionContext(codegen) {
expected_stack_height_ = codegen->stack_height() + 1;
}
: ExpressionContext(codegen) { }
virtual void Plug(bool flag) const;
virtual void Plug(Register reg) const;
......@@ -746,9 +707,7 @@ class FullCodeGenerator: public AstVisitor {
condition_(condition),
true_label_(true_label),
false_label_(false_label),
fall_through_(fall_through) {
expected_stack_height_ = codegen->stack_height();
}
fall_through_(fall_through) { }
static const TestContext* cast(const ExpressionContext* context) {
ASSERT(context->IsTest());
......@@ -785,10 +744,7 @@ class FullCodeGenerator: public AstVisitor {
class EffectContext : public ExpressionContext {
public:
explicit EffectContext(FullCodeGenerator* codegen)
: ExpressionContext(codegen) {
expected_stack_height_ = codegen->stack_height();
}
: ExpressionContext(codegen) { }
virtual void Plug(bool flag) const;
virtual void Plug(Register reg) const;
......@@ -812,7 +768,6 @@ class FullCodeGenerator: public AstVisitor {
Label return_label_;
NestedStatement* nesting_stack_;
int loop_depth_;
int stack_height_;
const ExpressionContext* context_;
ZoneList<BailoutEntry> bailout_entries_;
ZoneList<BailoutEntry> stack_checks_;
......
This diff is collapsed.
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