ruby-changes:45546
From: nobu <ko1@a...>
Date: Mon, 13 Feb 2017 17:14:23 +0900 (JST)
Subject: [ruby-changes:45546] nobu:r57619 (trunk): ruby.h: RB_GC_GUARD stronger than gcc7
nobu 2017-02-13 17:14:19 +0900 (Mon, 13 Feb 2017) New Revision: 57619 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57619 Log: ruby.h: RB_GC_GUARD stronger than gcc7 * include/ruby/ruby.h (RB_GC_GUARD): prevent guarded pointer from optimization by using as an input to inline asm. Modified files: trunk/include/ruby/ruby.h trunk/marshal.c Index: marshal.c =================================================================== --- marshal.c (revision 57618) +++ marshal.c (revision 57619) @@ -1024,7 +1024,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/marshal.c#L1024 rb_marshal_dump_limited(VALUE obj, VALUE port, int limit) { struct dump_arg *arg; - volatile VALUE wrapper; /* used to avoid memory leak in case of exception */ + VALUE wrapper; /* used to avoid memory leak in case of exception */ wrapper = TypedData_Make_Struct(rb_cData, struct dump_arg, &dump_arg_data, arg); arg->dest = 0; @@ -2038,7 +2038,7 @@ rb_marshal_load_with_proc(VALUE port, VA https://github.com/ruby/ruby/blob/trunk/marshal.c#L2038 { int major, minor, infection = 0; VALUE v; - volatile VALUE wrapper; /* used to avoid memory leak in case of exception */ + VALUE wrapper; /* used to avoid memory leak in case of exception */ struct load_arg *arg; v = rb_check_string_type(port); Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 57618) +++ include/ruby/ruby.h (revision 57619) @@ -536,7 +536,11 @@ static inline int rb_type(VALUE obj); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L536 #ifdef __GNUC__ #define RB_GC_GUARD(v) \ - (*__extension__ ({volatile VALUE *rb_gc_guarded_ptr = &(v); rb_gc_guarded_ptr;})) + (*__extension__ ({ \ + volatile VALUE *rb_gc_guarded_ptr = &(v); \ + __asm__("### RB_GC_GUARD("#v")" : : "m"(rb_gc_guarded_ptr)); \ + rb_gc_guarded_ptr; \ + })) #elif defined _MSC_VER #pragma optimize("", off) static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr;} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/