From patchwork Wed May 8 04:29:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1096660 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-500286-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=golang.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TQymcR5O"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=golang-org.20150623.gappssmtp.com header.i=@golang-org.20150623.gappssmtp.com header.b="WcAJhy6b"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44zNnh66bcz9s3Z for ; Wed, 8 May 2019 14:30:48 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=CGbOAYKJxj8b0Cy+V1vcblA1ayo8tIrbIIJMlhAKOSQCjd MsbWhzUl7f2iDUuvIvd47e8jhHCbYSHaiV2VzDNzTJH1LjFNx246H0shrIPENebo hrDZC+znqu51mZraNm0guslEVsXCEACsBH+BZLsLEywXPbnix3xnEqxbkDZ/E= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=aVGP5ANZcHnSDkJZnBE7GRaXINM=; b=TQymcR5OnaUZt2qQP8cu natLCD8p4XFacaNQ1L8GMGgVy+UuhWvE/F0+QPaji0xbychnI0hAhGFL6BBIlleN tFWhuQTLmJStCsJKnzlm9ujFdmg7C7bDHBwFOIXe02m1jlqEoFPE4fVqeBjydVW2 cRLnp9auImjoNKCy6za7aTY= Received: (qmail 84297 invoked by alias); 8 May 2019 04:30:40 -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 78113 invoked by uid 89); 8 May 2019 04:30:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-lj1-f178.google.com Received: from mail-lj1-f178.google.com (HELO mail-lj1-f178.google.com) (209.85.208.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 May 2019 04:30:19 +0000 Received: by mail-lj1-f178.google.com with SMTP id u21so7109126lja.5 for ; Tue, 07 May 2019 21:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=eljamGmji4UODS8nMGNqAAoN6sKmTNa0HWyruWLI0tA=; b=WcAJhy6b2e/cFFmsH1avVzGbpVXJOWnzussNAbxHVvwRLP1LFamWp8l2LO0sal2E7T TNhKMGv5V5yHLnH01GN+I8dhpDDOTSrflb3WLdO/0i+9Dsrs2gNJ2fAAwj9lYnPlm7VX koH5bwmHHvEHGRBM1grLYgEEaeYSQrM00gZRp+jhgYJvFz8wyUpfSycWbLB5+v8UtDrw 5KIDETHNjXxVo1hlQkcbarUVYryeTYPXfYHuL1+Mge6DuZZG4/EOKOyUyTPx5ptTSpC4 7alQP/oT5JWqxsS+Nc17sqXq5jQklZ8U7hCRNgMAv8ukAH73oV0BaVg0PO5LQ0xA1zq6 KoCw== MIME-Version: 1.0 From: Ian Lance Taylor Date: Tue, 7 May 2019 21:29:54 -0700 Message-ID: Subject: Go patch committed: Handle value method of direct interface type To: gcc-patches , gofrontend-dev This patch to the Go frontend by Cherry Zhang avoids using a double pointer for the value method of a direct interface type. For a direct interface type T with a value method M, its pointer type (*T)'s method table includes a stub method of M which takes a (*T) as the receiver instead of a T. However, for the "typ" field of the method table entry, we added another layer of indirection, which makes it appear to take a **T, which is wrong. This causes problems when using reflect.Type.Method to get the method. This CL fixes the second, incorrect, indirection. A test case for this can be found in https://golang.org/cl/175880. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 270993) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -dc9c1b43753f392fdc2045bcb7a4abaa44fe79f1 +e3ba8828baf60343316bb68002e94570ee63ad1e The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/types.cc =================================================================== --- gcc/go/gofrontend/types.cc (revision 270877) +++ gcc/go/gofrontend/types.cc (working copy) @@ -3440,14 +3440,15 @@ Type::method_constructor(Gogo*, Type* me vals->push_back(Expression::make_unary(OPERATOR_AND, s, bloc)); } - Named_object* no = - ((this->points_to() != NULL - && this->points_to()->is_direct_iface_type() - && m->is_value_method()) - ? m->iface_stub_object() - : (m->needs_stub_method() - ? m->stub_object() - : m->named_object())); + bool use_direct_iface_stub = + this->points_to() != NULL + && this->points_to()->is_direct_iface_type() + && m->is_value_method(); + Named_object* no = (use_direct_iface_stub + ? m->iface_stub_object() + : (m->needs_stub_method() + ? m->stub_object() + : m->named_object())); Function_type* mtype; if (no->is_function()) @@ -3463,7 +3464,8 @@ Type::method_constructor(Gogo*, Type* me ++p; go_assert(p->is_field_name("typ")); - bool want_pointer_receiver = !only_value_methods && m->is_value_method(); + bool want_pointer_receiver = (!only_value_methods && m->is_value_method() + && !use_direct_iface_stub); nonmethod_type = mtype->copy_with_receiver_as_param(want_pointer_receiver); vals->push_back(Expression::make_type_descriptor(nonmethod_type, bloc));