From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115489 invoked by alias); 27 Feb 2019 20:19:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 115346 invoked by uid 89); 27 Feb 2019 20:19:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=fmt, Hx-languages-length:2781 X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.150.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Feb 2019 20:19:00 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway30.websitewelcome.com (Postfix) with ESMTP id A96B3C969 for ; Wed, 27 Feb 2019 14:18:59 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id z5fPg62smYTGMz5fPgMsOt; Wed, 27 Feb 2019 14:18:59 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3CB194noQeDaQpDNRi901CaQtufoHZnZk09N/LYqatw=; b=DqaXe7eB8uzWUVFeFJdoZTk4PQ 7q6nl/TimaliauCdwfKbF0GpnsfmYIIGetqPNzpkqxLd1TXF5T9f6igKPgBZpaeCYAzaWAhuLyxuI dt+j5KF+epaYa+IKTj8DGdCef; Received: from 75-166-85-218.hlrn.qwest.net ([75.166.85.218]:36364 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gz5fP-004Fi1-Et; Wed, 27 Feb 2019 14:18:59 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 19/22] Make exception throwing a bit more efficient Date: Wed, 27 Feb 2019 20:19:00 -0000 Message-Id: <20190227201849.32210-20-tom@tromey.com> In-Reply-To: <20190227201849.32210-1-tom@tromey.com> References: <20190227201849.32210-1-tom@tromey.com> X-SW-Source: 2019-02/txt/msg00524.txt.bz2 This makes exception throwing a bit more efficient, by removing some copies. This is good now that exceptions are more expensive to copy. gdb/ChangeLog 2019-02-27 Tom Tromey * common/common-exceptions.c (throw_exception): Rename from throw_exception_cxx. Remove old copy. Make argument const. (throw_it): Create and throw exception objects directly. * common/common-exceptions.h (throw_exception): Make argument const. --- gdb/ChangeLog | 8 ++++++++ gdb/common/common-exceptions.c | 37 ++++++++++++++++++++-------------- gdb/common/common-exceptions.h | 2 +- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/gdb/common/common-exceptions.c b/gdb/common/common-exceptions.c index 4feb80731ac..99a6267c163 100644 --- a/gdb/common/common-exceptions.c +++ b/gdb/common/common-exceptions.c @@ -188,8 +188,8 @@ throw_exception_sjlj (struct gdb_exception exception) /* Implementation of throw_exception that uses C++ try/catch. */ -static ATTRIBUTE_NORETURN void -throw_exception_cxx (struct gdb_exception exception) +void +throw_exception (const struct gdb_exception &exception) { if (exception.reason == RETURN_QUIT) { @@ -209,25 +209,32 @@ throw_exception_cxx (struct gdb_exception exception) gdb_assert_not_reached ("invalid return reason"); } -void -throw_exception (struct gdb_exception exception) -{ - throw_exception_cxx (exception); -} - static void ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0) throw_it (enum return_reason reason, enum errors error, const char *fmt, va_list ap) { - struct gdb_exception e; + if (reason == RETURN_QUIT) + { + gdb_exception_quit ex; - /* Create the exception. */ - e.reason = reason; - e.error = error; - e.message = string_vprintf (fmt, ap); + ex.reason = reason; + ex.error = error; + ex.message = string_vprintf (fmt, ap); - /* Throw the exception. */ - throw_exception (e); + throw ex; + } + else if (reason == RETURN_ERROR) + { + gdb_exception_error ex; + + ex.reason = reason; + ex.error = error; + ex.message = string_vprintf (fmt, ap); + + throw ex; + } + else + gdb_assert_not_reached ("invalid return reason"); } void diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h index c6a8fa66ad6..9d83cad6bec 100644 --- a/gdb/common/common-exceptions.h +++ b/gdb/common/common-exceptions.h @@ -205,7 +205,7 @@ struct gdb_quit_bad_alloc /* Throw an exception (as described by "struct gdb_exception"), landing in the inner most containing exception handler established using TRY/CATCH. */ -extern void throw_exception (struct gdb_exception exception) +extern void throw_exception (const struct gdb_exception &exception) ATTRIBUTE_NORETURN; /* Throw an exception by executing a LONG JUMP to the inner most -- 2.17.2