Skip to content

Commit 4c09479

Browse files
authored
Merge branch 'master' into share-jit-glue
2 parents 65f8bc7 + 8519826 commit 4c09479

33 files changed

Lines changed: 428 additions & 103 deletions

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ The following default gems are updated.
6666
* json 2.11.3
6767
* optparse 0.7.0.dev.2
6868
* prism 1.4.0
69-
* psych 5.2.3
69+
* psych 5.2.4
7070
* stringio 3.1.8.dev
71-
* strscan 3.1.4.dev
71+
* strscan 3.1.5.dev
7272
* uri 1.0.3
7373

7474
The following bundled gems are added.

addr2line.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,9 +2175,8 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
21752175
}
21762176
}
21772177

2178-
if (offset == -1) {
2178+
if (offset == 0) {
21792179
/* main executable */
2180-
offset = 0;
21812180
if (dynsym_shdr && dynstr_shdr) {
21822181
char *strtab = file + dynstr_shdr->sh_offset;
21832182
ElfW(Sym) *symtab = (ElfW(Sym) *)(file + dynsym_shdr->sh_offset);

doc/string/new.rdoc

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
Returns a new \String that is a copy of +string+.
1+
Returns a new \String object containing the given +string+.
22

3-
With no arguments, returns the empty string with the Encoding <tt>ASCII-8BIT</tt>:
3+
The +options+ are optional keyword options (see below).
44

5-
s = String.new
6-
s # => ""
7-
s.encoding # => #<Encoding:ASCII-8BIT>
5+
With no argument given and keyword +encoding+ also not given,
6+
returns an empty string with the Encoding <tt>ASCII-8BIT</tt>:
87

9-
With optional argument +string+ and no keyword arguments,
10-
returns a copy of +string+ with the same encoding:
8+
s = String.new # => ""
9+
s.encoding # => #<Encoding:ASCII-8BIT>
1110

12-
String.new('foo') # => "foo"
13-
String.new('тест') # => "тест"
14-
String.new('こんにちは') # => "こんにちは"
11+
With argument +string+ given and keyword option +encoding+ not given,
12+
returns a new string with the same encoding as +string+:
13+
14+
s0 = 'foo'.encode(Encoding::UTF_16)
15+
s1 = String.new(s0)
16+
s1.encoding # => #<Encoding:UTF-16 (dummy)>
1517

1618
(Unlike \String.new,
1719
a {string literal}[rdoc-ref:syntax/literals.rdoc@String+Literals] like <tt>''</tt> or a
1820
{here document literal}[rdoc-ref:syntax/literals.rdoc@Here+Document+Literals]
1921
always has {script encoding}[rdoc-ref:encodings.rdoc@Script+Encoding].)
2022

21-
With optional keyword argument +encoding+, returns a copy of +string+
22-
with the specified encoding;
23+
With keyword option +encoding+ given,
24+
returns a string with the specified encoding;
2325
the +encoding+ may be an Encoding object, an encoding name,
2426
or an encoding name alias:
2527

28+
String.new(encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII>
29+
String.new('', encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII>
2630
String.new('foo', encoding: Encoding::US_ASCII).encoding # => #<Encoding:US-ASCII>
2731
String.new('foo', encoding: 'US-ASCII').encoding # => #<Encoding:US-ASCII>
2832
String.new('foo', encoding: 'ASCII').encoding # => #<Encoding:US-ASCII>
2933

3034
The given encoding need not be valid for the string's content,
31-
and that validity is not checked:
35+
and its validity is not checked:
3236

3337
s = String.new('こんにちは', encoding: 'ascii')
3438
s.valid_encoding? # => false
@@ -37,19 +41,11 @@ But the given +encoding+ itself is checked:
3741

3842
String.new('foo', encoding: 'bar') # Raises ArgumentError.
3943

40-
With optional keyword argument +capacity+, returns a copy of +string+
41-
(or an empty string, if +string+ is not given);
42-
the given +capacity+ is advisory only,
44+
With keyword option +capacity+ given,
45+
the given value is advisory only,
4346
and may or may not set the size of the internal buffer,
4447
which may in turn affect performance:
4548

46-
String.new(capacity: 1)
47-
String.new('foo', capacity: 4096)
48-
49-
Note that Ruby strings are null-terminated internally, so the internal
50-
buffer size will be one or more bytes larger than the requested capacity
51-
depending on the encoding.
52-
53-
The +string+, +encoding+, and +capacity+ arguments may all be used together:
54-
55-
String.new('hello', encoding: 'UTF-8', capacity: 25)
49+
String.new('foo', capacity: 1) # Buffer size is at least 4 (includes terminal null byte).
50+
String.new('foo', capacity: 4096) # Buffer size is at least 4;
51+
# may be equal to, greater than, or less than 4096.

ext/digest/defs.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,26 @@
1616
# define __END_DECLS
1717
#endif
1818

19+
#define RB_DIGEST_DIAGNOSTIC(compiler, op, flag) _Pragma(STRINGIZE(compiler diagnostic op flag))
20+
#ifdef RBIMPL_WARNING_IGNORED
21+
# define RB_DIGEST_WARNING_IGNORED(flag) RBIMPL_WARNING_IGNORED(flag)
22+
# define RB_DIGEST_WARNING_PUSH() RBIMPL_WARNING_PUSH()
23+
# define RB_DIGEST_WARNING_POP() RBIMPL_WARNING_POP()
24+
#elif defined(__clang__)
25+
# define RB_DIGEST_WARNING_IGNORED(flag) RB_DIGEST_DIAGNOSTIC(clang, ignored, #flag)
26+
# define RB_DIGEST_WARNING_PUSH() _Pragma("clang diagnostic push")
27+
# define RB_DIGEST_WARNING_POP() _Pragma("clang diagnostic pop")
28+
#else /* __GNUC__ */
29+
# define RB_DIGEST_WARNING_IGNORED(flag) RB_DIGEST_DIAGNOSTIC(GCC, ignored, #flag)
30+
# define RB_DIGEST_WARNING_PUSH() _Pragma("GCC diagnostic push")
31+
# define RB_DIGEST_WARNING_POP() _Pragma("GCC diagnostic pop")
32+
#endif
33+
#ifdef RBIMPL_HAS_WARNING
34+
# define RB_DIGEST_HAS_WARNING(_) RBIMPL_HAS_WARNING(_)
35+
#elif defined(__has_warning)
36+
# define RB_DIGEST_HAS_WARNING(_) __has_warning(_)
37+
#else
38+
# define RB_DIGEST_HAS_WARNING(_) 0
39+
#endif
40+
1941
#endif /* DEFS_H */

ext/digest/digest_conf.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
def digest_conf(name)
44
unless with_config("bundled-#{name}")
5-
cc = with_config("common-digest")
6-
if cc != false or /\b#{name}\b/ =~ cc
7-
if File.exist?("#$srcdir/#{name}cc.h") and
8-
have_header("CommonCrypto/CommonDigest.h")
9-
$defs << "-D#{name.upcase}_USE_COMMONDIGEST"
10-
$headers << "#{name}cc.h"
11-
return :commondigest
12-
end
5+
case cc = with_config("common-digest", true)
6+
when true, false
7+
else
8+
cc = cc.split(/[\s,]++/).any? {|pat| File.fnmatch?(pat, name)}
9+
end
10+
if cc and File.exist?("#$srcdir/#{name}cc.h") and
11+
have_header("CommonCrypto/CommonDigest.h")
12+
$defs << "-D#{name.upcase}_USE_COMMONDIGEST"
13+
$headers << "#{name}cc.h"
14+
return :commondigest
1315
end
1416
end
1517
$objs << "#{name}.#{$OBJEXT}"

ext/digest/md5/md5cc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
#include <CommonCrypto/CommonDigest.h>
33

44
#ifdef __GNUC__
5-
# define RB_DIGEST_DIAGNOSTIC(compiler, op, flag) _Pragma(STRINGIZE(compiler diagnostic op flag))
6-
# ifdef RBIMPL_WARNING_IGNORED
7-
# define RB_DIGEST_WARNING_IGNORED(flag) RBIMPL_WARNING_IGNORED(flag)
8-
# elif defined(__clang__)
9-
# define RB_DIGEST_WARNING_IGNORED(flag) RB_DIGEST_DIAGNOSTIC(clang, ignored, #flag)
10-
# else /* __GNUC__ */
11-
# define RB_DIGEST_WARNING_IGNORED(flag) RB_DIGEST_DIAGNOSTIC(GCC, ignored, #flag)
12-
# endif
135
RB_DIGEST_WARNING_IGNORED(-Wdeprecated-declarations)
146
/* Suppress deprecation warnings of MD5 from Xcode 11.1 */
157
/* Although we know MD5 is deprecated too, provide just for backward

ext/digest/md5/md5init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <ruby/ruby.h>
55
#include "../digest.h"
6+
#include "../defs.h"
67
#if defined(MD5_USE_COMMONDIGEST)
78
#include "md5cc.h"
89
#else

ext/digest/sha1/sha1.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,14 @@ void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
232232
if ((j + len) > 63) {
233233
(void)memcpy(&context->buffer[j], data, (i = 64-j));
234234
SHA1_Transform(context->state, context->buffer);
235-
for ( ; i + 63 < len; i += 64)
235+
for ( ; i + 63 < len; i += 64) {
236+
RB_DIGEST_WARNING_PUSH();
237+
#if defined(__GNUC__) && !defined(__clang__)
238+
RB_DIGEST_WARNING_IGNORED(-Wstringop-overread);
239+
#endif
236240
SHA1_Transform(context->state, &data[i]);
241+
RB_DIGEST_WARNING_POP();
242+
}
237243
j = 0;
238244
} else {
239245
i = 0;

ext/json/generator/extconf.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
return 0;
1919
}
2020
SRC
21-
$defs.push("-DENABLE_SIMD")
21+
$defs.push("-DJSON_ENABLE_SIMD")
2222
end
2323
end
2424

@@ -29,7 +29,7 @@
2929
return 0;
3030
}
3131
SRC
32-
$defs.push("-DENABLE_SIMD")
32+
$defs.push("-DJSON_ENABLE_SIMD")
3333
end
3434

3535
have_header('cpuid.h')

ext/json/generator/generator.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ typedef struct _search_state {
112112
const char *cursor;
113113
FBuffer *buffer;
114114

115-
#ifdef ENABLE_SIMD
115+
#ifdef HAVE_SIMD
116116
const char *chunk_base;
117117
const char *chunk_end;
118118
bool has_matches;
@@ -124,7 +124,7 @@ typedef struct _search_state {
124124
#else
125125
#error "Unknown SIMD Implementation."
126126
#endif /* HAVE_SIMD_NEON */
127-
#endif /* ENABLE_SIMD */
127+
#endif /* HAVE_SIMD */
128128
} search_state;
129129

130130
#if (defined(__GNUC__ ) || defined(__clang__))
@@ -189,15 +189,11 @@ static inline FORCE_INLINE void escape_UTF8_char_basic(search_state *search)
189189
case '\r': fbuffer_append(search->buffer, "\\r", 2); break;
190190
case '\t': fbuffer_append(search->buffer, "\\t", 2); break;
191191
default: {
192-
if (ch < ' ') {
193-
const char *hexdig = "0123456789abcdef";
194-
char scratch[6] = { '\\', 'u', '0', '0', 0, 0 };
195-
scratch[4] = hexdig[(ch >> 4) & 0xf];
196-
scratch[5] = hexdig[ch & 0xf];
197-
fbuffer_append(search->buffer, scratch, 6);
198-
} else {
199-
fbuffer_append_char(search->buffer, ch);
200-
}
192+
const char *hexdig = "0123456789abcdef";
193+
char scratch[6] = { '\\', 'u', '0', '0', 0, 0 };
194+
scratch[4] = hexdig[(ch >> 4) & 0xf];
195+
scratch[5] = hexdig[ch & 0xf];
196+
fbuffer_append(search->buffer, scratch, 6);
201197
break;
202198
}
203199
}
@@ -265,7 +261,7 @@ static inline void escape_UTF8_char(search_state *search, unsigned char ch_len)
265261
search->cursor = (search->ptr += ch_len);
266262
}
267263

268-
#ifdef ENABLE_SIMD
264+
#ifdef HAVE_SIMD
269265

270266
static inline FORCE_INLINE char *copy_remaining_bytes(search_state *search, unsigned long vec_len, unsigned long len)
271267
{
@@ -537,7 +533,7 @@ static inline TARGET_SSE2 FORCE_INLINE unsigned char search_escape_basic_sse2(se
537533

538534
#endif /* HAVE_SIMD_SSE2 */
539535

540-
#endif /* ENABLE_SIMD */
536+
#endif /* HAVE_SIMD */
541537

542538
static const unsigned char script_safe_escape_table[256] = {
543539
// ASCII Control Characters
@@ -1302,11 +1298,11 @@ static void generate_json_string(FBuffer *buffer, struct generate_json_data *dat
13021298
search.cursor = search.ptr;
13031299
search.end = search.ptr + len;
13041300

1305-
#ifdef ENABLE_SIMD
1301+
#ifdef HAVE_SIMD
13061302
search.matches_mask = 0;
13071303
search.has_matches = false;
13081304
search.chunk_base = NULL;
1309-
#endif /* ENABLE_SIMD */
1305+
#endif /* HAVE_SIMD */
13101306

13111307
switch(rb_enc_str_coderange(obj)) {
13121308
case ENC_CODERANGE_7BIT:
@@ -2174,7 +2170,7 @@ void Init_generator(void)
21742170

21752171

21762172
switch(find_simd_implementation()) {
2177-
#ifdef ENABLE_SIMD
2173+
#ifdef HAVE_SIMD
21782174
#ifdef HAVE_SIMD_NEON
21792175
case SIMD_NEON:
21802176
search_escape_basic_impl = search_escape_basic_neon;
@@ -2185,7 +2181,7 @@ void Init_generator(void)
21852181
search_escape_basic_impl = search_escape_basic_sse2;
21862182
break;
21872183
#endif /* HAVE_SIMD_SSE2 */
2188-
#endif /* ENABLE_SIMD */
2184+
#endif /* HAVE_SIMD */
21892185
default:
21902186
search_escape_basic_impl = search_escape_basic;
21912187
break;

0 commit comments

Comments
 (0)