From 55a78d2d889d921672091dbb70ab645e41423e80 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 8 Apr 2015 11:41:09 -0700 Subject: [PATCH] Bug 1152415 - OdinMonkey: Zero out struct padding to avoid valgrind warnings r=luke --- js/src/asmjs/AsmJSModule.h | 1 + js/src/jit/shared/Assembler-shared.h | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/js/src/asmjs/AsmJSModule.h b/js/src/asmjs/AsmJSModule.h index 13fd3ab48663..629c4b797852 100644 --- a/js/src/asmjs/AsmJSModule.h +++ b/js/src/asmjs/AsmJSModule.h @@ -251,6 +251,7 @@ class AsmJSModule friend class AsmJSModule; Global(Which which, PropertyName* name) { + mozilla::PodZero(&pod); // zero padding for Valgrind pod.which_ = which; name_ = name; MOZ_ASSERT_IF(name_, name_->isTenured()); diff --git a/js/src/jit/shared/Assembler-shared.h b/js/src/jit/shared/Assembler-shared.h index bd19b837b0c2..10e4993f304a 100644 --- a/js/src/jit/shared/Assembler-shared.h +++ b/js/src/jit/shared/Assembler-shared.h @@ -794,27 +794,32 @@ class AsmJSHeapAccess // If 'cmp' equals 'insnOffset' or if it is not supplied then the // cmpDelta_ is zero indicating that there is no length to patch. AsmJSHeapAccess(uint32_t insnOffset, uint32_t after, uint32_t cmp = NoLengthCheck) - : insnOffset_(insnOffset), - opLength_(after - insnOffset), - cmpDelta_(cmp == NoLengthCheck ? 0 : insnOffset - cmp) - {} + { + mozilla::PodZero(this); // zero padding for Valgrind + insnOffset_ = insnOffset; + opLength_ = after - insnOffset; + cmpDelta_ = cmp == NoLengthCheck ? 0 : insnOffset - cmp; + } #elif defined(JS_CODEGEN_X64) // If 'cmp' equals 'insnOffset' or if it is not supplied then the // cmpDelta_ is zero indicating that there is no length to patch. AsmJSHeapAccess(uint32_t insnOffset, WhatToDoOnOOB oob, uint32_t cmp = NoLengthCheck, uint32_t offsetWithinWholeSimdVector = 0) - : insnOffset_(insnOffset), - offsetWithinWholeSimdVector_(offsetWithinWholeSimdVector), - throwOnOOB_(oob == Throw), - cmpDelta_(cmp == NoLengthCheck ? 0 : insnOffset - cmp) { + mozilla::PodZero(this); // zero padding for Valgrind + insnOffset_ = insnOffset; + offsetWithinWholeSimdVector_ = offsetWithinWholeSimdVector; + throwOnOOB_ = oob == Throw; + cmpDelta_ = cmp == NoLengthCheck ? 0 : insnOffset - cmp; MOZ_ASSERT(offsetWithinWholeSimdVector_ == offsetWithinWholeSimdVector); } #elif defined(JS_CODEGEN_ARM) || defined(JS_CODEGEN_MIPS) explicit AsmJSHeapAccess(uint32_t insnOffset) - : insnOffset_(insnOffset) - {} + { + mozilla::PodZero(this); // zero padding for Valgrind + insnOffset_ = insnOffset; + } #endif uint32_t insnOffset() const { return insnOffset_; }