Changeset 233071 in webkit
- Timestamp:
- Jun 21, 2018 11:41:10 PM (6 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r233006 r233071 1 2018-06-21 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GLIB] improve get_type() fast path in WEBKIT_DEFINE_TYPE 4 https://bugs.webkit.org/show_bug.cgi?id=186885 5 6 Reviewed by Anders Carlsson. 7 8 This is a backport of glib commit 9 https://gitlab.gnome.org/GNOME/glib/commit/e924f777369710221c3e0a9d7bf40392a27d1fa4 10 11 "The -fstack-protector-strong used in many distributions by default has a 12 rather drastic slowdown of the fast path in generated _get_type() 13 functions using G_DEFINE_* macros. The amount can vary by architecture, 14 GCC version, and compiler flags. 15 16 To work around this, and ensure a higher probability that our fast-path 17 will match what we had previously, we need to break out the slow-path 18 (registering the type) into a secondary function that is not a candidate 19 for inlining. 20 21 This ensures that the common case (type registered, return the GType id) 22 is the hot path and handled in the prologue of the generated assembly even 23 when -fstack-protector-strong is enabled." 24 25 * wtf/glib/WTFGType.h: 26 1 27 2018-06-20 Yusuke Suzuki <utatane.tea@gmail.com> 2 28 -
trunk/Source/WTF/wtf/glib/WTFGType.h
r231565 r233071 21 21 22 22 #include <glib.h> 23 #include <wtf/Compiler.h> 23 24 24 25 #define WEBKIT_PARAM_READABLE (static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)) … … 47 48 \ 48 49 static void type_name##_class_init(TypeName##Class* klass); \ 50 static GType type_name##_get_type_once(void); \ 49 51 static gpointer type_name##_parent_class = 0; \ 50 52 static void type_name##_finalize(GObject* object) \ … … 69 71 self->priv = priv; \ 70 72 new (priv) TypeName##Private(); \ 71 }\ 73 } \ 74 \ 72 75 GType type_name##_get_type(void) \ 73 76 { \ 74 77 static volatile gsize g_define_type_id__volatile = 0; \ 75 78 if (g_once_init_enter(&g_define_type_id__volatile)) { \ 76 GType g_define_type_id = \ 77 g_type_register_static_simple( \ 78 TYPE_PARENT, \ 79 g_intern_static_string(#TypeName), \ 80 sizeof(TypeName##Class), \ 81 (GClassInitFunc)type_name##_class_intern_init, \ 82 sizeof(TypeName), \ 83 (GInstanceInitFunc)type_name##_init, \ 84 (GTypeFlags)flags); \ 85 // Custom code follows. 86 #define _WEBKIT_DEFINE_TYPE_EXTENDED_END() \ 79 GType g_define_type_id = type_name##_get_type_once(); \ 87 80 g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); \ 88 81 } \ 89 82 return g_define_type_id__volatile; \ 90 } // Closes type_name##_get_type(). 83 } /* Closes type_name##_get_type(). */ \ 84 \ 85 NEVER_INLINE static GType type_name##_get_type_once(void) \ 86 { \ 87 GType g_define_type_id = \ 88 g_type_register_static_simple( \ 89 TYPE_PARENT, \ 90 g_intern_static_string(#TypeName), \ 91 sizeof(TypeName##Class), \ 92 (GClassInitFunc)(void (*)(void))type_name##_class_intern_init, \ 93 sizeof(TypeName), \ 94 (GInstanceInitFunc)(void (*)(void))type_name##_init, \ 95 (GTypeFlags)flags); \ 96 /* Custom code follows. */ 97 #define _WEBKIT_DEFINE_TYPE_EXTENDED_END() \ 98 return g_define_type_id; \ 99 } /* Closes type_name##_get_type_once() */
Note: See TracChangeset
for help on using the changeset viewer.