mini_racer 0.17.0.pre13 → 0.18.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: 02c93cf015b4c5e591ce5f6b3f61b787c3c12ea1d98b33dde6879461140ef9bd
4
- data.tar.gz: f77c6dbdee02fedcea41a2fe077aa71bc30c2c0dbc0630a1c09ebc90f075e4a1
3
+ metadata.gz: fef1f817dc1b549c08a4755afd1c767ea3bdfc34f44febd1792df24f867f28e8
4
+ data.tar.gz: 559080d182a14c5c52215d119afb9e79aec02a11a976b39b18088cb0841cbc6e
5
5
  SHA512:
6
- metadata.gz: 5b9370d3e4aa2bb017e9c450651381bc3b11880bcfee9448949cdc1cb0a7c01a3bb0836112c10a32d2f9c199c687cea16a5374142e9ba5201b5c526e524b09dc
7
- data.tar.gz: fecf25f26fa787280cc22eccd13deeee4dd554a36ee23e347149bc4e6d34b6a5eab623b8454d6ad0b6ad685e06e47cf8d45625ee015b033a1ed115ffb931e181
6
+ metadata.gz: b88dd39b59e72befdecc2312096e32e6fd79ee0822ea9ae2b319cfec4fc1327c1092a84bf8c30db721a7309fe279e009b2939cef9ce8334094cd701aea229540
7
+ data.tar.gz: 691b89578567b3fa2325f15a13a294f8cad664897fd0e966b78dfb13eae455abfb51d489ca73ffb166738b46a0e37b8ad8ccc225205170d19c58322e11ff10b3
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ - 0.18.0 - 05-03-2025
2
+ - Time for a major release
3
+ - Handle ActiveSupport TimeWithZone objects during serialization - Sam Saffron
4
+
5
+ - 0.18.0.pre1 - 06-02-2025
6
+ - Updated to node 23.6.1.0
7
+
1
8
  - 0.17.0.pre13 - 04-02-2025
2
9
  - Only issue idle GC once post dispatch - reduces CPU usage for auto cleanup - Sam Saffron
3
10
 
