| Index: src/full-codegen.h
|
| diff --git a/src/full-codegen.h b/src/full-codegen.h
|
| index 148d0c02de2736cc27149e3b6c2be654ffdd86d9..16f484d9c83675b9a55502a1445fd120938d91da 100644
|
| --- a/src/full-codegen.h
|
| +++ b/src/full-codegen.h
|
| @@ -20,6 +20,34 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| +#if defined(COMPARE_OPT_STACK_HEIGHT)
|
| +
|
| +class StackHeightWrapper {
|
| + public:
|
| + StackHeightWrapper() : stack_height_(0) { }
|
| +
|
| + void updateBy(int incrementBy) {
|
| + stack_height_ += incrementBy;
|
| + ASSERT(stack_height_ >= 0);
|
| + }
|
| +
|
| + int get() const { return stack_height_; }
|
| +
|
| + private:
|
| + int stack_height_;
|
| +};
|
| +
|
| +#else
|
| +
|
| +class StackHeightWrapper {
|
| + public:
|
| + StackHeightWrapper() { }
|
| + void updateBy(int incrementBy) { }
|
| + int get() const { return 0; }
|
| +};
|
| +
|
| +#endif // defined(COMPARE_OPT_STACK_HEIGHT)
|
| +
|
| // Forward declarations.
|
| class JumpPatchSite;
|
|
|
| @@ -155,6 +183,8 @@ class FullCodeGenerator: public AstVisitor {
|
| }
|
|
|
| protected:
|
| + FullCodeGenerator* codegen() { return codegen_; }
|
| +
|
| MacroAssembler* masm() { return codegen_->masm(); }
|
|
|
| FullCodeGenerator* codegen_;
|
| @@ -565,6 +595,72 @@ class FullCodeGenerator: public AstVisitor {
|
| void SetStatementPosition(int pos);
|
| void SetSourcePosition(int pos);
|
|
|
| + void AsmPush(Register reg) {
|
| + masm()->push(reg);
|
| + UpdateStackHeight(1);
|
| + }
|
| +
|
| + void AsmPush(const Operand& op);
|
| +
|
| + void AsmPushHandle(Handle<Object> handle) {
|
| + masm()->Push(handle);
|
| + UpdateStackHeight(1);
|
| + }
|
| +
|
| + void AsmPushSmi(Smi* smi) {
|
| + masm()->Push(smi);
|
| + UpdateStackHeight(1);
|
| + }
|
| +
|
| + void AsmPop(Register reg) {
|
| + masm()->pop(reg);
|
| + UpdateStackHeight(-1);
|
| + }
|
| +
|
| + void AsmInvokeBuiltin(Builtins::JavaScript id,
|
| + InvokeFlag flag,
|
| + int arg_count,
|
| + const CallWrapper& call_wrapper = NullCallWrapper()) {
|
| + masm()->InvokeBuiltin(id, flag, call_wrapper);
|
| + UpdateStackHeight(-arg_count);
|
| + }
|
| +
|
| + void AsmDrop(int n) {
|
| + masm()->Drop(n);
|
| + UpdateStackHeight(-n);
|
| + }
|
| +
|
| + void AsmCallRuntime(const Runtime::Function* f,
|
| + int num_arguments,
|
| + SaveFPRegsMode save_doubles = kDontSaveFPRegs) {
|
| + masm()->CallRuntime(f, num_arguments, save_doubles);
|
| + UpdateStackHeight(-num_arguments);
|
| + }
|
| +
|
| + void AsmCallRuntime(Runtime::FunctionId id,
|
| + int num_arguments,
|
| + SaveFPRegsMode save_doubles = kDontSaveFPRegs) {
|
| + masm()->CallRuntime(id, num_arguments, save_doubles);
|
| + UpdateStackHeight(-num_arguments);
|
| + }
|
| +
|
| + void AsmPushTryHandler(StackHandler::Kind kind, int handler_index) {
|
| + masm()->PushTryHandler(kind, handler_index);
|
| + UpdateStackHeight(StackHandlerConstants::kSize / kPointerSize);
|
| + }
|
| +
|
| + void AsmPopTryHandler() {
|
| + masm()->PopTryHandler();
|
| + UpdateStackHeight(-StackHandlerConstants::kSize / kPointerSize);
|
| + }
|
| +
|
| + // Call a code stub. Generate the code if necessary.
|
| + void AsmCallStub(CodeStub* stub,
|
| + int arg_count) {
|
| + masm()->CallStub(stub);
|
| + UpdateStackHeight(-arg_count);
|
| + }
|
| +
|
| // Non-local control flow support.
|
| void EnterFinallyBlock();
|
| void ExitFinallyBlock();
|
| @@ -625,6 +721,7 @@ class FullCodeGenerator: public AstVisitor {
|
| struct BailoutEntry {
|
| BailoutId id;
|
| unsigned pc_and_state;
|
| + int stack_height;
|
| };
|
|
|
| struct BackEdgeEntry {
|
| @@ -809,12 +906,35 @@ class FullCodeGenerator: public AstVisitor {
|
| virtual bool IsEffect() const { return true; }
|
| };
|
|
|
| + void CheckStackHeight() {
|
| +#if defined(VERIFY_STACK_HEIGHT)
|
| + AddStackHeightVerifier();
|
| +#endif // defined(VERIFY_STACK_HEIGHT)
|
| + }
|
| +
|
| + void UpdateStackHeight(int difference) {
|
| + stack_height_.updateBy(difference);
|
| + }
|
| +
|
| + void SetStackHeight(StackHeightWrapper height) {
|
| + stack_height_ = height;
|
| + }
|
| +
|
| + StackHeightWrapper CurrentStackHeight() {
|
| + return stack_height_;
|
| + }
|
| +
|
| +#if defined(VERIFY_STACK_HEIGHT)
|
| + void AddStackHeightVerifier();
|
| +#endif // defined(VERIFY_STACK_HEIGHT)
|
| +
|
| MacroAssembler* masm_;
|
| CompilationInfo* info_;
|
| Scope* scope_;
|
| Label return_label_;
|
| NestedStatement* nesting_stack_;
|
| int loop_depth_;
|
| + StackHeightWrapper stack_height_;
|
| ZoneList<Handle<Object> >* globals_;
|
| Handle<FixedArray> modules_;
|
| int module_index_;
|
|
|