Creating a separate Isolate for RegExp work is certainly possible. Whether
it's a good idea depends on your constraints. Things to consider:
- creating an Isolate has a cost; you can reduce overhead if you can keep
it around for several RegExp evaluations
- on the flip side, keeping an Isolate (and its heap) around consumes more
memory
- you could ship another RegExp engine instead, at the cost of some binary
size
- depending on how many RegExps you want to evaluate and at what times, you
could consider doing that on the main thread in the existing (Node)
Isolate, and only do non-RegExp work on the background thread.


On Tue, Aug 4, 2020 at 12:38 AM Maréchal Paul <[email protected]>
wrote:

> Hi Jakob,
>
> Thank you for the answer. Now that you mention it, even with the
> `Local<RegExp> New(Local<String> pattern, Flags flags)` method, I'd need an
> isolate to hold the pattern indeed.
>
> Then I have the following question: Is it a good idea for me to try and
> instantiate an Isolate of some sort, and have that run in the native thread
> I try to run the regexp into?
>
> Le lun. 3 août 2020 à 17:44, Jakob Kummerow <[email protected]> a
> écrit :
>
>> A v8::RegExp requires an Isolate. (There are at least two indicators for
>> this: (1) the class RegExp derives from Object, as such they are JavaScript
>> objects, and JavaScript objects always belong to an Isolate; (2) Local<>s
>> are used to hold RegExp instances, and Locals are used to refer to objects
>> on the managed heap, which is part of an Isolate.)
>>
>> Aside from that, v8::RegExps operate on v8::Strings, which also require
>> an Isolate to live in.
>>
>>
>> On Mon, Aug 3, 2020 at 10:37 PM Paul Maréchal <[email protected]>
>> wrote:
>>
>>> Hi,
>>>
>>> I am writing a Node.js addon that does work in a native thread. I need
>>> to run a regex match in said thread and I was hoping to use V8's RegExp
>>> objects.
>>>
>>> It is fair to say that I'm not a C++ expert, so I was wondering if
>>> anyone had any pointers regarding this? Is it even possible/a good idea?
>>>
>>> The API I am looking at has a deprecated static method that looked
>>> interesting but I don't understand how I am supposed to use the new one?
>>> https://v8docs.nodesource.com/node-10.15/d8/da7/classv8_1_1_reg_exp.html#aad5eb4ac27a23660c32f289da9427367
>>>
>>> Thanks in advance,
>>> Paul.
>>>
>>> --
>>> --
>>> v8-dev mailing list
>>> [email protected]
>>> http://groups.google.com/group/v8-dev
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "v8-dev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/v8-dev/667aed79-f5df-4005-ab55-e079cfc20b92n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/v8-dev/667aed79-f5df-4005-ab55-e079cfc20b92n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> --
>> v8-dev mailing list
>> [email protected]
>> http://groups.google.com/group/v8-dev
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "v8-dev" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/v8-dev/B7tJko0Itnk/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/v8-dev/CAKSzg3QpALxgBg8d4x1Uc8DENY09xRmhT%2Bjuo%2B_GYpOFDfpgng%40mail.gmail.com
>> <https://groups.google.com/d/msgid/v8-dev/CAKSzg3QpALxgBg8d4x1Uc8DENY09xRmhT%2Bjuo%2B_GYpOFDfpgng%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-dev/CAOKZV0a-X7RVVrr%3DQ%2B%2B%2Bi0FsCdfXt8VdTGWycofVvXJYyeTdfQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/v8-dev/CAOKZV0a-X7RVVrr%3DQ%2B%2B%2Bi0FsCdfXt8VdTGWycofVvXJYyeTdfQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CAKSzg3TRnt6dfn_%2B-1j%2BFBeCdvo3N1QaSN-%3D_48f%3D6YNfzV6-g%40mail.gmail.com.

Reply via email to