From patchwork Wed Dec 11 22:42:49 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: 300467 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9D3402C020A for ; Thu, 12 Dec 2013 09:43:03 +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=G4ipPXma0TZ5hI7Ae1R8Mr02+ccwXmNBEq4m1+gjq82V6IPfWDHK8 5Cieh7WZmbvO8nq/Gk5KFSUs8YmgO+fBLRH61tDIj4Bk15HIChurAzIX3937fWkl qejKk/MFLqZ3ayRJWUal2RzGCMkeZKsjCJL3c5/eQi8N1ZKVPvTQ/g= 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=3Wb4PpHX874RQEnFq+8RyoJFQmM=; b=EWStNSGDrk8mMqf3n/B5 YLx3Uzvy/c578QAnDpP1eL2nDTVYWSI92gD5Cy2+Dvho5wr9RF77Wqv31SJ2AQHL a170G7CddxsQK59LMHgetvx6rCTnt6iEHnbobgpwawjShcqE8NdgNhEJqZbD+NvX 35RLHdGXcEpNiOV08fwWg04= Received: (qmail 11019 invoked by alias); 11 Dec 2013 22:42:56 -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 11008 invoked by uid 89); 11 Dec 2013 22:42:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS, T_TVD_MIME_NO_HEADERS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f182.google.com Received: from mail-pd0-f182.google.com (HELO mail-pd0-f182.google.com) (209.85.192.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 11 Dec 2013 22:42:54 +0000 Received: by mail-pd0-f182.google.com with SMTP id v10so10303623pde.41 for ; Wed, 11 Dec 2013 14:42:52 -0800 (PST) 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=Uo3Xu2R5TOfbwV68U1sxkrVY4H+mraX7XTuvIxxsI74=; b=Ddkrdk+BL2DByvYKs8naQzn7JDkVinu+OQ60C13Q+V5azt+TcSc+6ByduN+qViK7Ee 2+uA9liLTxZleBOLa47ZQX/WkAk7Jmh7JAfUHLv71auKSCC1dycz29VEACbCho8xLBCg iUga67Zil+2imQPtAEVfVNuv1o32r6Z1XNLn3y0wKTAoJ7zLmWHXEDDsW88WYd/U3YXK HJ82OV5XsqFcQe+smwauT0y3nKISXdOIr8qfFOgeab1lIvlr1IzOPtuGbHnTKxDmMxha hjKOITOMEqHUQS8KnjHyWTK1p/YQHNHo9WC8JGedHxacZJkVZQ8A1V0nUmDeZjqCFgnz s4Fg== X-Gm-Message-State: ALoCoQkzFUjhaUy1gMX6KH0qI3t+ghCAefbbYKMkDTS+UhjPcu2C8yX13Hrl15SjmC7UOCGULXwjxclmJPNg/dWumlQZUewcBtfFUFIIpBNjNBHRyPhAGeEzgIPJy1AhlRMJ99583q/FMu53/CVM6hlPrZbpvp5Q3u0QVO5xMUdkieZ5LLf6Xw+kphUDAw2+bCoiMGraTqJaqDyd1DzkzVr2qfuCPwtpMA== X-Received: by 10.68.209.193 with SMTP id mo1mr5668153pbc.38.1386801772633; Wed, 11 Dec 2013 14:42:52 -0800 (PST) Received: from iant-glaptop.roam.corp.google.com.google.com ([172.26.49.29]) by mx.google.com with ESMTPSA id at4sm35212639pbc.30.2013.12.11.14.42.51 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 11 Dec 2013 14:42:51 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Minor fixes for recover thunks Date: Wed, 11 Dec 2013 14:42:49 -0800 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 a couple of problems with recover thunks. First, it avoids name collisions when methods call recover; previously if two different methods with the same name (for different types) called recover, the assembler symbols would be the same. Second, it avoids crashing if a method with an unnamed receiver calls recover. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.8 branch. Ian diff -r ba0adcfb4e6a go/gogo.cc --- a/go/gogo.cc Fri Dec 06 10:24:09 2013 -0800 +++ b/go/gogo.cc Wed Dec 11 14:21:36 2013 -0800 @@ -2822,7 +2822,10 @@ if (orig_fntype->is_varargs()) new_fntype->set_is_varargs(); - std::string name = orig_no->name() + "$recover"; + std::string name = orig_no->name(); + if (orig_fntype->is_method()) + name += "$" + orig_fntype->receiver()->type()->mangled_name(gogo); + name += "$recover"; Named_object *new_no = gogo->start_function(name, new_fntype, false, location); Function *new_func = new_no->func_value(); @@ -2916,7 +2919,25 @@ && !orig_rec_no->var_value()->is_receiver()); orig_rec_no->var_value()->set_is_receiver(); - const std::string& new_receiver_name(orig_fntype->receiver()->name()); + std::string new_receiver_name(orig_fntype->receiver()->name()); + if (new_receiver_name.empty()) + { + // Find the receiver. It was named "r.NNN" in + // Gogo::start_function. + for (Bindings::const_definitions_iterator p = + new_bindings->begin_definitions(); + p != new_bindings->end_definitions(); + ++p) + { + const std::string& pname((*p)->name()); + if (pname[0] == 'r' && pname[1] == '.') + { + new_receiver_name = pname; + break; + } + } + go_assert(!new_receiver_name.empty()); + } Named_object* new_rec_no = new_bindings->lookup_local(new_receiver_name); if (new_rec_no == NULL) go_assert(saw_errors());