From 7783cc48fd195ce2d2bbbc73c308d25a1c5ad033 Mon Sep 17 00:00:00 2001 From: "ricow@chromium.org" Date: Wed, 9 Mar 2011 10:02:47 +0000 Subject: [PATCH] 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. Review URL: http://codereview.chromium.org/6647012 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7095 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/lithium-codegen-x64.cc | 18 +++++++----------- src/x64/lithium-codegen-x64.h | 12 ++++++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index c5124a0..e1cd458 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -258,9 +258,9 @@ LInstruction* LCodeGen::GetNextInstruction() { 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); + JumpTableEntry* info = &jump_table_[i]; + __ bind(&jump_table_[i].label); + __ Jump(info->address, RelocInfo::RUNTIME_ENTRY); } return !is_aborted(); } @@ -538,17 +538,13 @@ void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) { if (cc == no_condition) { __ Jump(entry, RelocInfo::RUNTIME_ENTRY); } else { - JumpTableEntry* jump_info = NULL; // 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_info = jump_table_[jump_table_.length() - 1]; - } else { - jump_info = new JumpTableEntry(entry); - jump_table_.Add(jump_info); + if (jump_table_.is_empty() || + jump_table_.last().address != entry) { + jump_table_.Add(entry); } - __ j(cc, &jump_info->label_); + __ j(cc, &jump_table_.last().label); } } diff --git a/src/x64/lithium-codegen-x64.h b/src/x64/lithium-codegen-x64.h index 8b49759..d2bde6f 100644 --- a/src/x64/lithium-codegen-x64.h +++ b/src/x64/lithium-codegen-x64.h @@ -241,11 +241,11 @@ class LCodeGen BASE_EMBEDDED { void EmitPushConstantOperand(LOperand* operand); struct JumpTableEntry { - inline JumpTableEntry(Address address) - : label_(), - address_(address) { } - Label label_; - Address address_; + inline JumpTableEntry(Address entry) + : label(), + address(entry) { } + Label label; + Address address; }; LChunk* const chunk_; @@ -256,7 +256,7 @@ class LCodeGen BASE_EMBEDDED { int current_instruction_; const ZoneList* instructions_; ZoneList deoptimizations_; - ZoneList jump_table_; + ZoneList jump_table_; ZoneList > deoptimization_literals_; int inlined_function_count_; Scope* const scope_; -- 2.7.4