Skip to content

Commit

Permalink
Introduce AddCheckCastPass
Browse files Browse the repository at this point in the history
Summary: Install time class verification could fail because of missing classes from the base apk. This particular case is when types   voltron modules are being implicitly casted and returned in a method.

Reviewed By: NTillmann

Differential Revision: D50173116

fbshipit-source-id: 93e45ce419027a6920f997ccfbda27d2367fe62b
  • Loading branch information
Jidong Chen authored and facebook-github-bot committed Nov 7, 2023
1 parent ce0d45c commit adc8dc3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
13 changes: 13 additions & 0 deletions libredex/ControlFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3350,3 +3350,16 @@ std::size_t ControlFlowGraph::opcode_hash() const {
}

} // namespace cfg

std::unordered_map<const IRInstruction*, ParamIndex> get_load_param_map(
const cfg::ControlFlowGraph& cfg) {
std::unordered_map<const IRInstruction*, ParamIndex> map;
const auto param_insns = InstructionIterable(cfg.get_param_instructions());
ParamIndex index = 0;
for (auto it = param_insns.begin(); it != param_insns.end(); it++) {
const auto insn = it->insn;
always_assert(opcode::is_a_load_param(insn->opcode()));
map.insert({insn, index++});
}
return map;
}
11 changes: 11 additions & 0 deletions libredex/ControlFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@
*/

extern std::atomic<size_t> build_cfg_counter;
/*
* An index into the list of load-param instructions.
*/
using ParamIndex = uint32_t;

/*
* A helper function that computes the mapping of load param instructions
* to their respective indices.
*/
std::unordered_map<const IRInstruction*, ParamIndex> get_load_param_map(
const cfg::ControlFlowGraph& cfg);

namespace source_blocks {
namespace impl {
Expand Down
1 change: 1 addition & 0 deletions libredex/Trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class DexType;
TM(KOTLIN_INSTANCE) \
TM(KOTLIN_STATS) \
TM(KOTLIN_OBJ_INLINE) \
TM(ACC) \
/* End of list */

enum TraceModule : int {
Expand Down
13 changes: 0 additions & 13 deletions opt/result-propagation/ResultPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,6 @@ class Analyzer final : public BaseIRAnalyzer<ParamDomainEnvironment> {

////////////////////////////////////////////////////////////////////////////////

std::unordered_map<const IRInstruction*, ParamIndex> get_load_param_map(
const cfg::ControlFlowGraph& cfg) {
std::unordered_map<const IRInstruction*, ParamIndex> map;
const auto param_insns = InstructionIterable(cfg.get_param_instructions());
ParamIndex index = 0;
for (auto it = param_insns.begin(); it != param_insns.end(); it++) {
const auto insn = it->insn;
always_assert(opcode::is_a_load_param(insn->opcode()));
map.insert({insn, index++});
}
return map;
}

boost::optional<ParamIndex> ReturnParamResolver::get_return_param_index(
const IRInstruction* insn,
const std::unordered_map<const DexMethod*, ParamIndex>&
Expand Down
12 changes: 0 additions & 12 deletions opt/result-propagation/ResultPropagation.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ namespace cfg {
class ControlFlowGraph;
} // namespace cfg

/*
* An index into the list of load-param instructions.
*/
using ParamIndex = uint32_t;

/*
* A helper function that computes the mapping of load param instructions
* to their respective indices.
*/
std::unordered_map<const IRInstruction*, ParamIndex> get_load_param_map(
const cfg::ControlFlowGraph& cfg);

/*
* A helper class for figuring out whether the regular return value of
* methods and invocations is always a particular incoming parameter.
Expand Down

0 comments on commit adc8dc3

Please sign in to comment.