[前][次][番号順一覧][スレッド一覧]

ruby-changes:54008

From: ko1 <ko1@a...>
Date: Thu, 6 Dec 2018 02:23:39 +0900 (JST)
Subject: [ruby-changes:54008] ko1:r66228 (trunk): Introduce "COLDFUNC" function attribute.

ko1	2018-12-06 02:23:32 +0900 (Thu, 06 Dec 2018)

  New Revision: 66228

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66228

  Log:
    Introduce "COLDFUNC" function attribute.
    
    * include/ruby/defines.h: introduce "COLDFUNC" function attribute
      on several compilers for called unlikely functions.
      Apply to rb_memerror, rb_warn and rb_bug.
    
      A patch form  methodmissing <lourens@b...>.

  Modified files:
    trunk/include/ruby/defines.h
    trunk/include/ruby/intern.h
    trunk/include/ruby/ruby.h
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 66227)
+++ include/ruby/intern.h	(revision 66228)
@@ -479,7 +479,7 @@ VALUE rb_file_directory_p(VALUE,VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L479
 VALUE rb_str_encode_ospath(VALUE);
 int rb_is_absolute_path(const char *);
 /* gc.c */
-NORETURN(void rb_memerror(void));
+COLDFUNC NORETURN(void rb_memerror(void));
 PUREFUNC(int rb_during_gc(void));
 void rb_gc_mark_locations(const VALUE*, const VALUE*);
 void rb_mark_tbl(struct st_table*);
Index: include/ruby/defines.h
===================================================================
--- include/ruby/defines.h	(revision 66227)
+++ include/ruby/defines.h	(revision 66228)
@@ -89,6 +89,16 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L89
 #define RB_UNLIKELY(x) (x)
 #endif /* __GNUC__ >= 3 */
 
+/*
+  cold attribute for code layout improvements
+  RUBY_FUNC_ATTRIBUTE not used because MSVC does not like nested func macros
+ */
+#if defined(__clang__) || GCC_VERSION_SINCE(4, 3, 0)
+#define COLDFUNC __attribute__((cold))
+#else
+#define COLDFUNC
+#endif
+
 #ifdef __GNUC__
 #if defined __MINGW_PRINTF_FORMAT
 #define PRINTF_ARGS(decl, string_index, first_to_check) \
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 66227)
+++ include/ruby/ruby.h	(revision 66228)
@@ -1901,7 +1901,7 @@ enum rb_io_wait_readwrite {RB_IO_WAIT_RE https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1901
 
 PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3);
 PRINTF_ARGS(NORETURN(void rb_fatal(const char*, ...)), 1, 2);
-PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2);
+COLDFUNC PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2);
 NORETURN(void rb_bug_errno(const char*, int));
 NORETURN(void rb_sys_fail(const char*));
 NORETURN(void rb_sys_fail_str(VALUE));
@@ -1925,7 +1925,7 @@ PRINTF_ARGS(void rb_warning(const char*, https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1925
 PRINTF_ARGS(void rb_compile_warning(const char *, int, const char*, ...), 3, 4);
 PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
 /* reports always */
-PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
+COLDFUNC PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
 PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
 
 #define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]