xpcom/analysis/mayreturn.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 /* May-return analysis.
michael@0 6 * This makes sense only for functions that return a value. The analysis
michael@0 7 * determines the set of variables that may transitively reach the return
michael@0 8 * statement. */
michael@0 9
michael@0 10 function MayReturnAnalysis() {
michael@0 11 BackwardAnalysis.apply(this, arguments);
michael@0 12 // May-return variables. We collect them all here.
michael@0 13 this.vbls = create_decl_set();
michael@0 14 // The return value variable itself
michael@0 15 this.retvar = undefined;
michael@0 16 }
michael@0 17
michael@0 18 MayReturnAnalysis.prototype = new BackwardAnalysis;
michael@0 19
michael@0 20 MayReturnAnalysis.prototype.flowState = function(isn, state) {
michael@0 21 if (TREE_CODE(isn) == GIMPLE_RETURN) {
michael@0 22 let v = return_expr(isn);
michael@0 23 if (!v)
michael@0 24 return;
michael@0 25 if (v.tree_code() == RESULT_DECL) // only an issue with 4.3
michael@0 26 throw new Error("Weird case hit");
michael@0 27 this.vbls.add(v);
michael@0 28 state.add(v);
michael@0 29 this.retvar = v;
michael@0 30 } else if (TREE_CODE(isn) == GIMPLE_ASSIGN) {
michael@0 31 let lhs = gimple_op(isn, 0);
michael@0 32 let rhs = gimple_op(isn, 1);
michael@0 33 if (DECL_P(rhs) && DECL_P(lhs) && state.has(lhs)) {
michael@0 34 this.vbls.add(rhs);
michael@0 35 state.add(rhs);
michael@0 36 }
michael@0 37
michael@0 38 for (let e in isn_defs(isn, 'strong')) {
michael@0 39 if (DECL_P(e)) {
michael@0 40 state.remove(e);
michael@0 41 }
michael@0 42 }
michael@0 43 }
michael@0 44 };

mercurial