Skip to content

Commit

Permalink
Propagate types through blocks when they are called or escape. (#2597)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperl authored Oct 23, 2024
1 parent f1915e4 commit bfb1b64
Show file tree
Hide file tree
Showing 19 changed files with 1,688 additions and 102 deletions.
8 changes: 3 additions & 5 deletions src/compiler/propagation/concrete_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class ConcreteType {
explicit ConcreteType(unsigned id)
: data_((id << 1) | 1) {}

explicit ConcreteType(BlockTemplate* block)
: data_(reinterpret_cast<uword>(block)) {}

static ConcreteType any() { return ConcreteType(); }

bool is_block() const {
Expand Down Expand Up @@ -72,11 +75,6 @@ class ConcreteType {
uword data_;

ConcreteType() : data_(ANY) {}

explicit ConcreteType(BlockTemplate* block)
: data_(reinterpret_cast<uword>(block)) {}

friend class BlockTemplate;
};

} // namespace toit::compiler
Expand Down
7 changes: 6 additions & 1 deletion src/compiler/propagation/type_primitive_encoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ MODULE_TYPES(encoding, MODULE_ENCODING)

TYPE_PRIMITIVE_ANY(base64_encode)
TYPE_PRIMITIVE_ANY(base64_decode)
TYPE_PRIMITIVE_ANY(tison_encode)
TYPE_PRIMITIVE_ANY(tison_decode)

TYPE_PRIMITIVE(tison_encode) {
result.add_byte_array(program);
failure.add_string(program);
failure.add_array(program);
}

} // namespace toit::compiler
} // namespace toit
7 changes: 6 additions & 1 deletion src/compiler/propagation/type_primitive_programs_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ namespace compiler {
MODULE_TYPES(programs_registry, MODULE_PROGRAMS_REGISTRY)

TYPE_PRIMITIVE_ANY(next_group_id)
TYPE_PRIMITIVE_ANY(spawn)
TYPE_PRIMITIVE_ANY(is_running)
TYPE_PRIMITIVE_ANY(kill)
TYPE_PRIMITIVE_ANY(bundled_images)
TYPE_PRIMITIVE_ANY(assets)
TYPE_PRIMITIVE_ANY(config)

TYPE_PRIMITIVE(spawn) {
result.add_smi(program);
failure.add_string(program);
failure.add_array(program);
}

} // namespace toit::compiler
} // namespace toit
Loading

0 comments on commit bfb1b64

Please sign in to comment.