Fix informant compile (#9571)

This commit is contained in:
Wei Tang 2018-09-17 22:16:49 +08:00 committed by Marek Kotewicz
parent a72436f330
commit d04e5e49d0
3 changed files with 7 additions and 9 deletions

View File

@ -45,7 +45,7 @@ macro_rules! enum_with_from_u8 {
enum_with_from_u8! { enum_with_from_u8! {
#[doc = "Virtual machine bytecode instruction."] #[doc = "Virtual machine bytecode instruction."]
#[repr(u8)] #[repr(u8)]
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)] #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug, Hash)]
pub enum Instruction { pub enum Instruction {
#[doc = "halts execution"] #[doc = "halts execution"]
STOP = 0x00, STOP = 0x00,

View File

@ -42,7 +42,7 @@ mod inner {
use ethereum_types::U256; use ethereum_types::U256;
use interpreter::stack::Stack; use interpreter::stack::Stack;
use instructions::{Instruction, InstructionInfo, INSTRUCTIONS}; use instructions::{Instruction, InstructionInfo};
use CostType; use CostType;
macro_rules! evm_debug { macro_rules! evm_debug {
@ -97,7 +97,7 @@ mod inner {
&self.spacing, &self.spacing,
pc, pc,
Self::color(instruction, info.name), Self::color(instruction, info.name),
instruction, instruction as u8,
current_gas, current_gas,
Self::as_micro(&time), Self::as_micro(&time),
)); ));
@ -117,18 +117,16 @@ mod inner {
pub fn done(&mut self) { pub fn done(&mut self) {
// Print out stats // Print out stats
let infos = &*INSTRUCTIONS;
let mut stats: Vec<(_,_)> = self.stats.drain().collect(); let mut stats: Vec<(_,_)> = self.stats.drain().collect();
stats.sort_by(|ref a, ref b| b.1.avg().cmp(&a.1.avg())); stats.sort_by(|ref a, ref b| b.1.avg().cmp(&a.1.avg()));
print(format!("\n{}-------OPCODE STATS:", self.spacing)); print(format!("\n{}-------OPCODE STATS:", self.spacing));
for (instruction, stats) in stats.into_iter() { for (instruction, stats) in stats.into_iter() {
let info = infos[instruction as usize]; let info = instruction.info();
print(format!("{}-------{:>19}(0x{:<2x}) count: {:4}, avg: {:10}μs", print(format!("{}-------{:>19}(0x{:<2x}) count: {:4}, avg: {:10}μs",
self.spacing, self.spacing,
Self::color(instruction, info.name), Self::color(instruction, info.name),
instruction, instruction as u8,
stats.count, stats.count,
stats.avg(), stats.avg(),
)); ));

View File

@ -274,7 +274,7 @@ impl<Cost: CostType> Interpreter<Cost> {
self.gasometer.as_mut().expect(GASOMETER_PROOF).current_mem_gas = requirements.memory_total_gas; self.gasometer.as_mut().expect(GASOMETER_PROOF).current_mem_gas = requirements.memory_total_gas;
self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas = self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas - requirements.gas_cost; self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas = self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas - requirements.gas_cost;
evm_debug!({ informant.before_instruction(reader.position, instruction, info, &self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas, &stack) }); evm_debug!({ self.informant.before_instruction(self.reader.position, instruction, info, &self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas, &self.stack) });
let (mem_written, store_written) = match self.do_trace { let (mem_written, store_written) = match self.do_trace {
true => (Self::mem_written(instruction, &self.stack), Self::store_written(instruction, &self.stack)), true => (Self::mem_written(instruction, &self.stack), Self::store_written(instruction, &self.stack)),
@ -287,7 +287,7 @@ impl<Cost: CostType> Interpreter<Cost> {
current_gas, ext, instruction, requirements.provide_gas current_gas, ext, instruction, requirements.provide_gas
)?; )?;
evm_debug!({ informant.after_instruction(instruction) }); evm_debug!({ self.informant.after_instruction(instruction) });
if let InstructionResult::UnusedGas(ref gas) = result { if let InstructionResult::UnusedGas(ref gas) = result {
self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas = self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas + *gas; self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas = self.gasometer.as_mut().expect(GASOMETER_PROOF).current_gas + *gas;