Intro
作为一名算法工程师,在我的工作中经常都会写各种 Python 脚本来处理大量数据,做数据清洗、信息提取等。通常情况下,这些数据的处理并不涉及竞争条件(Race Condition),而是简单的数据并行(Data Parallel),属于 CPU 密集型任务。通常情况下,这样的任务可以被抽象为 map(fn, data)
的模式
对于 OOP 语言来说,搭建调用图的核心问题是有多态的场景下如何确定到底是哪一个方法被调用了,下面是 Java 的一些可能的函数调用 1
Static Call | Special Call | Virtual Call | |
---|---|---|---|
Instruction | invokestatic |
invokespecial |
invokeinterface, invokevirtual |
Receiver Objects | ❌ | ✅ | ✅ |
Target Methods | Static Method | Constructor, Private Instance Method, Superclass Instance Method | Other Instance Method |
Count of Possible Target Methods | 1 | 1 | $\ge 1$ (polymorphism) |
Determinancy | Compile-time | Compile-time | Run-time |
其中 Virtual Call 因为包含了多态,方法调用存在多个可能的目标方法