data/README.md CHANGED
@@ -97,19 +97,6 @@ context.eval("var a = new Array(10000); while(true) {a = a.concat(new Array(1000
97
97
  # => V8OutOfMemoryError is raised
98
98
  ```
99
99
 
100
- ### Object marshal max Stack Ddepth Support
101
-
102
- Contexts can specify a stack depth limit for object marshalling. Max depth is unbounded by default.
103
-
104
- ```ruby
105
- # terminates script if stack depth exceeds max during marshal
106
- context = MiniRacer::Context.new(marshal_stack_depth: 500)
107
- context.attach("a", proc{|a| a})
108
-
109
- context.eval("let arr = []; arr.push(arr); a(arr)")
110
- # => RuntimeError is raised
111
- ```
112
-
113
100
  ### Rich Debugging with File Name in Stack Trace Support
114
101
 
115
102
  You can provide `filename:` to `#eval` which will be used in stack traces produced by V8:
@@ -208,25 +195,7 @@ context.eval("counter")
208
195
 
209
196
  ### Garbage collection
210
197
 
211
- Re-using the same context over and over again means V8's garbage collector will have to run to clean it up every now and then; it's possible to trigger a _blocking_ V8 GC run inside your context by running the `idle_notification` method on it, which takes a single argument: the amount of time (in milliseconds) that V8 should use at most for garbage collecting:
212
-
213
- ```ruby
214
- context = MiniRacer::Context.new
215
-
216
- # do stuff with that context...
217
-
218
- # give up to 100ms for V8 garbage collection
219
- context.idle_notification(100)
220
-
221
- # force V8 to perform a full GC
222
- context.low_memory_notification
223
- ```
224
-
225
- This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
226
-
227
- Note that this method maps directly to [`v8::Isolate::IdleNotification`](http://bespin.cz/~ondras/html/classv8_1_1Isolate.html#aea16cbb2e351de9a3ae7be2b7cb48297), and that in particular its return value is the same (true if there is no further garbage to collect, false otherwise) and the same caveats apply, in particular that `there is no guarantee that the [call will return] within the time limit.`
228
-
229
- Additionally you may automate this process on a context by defining it with `MiniRacer::Context.new(ensure_gc_after_idle: 1000)`. Using this will ensure V8 will run a full GC using `context.low_memory_notification` 1 second after the last eval on the context. Low memory notification is both slower and more aggressive than an idle_notification and will ensure long living contexts use minimal amounts of memory.
198
+ You can make the garbage collector more aggressive by defining the context with `MiniRacer::Context.new(ensure_gc_after_idle: 1000)`. Using this will ensure V8 will run a full GC using `context.low_memory_notification` 1 second after the last eval on the context. Low memory notifications ensure long living contexts use minimal amounts of memory.
230
199
 
231
200
  ### V8 Runtime flags
232
201
 
@@ -395,7 +364,8 @@ Or install it yourself as:
395
364
  $ gem install mini_racer
396
365
  ```
397
366
 
398
- **Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or GCC 6.3 (or later).
367
+ **Note** using v8.h and compiling MiniRacer requires a C++20 capable compiler.
368
+ gcc >= 12.2 and Xcode >= 13 are, at the time of writing, known to work.
399
369
 
400
370
  ## Similar Projects
401
371
 
@@ -19,7 +19,7 @@ $CXXFLAGS += " -Wall" unless $CXXFLAGS.split.include? "-Wall"
19
19
  $CXXFLAGS += " -g" unless $CXXFLAGS.split.include? "-g"
20
20
  $CXXFLAGS += " -rdynamic" unless $CXXFLAGS.split.include? "-rdynamic"
21
21
  $CXXFLAGS += " -fPIC" unless $CXXFLAGS.split.include? "-rdynamic" or IS_DARWIN
22
- $CXXFLAGS += " -std=c++17"
22
+ $CXXFLAGS += " -std=c++20"
23
23
  $CXXFLAGS += " -fpermissive"
24
24
  $CXXFLAGS += " -fno-rtti"
25
25
  $CXXFLAGS += " -fno-exceptions"
@@ -47,28 +47,6 @@ if ENV['CXX']
47
47
  CONFIG['CXX'] = ENV['CXX']
48
48
  end
49
49
 
50
- CXX11_TEST = <<EOS
51
- #if __cplusplus <= 199711L
52
- # error A compiler that supports at least C++11 is required in order to compile this project.
53
- #endif
54
- EOS
55
-
56
- `echo "#{CXX11_TEST}" | #{CONFIG['CXX']} -std=c++0x -x c++ -E -`
57
- unless $?.success?
58
- warn <<EOS
59
-
60
-
61
- WARNING: C++11 support is required for compiling mini_racer. Please make sure
62
- you are using a compiler that supports at least C++11. Examples of such
63
- compilers are GCC 4.7+ and Clang 3.2+.
64
-
65
- If you are using Travis, consider either migrating your build to Ubuntu Trusty or
66
- installing GCC 4.8. See mini_racer's README.md for more information.
67
-
68
-
69
- EOS
70
- end
71
-
72
50
  CONFIG['LDSHARED'] = '$(CXX) -shared' unless IS_DARWIN
73
51
  if CONFIG['warnflags']
74
52
  CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
@@ -604,6 +604,20 @@ static int serialize1(Ser *s, VALUE refs, VALUE v)
604
604
  case T_STRING:
605
605
  add_string(s, v);
606
606
  break;
607
+ case T_OBJECT:
608
+ // this is somewhat wide, but we have active support which creates
609
+ // entirely new objects
610
+ if (rb_respond_to(v, rb_intern("to_time"))) {
611
+ v = rb_funcall(v, rb_intern("to_time"), 0);
612
+ }
613
+ if (rb_obj_is_kind_of(v, rb_cTime)) {
614
+ struct timeval tv = rb_time_timeval(v);
615
+ ser_date(s, tv.tv_sec*1e3 + tv.tv_usec/1e3);
616
+ } else {
617
+ snprintf(s->err, sizeof(s->err), "unsupported type %s", rb_class2name(CLASS_OF(v)));
618
+ return -1;
619
+ }
620
+ break;
607
621
  default:
608
622
  snprintf(s->err, sizeof(s->err), "unsupported type %x", TYPE(v));
609
623
  return -1;
@@ -703,7 +717,6 @@ static void dispatch1(Context *c, const uint8_t *p, size_t n)
703
717
  case 'C': return v8_timedwait(c, p+1, n-1, v8_call);
704
718
  case 'E': return v8_timedwait(c, p+1, n-1, v8_eval);
705
719
  case 'H': return v8_heap_snapshot(c->pst);
706
- case 'I': return v8_idle_notification(c->pst, p+1, n-1);
707
720
  case 'P': return v8_pump_message_loop(c->pst);
708
721
  case 'S': return v8_heap_stats(c->pst);
709
722
  case 'T': return v8_snapshot(c->pst, p+1, n-1);
@@ -1301,20 +1314,6 @@ static VALUE context_pump_message_loop(VALUE self)
1301
1314
  return rendezvous(c, &b); // takes ownership of |b|
1302
1315
  }
1303
1316
 
1304
- static VALUE context_idle_notification(VALUE self, VALUE arg)
1305
- {
1306
- Context *c;
1307
- Ser s;
1308
-
1309
- Check_Type(arg, T_FIXNUM);
1310
- TypedData_Get_Struct(self, Context, &context_type, c);
1311
- // request is (I)dle notification, idle_time_in_seconds
1312
- ser_init1(&s, 'I');
1313
- ser_num(&s, LONG2FIX(arg) / 1e3);
1314
- // response is |undefined|
1315
- return rendezvous(c, &s.b); // takes ownership of |s.b|
1316
- }
1317
-
1318
1317
  static VALUE context_low_memory_notification(VALUE self)
1319
1318
  {
1320
1319
  Buf req, res;
@@ -1638,7 +1637,6 @@ void Init_mini_racer_extension(void)
1638
1637
  rb_define_method(c, "heap_stats", context_heap_stats, 0);
1639
1638
  rb_define_method(c, "heap_snapshot", context_heap_snapshot, 0);
1640
1639
  rb_define_method(c, "pump_message_loop", context_pump_message_loop, 0);
1641
- rb_define_method(c, "idle_notification", context_idle_notification, 1);
1642
1640
  rb_define_method(c, "low_memory_notification", context_low_memory_notification, 0);
1643
1641
  rb_define_alloc_func(c, context_alloc);
1644
1642
 
@@ -834,26 +834,6 @@ fail:
834
834
  }
835
835
  }
