Reviewers: Lasse Reichstein, Description: Fix memory leaks on x64
This change uses ZoneObject as base class for our jumptable entry. In addition this change refactors the JumpTableEntry a bit. Please review this at http://codereview.chromium.org/6647012/ SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/x64/lithium-codegen-x64.h M src/x64/lithium-codegen-x64.cc Index: src/x64/lithium-codegen-x64.cc =================================================================== --- src/x64/lithium-codegen-x64.cc (revision 7090) +++ src/x64/lithium-codegen-x64.cc (working copy) @@ -259,8 +259,8 @@ bool LCodeGen::GenerateJumpTable() { for (int i = 0; i < jump_table_.length(); i++) { JumpTableEntry* info = jump_table_[i]; - __ bind(&(info->label_)); - __ Jump(info->address_, RelocInfo::RUNTIME_ENTRY); + __ bind(info->label()); + __ Jump(info->address(), RelocInfo::RUNTIME_ENTRY); } return !is_aborted(); } @@ -542,13 +542,14 @@ // We often have several deopts to the same entry, reuse the last // jump entry if this is the case. if (jump_table_.length() > 0 && - jump_table_[jump_table_.length() - 1]->address_ == entry) { + jump_table_[jump_table_.length() - 1]->address() == entry) { jump_info = jump_table_[jump_table_.length() - 1]; } else { - jump_info = new JumpTableEntry(entry); + jump_info = new JumpTableEntry(); + jump_info->SetAddress(entry); jump_table_.Add(jump_info); } - __ j(cc, &jump_info->label_); + __ j(cc, jump_info->label()); } } Index: src/x64/lithium-codegen-x64.h =================================================================== --- src/x64/lithium-codegen-x64.h (revision 7090) +++ src/x64/lithium-codegen-x64.h (working copy) @@ -42,6 +42,7 @@ // Forward declarations. class LDeferredCode; class SafepointGenerator; +class JumpTableEntry; class LCodeGen BASE_EMBEDDED { public: @@ -240,13 +241,6 @@ // Emits code for pushing a constant operand. void EmitPushConstantOperand(LOperand* operand); - struct JumpTableEntry { - inline JumpTableEntry(Address address) - : label_(), - address_(address) { } - Label label_; - Address address_; - }; LChunk* const chunk_; MacroAssembler* const masm_; @@ -275,10 +269,24 @@ friend class LDeferredCode; friend class LEnvironment; friend class SafepointGenerator; + friend class JumpTableEntry; DISALLOW_COPY_AND_ASSIGN(LCodeGen); }; +class JumpTableEntry : public ZoneObject { + public: + explicit JumpTableEntry() : address_(NULL) { } + void SetAddress(Address address) { address_ = address; } + byte* address() { return address_; } + Label* label() { return &label_; } + + private: + Label label_; + byte* address_; +}; + + class LDeferredCode: public ZoneObject { public: explicit LDeferredCode(LCodeGen* codegen) -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
