Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate types through blocks when they are called or escape. #2597

Merged
merged 8 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading