execjs-pcruntime 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/README.md +17 -0
- data/doc_resources/out/sequence_fastnode1/sequence_fastnode1.svg +35 -0
- data/doc_resources/out/sequence_fastnode2/sequence_fastnode2.svg +70 -0
- data/doc_resources/out/sequence_nodejs/sequence_nodejs.svg +37 -0
- data/doc_resources/out/sequence_pcruntime/sequence_pcruntime.svg +50 -0
- data/doc_resources/sequence_fastnode1.pu +25 -0
- data/doc_resources/sequence_fastnode2.pu +60 -0
- data/doc_resources/sequence_nodejs.pu +27 -0
- data/doc_resources/sequence_pcruntime.pu +40 -0
- data/lib/execjs/pcruntime/context_process_runtime.rb +8 -4
- data/lib/execjs/pcruntime/runner.js +4 -3
- data/lib/execjs/pcruntime/version.rb +1 -1
- data/lib/execjs/pcruntime.rb +2 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec9e69936452420277727dacd0c7d27331b7766c8008c433cd840a8c6f38f45
|
4
|
+
data.tar.gz: 75271e7344781d9338c09263b1ac036355147cd228ae0b7581272cfb3dc53a1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz: '
|
6
|
+
metadata.gz: b8a8075e90042f2e6183dae5faf84e3c8749b0b8138e9f30fc3499287eef1cf2a3120f5bc7d5c9e3427ce9fe088ad0b28f38cfa3a4471df6b9c25cb4b3c38006
|
7
|
+
data.tar.gz: '088fe43e02e523346e26ad05cd8617aa3298e046b90760cdafcdb7d0f74fd9a4b3c0ab56e8489e65ac51493850611faf267bd1899a3486088153ddc9fd594ad0'
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,23 @@ Accelerated ExecJS Runtime by launching Node.js Processes per Context, not per e
|
|
4
4
|
|
5
5
|
inspired by [execjs-fastnode](https://github.com/jhawthorn/execjs-fastnode)
|
6
6
|
|
7
|
+
## How PCRuntime fast?
|
8
|
+
|
9
|
+
The existing Node.js runtime spawns a Node.js process for each eval, regardless of whether it compiles or not.
|
10
|
+
To reduce this overhead, execjs-fastnode is designed to launch a single Node.js process and manage the Context in JavaScript.
|
11
|
+
|
12
|
+
| Node.js | execjs-fastnode |
|
13
|
+
|:-------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------:|
|
14
|
+
| ![Sequence Diagram of Node.js Runtime](./doc_resources/out/sequence_nodejs/sequence_nodejs.svg) | ![Sequence Diagram of FastNode Runtime](./doc_resources/out/sequence_fastnode1/sequence_fastnode1.svg) |
|
15
|
+
|
16
|
+
execjs-fastnode is designed to limit the number of threads that can access a Node.js process to 1 to avoid the race condition when multiple Contexts are used.
|
17
|
+
execjs-pcruntime works lock-free by creating a Node.js process for each Context.
|
18
|
+
This improves performance when used with multi-threading.
|
19
|
+
|
20
|
+
| execjs-fastnode(multi-threading) | execjs-pcruntime |
|
21
|
+
|:-------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
|
22
|
+
| ![Sequence Diagram of FastNode Runtime in multi-threading](./doc_resources/out/sequence_fastnode2/sequence_fastnode2.svg) | ![Sequence Diagram of PCRuntime](./doc_resources/out/sequence_pcruntime/sequence_pcruntime.svg) |
|
23
|
+
|
7
24
|
## Requirements
|
8
25
|
|
9
26
|
- Ruby >= 3.0.0
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="417px" preserveAspectRatio="none" style="width:603px;height:417px;background:#FFFFFF;" version="1.1" viewBox="0 0 603 417" width="603px" zoomAndPan="magnify"><defs/><g><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="59.5" x2="59.5" y1="36.4883" y2="381.2598"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="394.5" x2="394.5" y1="44.4883" y2="381.2598"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="536.5" x2="536.5" y1="75.9766" y2="381.2598"/><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="109" x="5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="95" x="12" y="25.5352">User program</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="109" x="5" y="381.2598"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="95" x="12" y="401.7949">User program</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="336.5" y="381.2598"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="343.5" y="401.7949">execjs Context</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="122" x="475.5" y="381.2598"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="108" x="482.5" y="401.7949">Node.js process</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="336.5" y="44.4883"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="343.5" y="65.0234">execjs Context</text><polygon fill="#181818" points="324.5,61.7988,334.5,65.7988,324.5,69.7988,328.5,65.7988" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="59.5" x2="330.5" y1="65.7988" y2="65.7988"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="253" x="66.5" y="61.0566">context = ExecJS.compile(initial_source)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="122" x="475.5" y="75.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="108" x="482.5" y="96.5117">Node.js process</text><polygon fill="#181818" points="463.5,93.2871,473.5,97.2871,463.5,101.2871,467.5,97.2871" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="394.5" x2="469.5" y1="97.2871" y2="97.2871"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="40" x="401.5" y="92.5449">spawn</text><polygon fill="#181818" points="524.5,124.7754,534.5,128.7754,524.5,132.7754,528.5,128.7754" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="394.5" x2="530.5" y1="128.7754" y2="128.7754"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="401.5" y="124.0332">eval(initial_source)</text><polygon fill="#181818" points="382.5,154.0859,392.5,158.0859,382.5,162.0859,386.5,158.0859" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="59.5" x2="388.5" y1="158.0859" y2="158.0859"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="132" x="66.5" y="153.3438">context.call(source1)</text><polygon fill="#181818" points="524.5,183.3965,534.5,187.3965,524.5,191.3965,528.5,187.3965" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="394.5" x2="530.5" y1="187.3965" y2="187.3965"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="83" x="401.5" y="182.6543">eval(source1)</text><polygon fill="#181818" points="405.5,212.707,395.5,216.707,405.5,220.707,401.5,216.707" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="399.5" x2="535.5" y1="216.707" y2="216.707"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="411.5" y="211.9648">result: string</text><polygon fill="#181818" points="70.5,242.0176,60.5,246.0176,70.5,250.0176,66.5,246.0176" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="64.5" x2="393.5" y1="246.0176" y2="246.0176"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="76.5" y="241.2754">result: Ruby object</text><polygon fill="#181818" points="382.5,271.3281,392.5,275.3281,382.5,279.3281,386.5,275.3281" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="59.5" x2="388.5" y1="275.3281" y2="275.3281"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="132" x="66.5" y="270.5859">context.call(source2)</text><polygon fill="#181818" points="524.5,300.6387,534.5,304.6387,524.5,308.6387,528.5,304.6387" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="394.5" x2="530.5" y1="304.6387" y2="304.6387"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="83" x="401.5" y="299.8965">eval(source2)</text><polygon fill="#181818" points="405.5,329.9492,395.5,333.9492,405.5,337.9492,401.5,333.9492" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="399.5" x2="535.5" y1="333.9492" y2="333.9492"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="411.5" y="329.207">result: string</text><polygon fill="#181818" points="70.5,359.2598,60.5,363.2598,70.5,367.2598,66.5,363.2598" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="64.5" x2="393.5" y1="363.2598" y2="363.2598"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="76.5" y="358.5176">result: Ruby object</text><!--MD5=[7b77d49a8f754d39ea997907a8f03ad1]
|
2
|
+
@startuml
|
3
|
+
|
4
|
+
!pragma teoz true
|
5
|
+
|
6
|
+
participant "User program" as ruby
|
7
|
+
participant "execjs Context" as context
|
8
|
+
participant "Node.js process" as node
|
9
|
+
|
10
|
+
create context
|
11
|
+
ruby -> context : context = ExecJS.compile(initial_source)
|
12
|
+
create node
|
13
|
+
context -> node : spawn
|
14
|
+
context -> node : eval(initial_source)
|
15
|
+
|
16
|
+
ruby -> context : context.call(source1)
|
17
|
+
context -> node : eval(source1)
|
18
|
+
node -> context : result: string
|
19
|
+
context -> ruby : result: Ruby object
|
20
|
+
|
21
|
+
ruby -> context : context.call(source2)
|
22
|
+
context -> node : eval(source2)
|
23
|
+
node -> context : result: string
|
24
|
+
context -> ruby : result: Ruby object
|
25
|
+
|
26
|
+
@enduml
|
27
|
+
|
28
|
+
PlantUML version 1.2022.7(Tue Aug 23 02:01:30 JST 2022)
|
29
|
+
(GPL source distribution)
|
30
|
+
Java Runtime: Java(TM) SE Runtime Environment
|
31
|
+
JVM: Java HotSpot(TM) 64-Bit Server VM
|
32
|
+
Default Encoding: UTF-8
|
33
|
+
Language: ja
|
34
|
+
Country: JP
|
35
|
+
--></g></svg>
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="1107px" preserveAspectRatio="none" style="width:1475px;height:1107px;background:#FFFFFF;" version="1.1" viewBox="0 0 1475 1107" width="1475px" zoomAndPan="magnify"><defs/><g><rect fill="none" height="88.1094" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="140.7754"/><rect fill="none" height="56.6211" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="246.8848"/><rect fill="none" height="85.9316" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="380.127"/><rect fill="none" height="85.9316" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="530.6797"/><rect fill="none" height="85.9316" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="751.8535"/><rect fill="none" height="85.9316" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="902.4063"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="93.5" x2="93.5" y1="36.4883" y2="1070.959"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="449" x2="449" y1="44.4883" y2="1070.959"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="668" x2="668" y1="36.4883" y2="1070.959"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="892" x2="892" y1="168.0859" y2="1070.959"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="1025.5" x2="1025.5" y1="75.9766" y2="1070.959"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="1381" x2="1381" y1="36.4883" y2="1070.959"/><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="177" x="5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="163" x="12" y="25.5352">User program(Thread1)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="113" x="611.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="99" x="618.5" y="25.5352">internal object</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="177" x="1292.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="163" x="1299.5" y="25.5352">User program(Thread2)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="177" x="5" y="1070.959"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="163" x="12" y="1091.4941">User program(Thread1)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="125" x="386.5" y="1070.959"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="111" x="393.5" y="1091.4941">execjs Context1</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="113" x="611.5" y="1070.959"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="99" x="618.5" y="1091.4941">internal object</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="122" x="831" y="1070.959"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="108" x="838" y="1091.4941">Node.js process</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="125" x="963" y="1070.959"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="111" x="970" y="1091.4941">execjs Context2</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="177" x="1292.5" y="1070.959"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="163" x="1299.5" y="1091.4941">User program(Thread2)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="125" x="386.5" y="44.4883"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="111" x="393.5" y="65.0234">execjs Context1</text><polygon fill="#181818" points="374.5,61.7988,384.5,65.7988,374.5,69.7988,378.5,65.7988" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="93.5" x2="380.5" y1="65.7988" y2="65.7988"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="269" x="100.5" y="61.0566">context1 = ExecJS.compile(initial_source1)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="125" x="963" y="75.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="111" x="970" y="96.5117">execjs Context2</text><polygon fill="#181818" points="1099,93.2871,1089,97.2871,1099,101.2871,1095,97.2871" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1093" x2="1380" y1="97.2871" y2="97.2871"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="269" x="1105" y="92.5449">context2 = ExecJS.compile(initial_source2)</text><polygon fill="#181818" points="656,124.7754,666,128.7754,656,132.7754,660,128.7754" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="449" x2="662" y1="128.7754" y2="128.7754"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="195" x="456" y="124.0332">Create Context(initial_source1)</text><polygon fill="#181818" points="679,124.7754,669,128.7754,679,132.7754,675,128.7754" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="673" x2="1024.5" y1="128.7754" y2="128.7754"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="195" x="685" y="124.0332">Create Context(initial_source2)</text><path d="M652,140.7754 L780,140.7754 L780,148.0859 L770,158.0859 L652,158.0859 L652,140.7754 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.5;"/><rect fill="none" height="88.1094" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="140.7754"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="83" x="667" y="154.3438">synchronize</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="122" x="831" y="168.0859"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="108" x="838" y="188.6211">Node.js process</text><polygon fill="#181818" points="819,185.3965,829,189.3965,819,193.3965,823,189.3965" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="825" y1="189.3965" y2="189.3965"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="40" x="675" y="184.6543">spawn</text><polygon fill="#181818" points="880,216.8848,890,220.8848,880,224.8848,884,220.8848" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="886" y1="220.8848" y2="220.8848"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="200" x="675" y="216.1426">eval(context=1, initial_source1)</text><path d="M652,246.8848 L780,246.8848 L780,254.1953 L770,264.1953 L652,264.1953 L652,246.8848 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.5;"/><rect fill="none" height="56.6211" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="246.8848"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="83" x="667" y="260.4531">synchronize</text><polygon fill="#181818" points="880,291.5059,890,295.5059,880,299.5059,884,295.5059" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="886" y1="295.5059" y2="295.5059"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="200" x="675" y="290.7637">eval(context=2, initial_source2)</text><polygon fill="#181818" points="437,334.8164,447,338.8164,437,342.8164,441,338.8164" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="93.5" x2="443" y1="338.8164" y2="338.8164"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="140" x="100.5" y="334.0742">context1.call(source1)</text><polygon fill="#181818" points="1036.5,334.8164,1026.5,338.8164,1036.5,342.8164,1032.5,338.8164" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1030.5" x2="1380" y1="338.8164" y2="338.8164"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="140" x="1042.5" y="334.0742">context2.call(source2)</text><polygon fill="#181818" points="656,364.127,666,368.127,656,372.127,660,368.127" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="449" x2="662" y1="368.127" y2="368.127"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="157" x="456" y="363.3848">eval(context=1, source1)</text><polygon fill="#181818" points="679,364.127,669,368.127,679,372.127,675,368.127" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="673" x2="1024.5" y1="368.127" y2="368.127"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="157" x="685" y="363.3848">eval(context=2, source2)</text><path d="M652,380.127 L780,380.127 L780,387.4375 L770,397.4375 L652,397.4375 L652,380.127 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.5;"/><rect fill="none" height="85.9316" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="380.127"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="83" x="667" y="393.6953">synchronize</text><polygon fill="#181818" points="880,424.748,890,428.748,880,432.748,884,428.748" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="886" y1="428.748" y2="428.748"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="157" x="675" y="424.0059">eval(context=1, source1)</text><polygon fill="#181818" points="679,454.0586,669,458.0586,679,462.0586,675,458.0586" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="673" x2="891" y1="458.0586" y2="458.0586"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="685" y="453.3164">result: string</text><polygon fill="#181818" points="460,497.3691,450,501.3691,460,505.3691,456,501.3691" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="454" x2="667" y1="501.3691" y2="501.3691"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="466" y="496.627">result: Ruby object</text><polygon fill="#181818" points="104.5,526.6797,94.5,530.6797,104.5,534.6797,100.5,530.6797" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="98.5" x2="448" y1="530.6797" y2="530.6797"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="110.5" y="525.9375">result: Ruby object</text><path d="M652,530.6797 L780,530.6797 L780,537.9902 L770,547.9902 L652,547.9902 L652,530.6797 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.5;"/><rect fill="none" height="85.9316" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="530.6797"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="83" x="667" y="544.248">synchronize</text><polygon fill="#181818" points="880,575.3008,890,579.3008,880,583.3008,884,579.3008" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="886" y1="579.3008" y2="579.3008"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="157" x="675" y="574.5586">eval(context=2, source2)</text><polygon fill="#181818" points="679,604.6113,669,608.6113,679,612.6113,675,608.6113" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="673" x2="891" y1="608.6113" y2="608.6113"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="685" y="603.8691">result: string</text><polygon fill="#181818" points="1013.5,647.9219,1023.5,651.9219,1013.5,655.9219,1017.5,651.9219" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="1019.5" y1="651.9219" y2="651.9219"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="675" y="647.1797">result: Ruby object</text><polygon fill="#181818" points="1369,677.2324,1379,681.2324,1369,685.2324,1373,681.2324" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1025.5" x2="1375" y1="681.2324" y2="681.2324"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="1032.5" y="676.4902">result: Ruby object</text><polygon fill="#181818" points="437,706.543,447,710.543,437,714.543,441,710.543" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="93.5" x2="443" y1="710.543" y2="710.543"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="140" x="100.5" y="705.8008">context1.call(source3)</text><polygon fill="#181818" points="1036.5,706.543,1026.5,710.543,1036.5,714.543,1032.5,710.543" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1030.5" x2="1380" y1="710.543" y2="710.543"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="140" x="1042.5" y="705.8008">context2.call(source4)</text><polygon fill="#181818" points="656,735.8535,666,739.8535,656,743.8535,660,739.8535" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="449" x2="662" y1="739.8535" y2="739.8535"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="157" x="456" y="735.1113">eval(context=1, source3)</text><polygon fill="#181818" points="679,735.8535,669,739.8535,679,743.8535,675,739.8535" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="673" x2="1024.5" y1="739.8535" y2="739.8535"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="157" x="685" y="735.1113">eval(context=2, source4)</text><path d="M652,751.8535 L780,751.8535 L780,759.1641 L770,769.1641 L652,769.1641 L652,751.8535 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.5;"/><rect fill="none" height="85.9316" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="751.8535"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="83" x="667" y="765.4219">synchronize</text><polygon fill="#181818" points="880,796.4746,890,800.4746,880,804.4746,884,800.4746" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="886" y1="800.4746" y2="800.4746"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="157" x="675" y="795.7324">eval(context=2, source4)</text><polygon fill="#181818" points="679,825.7852,669,829.7852,679,833.7852,675,829.7852" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="673" x2="891" y1="829.7852" y2="829.7852"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="685" y="825.043">result: string</text><polygon fill="#181818" points="1013.5,869.0957,1023.5,873.0957,1013.5,877.0957,1017.5,873.0957" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="1019.5" y1="873.0957" y2="873.0957"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="675" y="868.3535">result: Ruby object</text><polygon fill="#181818" points="1369,898.4063,1379,902.4063,1369,906.4063,1373,902.4063" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1025.5" x2="1375" y1="902.4063" y2="902.4063"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="1032.5" y="897.6641">result: Ruby object</text><path d="M652,902.4063 L780,902.4063 L780,909.7168 L770,919.7168 L652,919.7168 L652,902.4063 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.5;"/><rect fill="none" height="85.9316" style="stroke:#000000;stroke-width:1.5;" width="256" x="652" y="902.4063"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="83" x="667" y="915.9746">synchronize</text><polygon fill="#181818" points="880,947.0273,890,951.0273,880,955.0273,884,951.0273" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="668" x2="886" y1="951.0273" y2="951.0273"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="157" x="675" y="946.2852">eval(context=1, source3)</text><polygon fill="#181818" points="679,976.3379,669,980.3379,679,984.3379,675,980.3379" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="673" x2="891" y1="980.3379" y2="980.3379"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="685" y="975.5957">result: string</text><polygon fill="#181818" points="460,1019.6484,450,1023.6484,460,1027.6484,456,1023.6484" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="454" x2="667" y1="1023.6484" y2="1023.6484"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="466" y="1018.9063">result: Ruby object</text><polygon fill="#181818" points="104.5,1048.959,94.5,1052.959,104.5,1056.959,100.5,1052.959" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="98.5" x2="448" y1="1052.959" y2="1052.959"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="110.5" y="1048.2168">result: Ruby object</text><!--MD5=[8231295b6a95a226c222b426b1af1829]
|
2
|
+
@startuml
|
3
|
+
|
4
|
+
!pragma teoz true
|
5
|
+
|
6
|
+
participant "User program(Thread1)" as ruby1
|
7
|
+
participant "execjs Context1" as context1
|
8
|
+
participant "internal object" as vm
|
9
|
+
participant "Node.js process" as node
|
10
|
+
participant "execjs Context2" as context2
|
11
|
+
participant "User program(Thread2)" as ruby2
|
12
|
+
|
13
|
+
create context1
|
14
|
+
ruby1 -> context1 : context1 = ExecJS.compile(initial_source1)
|
15
|
+
create context2
|
16
|
+
ruby2 -> context2 : context2 = ExecJS.compile(initial_source2)
|
17
|
+
context1 -> vm : Create Context(initial_source1)
|
18
|
+
& context2 -> vm : Create Context(initial_source2)
|
19
|
+
create node
|
20
|
+
group synchronize
|
21
|
+
vm -> node : spawn
|
22
|
+
vm -> node : eval(context=1, initial_source1)
|
23
|
+
end
|
24
|
+
group synchronize
|
25
|
+
vm -> node : eval(context=2, initial_source2)
|
26
|
+
end
|
27
|
+
|
28
|
+
ruby1 -> context1 : context1.call(source1)
|
29
|
+
& ruby2 -> context2 : context2.call(source2)
|
30
|
+
context1 -> vm : eval(context=1, source1)
|
31
|
+
& context2 -> vm : eval(context=2, source2)
|
32
|
+
group synchronize
|
33
|
+
vm -> node : eval(context=1, source1)
|
34
|
+
node -> vm : result: string
|
35
|
+
end
|
36
|
+
vm -> context1 : result: Ruby object
|
37
|
+
context1 -> ruby1 : result: Ruby object
|
38
|
+
& group synchronize
|
39
|
+
vm -> node : eval(context=2, source2)
|
40
|
+
node -> vm : result: string
|
41
|
+
end
|
42
|
+
vm -> context2 : result: Ruby object
|
43
|
+
context2 -> ruby2 : result: Ruby object
|
44
|
+
|
45
|
+
ruby1 -> context1 : context1.call(source3)
|
46
|
+
& ruby2 -> context2 : context2.call(source4)
|
47
|
+
context1 -> vm : eval(context=1, source3)
|
48
|
+
& context2 -> vm : eval(context=2, source4)
|
49
|
+
group synchronize
|
50
|
+
vm -> node : eval(context=2, source4)
|
51
|
+
node -> vm : result: string
|
52
|
+
end
|
53
|
+
vm -> context2 : result: Ruby object
|
54
|
+
context2 -> ruby2 : result: Ruby object
|
55
|
+
& group synchronize
|
56
|
+
vm -> node : eval(context=1, source3)
|
57
|
+
node -> vm : result: string
|
58
|
+
end
|
59
|
+
vm -> context1 : result: Ruby object
|
60
|
+
context1 -> ruby1 : result: Ruby object
|
61
|
+
@enduml
|
62
|
+
|
63
|
+
PlantUML version 1.2022.7(Tue Aug 23 02:01:30 JST 2022)
|
64
|
+
(GPL source distribution)
|
65
|
+
Java Runtime: Java(TM) SE Runtime Environment
|
66
|
+
JVM: Java HotSpot(TM) 64-Bit Server VM
|
67
|
+
Default Encoding: UTF-8
|
68
|
+
Language: ja
|
69
|
+
Country: JP
|
70
|
+
--></g></svg>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="361px" preserveAspectRatio="none" style="width:882px;height:361px;background:#FFFFFF;" version="1.1" viewBox="0 0 882 361" width="882px" zoomAndPan="magnify"><defs/><g><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="59.5" x2="59.5" y1="36.4883" y2="324.8164"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="394.5" x2="394.5" y1="44.4883" y2="324.8164"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="670" x2="670" y1="105.2871" y2="324.8164"/><line style="stroke:#181818;stroke-width:2.0;" x1="661" x2="679" y1="149.0859" y2="167.0859"/><line style="stroke:#181818;stroke-width:2.0;" x1="661" x2="679" y1="167.0859" y2="149.0859"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="811" x2="811" y1="224.707" y2="324.8164"/><line style="stroke:#181818;stroke-width:2.0;" x1="802" x2="820" y1="268.5059" y2="286.5059"/><line style="stroke:#181818;stroke-width:2.0;" x1="802" x2="820" y1="286.5059" y2="268.5059"/><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="109" x="5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="95" x="12" y="25.5352">User program</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="109" x="5" y="324.8164"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="95" x="12" y="345.3516">User program</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="336.5" y="324.8164"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="343.5" y="345.3516">execjs Context</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="131" x="604.5" y="324.8164"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="611.5" y="345.3516">Node.js process1</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="131" x="745.5" y="324.8164"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="752.5" y="345.3516">Node.js process2</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="336.5" y="44.4883"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="343.5" y="65.0234">execjs Context</text><polygon fill="#181818" points="324.5,61.7988,334.5,65.7988,324.5,69.7988,328.5,65.7988" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="59.5" x2="330.5" y1="65.7988" y2="65.7988"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="253" x="66.5" y="61.0566">context = ExecJS.compile(initial_source)</text><polygon fill="#181818" points="382.5,93.2871,392.5,97.2871,382.5,101.2871,386.5,97.2871" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="59.5" x2="388.5" y1="97.2871" y2="97.2871"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="132" x="66.5" y="92.5449">context.call(source1)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="131" x="604.5" y="105.2871"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="611.5" y="125.8223">Node.js process1</text><polygon fill="#181818" points="592.5,122.5977,602.5,126.5977,592.5,130.5977,596.5,126.5977" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="394.5" x2="598.5" y1="126.5977" y2="126.5977"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="186" x="401.5" y="121.8555">eval(initial_source + source1)</text><polygon fill="#181818" points="405.5,154.0859,395.5,158.0859,405.5,162.0859,401.5,158.0859" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="399.5" x2="669" y1="158.0859" y2="158.0859"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="411.5" y="153.3438">result: string</text><polygon fill="#181818" points="70.5,183.3965,60.5,187.3965,70.5,191.3965,66.5,187.3965" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="64.5" x2="393.5" y1="187.3965" y2="187.3965"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="76.5" y="182.6543">result: Ruby object</text><polygon fill="#181818" points="382.5,212.707,392.5,216.707,382.5,220.707,386.5,216.707" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="59.5" x2="388.5" y1="216.707" y2="216.707"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="132" x="66.5" y="211.9648">context.call(source2)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="131" x="745.5" y="224.707"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="752.5" y="245.2422">Node.js process2</text><polygon fill="#181818" points="733.5,242.0176,743.5,246.0176,733.5,250.0176,737.5,246.0176" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="394.5" x2="739.5" y1="246.0176" y2="246.0176"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="186" x="401.5" y="241.2754">eval(initial_source + source2)</text><polygon fill="#181818" points="405.5,273.5059,395.5,277.5059,405.5,281.5059,401.5,277.5059" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="399.5" x2="810" y1="277.5059" y2="277.5059"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="411.5" y="272.7637">result: string</text><polygon fill="#181818" points="70.5,302.8164,60.5,306.8164,70.5,310.8164,66.5,306.8164" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="64.5" x2="393.5" y1="306.8164" y2="306.8164"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="76.5" y="302.0742">result: Ruby object</text><!--MD5=[a771d5800578c0fe5d3a9efcad94a7c7]
|
2
|
+
@startuml
|
3
|
+
|
4
|
+
!pragma teoz true
|
5
|
+
|
6
|
+
participant "User program" as ruby
|
7
|
+
participant "execjs Context" as context
|
8
|
+
participant "Node.js process1" as node1
|
9
|
+
participant "Node.js process2" as node2
|
10
|
+
|
11
|
+
create context
|
12
|
+
ruby -> context : context = ExecJS.compile(initial_source)
|
13
|
+
|
14
|
+
ruby -> context : context.call(source1)
|
15
|
+
create node1
|
16
|
+
context -> node1 : eval(initial_source + source1)
|
17
|
+
node1 -> context : result: string
|
18
|
+
destroy node1
|
19
|
+
context -> ruby : result: Ruby object
|
20
|
+
|
21
|
+
ruby -> context : context.call(source2)
|
22
|
+
create node2
|
23
|
+
context -> node2 : eval(initial_source + source2)
|
24
|
+
node2 -> context : result: string
|
25
|
+
destroy node2
|
26
|
+
context -> ruby : result: Ruby object
|
27
|
+
|
28
|
+
@enduml
|
29
|
+
|
30
|
+
PlantUML version 1.2022.7(Tue Aug 23 02:01:30 JST 2022)
|
31
|
+
(GPL source distribution)
|
32
|
+
Java Runtime: Java(TM) SE Runtime Environment
|
33
|
+
JVM: Java HotSpot(TM) 64-Bit Server VM
|
34
|
+
Default Encoding: UTF-8
|
35
|
+
Language: ja
|
36
|
+
Country: JP
|
37
|
+
--></g></svg>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="480px" preserveAspectRatio="none" style="width:1340px;height:480px;background:#FFFFFF;" version="1.1" viewBox="0 0 1340 480" width="1340px" zoomAndPan="magnify"><defs/><g><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="93.5" x2="93.5" y1="36.4883" y2="444.2363"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="449" x2="449" y1="44.4883" y2="444.2363"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="599" x2="599" y1="107.4648" y2="444.2363"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="763" x2="763" y1="36.4883" y2="444.2363"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="1118.5" x2="1118.5" y1="75.9766" y2="444.2363"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="1268.5" x2="1268.5" y1="138.9531" y2="444.2363"/><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="177" x="5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="163" x="12" y="25.5352">User program(Thread1)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="177" x="674.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="163" x="681.5" y="25.5352">User program(Thread2)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="177" x="5" y="444.2363"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="163" x="12" y="464.7715">User program(Thread1)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="125" x="386.5" y="444.2363"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="111" x="393.5" y="464.7715">execjs Context1</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="131" x="533.5" y="444.2363"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="540.5" y="464.7715">Node.js process1</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="177" x="674.5" y="444.2363"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="163" x="681.5" y="464.7715">User program(Thread2)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="125" x="1056" y="444.2363"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="111" x="1063" y="464.7715">execjs Context2</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="131" x="1203" y="444.2363"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="1210" y="464.7715">Node.js process2</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="125" x="386.5" y="44.4883"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="111" x="393.5" y="65.0234">execjs Context1</text><polygon fill="#181818" points="374.5,61.7988,384.5,65.7988,374.5,69.7988,378.5,65.7988" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="93.5" x2="380.5" y1="65.7988" y2="65.7988"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="269" x="100.5" y="61.0566">context1 = ExecJS.compile(initial_source1)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="125" x="1056" y="75.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="111" x="1063" y="96.5117">execjs Context2</text><polygon fill="#181818" points="1044,93.2871,1054,97.2871,1044,101.2871,1048,97.2871" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="763" x2="1050" y1="97.2871" y2="97.2871"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="269" x="770" y="92.5449">context2 = ExecJS.compile(initial_source2)</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="131" x="533.5" y="107.4648"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="540.5" y="128">Node.js process1</text><polygon fill="#181818" points="521.5,124.7754,531.5,128.7754,521.5,132.7754,525.5,128.7754" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="449" x2="527.5" y1="128.7754" y2="128.7754"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="40" x="456" y="124.0332">spawn</text><rect fill="#E2E2F0" height="30.4883" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="131" x="1203" y="138.9531"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="1210" y="159.4883">Node.js process2</text><polygon fill="#181818" points="1191,156.2637,1201,160.2637,1191,164.2637,1195,160.2637" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1118.5" x2="1197" y1="160.2637" y2="160.2637"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="40" x="1125.5" y="155.5215">spawn</text><polygon fill="#181818" points="587,187.752,597,191.752,587,195.752,591,191.752" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="449" x2="593" y1="191.752" y2="191.752"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="126" x="456" y="187.0098">eval(initial_source1)</text><polygon fill="#181818" points="1256.5,187.752,1266.5,191.752,1256.5,195.752,1260.5,191.752" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1118.5" x2="1262.5" y1="191.752" y2="191.752"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="126" x="1125.5" y="187.0098">eval(initial_source2)</text><polygon fill="#181818" points="437,217.0625,447,221.0625,437,225.0625,441,221.0625" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="93.5" x2="443" y1="221.0625" y2="221.0625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="140" x="100.5" y="216.3203">context1.call(source1)</text><polygon fill="#181818" points="1106.5,217.0625,1116.5,221.0625,1106.5,225.0625,1110.5,221.0625" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="763" x2="1112.5" y1="221.0625" y2="221.0625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="140" x="770" y="216.3203">context2.call(source2)</text><polygon fill="#181818" points="587,246.373,597,250.373,587,254.373,591,250.373" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="449" x2="593" y1="250.373" y2="250.373"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="83" x="456" y="245.6309">eval(source1)</text><polygon fill="#181818" points="1256.5,246.373,1266.5,250.373,1256.5,254.373,1260.5,250.373" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1118.5" x2="1262.5" y1="250.373" y2="250.373"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="83" x="1125.5" y="245.6309">eval(source2)</text><polygon fill="#181818" points="460,275.6836,450,279.6836,460,283.6836,456,279.6836" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="454" x2="598" y1="279.6836" y2="279.6836"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="466" y="274.9414">result: string</text><polygon fill="#181818" points="1129.5,275.6836,1119.5,279.6836,1129.5,283.6836,1125.5,279.6836" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1123.5" x2="1267.5" y1="279.6836" y2="279.6836"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="1135.5" y="274.9414">result: string</text><polygon fill="#181818" points="104.5,304.9941,94.5,308.9941,104.5,312.9941,100.5,308.9941" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="98.5" x2="448" y1="308.9941" y2="308.9941"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="110.5" y="304.252">result: Ruby object</text><polygon fill="#181818" points="774,304.9941,764,308.9941,774,312.9941,770,308.9941" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="768" x2="1117.5" y1="308.9941" y2="308.9941"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="780" y="304.252">result: Ruby object</text><polygon fill="#181818" points="437,334.3047,447,338.3047,437,342.3047,441,338.3047" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="93.5" x2="443" y1="338.3047" y2="338.3047"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="140" x="100.5" y="333.5625">context1.call(source3)</text><polygon fill="#181818" points="1106.5,334.3047,1116.5,338.3047,1106.5,342.3047,1110.5,338.3047" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="763" x2="1112.5" y1="338.3047" y2="338.3047"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="140" x="770" y="333.5625">context2.call(source4)</text><polygon fill="#181818" points="587,363.6152,597,367.6152,587,371.6152,591,367.6152" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="449" x2="593" y1="367.6152" y2="367.6152"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="83" x="456" y="362.873">eval(source3)</text><polygon fill="#181818" points="1256.5,363.6152,1266.5,367.6152,1256.5,371.6152,1260.5,367.6152" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1118.5" x2="1262.5" y1="367.6152" y2="367.6152"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="83" x="1125.5" y="362.873">eval(source4)</text><polygon fill="#181818" points="460,392.9258,450,396.9258,460,400.9258,456,396.9258" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="454" x2="598" y1="396.9258" y2="396.9258"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="466" y="392.1836">result: string</text><polygon fill="#181818" points="1129.5,392.9258,1119.5,396.9258,1129.5,400.9258,1125.5,396.9258" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="1123.5" x2="1267.5" y1="396.9258" y2="396.9258"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="1135.5" y="392.1836">result: string</text><polygon fill="#181818" points="104.5,422.2363,94.5,426.2363,104.5,430.2363,100.5,426.2363" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="98.5" x2="448" y1="426.2363" y2="426.2363"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="110.5" y="421.4941">result: Ruby object</text><polygon fill="#181818" points="774,422.2363,764,426.2363,774,430.2363,770,426.2363" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="768" x2="1117.5" y1="426.2363" y2="426.2363"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="118" x="780" y="421.4941">result: Ruby object</text><!--MD5=[ee283807631a6e11c93e5d8079e71f92]
|
2
|
+
@startuml
|
3
|
+
|
4
|
+
!pragma teoz true
|
5
|
+
|
6
|
+
participant "User program(Thread1)" as ruby1
|
7
|
+
participant "execjs Context1" as context1
|
8
|
+
participant "Node.js process1" as node1
|
9
|
+
participant "User program(Thread2)" as ruby2
|
10
|
+
participant "execjs Context2" as context2
|
11
|
+
participant "Node.js process2" as node2
|
12
|
+
|
13
|
+
create context1
|
14
|
+
ruby1 -> context1 : context1 = ExecJS.compile(initial_source1)
|
15
|
+
create context2
|
16
|
+
ruby2 -> context2 : context2 = ExecJS.compile(initial_source2)
|
17
|
+
create node1
|
18
|
+
context1 -> node1 : spawn
|
19
|
+
create node2
|
20
|
+
context2 -> node2 : spawn
|
21
|
+
context1 -> node1 : eval(initial_source1)
|
22
|
+
& context2 -> node2 : eval(initial_source2)
|
23
|
+
|
24
|
+
ruby1 -> context1 : context1.call(source1)
|
25
|
+
& ruby2 -> context2 : context2.call(source2)
|
26
|
+
context1 -> node1 : eval(source1)
|
27
|
+
& context2 -> node2 : eval(source2)
|
28
|
+
node1 -> context1 : result: string
|
29
|
+
& node2 -> context2 : result: string
|
30
|
+
context1 -> ruby1 : result: Ruby object
|
31
|
+
& context2 -> ruby2 : result: Ruby object
|
32
|
+
|
33
|
+
ruby1 -> context1 : context1.call(source3)
|
34
|
+
& ruby2 -> context2 : context2.call(source4)
|
35
|
+
context1 -> node1 : eval(source3)
|
36
|
+
& context2 -> node2 : eval(source4)
|
37
|
+
node1 -> context1 : result: string
|
38
|
+
& node2 -> context2 : result: string
|
39
|
+
context1 -> ruby1 : result: Ruby object
|
40
|
+
& context2 -> ruby2 : result: Ruby object
|
41
|
+
@enduml
|
42
|
+
|
43
|
+
PlantUML version 1.2022.7(Tue Aug 23 02:01:30 JST 2022)
|
44
|
+
(GPL source distribution)
|
45
|
+
Java Runtime: Java(TM) SE Runtime Environment
|
46
|
+
JVM: Java HotSpot(TM) 64-Bit Server VM
|
47
|
+
Default Encoding: UTF-8
|
48
|
+
Language: ja
|
49
|
+
Country: JP
|
50
|
+
--></g></svg>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
@startuml
|
2
|
+
|
3
|
+
!pragma teoz true
|
4
|
+
|
5
|
+
participant "User program" as ruby
|
6
|
+
participant "execjs Context" as context
|
7
|
+
participant "Node.js process" as node
|
8
|
+
|
9
|
+
create context
|
10
|
+
ruby -> context : context = ExecJS.compile(initial_source)
|
11
|
+
create node
|
12
|
+
context -> node : spawn
|
13
|
+
context -> node : eval(initial_source)
|
14
|
+
|
15
|
+
ruby -> context : context.call(source1)
|
16
|
+
context -> node : eval(source1)
|
17
|
+
node -> context : result: string
|
18
|
+
context -> ruby : result: Ruby object
|
19
|
+
|
20
|
+
ruby -> context : context.call(source2)
|
21
|
+
context -> node : eval(source2)
|
22
|
+
node -> context : result: string
|
23
|
+
context -> ruby : result: Ruby object
|
24
|
+
|
25
|
+
@enduml
|
@@ -0,0 +1,60 @@
|
|
1
|
+
@startuml
|
2
|
+
|
3
|
+
!pragma teoz true
|
4
|
+
|
5
|
+
participant "User program(Thread1)" as ruby1
|
6
|
+
participant "execjs Context1" as context1
|
7
|
+
participant "internal object" as vm
|
8
|
+
participant "Node.js process" as node
|
9
|
+
participant "execjs Context2" as context2
|
10
|
+
participant "User program(Thread2)" as ruby2
|
11
|
+
|
12
|
+
create context1
|
13
|
+
ruby1 -> context1 : context1 = ExecJS.compile(initial_source1)
|
14
|
+
create context2
|
15
|
+
ruby2 -> context2 : context2 = ExecJS.compile(initial_source2)
|
16
|
+
context1 -> vm : Create Context(initial_source1)
|
17
|
+
& context2 -> vm : Create Context(initial_source2)
|
18
|
+
create node
|
19
|
+
group synchronize
|
20
|
+
vm -> node : spawn
|
21
|
+
vm -> node : eval(context=1, initial_source1)
|
22
|
+
end
|
23
|
+
group synchronize
|
24
|
+
vm -> node : eval(context=2, initial_source2)
|
25
|
+
end
|
26
|
+
|
27
|
+
ruby1 -> context1 : context1.call(source1)
|
28
|
+
& ruby2 -> context2 : context2.call(source2)
|
29
|
+
context1 -> vm : eval(context=1, source1)
|
30
|
+
& context2 -> vm : eval(context=2, source2)
|
31
|
+
group synchronize
|
32
|
+
vm -> node : eval(context=1, source1)
|
33
|
+
node -> vm : result: string
|
34
|
+
end
|
35
|
+
vm -> context1 : result: Ruby object
|
36
|
+
context1 -> ruby1 : result: Ruby object
|
37
|
+
& group synchronize
|
38
|
+
vm -> node : eval(context=2, source2)
|
39
|
+
node -> vm : result: string
|
40
|
+
end
|
41
|
+
vm -> context2 : result: Ruby object
|
42
|
+
context2 -> ruby2 : result: Ruby object
|
43
|
+
|
44
|
+
ruby1 -> context1 : context1.call(source3)
|
45
|
+
& ruby2 -> context2 : context2.call(source4)
|
46
|
+
context1 -> vm : eval(context=1, source3)
|
47
|
+
& context2 -> vm : eval(context=2, source4)
|
48
|
+
group synchronize
|
49
|
+
vm -> node : eval(context=2, source4)
|
50
|
+
node -> vm : result: string
|
51
|
+
end
|
52
|
+
vm -> context2 : result: Ruby object
|
53
|
+
context2 -> ruby2 : result: Ruby object
|
54
|
+
& group synchronize
|
55
|
+
vm -> node : eval(context=1, source3)
|
56
|
+
node -> vm : result: string
|
57
|
+
end
|
58
|
+
vm -> context1 : result: Ruby object
|
59
|
+
context1 -> ruby1 : result: Ruby object
|
60
|
+
@enduml
|
@@ -0,0 +1,27 @@
|
|
1
|
+
@startuml
|
2
|
+
|
3
|
+
!pragma teoz true
|
4
|
+
|
5
|
+
participant "User program" as ruby
|
6
|
+
participant "execjs Context" as context
|
7
|
+
participant "Node.js process1" as node1
|
8
|
+
participant "Node.js process2" as node2
|
9
|
+
|
10
|
+
create context
|
11
|
+
ruby -> context : context = ExecJS.compile(initial_source)
|
12
|
+
|
13
|
+
ruby -> context : context.call(source1)
|
14
|
+
create node1
|
15
|
+
context -> node1 : eval(initial_source + source1)
|
16
|
+
node1 -> context : result: string
|
17
|
+
destroy node1
|
18
|
+
context -> ruby : result: Ruby object
|
19
|
+
|
20
|
+
ruby -> context : context.call(source2)
|
21
|
+
create node2
|
22
|
+
context -> node2 : eval(initial_source + source2)
|
23
|
+
node2 -> context : result: string
|
24
|
+
destroy node2
|
25
|
+
context -> ruby : result: Ruby object
|
26
|
+
|
27
|
+
@enduml
|
@@ -0,0 +1,40 @@
|
|
1
|
+
@startuml
|
2
|
+
|
3
|
+
!pragma teoz true
|
4
|
+
|
5
|
+
participant "User program(Thread1)" as ruby1
|
6
|
+
participant "execjs Context1" as context1
|
7
|
+
participant "Node.js process1" as node1
|
8
|
+
participant "User program(Thread2)" as ruby2
|
9
|
+
participant "execjs Context2" as context2
|
10
|
+
participant "Node.js process2" as node2
|
11
|
+
|
12
|
+
create context1
|
13
|
+
ruby1 -> context1 : context1 = ExecJS.compile(initial_source1)
|
14
|
+
create context2
|
15
|
+
ruby2 -> context2 : context2 = ExecJS.compile(initial_source2)
|
16
|
+
create node1
|
17
|
+
context1 -> node1 : spawn
|
18
|
+
create node2
|
19
|
+
context2 -> node2 : spawn
|
20
|
+
context1 -> node1 : eval(initial_source1)
|
21
|
+
& context2 -> node2 : eval(initial_source2)
|
22
|
+
|
23
|
+
ruby1 -> context1 : context1.call(source1)
|
24
|
+
& ruby2 -> context2 : context2.call(source2)
|
25
|
+
context1 -> node1 : eval(source1)
|
26
|
+
& context2 -> node2 : eval(source2)
|
27
|
+
node1 -> context1 : result: string
|
28
|
+
& node2 -> context2 : result: string
|
29
|
+
context1 -> ruby1 : result: Ruby object
|
30
|
+
& context2 -> ruby2 : result: Ruby object
|
31
|
+
|
32
|
+
ruby1 -> context1 : context1.call(source3)
|
33
|
+
& ruby2 -> context2 : context2.call(source4)
|
34
|
+
context1 -> node1 : eval(source3)
|
35
|
+
& context2 -> node2 : eval(source4)
|
36
|
+
node1 -> context1 : result: string
|
37
|
+
& node2 -> context2 : result: string
|
38
|
+
context1 -> ruby1 : result: Ruby object
|
39
|
+
& context2 -> ruby2 : result: Ruby object
|
40
|
+
@enduml
|
@@ -5,6 +5,7 @@ require 'tmpdir'
|
|
5
5
|
require 'json'
|
6
6
|
require 'net/protocol'
|
7
7
|
require 'net/http'
|
8
|
+
require 'shellwords'
|
8
9
|
|
9
10
|
module ExecJS
|
10
11
|
module PCRuntime
|
@@ -157,7 +158,10 @@ module ExecJS
|
|
157
158
|
request['Connection'] = 'close'
|
158
159
|
unless content_type.nil?
|
159
160
|
request['Content-Type'] = content_type
|
160
|
-
|
161
|
+
# URI.encode_www_form_component replaces space(U+0020) into '+' (not '%20')
|
162
|
+
# but decodeURIComponent(in JavaScript) cannot decode '+' into space
|
163
|
+
# so, replace '+' into '%20'
|
164
|
+
request.body = URI.encode_www_form_component(body).gsub('+', '%20')
|
161
165
|
end
|
162
166
|
|
163
167
|
# Net::HTTPGenericRequest#exec
|
@@ -171,13 +175,13 @@ module ExecJS
|
|
171
175
|
end while response.is_a?(Net::HTTPContinue)
|
172
176
|
# rubocop:enable Lint/Loop
|
173
177
|
response.reading_body(socket, request.response_body_permitted?) {}
|
178
|
+
result = URI.decode_www_form_component response.body
|
174
179
|
|
175
180
|
if response.code == '200'
|
176
|
-
result
|
177
|
-
::JSON.parse(response.body, create_additions: false) if /\S/.match?(result)
|
181
|
+
::JSON.parse(result, create_additions: false) if /\S/.match?(result)
|
178
182
|
else
|
179
183
|
# expects ErrorMessage\0StackTrace =~ response.body
|
180
|
-
message, stack =
|
184
|
+
message, stack = result.split "\0"
|
181
185
|
error_class = /SyntaxError:/.match?(message) ? RuntimeError : ProgramError
|
182
186
|
error = error_class.new(message)
|
183
187
|
error.set_backtrace(stack)
|
@@ -14,16 +14,17 @@ const server = http.createServer(function (req, res) {
|
|
14
14
|
req.on('data', (data) => allData += data);
|
15
15
|
req.on('end', () => {
|
16
16
|
try {
|
17
|
-
|
17
|
+
// Percent-encoding HTTP requests and responses to avoid invalid UTF-8 sequences.
|
18
|
+
const result = vm.runInContext(decodeURIComponent(allData), context, "(execjs)");
|
18
19
|
res.statusCode = 200;
|
19
20
|
res.setHeader('Content-Type', 'application/json');
|
20
|
-
res.end(JSON.stringify(result)
|
21
|
+
res.end(encodeURIComponent(JSON.stringify(result) || null));
|
21
22
|
} catch (e) {
|
22
23
|
res.statusCode = 500;
|
23
24
|
res.setHeader('Content-Type', 'text/plain');
|
24
25
|
// to split by \0 on Ruby side
|
25
26
|
// see context_process_runtime.rb:179
|
26
|
-
res.end(e.toString() + "\0" + (e.stack || ""));
|
27
|
+
res.end(encodeURIComponent(e.toString() + "\0" + (e.stack || "")));
|
27
28
|
}
|
28
29
|
});
|
29
30
|
break;
|
data/lib/execjs/pcruntime.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: execjs-pcruntime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- White-Green
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|
@@ -40,6 +40,14 @@ files:
|
|
40
40
|
- Rakefile
|
41
41
|
- bin/console
|
42
42
|
- bin/setup
|
43
|
+
- doc_resources/out/sequence_fastnode1/sequence_fastnode1.svg
|
44
|
+
- doc_resources/out/sequence_fastnode2/sequence_fastnode2.svg
|
45
|
+
- doc_resources/out/sequence_nodejs/sequence_nodejs.svg
|
46
|
+
- doc_resources/out/sequence_pcruntime/sequence_pcruntime.svg
|
47
|
+
- doc_resources/sequence_fastnode1.pu
|
48
|
+
- doc_resources/sequence_fastnode2.pu
|
49
|
+
- doc_resources/sequence_nodejs.pu
|
50
|
+
- doc_resources/sequence_pcruntime.pu
|
43
51
|
- execjs-pcruntime.gemspec
|
44
52
|
- lib/execjs/pcruntime.rb
|
45
53
|
- lib/execjs/pcruntime/context_process_runtime.rb
|
@@ -68,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
76
|
- !ruby/object:Gem::Version
|
69
77
|
version: '0'
|
70
78
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
79
|
+
rubygems_version: 3.3.26
|
72
80
|
signing_key:
|
73
81
|
specification_version: 4
|
74
82
|
summary: Fast ExecJS Runtime using Process as a Context.
|