Commit 61a02d1e by Ian Lance Taylor

compiler: rework type and package tracking in exporter

    
    Revamps the way the exporter tracks exported types and imported
    packages that need to be mentioned in the export data.
    
    The previous implementation wasn't properly handling the case where an
    exported non-inlinable function refers to an imported type whose
    method set includes an inlinable function whose body makes a call to a
    function in another package that's not directly used in the original
    package.
    
    This patch integrates together two existing traversal helper classes,
    "Collect_references_from_inline" and "Find_types_to_prepare" into a
    single helper "Collect_export_references", so as to have common/shared
    code that looks for indirectly imported packages.
    
    Fixes golang/go#32778
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183850

From-SVN: r272955
parent 5935baf5
7f753feb8df400d6ed17cdbdfb364f7f3a42fb31
aebd2d6303e4bb970b088e84f6c66279095dfea6
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
......@@ -160,9 +160,15 @@ class Export : public String_dump
const Import_init_set& imported_init_fns,
const Bindings* bindings);
// Set the index of a type.
// Record a type that is mentioned in export data. Return value is
// TRUE for newly visited types, FALSE for types that have been seen
// previously.
bool
set_type_index(Type*);
record_type(Type*);
// Assign type indices to types mentioned in export data.
int
assign_type_indices(const std::vector<Named_object*>& sorted_exports);
// Write a string to the export stream.
void
......@@ -213,11 +219,6 @@ class Export : public String_dump
Export(const Export&);
Export& operator=(const Export&);
// Prepare types for exporting.
int
prepare_types(const std::vector<Named_object*>* exports,
Unordered_set(const Package*)* imports);
// Write out all known packages.
void
write_packages(const std::map<std::string, Package*>& packages);
......@@ -258,6 +259,10 @@ class Export : public String_dump
int
type_index(const Type*);
// Set the index of a type.
void
set_type_index(const Type*);
// The stream to which we are writing data.
Stream* stream_;
// Index number of next type.
......
......@@ -914,7 +914,7 @@ class Gogo
// Return the name for a type descriptor symbol.
std::string
type_descriptor_name(Type*, Named_type*);
type_descriptor_name(const Type*, Named_type*);
// Return the name of the type descriptor list symbol of a package.
std::string
......
......@@ -936,7 +936,7 @@ Named_type::append_mangled_type_name(Gogo* gogo, bool use_alias,
// it is the name to use.
std::string
Gogo::type_descriptor_name(Type* type, Named_type* nt)
Gogo::type_descriptor_name(const Type* type, Named_type* nt)
{
// The type descriptor symbol for the unsafe.Pointer type is defined
// in libgo/runtime/go-unsafe-pointer.c, so just use a reference to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment