mini_racer 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +15 -1
- data/ext/mini_racer_extension/extconf.rb +5 -0
- data/ext/mini_racer_extension/mini_racer_extension.cc +56 -45
- data/lib/mini_racer/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e832863760637f983976194ebef263d8815c149d48ff26c7200367ab33640dda
|
4
|
+
data.tar.gz: 7c1c393ae6403a75d2a413395d56e7d5f3affe706b81c121273b4c6b5d471bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4504cb3a564e5b311b65de74bac321b058995af17df47f9f3dc01fcb589a87eebfda55497e0ddb135a2ab15ef1818760652561d434d3f497c0dbd036451934c6
|
7
|
+
data.tar.gz: b83df123a61092ab4041212bb6e4f15b276d5e32e8be8d2b5cbc014988b8cf20ed0e0b3b30595de53ca4c0d599a86112d695009cda13891fe177742aff7d911e
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,20 @@
|
|
1
|
+
- 17-01-2021
|
2
|
+
|
3
|
+
- 0.6.2
|
4
|
+
|
5
|
+
- Fix support for compilation on 2.6, llvm compiles
|
6
|
+
- Stability patches to handle rare memory leaks
|
7
|
+
- Corrected re-raising of exceptions to support strings
|
8
|
+
- During early termination of context under certain conditions MiniRacer could crash
|
9
|
+
|
10
|
+
|
1
11
|
- 31-12-2021
|
2
12
|
|
13
|
+
- 0.6.1
|
14
|
+
|
15
|
+
- Added support for single threaded platform: `MiniRacer::Platform.set_flags! :single_threaded`
|
16
|
+
must be called prior to booting ANY MiniRacer::Context
|
17
|
+
|
3
18
|
- 0.6.0
|
4
19
|
|
5
20
|
- Ruby 3.1 support
|
@@ -13,7 +28,6 @@
|
|
13
28
|
- Fixes issues on aarch (Apple M1)
|
14
29
|
- Update to use libv8-node 16.x (#210) [Loic Nageleisen]
|
15
30
|
- FEATURE: Configurable max marshal stack depth (#202) [seanmakesgames]
|
16
|
-
- FEATURE: Configurable max marshal stack depth (#202) [seanmakesgames]
|
17
31
|
- Ruby 2.3 and 2.4 are EOL, we no longer support them
|
18
32
|
|
19
33
|
- 0.4.0
|
@@ -75,4 +75,9 @@ if enable_config('asan')
|
|
75
75
|
$LDFLAGS.insert(0, " -fsanitize=address ")
|
76
76
|
end
|
77
77
|
|
78
|
+
# there doesn't seem to be a CPP macro for this in Ruby 2.6:
|
79
|
+
if RUBY_ENGINE == 'ruby'
|
80
|
+
$CPPFLAGS += ' -DENGINE_IS_CRUBY '
|
81
|
+
end
|
82
|
+
|
78
83
|
create_makefile 'mini_racer_extension'
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#include <ruby.h>
|
3
3
|
#include <ruby/thread.h>
|
4
4
|
#include <ruby/io.h>
|
5
|
+
#include <ruby/version.h>
|
5
6
|
#include <v8.h>
|
6
7
|
#include <v8-profiler.h>
|
7
8
|
#include <libplatform/libplatform.h>
|
@@ -13,6 +14,14 @@
|
|
13
14
|
#include <math.h>
|
14
15
|
#include <errno.h>
|
15
16
|
|
17
|
+
/* workaround C Ruby <= 2.x problems w/ clang in C++ mode */
|
18
|
+
#if defined(ENGINE_IS_CRUBY) && \
|
19
|
+
RUBY_API_VERSION_MAJOR == 2 && RUBY_API_VERSION_MINOR <= 6
|
20
|
+
# define MR_METHOD_FUNC(fn) RUBY_METHOD_FUNC(fn)
|
21
|
+
#else
|
22
|
+
# define MR_METHOD_FUNC(fn) fn
|
23
|
+
#endif
|
24
|
+
|
16
25
|
using namespace v8;
|
17
26
|
|
18
27
|
typedef struct {
|
@@ -337,7 +346,7 @@ static VALUE rb_platform_set_flag_as_str(VALUE _klass, VALUE flag_as_str) {
|
|
337
346
|
if (!strcmp(RSTRING_PTR(flag_as_str), "--single_threaded")) {
|
338
347
|
single_threaded = true;
|
339
348
|
}
|
340
|
-
V8::SetFlagsFromString(RSTRING_PTR(flag_as_str), (
|
349
|
+
V8::SetFlagsFromString(RSTRING_PTR(flag_as_str), RSTRING_LENINT(flag_as_str));
|
341
350
|
} else {
|
342
351
|
platform_already_initialized = true;
|
343
352
|
}
|
@@ -360,7 +369,11 @@ static void init_v8() {
|
|
360
369
|
|
361
370
|
if (current_platform == NULL) {
|
362
371
|
V8::InitializeICU();
|
363
|
-
|
372
|
+
if (single_threaded) {
|
373
|
+
current_platform = platform::NewSingleThreadedDefaultPlatform();
|
374
|
+
} else {
|
375
|
+
current_platform = platform::NewDefaultPlatform();
|
376
|
+
}
|
364
377
|
V8::InitializePlatform(current_platform.get());
|
365
378
|
V8::Initialize();
|
366
379
|
}
|
@@ -405,28 +418,32 @@ static void prepare_result(MaybeLocal<Value> v8res,
|
|
405
418
|
Local<Value> local_value = v8res.ToLocalChecked();
|
406
419
|
if ((local_value->IsObject() || local_value->IsArray()) &&
|
407
420
|
!local_value->IsDate() && !local_value->IsFunction()) {
|
408
|
-
|
409
|
-
context, String::NewFromUtf8Literal(isolate, "JSON"))
|
410
|
-
.ToLocalChecked().As<Object>();
|
411
|
-
|
412
|
-
Local<Function> stringify = JSON->Get(
|
413
|
-
context, v8::String::NewFromUtf8Literal(isolate, "stringify"))
|
414
|
-
.ToLocalChecked().As<Function>();
|
421
|
+
MaybeLocal<v8::Value> ml = context->Global()->Get(
|
422
|
+
context, String::NewFromUtf8Literal(isolate, "JSON"));
|
415
423
|
|
416
|
-
|
417
|
-
const unsigned argc = 1;
|
418
|
-
Local<Value> argv[argc] = { object };
|
419
|
-
MaybeLocal<Value> json = stringify->Call(context, JSON, argc, argv);
|
420
|
-
|
421
|
-
if (json.IsEmpty()) {
|
424
|
+
if (ml.IsEmpty()) { // exception
|
422
425
|
evalRes.executed = false;
|
423
426
|
} else {
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
427
|
+
Local<Object> JSON = ml.ToLocalChecked().As<Object>();
|
428
|
+
|
429
|
+
Local<Function> stringify = JSON->Get(
|
430
|
+
context, v8::String::NewFromUtf8Literal(isolate, "stringify"))
|
431
|
+
.ToLocalChecked().As<Function>();
|
432
|
+
|
433
|
+
Local<Object> object = local_value->ToObject(context).ToLocalChecked();
|
434
|
+
const unsigned argc = 1;
|
435
|
+
Local<Value> argv[argc] = { object };
|
436
|
+
MaybeLocal<Value> json = stringify->Call(context, JSON, argc, argv);
|
437
|
+
|
438
|
+
if (json.IsEmpty()) {
|
439
|
+
evalRes.executed = false;
|
440
|
+
} else {
|
441
|
+
evalRes.json = true;
|
442
|
+
Persistent<Value>* persistent = new Persistent<Value>();
|
443
|
+
persistent->Reset(isolate, json.ToLocalChecked());
|
444
|
+
evalRes.value = persistent;
|
445
|
+
}
|
428
446
|
}
|
429
|
-
|
430
447
|
} else {
|
431
448
|
Persistent<Value>* persistent = new Persistent<Value>();
|
432
449
|
persistent->Reset(isolate, local_value);
|
@@ -707,7 +724,7 @@ static Local<Value> convert_ruby_to_v8(Isolate* isolate, Local<Context> context,
|
|
707
724
|
case T_FLOAT:
|
708
725
|
return scope.Escape(Number::New(isolate, NUM2DBL(value)));
|
709
726
|
case T_STRING:
|
710
|
-
return scope.Escape(String::NewFromUtf8(isolate, RSTRING_PTR(value), NewStringType::kNormal, (
|
727
|
+
return scope.Escape(String::NewFromUtf8(isolate, RSTRING_PTR(value), NewStringType::kNormal, RSTRING_LENINT(value)).ToLocalChecked());
|
711
728
|
case T_NIL:
|
712
729
|
return scope.Escape(Null(isolate));
|
713
730
|
case T_TRUE:
|
@@ -735,7 +752,7 @@ static Local<Value> convert_ruby_to_v8(Isolate* isolate, Local<Context> context,
|
|
735
752
|
return scope.Escape(object);
|
736
753
|
case T_SYMBOL:
|
737
754
|
value = rb_funcall(value, rb_intern("to_s"), 0);
|
738
|
-
return scope.Escape(String::NewFromUtf8(isolate, RSTRING_PTR(value), NewStringType::kNormal, (
|
755
|
+
return scope.Escape(String::NewFromUtf8(isolate, RSTRING_PTR(value), NewStringType::kNormal, RSTRING_LENINT(value)).ToLocalChecked());
|
739
756
|
case T_DATA:
|
740
757
|
klass = rb_funcall(value, rb_intern("class"), 0);
|
741
758
|
if (klass == rb_cTime || klass == rb_cDateTime)
|
@@ -1053,7 +1070,7 @@ static VALUE convert_result_to_ruby(VALUE self /* context */,
|
|
1053
1070
|
// a v8 scope, if we do the scope is never cleaned up properly and we leak
|
1054
1071
|
if (!result.parsed) {
|
1055
1072
|
if(TYPE(message) == T_STRING) {
|
1056
|
-
rb_raise(rb_eParseError, "%
|
1073
|
+
rb_raise(rb_eParseError, "%" PRIsVALUE, message);
|
1057
1074
|
} else {
|
1058
1075
|
rb_raise(rb_eParseError, "Unknown JavaScript Error during parse");
|
1059
1076
|
}
|
@@ -1077,15 +1094,17 @@ static VALUE convert_result_to_ruby(VALUE self /* context */,
|
|
1077
1094
|
|
1078
1095
|
// exception report about what happened
|
1079
1096
|
if (TYPE(backtrace) == T_STRING) {
|
1080
|
-
rb_raise(ruby_exception, "%
|
1097
|
+
rb_raise(ruby_exception, "%" PRIsVALUE, backtrace);
|
1081
1098
|
} else if(TYPE(message) == T_STRING) {
|
1082
|
-
rb_raise(ruby_exception, "%
|
1099
|
+
rb_raise(ruby_exception, "%" PRIsVALUE, message);
|
1083
1100
|
} else {
|
1084
1101
|
rb_raise(ruby_exception, "Unknown JavaScript Error during execution");
|
1085
1102
|
}
|
1103
|
+
} else if (rb_obj_is_kind_of(ruby_exception, rb_eException)) {
|
1104
|
+
rb_exc_raise(ruby_exception);
|
1086
1105
|
} else {
|
1087
1106
|
VALUE rb_str = rb_funcall(ruby_exception, rb_intern("to_s"), 0);
|
1088
|
-
rb_raise(CLASS_OF(ruby_exception), "%
|
1107
|
+
rb_raise(CLASS_OF(ruby_exception), "%" PRIsVALUE, rb_str);
|
1089
1108
|
}
|
1090
1109
|
}
|
1091
1110
|
|
@@ -1145,13 +1164,13 @@ static VALUE rb_context_eval_unsafe(VALUE self, VALUE str, VALUE filename) {
|
|
1145
1164
|
HandleScope handle_scope(isolate);
|
1146
1165
|
|
1147
1166
|
Local<String> eval = String::NewFromUtf8(isolate, RSTRING_PTR(str),
|
1148
|
-
NewStringType::kNormal, (
|
1167
|
+
NewStringType::kNormal, RSTRING_LENINT(str)).ToLocalChecked();
|
1149
1168
|
|
1150
1169
|
Local<String> local_filename;
|
1151
1170
|
|
1152
1171
|
if (filename != Qnil) {
|
1153
1172
|
local_filename = String::NewFromUtf8(isolate, RSTRING_PTR(filename),
|
1154
|
-
NewStringType::kNormal, (
|
1173
|
+
NewStringType::kNormal, RSTRING_LENINT(filename)).ToLocalChecked();
|
1155
1174
|
eval_params.filename = &local_filename;
|
1156
1175
|
} else {
|
1157
1176
|
eval_params.filename = NULL;
|
@@ -1275,8 +1294,8 @@ gvl_ruby_callback(void* data) {
|
|
1275
1294
|
VALUE callback_data_value = (VALUE)&callback_data;
|
1276
1295
|
|
1277
1296
|
// TODO: use rb_vrescue2 in Ruby 2.7 and above
|
1278
|
-
result = rb_rescue2(protected_callback, callback_data_value,
|
1279
|
-
rescue_callback, callback_data_value, rb_eException, (VALUE)0);
|
1297
|
+
result = rb_rescue2(MR_METHOD_FUNC(protected_callback), callback_data_value,
|
1298
|
+
MR_METHOD_FUNC(rescue_callback), callback_data_value, rb_eException, (VALUE)0);
|
1280
1299
|
|
1281
1300
|
if(callback_data.failed) {
|
1282
1301
|
rb_iv_set(parent, "@current_exception", result);
|
@@ -1337,7 +1356,7 @@ static VALUE rb_external_function_notify_v8(VALUE self) {
|
|
1337
1356
|
|
1338
1357
|
Local<String> v8_str =
|
1339
1358
|
String::NewFromUtf8(isolate, RSTRING_PTR(name),
|
1340
|
-
NewStringType::kNormal, (
|
1359
|
+
NewStringType::kNormal, RSTRING_LENINT(name))
|
1341
1360
|
.ToLocalChecked();
|
1342
1361
|
|
1343
1362
|
// Note that self (rb_cExternalFunction) is a pure Ruby T_OBJECT,
|
@@ -1357,7 +1376,7 @@ static VALUE rb_external_function_notify_v8(VALUE self) {
|
|
1357
1376
|
Local<String> eval =
|
1358
1377
|
String::NewFromUtf8(isolate, RSTRING_PTR(parent_object_eval),
|
1359
1378
|
NewStringType::kNormal,
|
1360
|
-
(
|
1379
|
+
RSTRING_LENINT(parent_object_eval))
|
1361
1380
|
.ToLocalChecked();
|
1362
1381
|
|
1363
1382
|
MaybeLocal<Script> parsed_script = Script::Compile(context, eval);
|
@@ -1816,23 +1835,15 @@ static VALUE rb_context_call_unsafe(int argc, VALUE *argv, VALUE self) {
|
|
1816
1835
|
if (val.IsEmpty() || !val.ToLocalChecked()->IsFunction()) {
|
1817
1836
|
missingFunction = true;
|
1818
1837
|
} else {
|
1819
|
-
|
1820
1838
|
Local<v8::Function> fun = Local<v8::Function>::Cast(val.ToLocalChecked());
|
1839
|
+
VALUE tmp;
|
1821
1840
|
call.fun = fun;
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
call.argv = (v8::Local<Value> *) malloc(sizeof(void *) * fun_argc);
|
1826
|
-
if (!call.argv) {
|
1827
|
-
return Qnil;
|
1828
|
-
}
|
1829
|
-
for(int i=0; i < fun_argc; i++) {
|
1830
|
-
call.argv[i] = convert_ruby_to_v8(isolate, context, call_argv[i]);
|
1831
|
-
}
|
1841
|
+
call.argv = (v8::Local<Value> *)RB_ALLOCV_N(void *, tmp, call.argc);
|
1842
|
+
for(int i=0; i < call.argc; i++) {
|
1843
|
+
call.argv[i] = convert_ruby_to_v8(isolate, context, call_argv[i]);
|
1832
1844
|
}
|
1833
1845
|
rb_thread_call_without_gvl(nogvl_context_call, &call, unblock_function, &call);
|
1834
|
-
|
1835
|
-
|
1846
|
+
RB_ALLOCV_END(tmp);
|
1836
1847
|
}
|
1837
1848
|
}
|
1838
1849
|
|
data/lib/mini_racer/version.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,9 +128,9 @@ licenses:
|
|
128
128
|
- MIT
|
129
129
|
metadata:
|
130
130
|
bug_tracker_uri: https://github.com/discourse/mini_racer/issues
|
131
|
-
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.6.
|
132
|
-
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.6.
|
133
|
-
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.6.
|
131
|
+
changelog_uri: https://github.com/discourse/mini_racer/blob/v0.6.2/CHANGELOG
|
132
|
+
documentation_uri: https://www.rubydoc.info/gems/mini_racer/0.6.2
|
133
|
+
source_code_uri: https://github.com/discourse/mini_racer/tree/v0.6.2
|
134
134
|
post_install_message:
|
135
135
|
rdoc_options: []
|
136
136
|
require_paths:
|