Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Opcode enum for efficient Operation type checks
Currently, when determining which concrete operation an instruction uses, Fuzzilli uses the following code pattern: switch instr.op { case is LoadInteger: ... case let op as CallMethod: ... } However, this is inefficient as it will be compiled to code such as: if (dynamicTypeCast(instr.op, LoadInteger)) { // it's a LoadInteger operation } else if (dynamicTypeCast(instr.op, CallMethod)) { // it's a CallMethod operation } else if ... and therefore require roughly linear time (in the number of operations). With this change, there is now a new Opcode enum which allows these switches to be rewritten as: switch instr.op.opcode { case .loadInteger: ... case .callMethod(let op): ... } The code genererated for this switch is efficient as it uses the enum's integer value to index into a jumptable. On a simple benchmark that generates random programs, then lifts them to JavaScript, this change appears to result in a ~1.5x speedup.
- Loading branch information