Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions actuator/src/main/java/org/tron/core/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ public static void play(Program program, JumpTable jumpTable) {
try {
long factor = DYNAMIC_ENERGY_FACTOR_DECIMAL;
long energyUsage = 0L;
// hoist once per execution: avoids a per-opcode VMConfig.current() thread-local lookup
final boolean allowDynamicEnergy = VMConfig.allowDynamicEnergy();

if (VMConfig.allowDynamicEnergy()) {
if (allowDynamicEnergy) {
factor = program.updateContextContractFactor();
}

Expand All @@ -47,7 +49,7 @@ public static void play(Program program, JumpTable jumpTable) {
String opName = Op.getNameOf(op.getOpcode());
/* spend energy before execution */
long energy = op.getEnergyCost(program);
if (VMConfig.allowDynamicEnergy()) {
if (allowDynamicEnergy) {
long actualEnergy = energy;
// CALL Ops have special calculation on energy.
if (CALL_OPS.contains(op.getOpcode())) {
Expand Down Expand Up @@ -101,7 +103,7 @@ public static void play(Program program, JumpTable jumpTable) {
}
}

if (VMConfig.allowDynamicEnergy()) {
if (allowDynamicEnergy) {
program.addContextContractUsage(energyUsage);
}

Expand Down
Loading