From 959c676207c831e187f8439130898c507714dff7 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Tue, 5 Jul 2022 14:22:57 +0900 Subject: [PATCH] propagate other method metadata as well --- src/ast.scm | 17 ++++++++++++++--- src/julia-syntax.scm | 4 +++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ast.scm b/src/ast.scm index c6f924b045189..bbb2180a8a92f 100644 --- a/src/ast.scm +++ b/src/ast.scm @@ -523,9 +523,20 @@ (and (if one (length= e 3) (length> e 2)) (eq? (car e) 'meta) (memq (cadr e) '(nospecialize specialize)))) -(define (inline-meta? e) - (and (length= e 2) - (eq? (car e) 'meta) (memq (cadr e) '(inline noinline)))) +(define (meta? e) + (and (length> e 1) (eq? (car e) 'meta))) + +(define (method-meta-sym? x) + (memq x '(inline noinline aggressive_constprop no_constprop propagate_inbounds))) + +(define (propagate-method-meta e) + `(meta ,@(filter (lambda (x) + (or (method-meta-sym? x) + (and (pair? x) (eq? (car x) 'purity)))) + (cdr e)))) + +(define (argwide-nospecialize-meta? e) + (and (length= e 2) (eq? (car e) 'meta) (memq (cadr e) '(nospecialize specialize)))) (define (if-generated? e) (and (length= e 4) (eq? (car e) 'if) (equal? (cadr e) '(generated)))) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 793180bdb7084..8af1bc8b80d23 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -562,7 +562,9 @@ ,(if (any kwarg? pargl) (gensy) UNUSED) (call (core kwftype) ,ftype)) ,kw ,@pargl ,@vararg) `(block - ,@(filter inline-meta? prologue) + ;; propagate method metadata to keyword sorter + ,@(map propagate-method-meta (filter meta? prologue)) + ,@(filter argwide-nospecialize-meta? prologue) ,@(let ((lnns (filter linenum? prologue))) (if (pair? lnns) (list (car lnns))