From 6e37e4a3902188ec41c4be05b2f0f0e324afc0cf Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Fri, 27 Feb 2015 10:24:07 +0100 Subject: [PATCH] Bug 1132953 - Zero AsmJSModule::CodeRange and AsmJSModule::ExportedFunction::pod on construction, to avoid Valgrind warnings. r=luke. --HG-- extra : rebase_source : 5dc08d0bd705aca6fbdae6a0a3d208321dcadb9f --- js/src/asmjs/AsmJSModule.cpp | 17 ++++++++++++++--- js/src/asmjs/AsmJSModule.h | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/js/src/asmjs/AsmJSModule.cpp b/js/src/asmjs/AsmJSModule.cpp index 74a8c9da810b..a2299d44bc4f 100644 --- a/js/src/asmjs/AsmJSModule.cpp +++ b/js/src/asmjs/AsmJSModule.cpp @@ -1304,6 +1304,7 @@ AsmJSModule::CodeRange::CodeRange(uint32_t nameIndex, uint32_t lineNumber, profilingReturn_(l.profilingReturn.offset()), end_(l.end.offset()) { + PodZero(&u); // zero padding for Valgrind u.kind_ = Function; setDeltas(l.entry.offset(), l.profilingJump.offset(), l.profilingEpilogue.offset()); @@ -1328,9 +1329,13 @@ AsmJSModule::CodeRange::setDeltas(uint32_t entry, uint32_t profilingJump, uint32 } AsmJSModule::CodeRange::CodeRange(Kind kind, uint32_t begin, uint32_t end) - : begin_(begin), + : nameIndex_(0), + lineNumber_(0), + begin_(begin), + profilingReturn_(0), end_(end) { + PodZero(&u); // zero padding for Valgrind u.kind_ = kind; MOZ_ASSERT(begin_ <= end_); @@ -1338,10 +1343,13 @@ AsmJSModule::CodeRange::CodeRange(Kind kind, uint32_t begin, uint32_t end) } AsmJSModule::CodeRange::CodeRange(Kind kind, uint32_t begin, uint32_t profilingReturn, uint32_t end) - : begin_(begin), + : nameIndex_(0), + lineNumber_(0), + begin_(begin), profilingReturn_(profilingReturn), end_(end) { + PodZero(&u); // zero padding for Valgrind u.kind_ = kind; MOZ_ASSERT(begin_ < profilingReturn_); @@ -1351,10 +1359,13 @@ AsmJSModule::CodeRange::CodeRange(Kind kind, uint32_t begin, uint32_t profilingR AsmJSModule::CodeRange::CodeRange(AsmJSExit::BuiltinKind builtin, uint32_t begin, uint32_t profilingReturn, uint32_t end) - : begin_(begin), + : nameIndex_(0), + lineNumber_(0), + begin_(begin), profilingReturn_(profilingReturn), end_(end) { + PodZero(&u); // zero padding for Valgrind u.kind_ = Thunk; u.thunk.target_ = builtin; diff --git a/js/src/asmjs/AsmJSModule.h b/js/src/asmjs/AsmJSModule.h index 2b95355f0cdf..6d51d8496658 100644 --- a/js/src/asmjs/AsmJSModule.h +++ b/js/src/asmjs/AsmJSModule.h @@ -453,6 +453,7 @@ class AsmJSModule name_ = name; maybeFieldName_ = maybeFieldName; argCoercions_ = mozilla::Move(argCoercions); + mozilla::PodZero(&pod); // zero padding for Valgrind pod.isChangeHeap_ = false; pod.returnType_ = returnType; pod.codeOffset_ = UINT32_MAX; @@ -468,6 +469,7 @@ class AsmJSModule MOZ_ASSERT_IF(maybeFieldName, maybeFieldName->isTenured()); name_ = name; maybeFieldName_ = maybeFieldName; + mozilla::PodZero(&pod); // zero padding for Valgrind pod.isChangeHeap_ = true; pod.startOffsetInModule_ = startOffsetInModule; pod.endOffsetInModule_ = endOffsetInModule; @@ -485,6 +487,7 @@ class AsmJSModule name_ = rhs.name_; maybeFieldName_ = rhs.maybeFieldName_; argCoercions_ = mozilla::Move(rhs.argCoercions_); + mozilla::PodZero(&pod); // zero padding for Valgrind pod = rhs.pod; }