Return-Path: X-Original-To: apmail-freemarker-notifications-archive@minotaur.apache.org Delivered-To: apmail-freemarker-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 958671883A for ; Tue, 15 Dec 2015 22:23:45 +0000 (UTC) Received: (qmail 76954 invoked by uid 500); 15 Dec 2015 22:23:45 -0000 Delivered-To: apmail-freemarker-notifications-archive@freemarker.apache.org Received: (qmail 76936 invoked by uid 500); 15 Dec 2015 22:23:45 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 76925 invoked by uid 99); 15 Dec 2015 22:23:45 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Dec 2015 22:23:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 0DF4B1A0610 for ; Tue, 15 Dec 2015 22:23:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.226 X-Spam-Level: * X-Spam-Status: No, score=1.226 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.554] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 3EyotU8mFkGW for ; Tue, 15 Dec 2015 22:23:44 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id B1141439AB for ; Tue, 15 Dec 2015 22:23:43 +0000 (UTC) Received: (qmail 76838 invoked by uid 99); 15 Dec 2015 22:23:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Dec 2015 22:23:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1CE5AE0AF9; Tue, 15 Dec 2015 22:23:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ddekany@apache.org To: notifications@freemarker.incubator.apache.org Date: Tue, 15 Dec 2015 22:24:01 -0000 Message-Id: <755fdb2382cc4cd3adda0ff2b6e3dc0f@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [20/23] incubator-freemarker git commit: Decreased guaranteed stack usage (which is the stack usage you see in exception stack traces) by 1 per visit(TemplateElement[]). Decreased guaranteed stack usage (which is the stack usage you see in exception stack traces) by 1 per visit(TemplateElement[]). Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/a97cf728 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/a97cf728 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/a97cf728 Branch: refs/heads/2.3 Commit: a97cf7289d53a69cf74cb3a9aa9f669e99e3949f Parents: bc303ab Author: ddekany Authored: Tue Dec 15 00:18:10 2015 +0100 Committer: ddekany Committed: Tue Dec 15 00:18:10 2015 +0100 ---------------------------------------------------------------------- src/main/java/freemarker/core/Environment.java | 27 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a97cf728/src/main/java/freemarker/core/Environment.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/core/Environment.java b/src/main/java/freemarker/core/Environment.java index a622e9b..ef7a301 100644 --- a/src/main/java/freemarker/core/Environment.java +++ b/src/main/java/freemarker/core/Environment.java @@ -320,6 +320,7 @@ public final class Environment extends Configurable { * "Visit" the template element. */ void visit(TemplateElement element) throws IOException, TemplateException { + // ATTENTION: This method body is manually "inlined" into visit(TemplateElement[]); keep them in sync! pushElement(element); try { TemplateElement[] templateElementsToVisit = element.accept(this); @@ -336,6 +337,7 @@ public final class Environment extends Configurable { } finally { popElement(); } + // ATTENTION: This method body above is manually "inlined" into visit(TemplateElement[]); keep them in sync! } /** @@ -348,11 +350,30 @@ public final class Environment extends Configurable { if (elementBuffer == null) { return; } - for (TemplateElement el : elementBuffer) { - if (el == null) { + for (TemplateElement element : elementBuffer) { + if (element == null) { break; // Skip unused trailing buffer capacity } - visit(el); + + // ATTENTION: This part is the manually "inlining" of visit(TemplateElement[]); keep them in sync! + // We don't just let Hotspot to do it, as we want a hard guarantee regarding maximum stack usage. + pushElement(element); + try { + TemplateElement[] templateElementsToVisit = element.accept(this); + if (templateElementsToVisit != null) { + for (TemplateElement el : templateElementsToVisit) { + if (el == null) { + break; // Skip unused trailing buffer capacity + } + visit(el); + } + } + } catch (TemplateException te) { + handleTemplateException(te); + } finally { + popElement(); + } + // ATTENTION: This part above is the manually "inlining" of visit(TemplateElement[]); keep them in sync! } }