Commit e60b6de
bootstrap: unify snapshot builder and embedder entry points
- Run the embedder entry point directly through
runEmbedderEntryPoint(), instead of going through another
JS -> C++ trip through the function returned by
getEmbedderEntryFunction()
- For --build-snapshot, read the snapshot script code directly in C++
and pass it to SnapshotBuilder::Generate(), this makes the entry point
more explicit instead of hiding it in JS land, and also makes it
possible to invoke SnapshotBuilder::Generate() internally to create
a custom snapshot.
- Previously we used process.execPath for the embedder to create
__filename and __dirname in the snapshot builder script while using
process.argv[1] for --build-snapshot (where it's always set) which
results in inconsistencies. We now require the embedder to also set
args[1] when creating the Environment if they intend to run snapshot
scripts with a context that contains __filename and __dirname, which
would be derived from args[1]. If they prefer not to include
build-time paths in the snapshot, we now provide
node::GetAnonymousMainPath() as an alternative.
PR-URL: #48242
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent 77cb1ee commit e60b6deCopy full SHA for e60b6de
File tree
Expand file treeCollapse file tree
9 files changed
+198
-138
lines changedOpen diff view settings
Filter options
- lib/internal/main
- src
- test/embedding
- tools/snapshot
Expand file treeCollapse file tree
9 files changed
+198
-138
lines changedOpen diff view settings
Collapse file
lib/internal/main/embedding.js
Copy file name to clipboardExpand all lines: lib/internal/main/embedding.js+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
6 | 6 | |
7 | 7 | |
8 | 8 | |
9 | | - |
| 9 | + |
10 | 10 | |
11 | 11 | |
12 | 12 | |
| ||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | | - |
| 18 | + |
Collapse file
lib/internal/main/mksnapshot.js
Copy file name to clipboardExpand all lines: lib/internal/main/mksnapshot.js+41-49Lines changed: 41 additions & 49 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
9 | 9 | |
10 | 10 | |
11 | 11 | |
12 | | - |
13 | 12 | |
14 | 13 | |
15 | | - |
| 14 | + |
16 | 15 | |
17 | | - |
| 16 | + |
| 17 | + |
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | | - |
25 | | - |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
26 | 36 | |
27 | 37 | |
28 | 38 | |
| ||
117 | 127 | |
118 | 128 | |
119 | 129 | |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
| 130 | + |
156 | 131 | |
157 | 132 | |
158 | 133 | |
| ||
161 | 136 | |
162 | 137 | |
163 | 138 | |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | 139 | |
173 | 140 | |
174 | 141 | |
| ||
181 | 148 | |
182 | 149 | |
183 | 150 | |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
184 | 176 | |
185 | 177 | |
186 | 178 | |
Collapse file
+19-8Lines changed: 19 additions & 8 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
290 | 290 | |
291 | 291 | |
292 | 292 | |
| 293 | + |
| 294 | + |
293 | 295 | |
294 | 296 | |
295 | 297 | |
| ||
311 | 313 | |
312 | 314 | |
313 | 315 | |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
318 | 316 | |
319 | 317 | |
320 | 318 | |
321 | 319 | |
322 | | - |
323 | 320 | |
324 | 321 | |
325 | 322 | |
| ||
1119 | 1116 | |
1120 | 1117 | |
1121 | 1118 | |
1122 | | - |
| 1119 | + |
| 1120 | + |
1123 | 1121 | |
1124 | 1122 | |
1125 | 1123 | |
| ||
1134 | 1132 | |
1135 | 1133 | |
1136 | 1134 | |
1137 | | - |
1138 | | - |
| 1135 | + |
| 1136 | + |
| 1137 | + |
| 1138 | + |
| 1139 | + |
| 1140 | + |
| 1141 | + |
| 1142 | + |
| 1143 | + |
| 1144 | + |
| 1145 | + |
| 1146 | + |
| 1147 | + |
| 1148 | + |
| 1149 | + |
1139 | 1150 | |
1140 | 1151 | |
1141 | 1152 | |
|
Collapse file
+10Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
816 | 816 | |
817 | 817 | |
818 | 818 | |
| 819 | + |
| 820 | + |
819 | 821 | |
820 | 822 | |
821 | 823 | |
| ||
848 | 850 | |
849 | 851 | |
850 | 852 | |
| 853 | + |
| 854 | + |
| 855 | + |
| 856 | + |
| 857 | + |
| 858 | + |
| 859 | + |
851 | 860 | |
852 | 861 | |
853 | 862 | |
| ||
909 | 918 | |
910 | 919 | |
911 | 920 | |
| 921 | + |
912 | 922 | |
913 | 923 | |
914 | 924 | |
|
Collapse file
src/node_snapshot_builder.h
Copy file name to clipboardExpand all lines: src/node_snapshot_builder.h+8-4Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
5 | 5 | |
6 | 6 | |
7 | 7 | |
| 8 | + |
| 9 | + |
8 | 10 | |
9 | 11 | |
10 | 12 | |
| ||
17 | 19 | |
18 | 20 | |
19 | 21 | |
20 | | - |
21 | | - |
| 22 | + |
| 23 | + |
| 24 | + |
22 | 25 | |
23 | 26 | |
24 | 27 | |
25 | | - |
26 | | - |
| 28 | + |
| 29 | + |
| 30 | + |
27 | 31 | |
28 | 32 | |
29 | 33 | |
|
0 commit comments