Class: Optimize::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/optimize/log.rb

Defined Under Namespace

Classes: Entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLog

Returns a new instance of Log.



7
8
9
10
11
# File 'lib/optimize/log.rb', line 7

def initialize
  @entries = []
  @rewrite_count = 0
  @convergence = {}
end

Instance Attribute Details

#convergenceObject (readonly)

Returns the value of attribute convergence.



17
18
19
# File 'lib/optimize/log.rb', line 17

def convergence
  @convergence
end

#rewrite_countObject (readonly)

Returns the value of attribute rewrite_count.



17
18
19
# File 'lib/optimize/log.rb', line 17

def rewrite_count
  @rewrite_count
end

Instance Method Details

#entriesObject



13
14
15
# File 'lib/optimize/log.rb', line 13

def entries
  @entries.dup.freeze
end

#for_pass(pass) ⇒ Object



37
38
39
# File 'lib/optimize/log.rb', line 37

def for_pass(pass)
  @entries.select { |e| e.pass == pass }
end

#record_convergence(function_key, iterations) ⇒ Object



33
34
35
# File 'lib/optimize/log.rb', line 33

def record_convergence(function_key, iterations)
  @convergence[function_key] = iterations
end

#rewrite(pass:, reason:, file:, line:) ⇒ Object

An optimization site that actually rewrote IR. Feeds fixed-point termination via rewrite_count.



21
22
23
24
# File 'lib/optimize/log.rb', line 21

def rewrite(pass:, reason:, file:, line:)
  @entries << Entry.new(pass: pass, reason: reason, file: file, line: line)
  @rewrite_count += 1
end

#skip(pass:, reason:, file:, line:) ⇒ Object

An optimization site that declined to rewrite. Does NOT count toward rewrite_count — fixed-point iteration must not treat a decline as a change.



29
30
31
# File 'lib/optimize/log.rb', line 29

def skip(pass:, reason:, file:, line:)
  @entries << Entry.new(pass: pass, reason: reason, file: file, line: line)
end