Skip to content

Commit 8be2bbb

Browse files
committed
Resolve todos and fix tests
1 parent 50b74b3 commit 8be2bbb

3 files changed

Lines changed: 113 additions & 387 deletions

File tree

zjit/src/hir_effect/gen_hir_effect.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ def to_graphviz type
4545
# Start at Any. All types are subtypes of Any.
4646
any = Type.new "Any"
4747
# Build the effect universe.
48-
frame = any.subtype "Frame"
4948
world = any.subtype "World"
49+
other = world.subtype "Other"
50+
frame = world.subtype "Frame"
5051
pc = frame.subtype "PC"
5152
locals = frame.subtype "Locals"
5253
stack = frame.subtype "Stack"
5354

55+
# Use the smallest unsigned value needed to describe all effect bits
56+
# If it becomes an issue, this can be generated but for now we do it manually
57+
$int_label = "u8"
58+
5459
# Define a new type that can be subclassed (most of them).
5560
# If c_name is given, mark the rb_cXYZ object as equivalent to this exact type.
5661
def base_type name, c_name: nil
@@ -79,13 +84,13 @@ def final_type name, base: $object, c_name: nil
7984

8085
# Assign individual bits to type leaves and union bit patterns to nodes with subtypes
8186
num_bits = 0
82-
$bits = {"None" => ["0u64"]}
87+
$bits = {"None" => ["0#{$int_label}"]}
8388
$numeric_bits = {"None" => 0}
8489
Set[any, *any.all_subtypes].sort_by(&:name).each {|type|
8590
subtypes = type.subtypes
8691
if subtypes.empty?
8792
# Assign bits for leaves
88-
$bits[type.name] = ["1u64 << #{num_bits}"]
93+
$bits[type.name] = ["1#{$int_label} << #{num_bits}"]
8994
$numeric_bits[type.name] = 1 << num_bits
9095
num_bits += 1
9196
else
@@ -116,17 +121,17 @@ def add_union name, type_names
116121
puts "mod bits {"
117122
$bits.keys.sort.map {|type_name|
118123
subtypes = $bits[type_name].join(" | ")
119-
puts " pub const #{type_name}: u64 = #{subtypes};"
124+
puts " pub const #{type_name}: #{$int_label} = #{subtypes};"
120125
}
121-
puts " pub const AllBitPatterns: [(&str, u64); #{$bits.size}] = ["
126+
puts " pub const AllBitPatterns: [(&str, #{$int_label}); #{$bits.size}] = ["
122127
# Sort the bit patterns by decreasing value so that we can print the densest
123128
# possible to-string representation of a Type. For example, CSigned instead of
124129
# CInt8|CInt16|...
125130
$numeric_bits.sort_by {|key, val| -val}.each {|type_name, _|
126131
puts " (\"#{type_name}\", #{type_name}),"
127132
}
128133
puts " ];"
129-
puts " pub const NumEffectBits: u64 = #{num_bits};
134+
puts " pub const NumEffectBits: #{$int_label} = #{num_bits};
130135
}"
131136

132137
puts "pub mod effects {

zjit/src/hir_effect/hir_effect.inc.rs

Lines changed: 13 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)