836
836
 
837
- extern "C" void v8_idle_notification(State *pst, const uint8_t *p, size_t n)
838
- {
839
- State& st = *pst;
840
- v8::TryCatch try_catch(st.isolate);
841
- v8::HandleScope handle_scope(st.isolate);
842
- v8::ValueDeserializer des(st.isolate, p, n);
843
- des.ReadHeader(st.context).Check();
844
- double idle_time_in_seconds = .01;
845
- {
846
- v8::Local<v8::Value> idle_time_in_seconds_v;
847
- if (!des.ReadValue(st.context).ToLocal(&idle_time_in_seconds_v)) goto fail;
848
- if (!idle_time_in_seconds_v->NumberValue(st.context).To(&idle_time_in_seconds)) goto fail;
849
- }
850
- fail:
851
- double now = platform->MonotonicallyIncreasingTime();
852
- bool stop = st.isolate->IdleNotificationDeadline(now + idle_time_in_seconds);
853
- auto result = v8::Boolean::New(st.isolate, stop);
854
- if (!reply(st, result)) abort();
855
- }
856
-
857
837
  extern "C" void v8_low_memory_notification(State *pst)
858
838
  {
859
839
  pst->isolate->LowMemoryNotification();
@@ -45,7 +45,6 @@ void v8_heap_snapshot(struct State *pst);
45
45
  void v8_pump_message_loop(struct State *pst);
46
46
  void v8_snapshot(struct State *pst, const uint8_t *p, size_t n);
47
47
  void v8_warmup(struct State *pst, const uint8_t *p, size_t n);
48
- void v8_idle_notification(struct State *pst, const uint8_t *p, size_t n);
49
48
  void v8_low_memory_notification(struct State *pst);
50
49
  void v8_terminate_execution(struct State *pst); // called from ruby or watchdog thread
51
50
  void v8_single_threaded_enter(struct State *pst, struct Context *c, void (*f)(struct Context *c));
@@ -67,10 +67,6 @@ module MiniRacer
67
67
  GC.start
68
68
  end
69
69
 
70
- def idle_notification(idle_time)
71
- true
72
- end
73
-
74
70
  private
75
71
 
76
72
  @context_initialized = false
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniRacer
4
- VERSION = "0.17.0.pre13"
5
- LIBV8_NODE_VERSION = "~> 22.7.0.4"
4
+ VERSION = "0.18.0"
5
+ LIBV8_NODE_VERSION = "~> 23.6.1.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.17.0.pre13
4
+ version: 0.18.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-02-04 00:00:00.000000000 Z
11
+ date: 2025-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">"
74
+ - !ruby/object:Gem::Version
75
+ version: '6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">"
81
+ - !ruby/object:Gem::Version
82
+ version: '6'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: m
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +100,14 @@ dependencies:
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 22.7.0.4
103
+ version: 23.6.1.0
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 22.7.0.4
110
+ version: 23.6.1.0
97
111
  description: Minimal embedded v8 engine for Ruby
98
112
  email:
99
113
  - sam.saffron@gmail.com
@@ -123,9 +137,9 @@ licenses:
123
137
  - MIT
124
138
  metadata:
125
139
  bug_tracker_uri: https://github.com/discourse/mini_racer/issues
126
- changelog_uri: https://github.com/discourse/mini_racer/blob/v0.17.0.pre13/CHANGELOG
127
- documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.17.0.pre13
128
- source_code_uri: https://github.com/discourse/mini_racer/tree/v0.17.0.pre13
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
129
143
  post_install_message:
130
144
  rdoc_options: []
131
145
  require_paths: