mini_racer 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fef1f817dc1b549c08a4755afd1c767ea3bdfc34f44febd1792df24f867f28e8
4
- data.tar.gz: 559080d182a14c5c52215d119afb9e79aec02a11a976b39b18088cb0841cbc6e
3
+ metadata.gz: 5923ad9b3aa9cdea7785f0f2eb3fa27357217d0feb5ed439dad46b5ea7eaea8f
4
+ data.tar.gz: ffac8a1b740c74467f40e0200730a3fe25892d63105022f8775fe8aaffdcdd20
5
5
  SHA512:
6
- metadata.gz: b88dd39b59e72befdecc2312096e32e6fd79ee0822ea9ae2b319cfec4fc1327c1092a84bf8c30db721a7309fe279e009b2939cef9ce8334094cd701aea229540
7
- data.tar.gz: 691b89578567b3fa2325f15a13a294f8cad664897fd0e966b78dfb13eae455abfb51d489ca73ffb166738b46a0e37b8ad8ccc225205170d19c58322e11ff10b3
6
+ metadata.gz: 0f8ab9852328121e3d55119fb1a2a8a875806b0a256d2c79ab09846fe2ed7df174beb68949213057fe8186376b73993b21dc21fe22ce82632f26e0a4354c982e
7
+ data.tar.gz: 88c0a37a5a26ab746312c76499a202578a0604098a1ec3fcf7b98110aace6facd95490b19bd0f6abb8afba136b9ae94f5f1367d55050d6abdcf62bd628d6b8f2
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ - 0.19.0 - 24-06-2025
2
+ - upgrade to node 24.1.0
3
+
4
+ - 0.18.1 - 03-04-2025
5
+ - Convert round doubles to fixnum for very big floats - this has better parity with JavaScript - Ben Noorhuis
6
+
1
7
  - 0.18.0 - 05-03-2025
2
8
  - Time for a major release
3
9
  - Handle ActiveSupport TimeWithZone objects during serialization - Sam Saffron
@@ -1,8 +1,10 @@
1
1
  #include <stdatomic.h>
2
+ #include <stdint.h>
2
3
  #include <stdio.h>
3
4
  #include <stdlib.h>
4
5
  #include <string.h>
5
6
  #include <pthread.h>
7
+ #include <math.h>
6
8
 
7
9
  #include "ruby.h"
8
10
  #include "ruby/encoding.h"
@@ -282,7 +284,11 @@ static void des_int(void *arg, int64_t v)
282
284
 
283
285
  static void des_num(void *arg, double v)
284
286
  {
285
- put(arg, DBL2NUM(v));
287
+ if (isfinite(v) && v == trunc(v) && v >= INT64_MIN && v <= INT64_MAX) {
288
+ put(arg, LONG2FIX(v));
289
+ } else {
290
+ put(arg, DBL2NUM(v));
291
+ }
286
292
  }
287
293
 
288
294
  static void des_date(void *arg, double v)
@@ -321,8 +327,19 @@ static void des_bigint(void *arg, const void *p, size_t n, int sign)
321
327
  if (t >> 63)
322
328
  *a++ = 0; // suppress sign extension
323
329
  v = rb_big_unpack(limbs, a-limbs);
324
- if (sign < 0)
325
- v = rb_big_mul(v, LONG2FIX(-1));
330
+ if (sign < 0) {
331
+ // rb_big_unpack returns T_FIXNUM for smallish bignums
332
+ switch (TYPE(v)) {
333
+ case T_BIGNUM:
334
+ v = rb_big_mul(v, LONG2FIX(-1));
335
+ break;
336
+ case T_FIXNUM:
337
+ v = LONG2FIX(-1 * FIX2LONG(v));
338
+ break;
339
+ default:
340
+ abort();
341
+ }
342
+ }
326
343
  put(c, v);
327
344
  }
328
345
 
@@ -614,14 +631,16 @@ static int serialize1(Ser *s, VALUE refs, VALUE v)
614
631
  struct timeval tv = rb_time_timeval(v);
615
632
  ser_date(s, tv.tv_sec*1e3 + tv.tv_usec/1e3);
616
633
  } else {
617
- snprintf(s->err, sizeof(s->err), "unsupported type %s", rb_class2name(CLASS_OF(v)));
618
- return -1;
634
+ snprintf(s->err, sizeof(s->err), "unsupported type %s", rb_class2name(CLASS_OF(v)));
635
+ return -1;
619
636
  }
620
637
  break;
621
638
  default:
622
639
  snprintf(s->err, sizeof(s->err), "unsupported type %x", TYPE(v));
623
640
  return -1;
624
641
  }
642
+ if (*s->err)
643
+ return -1;
625
644
  return 0;
626
645
  }
627
646
 
@@ -192,6 +192,24 @@ bool reply(State& st, v8::Local<v8::Value> result, v8::Local<v8::Value> err)
192
192
  return true;
193
193
  }
194
194
 
195
+ // for when a reply is not expected to fail because of serialization
196
+ // errors but can still fail when preempted by isolate termination;
197
+ // temporarily cancels the termination exception so it can send the reply
198
+ void reply_retry(State& st, v8::Local<v8::Value> response)
199
+ {
200
+ v8::TryCatch try_catch(st.isolate);
201
+ try_catch.SetVerbose(st.verbose_exceptions);
202
+ bool ok = reply(st, response);
203
+ while (!ok) {
204
+ assert(try_catch.HasCaught());
205
+ assert(try_catch.HasTerminated());
206
+ if (!try_catch.HasTerminated()) abort();
207
+ st.isolate->CancelTerminateExecution();
208
+ ok = reply(st, response);
209
+ st.isolate->TerminateExecution();
210
+ }
211
+ }
212
+
195
213
  v8::Local<v8::Value> sanitize(State& st, v8::Local<v8::Value> v)
196
214
  {
197
215
  // punch through proxies
@@ -434,7 +452,7 @@ extern "C" void v8_attach(State *pst, const uint8_t *p, size_t n)
434
452
  fail:
435
453
  if (!cause && try_catch.HasCaught()) cause = RUNTIME_ERROR;
436
454
  auto err = to_error(st, &try_catch, cause);
437
- if (!reply(st, err)) abort();
455
+ reply_retry(st, err);
438
456
  }
439
457
 
440
458
  // response is errback [result, err] array
@@ -590,7 +608,7 @@ extern "C" void v8_heap_stats(State *pst)
590
608
  PROP(number_of_native_contexts);
591
609
  PROP(number_of_detached_contexts);
592
610
  #undef PROP
593
- if (!reply(st, response)) abort();
611
+ reply_retry(st, response);
594
612
  }
595
613
 
596
614
  struct OutputStream : public v8::OutputStream
@@ -641,7 +659,7 @@ fail:
641
659
  st.err_reason = NO_ERROR;
642
660
  }
643
661
  auto result = v8::Boolean::New(st.isolate, ran_task);
644
- if (!reply(st, result)) abort();
662
+ reply_retry(st, result);
645
663
  }
646
664
 
647
665
  int snapshot(bool is_warmup, bool verbose_exceptions,
@@ -239,15 +239,44 @@ static void ser_num(Ser *s, double v)
239
239
  }
240
240
  }
241
241
 
242
+ // ser_bigint: |n| is in bytes, not quadwords
243
+ static void ser_bigint(Ser *s, const uint64_t *p, size_t n, int sign)
244
+ {
245
+ if (*s->err)
246
+ return;
247
+ if (n % 8) {
248
+ snprintf(s->err, sizeof(s->err), "bad bigint");
249
+ return;
250
+ }
251
+ w_byte(s, 'Z');
252
+ // chop off high all-zero words
253
+ n /= 8;
254
+ while (n--)
255
+ if (p[n])
256
+ break;
257
+ if (n == (size_t)-1) {
258
+ w_byte(s, 0); // normalized zero
259
+ } else {
260
+ n = 8*n + 8;
261
+ w_varint(s, 2*n + (sign < 0));
262
+ w(s, p, n);
263
+ }
264
+ }
265
+
242
266
  static void ser_int(Ser *s, int64_t v)
243
267
  {
268
+ uint64_t t;
269
+ int sign;
270
+
244
271
  if (*s->err)
245
272
  return;
246
273
  if (v < INT32_MIN || v > INT32_MAX) {
247
274
  if (v > INT64_MIN/1024)
248
275
  if (v <= INT64_MAX/1024)
249
276
  return ser_num(s, v);
250
- snprintf(s->err, sizeof(s->err), "out of range: %lld", (long long)v);
277
+ t = v < 0 ? -v : v;
278
+ sign = v < 0 ? -1 : 1;
279
+ ser_bigint(s, &t, sizeof(t), sign);
251
280
  } else {
252
281
  w_byte(s, 'I');
253
282
  w_zigzag(s, v);
@@ -265,30 +294,6 @@ static void ser_date(Ser *s, double v)
265
294
  }
266
295
  }
267
296
 
268
- // ser_bigint: |n| is in bytes, not quadwords
269
- static void ser_bigint(Ser *s, const uint64_t *p, size_t n, int sign)
270
- {
271
- if (*s->err)
272
- return;
273
- if (n % 8) {
274
- snprintf(s->err, sizeof(s->err), "bad bigint");
275
- return;
276
- }
277
- w_byte(s, 'Z');
278
- // chop off high all-zero words
279
- n /= 8;
280
- while (n--)
281
- if (p[n])
282
- break;
283
- if (n == (size_t)-1) {
284
- w_byte(s, 0); // normalized zero
285
- } else {
286
- n = 8*n + 8;
287
- w_varint(s, 2*n + (sign < 0));
288
- w(s, p, n);
289
- }
290
- }
291
-
292
297
  // string must be utf8
293
298
  static void ser_string(Ser *s, const char *p, size_t n)
294
299
  {
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniRacer
4
- VERSION = "0.18.0"
5
- LIBV8_NODE_VERSION = "~> 23.6.1.0"
4
+ VERSION = "0.19.0"
5
+ LIBV8_NODE_VERSION = "~> 24.1.0.0"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_racer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-05 00:00:00.000000000 Z
11
+ date: 2025-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 23.6.1.0
103
+ version: 24.1.0.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 23.6.1.0
110
+ version: 24.1.0.0
111
111
  description: Minimal embedded v8 engine for Ruby
112
112
  email:
113
113
  - sam.saffron@gmail.com
@@ -137,9 +137,9 @@ licenses:
137
137
  - MIT
138
138
  metadata:
139
139
  bug_tracker_uri: https://github.com/discourse/mini_racer/issues
140
- changelog_uri: https://github.com/discourse/mini_racer/blob/v0.18.0/CHANGELOG
141
- documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.18.0
142
- source_code_uri: https://github.com/discourse/mini_racer/tree/v0.18.0
140
+ changelog_uri: https://github.com/discourse/mini_racer/blob/v0.19.0/CHANGELOG
141
+ documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.19.0
142
+ source_code_uri: https://github.com/discourse/mini_racer/tree/v0.19.0
143
143
  post_install_message:
144
144
  rdoc_options: []
145
145
  require_paths: