Skip to content

[WIP] Serialize local functions inside transparent functions #1814

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

Closed

Conversation

slavapestov
Copy link
Contributor

No description provided.

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov force-pushed the serialize-transparent branch from e1a26ff to 89125ff Compare March 23, 2016 22:25
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

auto Tuple = static_cast<const TupleTypeMetadata *>(type);
return Tuple->NumElements;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this reordering intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is in its own patch. Unless I'm missing something the old ordering was a mistake?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels more natural to put the tuple functions together, after the '// -- Tuple destructuring.' section. Previously swift_TupleMirror_count came first, then some other unrelated functions, then the rest of the TupleMirror stuff.

If you prefer I can drop this patch, it's not related to anything else in the series. Arguably moving code around destroys 'git blame' history, but I have some other changes to this file that are not yet committed, so I decided to fix this nit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, it's fine. Just wondering why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's so much harder to make your code look good when the language doesn't enforce bottom-up function order ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the generative approach to declarations in ML family languages is so much more elegant than this multi-pass declarative crap

@slavapestov slavapestov force-pushed the serialize-transparent branch from 89125ff to b939500 Compare March 23, 2016 23:03
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov force-pushed the serialize-transparent branch from b939500 to 24ac970 Compare March 24, 2016 02:24
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov force-pushed the serialize-transparent branch from 24ac970 to b4ed608 Compare March 24, 2016 04:32
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov force-pushed the serialize-transparent branch from b4ed608 to dc29e3c Compare March 24, 2016 04:59
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov force-pushed the serialize-transparent branch 2 times, most recently from 21a6693 to 38f9841 Compare March 24, 2016 06:56
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov force-pushed the serialize-transparent branch from 38f9841 to ed8974d Compare March 24, 2016 06:58
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

…il-serialize-all

When we're not serializing SIL for all function bodies, @_transparent
functions can only reference internal functions that are declared
@_versioned, otherwise there's no serialized body and no public entry
point, so any client that inlines the @_transparent function will
not be able to link.

This patch adds the minimum set of @_versioned declarations to allow
a non-optimized build of the standard library and overlays.

Recall that this attribute is just a temporary hack to make progress
on building the standard library with resilience enabled.

Once availability and resilience learn about each other, @_versioned
will be replaced by having an availability annotation on an internal
declaration. Invariants will be diagnosed by Sema instead of asserting
in the SIL verifier.

Finally, the set of "internal but available" declarations will
eventually be audited instead of determined by experimentation.

This almost closes out https://bugs.swift.org/browse/SR-267.

The remaining issue is an interaction between SIL optimizations and
serialization that will be fixed with some upcoming changes to the
optimizer.
The original SILFunction may be [fragile] because it came from
an imported module, or maybe it was [fragile] because it was
declared @_transparent by the user.

Furthermore, the devirtualizer can devirtualize calls inside
[fragile] functions, pointing them at  non-fragile functions.

FIXME: For resilience, we cannot devirtualize this stuff anyway.
Instead, try to not set [fragile] on clones unless needed.
Let's abuse the [thunk] attribute to mean "serialize the body of this
function but only if it is referenced from a [fragile] function."
@slavapestov slavapestov force-pushed the serialize-transparent branch from ed8974d to daed4b3 Compare March 24, 2016 09:12
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

Note to self:

    Swift :: 1_stdlib/BridgeNonVerbatim.swift
    Swift :: 1_stdlib/Builtins.swift
    Swift :: 1_stdlib/RuntimeObjC.swift
    Swift :: 1_stdlib/SpriteKit.swift
    Swift :: DebugInfo/specialization.swift
    Swift :: IRGen/enum_derived.swift
    Swift :: IRGen/runtime_calling_conventions.swift
    Swift :: IRGen/vector_reduction.swift
    Swift :: SIL/Serialization/shared_function_serialization.sil
    Swift :: SIL/Serialization/specializer_can_deserialize.swift
    Swift :: SIL/parse_stdlib_0.sil
    Swift :: SIL/parse_stdlib_1.sil
    Swift :: SIL/parse_stdlib_10.sil
    Swift :: SIL/parse_stdlib_11.sil
    Swift :: SIL/parse_stdlib_12.sil
    Swift :: SIL/parse_stdlib_13.sil
    Swift :: SIL/parse_stdlib_14.sil
    Swift :: SIL/parse_stdlib_15.sil
    Swift :: SIL/parse_stdlib_16.sil
    Swift :: SIL/parse_stdlib_2.sil
    Swift :: SIL/parse_stdlib_3.sil
    Swift :: SIL/parse_stdlib_4.sil
    Swift :: SIL/parse_stdlib_5.sil
    Swift :: SIL/parse_stdlib_6.sil
    Swift :: SIL/parse_stdlib_7.sil
    Swift :: SIL/parse_stdlib_8.sil
    Swift :: SIL/parse_stdlib_9.sil
    Swift :: SILOptimizer/DestructorAnalysis.swift
    Swift :: SILOptimizer/allocbox_to_stack.sil
    Swift :: SILOptimizer/bridged_casts_folding.swift
    Swift :: SILOptimizer/cast_folding_objc.swift
    Swift :: SILOptimizer/cast_folding_objc_no_foundation.swift
    Swift :: SILOptimizer/devirt_base_class.swift
    Swift :: SILOptimizer/devirt_default_case.swift
    Swift :: SILOptimizer/diagnostic_constant_propagation.swift
    Swift :: SILOptimizer/eager_specialize.sil
    Swift :: SILOptimizer/functionsigopts.sil
    Swift :: SILOptimizer/functionsigopts_self.swift
    Swift :: SILOptimizer/functionsigopts_sroa.sil
    Swift :: SILOptimizer/prespecialize.swift
    Swift :: SILOptimizer/spec_conf1.swift
    Swift :: SILOptimizer/spec_conf2.swift
    Swift :: SILOptimizer/spec_recursion.swift
    Swift :: SILOptimizer/specialize.sil
    Swift :: SILOptimizer/specialize_chain.swift
    Swift :: SILOptimizer/specialize_default_witness.sil
    Swift :: SILOptimizer/specialize_ext.swift
    Swift :: SILOptimizer/specialize_partial_apply.swift
    Swift :: SILOptimizer/specialize_recursive_generics.sil
    Swift :: SILOptimizer/specialize_unconditional_checked_cast.swift
    Swift :: Serialization/basic_sil.swift
    Swift :: stdlib/ArrayNew.swift.gyb
    Swift :: stdlib/Dictionary.swift
    Swift :: stdlib/Set.swift

@slavapestov slavapestov changed the title Serialize local functions inside transparent functions [WIP] Serialize local functions inside transparent functions Mar 24, 2016
@slavapestov slavapestov deleted the serialize-transparent branch March 28, 2016 23:34
MaxDesiatov pushed a commit that referenced this pull request Oct 19, 2020
[pull] swiftwasm from master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants