Skip to content
Browse files

Add transformation to expand unreferenced sets.

  • Loading branch information...
1 parent b951115 commit 5eb389bf4f11a1eddd5ffe1f221fb6786aebf8ff @whitequark committed Aug 19, 2012
View
5 lib/furnace-avm2/abc/metadata/method_body_info.rb
@@ -42,10 +42,13 @@ def code_to_cfg(options={})
]),
Furnace::AVM2::Transform::LivenessAnalysis.new(idempotent: true),
+
+ Furnace::AVM2::Transform::FoldPassthroughAssignments.new,
Furnace::AVM2::Transform::PropagateConstants.new,
+ Furnace::AVM2::Transform::ExpandUnreferencedSets.new,
+
Furnace::AVM2::Transform::UpdateExceptionVariables.new,
- Furnace::AVM2::Transform::FoldPassthroughAssignments.new,
])
pipeline.run(code, self)
View
1 lib/furnace-avm2/transform.rb
@@ -18,6 +18,7 @@ module Furnace::AVM2::Transform
require_relative "transform/fold_boolean_shortcuts"
require_relative "transform/fold_passthrough_assignments"
require_relative "transform/fold_increment_decrement"
+require_relative "transform/expand_unreferenced_sets"
require_relative "transform/update_exception_variables"
require_relative "transform/cfg_reduce"
require_relative "transform/nf_normalize"
View
30 lib/furnace-avm2/transform/expand_unreferenced_sets.rb
@@ -0,0 +1,30 @@
+module Furnace::AVM2
+ module Transform
+ class ExpandUnreferencedSets
+ def transform(cfg)
+ cfg.nodes.each do |block|
+ block.metadata.sets.each do |id|
+ if !block.metadata.gets.include?(id) &&
+ block.targets.none? { |target|
+ target.metadata.live.include?(id)
+ }
+ set = block.metadata.set_map[id]
+
+ if set.metadata[:write_barrier].empty?
+ block.insns.delete set
+ else
+ _, set_value = set.children
+ set.update(set_value.type,
+ set_value.children)
+ end
+
+ block.metadata.remove_set id
+ end
+ end
+ end
+
+ cfg
+ end
+ end
+ end
+end

0 comments on commit 5eb389b

Please sign in to comment.
Something went wrong with that request. Please try again.