Commit a87ebbf
committed
runtime: Introduce the locals stack + use it for (inline) methods/blocks
This is a bit of a large commit because the changes are all
interconnected. The main idea is that now, instead of getting locals
from the activation object, we have a "locals stack" that is responsible
for storing all of the locals that are used by the various activations.
Every time a method is activated, the method needs to allocate some
space on the locals stack. This space is the total count of all locals
used by the method itself, and any inline methods/blocks defined
within (as blocks/inline methods also have access to the method's
locals).
To calculate all of the locals required, AstGen now has the
ObjectDescriptorLink struct which is weaved through code generation and
calculates the local index for each local that's accessible from a given
activation within a containing method. The sum is then recorded on the
CreateMethod instruction, and when the method is activated, the locals
stack gets the memory reserved.
The GetLocal/PutLocal instructions now offset into the locals stack
instead of using the activation object. In essence, we no longer use any
of the assignable slot values of the activation object itself anymore.
This gives us -15% wall clock time on the Fibonacci example, on top of
the -18.5% wall clock time with the initial locals implementation,
bringing the total performance boost of locals to -31% or 1.45x which is
pretty huge.
Note that because we still create the activation object, we currently
have to copy the assignable and argument slot values to the locals
stack, so there is still a lot of performance gains to be had. When
constants are obtainable without going through the activation object,
and the activation object is completely removed, the arguments will be
used directly off the argument stack instead of being copied which
should bring a further performance boost.1 parent 2f2e09e commit a87ebbf
12 files changed
Lines changed: 411 additions & 186 deletions
File tree
- src/runtime
- bytecode
- objects
- primitives
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
| |||
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| 72 | + | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
| |||
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
226 | 233 | | |
227 | 234 | | |
228 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
229 | 241 | | |
230 | 242 | | |
231 | | - | |
| 243 | + | |
232 | 244 | | |
233 | 245 | | |
234 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
| |||
81 | 93 | | |
82 | 94 | | |
83 | 95 | | |
| 96 | + | |
84 | 97 | | |
85 | 98 | | |
86 | 99 | | |
| |||
210 | 223 | | |
211 | 224 | | |
212 | 225 | | |
| 226 | + | |
213 | 227 | | |
214 | 228 | | |
215 | 229 | | |
| |||
221 | 235 | | |
222 | 236 | | |
223 | 237 | | |
| 238 | + | |
224 | 239 | | |
225 | 240 | | |
| 241 | + | |
226 | 242 | | |
227 | 243 | | |
228 | 244 | | |
229 | | - | |
| 245 | + | |
230 | 246 | | |
231 | 247 | | |
232 | 248 | | |
233 | 249 | | |
| 250 | + | |
234 | 251 | | |
235 | 252 | | |
236 | 253 | | |
| 254 | + | |
237 | 255 | | |
238 | 256 | | |
239 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
240 | 269 | | |
241 | | - | |
| 270 | + | |
242 | 271 | | |
243 | 272 | | |
244 | 273 | | |
| |||
270 | 299 | | |
271 | 300 | | |
272 | 301 | | |
273 | | - | |
274 | | - | |
275 | | - | |
| 302 | + | |
276 | 303 | | |
277 | 304 | | |
278 | 305 | | |
| |||
379 | 406 | | |
380 | 407 | | |
381 | 408 | | |
| 409 | + | |
382 | 410 | | |
383 | 411 | | |
384 | 412 | | |
385 | 413 | | |
386 | 414 | | |
387 | 415 | | |
| 416 | + | |
388 | 417 | | |
389 | 418 | | |
390 | 419 | | |
| |||
428 | 457 | | |
429 | 458 | | |
430 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
431 | 464 | | |
432 | 465 | | |
433 | 466 | | |
| |||
451 | 484 | | |
452 | 485 | | |
453 | 486 | | |
| 487 | + | |
454 | 488 | | |
455 | 489 | | |
456 | 490 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
| |||
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
| 335 | + | |
334 | 336 | | |
335 | 337 | | |
336 | 338 | | |
| |||
388 | 390 | | |
389 | 391 | | |
390 | 392 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
397 | 396 | | |
398 | 397 | | |
399 | 398 | | |
| |||
410 | 409 | | |
411 | 410 | | |
412 | 411 | | |
413 | | - | |
414 | | - | |
415 | | - | |
| 412 | + | |
| 413 | + | |
416 | 414 | | |
417 | 415 | | |
418 | 416 | | |
419 | 417 | | |
420 | 418 | | |
421 | | - | |
| 419 | + | |
422 | 420 | | |
423 | 421 | | |
424 | 422 | | |
| |||
747 | 745 | | |
748 | 746 | | |
749 | 747 | | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
750 | 751 | | |
751 | 752 | | |
752 | 753 | | |
| |||
755 | 756 | | |
756 | 757 | | |
757 | 758 | | |
| 759 | + | |
758 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
759 | 772 | | |
760 | 773 | | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
761 | 778 | | |
762 | 779 | | |
763 | 780 | | |
| |||
795 | 812 | | |
796 | 813 | | |
797 | 814 | | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
798 | 826 | | |
799 | | - | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
800 | 846 | | |
801 | 847 | | |
802 | 848 | | |
| |||
825 | 871 | | |
826 | 872 | | |
827 | 873 | | |
| 874 | + | |
828 | 875 | | |
829 | 876 | | |
830 | 877 | | |
| |||
847 | 894 | | |
848 | 895 | | |
849 | 896 | | |
| 897 | + | |
850 | 898 | | |
851 | 899 | | |
852 | 900 | | |
| |||
858 | 906 | | |
859 | 907 | | |
860 | 908 | | |
| 909 | + | |
861 | 910 | | |
862 | 911 | | |
863 | 912 | | |
| |||
896 | 945 | | |
897 | 946 | | |
898 | 947 | | |
| 948 | + | |
899 | 949 | | |
900 | 950 | | |
901 | 951 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
0 commit comments