From patchwork Fri Oct 11 22:53:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 282947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DF9672C032E for ; Sat, 12 Oct 2013 09:53:32 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=BuvEoqt7k+CKaOIILjLElRgm9Bq9/Ux0SbWwMHyDEX67Fl7GYaNOd 464GpbSCIT3k31QSKLt7FJnLsv7lppKWYsijZ3bUULHyot24/jVMT1pEMJOdMh0h 12xz8PoxowvD4yr3VmmbzmOHulPIePbb01AXMHtXMixOtvJ19pveVA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=qejn7Ag6H+WtqkG6gV+5Ybqqp/E=; b=ovPc+zWSPIHz7YeTWZzT DC9q1eBhW9dJXDhfXpikxscSnXtxWwnydEDC7wj4rkws/3qPIK+dChGU9iEyDedc Tj5ScFXEa8ebD4/rVMCjKBo6Mp+IxnLBhJZjjZSJXhHmrq6qHOs9rAjrIWtRrC2m wmYwP6JuPg1WFV/gY+Vbyjo= Received: (qmail 10134 invoked by alias); 11 Oct 2013 22:53:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10125 invoked by uid 89); 11 Oct 2013 22:53:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS, T_TVD_MIME_NO_HEADERS autolearn=ham version=3.3.2 X-HELO: mail-oa0-f52.google.com Received: from mail-oa0-f52.google.com (HELO mail-oa0-f52.google.com) (209.85.219.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 11 Oct 2013 22:53:23 +0000 Received: by mail-oa0-f52.google.com with SMTP id n2so2938249oag.11 for ; Fri, 11 Oct 2013 15:53:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-type; bh=0LfbIFMQZxTuFrYEqkg2VMzq/pMbrnRVbEs/Zkoc7Ck=; b=nHt408eKh5K7yiIFNL7iaNsLQMcJ0Q+H1BDklvju4fSfg3bMsS79FwMnEE2nRJ+eQL JAJ9bwLM506UDhcQ25fJzxzEl/QWD+GFH382dPwUxhBRA/6ETQwQCBafDvIKBQAsd+F2 MTkU/syvIF3RGrz/rtqo+W3nXbMZcLI51lfJY1CfkxrP81jp4ff+MG31X/s3CkfnrOxH TH1be2AbpXb6ppKCXNOVMbUHBjCBKEKbQYSNNZcYc3cvZUPQJbBEv7y5deky2VLcJ2To eBsuNTivgUCMRqw9eVv8Wc3tFx8CU5uuvMThzggn1Avh9yMwOLl6jkqL5eGrTRXeapmS 9rrw== X-Gm-Message-State: ALoCoQl4noos4+jueltHbZuqbx2aXm/0Qw1qewgHEzAoEAhJuwRxyaIvVh3q1Sijw82G5UvNz7lJe2QHiI66iD1rTEEGkNUGc3A37cE3jkAK/MmF+kdxflfjrHEAnBtOq1EumZFkHYS/K8NWN9B0ucBd1xLUZLxWbJ+c/Tb5dYgDx2TV7lt18bszcf6tWJ9FEqCZ7o2eUj8qu0Fz8YjMlXVvZdwUdHz+Ew== X-Received: by 10.60.40.67 with SMTP id v3mr16605900oek.16.1381532001335; Fri, 11 Oct 2013 15:53:21 -0700 (PDT) Received: from iant-glaptop.roam.corp.google.com.google.com ([2620:0:1000:3204:2d0f:b0a5:5b39:aae7]) by mx.google.com with ESMTPSA id xr8sm26552080obc.12.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 11 Oct 2013 15:53:20 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Fix handling of hidden methods for unnamed types Date: Fri, 11 Oct 2013 15:53:19 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes This patch to the Go frontend fixes the handling of hidden methods for unnamed types. If an interface has hidden methods, we must make the interface table comdat if it is for an unnamed type. When we create a stub method for an unnamed type, we don't make it publically visible. Bootstrapped and ran Go testsuite for x86_64-unknown-linux-gnu. Committed to mainline. Will commit to 4.8 branch when the branch reopens. Ian diff -r 92e9a04996ea go/gogo-tree.cc --- a/go/gogo-tree.cc Fri Oct 11 15:14:51 2013 -0700 +++ b/go/gogo-tree.cc Fri Oct 11 15:50:19 2013 -0700 @@ -2154,10 +2154,11 @@ TREE_CONSTANT(decl) = 1; DECL_INITIAL(decl) = constructor; - // If the interface type has hidden methods, then this is the only - // definition of the table. Otherwise it is a comdat table which - // may be defined in multiple packages. - if (has_hidden_methods) + // If the interface type has hidden methods, and the table is for a + // named type, then this is the only definition of the table. + // Otherwise it is a comdat table which may be defined in multiple + // packages. + if (has_hidden_methods && type->named_type() != NULL) TREE_PUBLIC(decl) = 1; else { diff -r 92e9a04996ea go/gogo.cc --- a/go/gogo.cc Fri Oct 11 15:14:51 2013 -0700 +++ b/go/gogo.cc Fri Oct 11 15:50:19 2013 -0700 @@ -3320,7 +3320,8 @@ closure_var_(NULL), block_(block), location_(location), labels_(), local_type_count_(0), descriptor_(NULL), fndecl_(NULL), defer_stack_(NULL), is_sink_(false), results_are_named_(false), nointerface_(false), - calls_recover_(false), is_recover_thunk_(false), has_recover_thunk_(false), + is_unnamed_type_stub_method_(false), calls_recover_(false), + is_recover_thunk_(false), has_recover_thunk_(false), in_unique_section_(false) { } @@ -3844,7 +3845,8 @@ else if (!Gogo::is_hidden_name(no->name()) || this->type_->is_method()) { - is_visible = true; + if (!this->is_unnamed_type_stub_method_) + is_visible = true; std::string pkgpath = gogo->pkgpath_symbol(); if (this->type_->is_method() && Gogo::is_hidden_name(no->name()) diff -r 92e9a04996ea go/gogo.h --- a/go/gogo.h Fri Oct 11 15:14:51 2013 -0700 +++ b/go/gogo.h Fri Oct 11 15:50:19 2013 -0700 @@ -953,6 +953,15 @@ this->nointerface_ = true; } + // Record that this function is a stub method created for an unnamed + // type. + void + set_is_unnamed_type_stub_method() + { + go_assert(this->is_method()); + this->is_unnamed_type_stub_method_ = true; + } + // Add a new field to the closure variable. void add_closure_field(Named_object* var, Location loc) @@ -1178,6 +1187,9 @@ bool results_are_named_ : 1; // True if this method should not be included in the type descriptor. bool nointerface_ : 1; + // True if this function is a stub method created for an unnamed + // type. + bool is_unnamed_type_stub_method_ : 1; // True if this function calls the predeclared recover function. bool calls_recover_ : 1; // True if this a thunk built for a function which calls recover. diff -r 92e9a04996ea go/types.cc --- a/go/types.cc Fri Oct 11 15:14:51 2013 -0700 +++ b/go/types.cc Fri Oct 11 15:50:19 2013 -0700 @@ -9031,6 +9031,8 @@ fntype->is_varargs(), location); gogo->finish_function(fntype->location()); + if (type->named_type() == NULL && stub->is_function()) + stub->func_value()->set_is_unnamed_type_stub_method(); if (m->nointerface() && stub->is_function()) stub->func_value()->set_nointerface(); }