aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile36
-rw-r--r--src/buildvm.c3
-rw-r--r--src/buildvm_ppcspe.h1100
-rw-r--r--src/lib_jit.c4
4 files changed, 1122 insertions, 21 deletions
diff --git a/src/Makefile b/src/Makefile
index ed5f0bf5..24d32656 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -257,6 +257,7 @@ DASM_DISTFLAGS= -LN
257DASM_FLAGS_X86= 257DASM_FLAGS_X86=
258DASM_FLAGS_X64= -D X64 258DASM_FLAGS_X64= -D X64
259DASM_FLAGS_X64WIN= -D X64 -D X64WIN 259DASM_FLAGS_X64WIN= -D X64 -D X64WIN
260DASM_FLAGS_PPCSPE= -D SPE
260 261
261BUILDVM_O= buildvm.o buildvm_asm.o buildvm_peobj.o buildvm_lib.o buildvm_fold.o 262BUILDVM_O= buildvm.o buildvm_asm.o buildvm_peobj.o buildvm_lib.o buildvm_fold.o
262BUILDVM_T= buildvm 263BUILDVM_T= buildvm
@@ -296,9 +297,9 @@ LUAJIT_SO= libluajit.so
296LUAJIT_T= luajit 297LUAJIT_T= luajit
297 298
298ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(BUILDVM_T) 299ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(BUILDVM_T)
299ALL_GEN= $(LJVM_S) lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h \ 300ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h
300 $(LIB_VMDEFP) lj_folddef.h 301ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
301ALL_DYNGEN= buildvm_*.h 302ALL_DYNGEN= buildvm_x86.h buildvm_x64.h buildvm_x64win.h buildvm_ppcspe.h
302WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk 303WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
303ALL_RM= $(ALL_T) $(ALL_GEN) *.o $(WIN_RM) 304ALL_RM= $(ALL_T) $(ALL_GEN) *.o $(WIN_RM)
304 305
@@ -381,28 +382,19 @@ distclean: clean
381 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X86) -o buildvm_x86.h buildvm_x86.dasc 382 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X86) -o buildvm_x86.h buildvm_x86.dasc
382 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64) -o buildvm_x64.h buildvm_x86.dasc 383 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64) -o buildvm_x64.h buildvm_x86.dasc
383 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64WIN) -o buildvm_x64win.h buildvm_x86.dasc 384 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_X64WIN) -o buildvm_x64win.h buildvm_x86.dasc
385 $(Q)$(DASM) $(DASM_DISTFLAGS) $(DASM_FLAGS_PPCSPE) -o buildvm_ppcspe.h buildvm_ppc.dasc
384 386
385depend: 387depend:
386 @test -f lj_bcdef.h || touch lj_bcdef.h 388 @for file in $(ALL_HDRGEN) $(ALL_DYNGEN); do \
387 @test -f lj_ffdef.h || touch lj_ffdef.h 389 test -f $$file || touch $$file; \
388 @test -f lj_libdef.h || touch lj_libdef.h 390 done
389 @test -f lj_recdef.h || touch lj_recdef.h
390 @test -f lj_folddef.h || touch lj_folddef.h
391 @test -f buildvm_x86.h || touch buildvm_x86.h
392 @test -f buildvm_x64.h || touch buildvm_x64.h
393 @test -f buildvm_x64win.h || touch buildvm_x64win.h
394 @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c | \ 391 @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c | \
395 sed -e "s| [^ ]*/dasm_\S*\.h||g" \ 392 sed -e "s| [^ ]*/dasm_\S*\.h||g" \
396 -e "s| buildvm_\S*\.h||g" \ 393 -e "s| buildvm_\S*\.h||g" \
397 -e "s| lj_target_\S*\.h| lj_target_*.h|g" >Makefile.dep 394 -e "s| lj_target_\S*\.h| lj_target_*.h|g" >Makefile.dep
398 @test -s lj_bcdef.h || $(HOST_RM) lj_bcdef.h 395 @for file in $(ALL_HDRGEN) $(ALL_DYNGEN); do \
399 @test -s lj_ffdef.h || $(HOST_RM) lj_ffdef.h 396 test -s $$file || $(HOST_RM) $$file; \
400 @test -s lj_libdef.h || $(HOST_RM) lj_libdef.h 397 done
401 @test -s lj_recdef.h || $(HOST_RM) lj_recdef.h
402 @test -s lj_folddef.h || $(HOST_RM) lj_folddef.h
403 @test -s buildvm_x86.h || $(HOST_RM) buildvm_x86.h
404 @test -s buildvm_x64.h || $(HOST_RM) buildvm_x64.h
405 @test -s buildvm_x64win.h || $(HOST_RM) buildvm_x64win.h
406 398
407.PHONY: default all amalg clean cleaner distclean depend 399.PHONY: default all amalg clean cleaner distclean depend
408 400
@@ -422,7 +414,11 @@ buildvm_x64win.h: buildvm_x86.dasc
422 $(E) "DYNASM $@" 414 $(E) "DYNASM $@"
423 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X64WIN) -o $@ buildvm_x86.dasc 415 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_X64WIN) -o $@ buildvm_x86.dasc
424 416
425buildvm.o: buildvm_x86.h buildvm_x64.h buildvm_x64win.h $(DASM_DIR)/dasm_*.h 417buildvm_ppcspe.h: buildvm_ppc.dasc
418 $(E) "DYNASM $@"
419 $(Q)$(DASM) $(DASM_FLAGS) $(DASM_FLAGS_PPCSPE) -o $@ buildvm_ppc.dasc
420
421buildvm.o: $(ALL_DYNGEN) $(DASM_DIR)/dasm_*.h
426 422
427$(BUILDVM_T): $(BUILDVM_O) 423$(BUILDVM_T): $(BUILDVM_O)
428 $(E) "HOSTLINK $@" 424 $(E) "HOSTLINK $@"
diff --git a/src/buildvm.c b/src/buildvm.c
index b11dbbea..c2011070 100644
--- a/src/buildvm.c
+++ b/src/buildvm.c
@@ -73,6 +73,9 @@ static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type);
73#else 73#else
74#include "buildvm_x64.h" 74#include "buildvm_x64.h"
75#endif 75#endif
76#elif LJ_TARGET_PPCSPE
77#include "../dynasm/dasm_ppc.h"
78#include "buildvm_ppcspe.h"
76#else 79#else
77#error "No support for this architecture (yet)" 80#error "No support for this architecture (yet)"
78#endif 81#endif
diff --git a/src/buildvm_ppcspe.h b/src/buildvm_ppcspe.h
new file mode 100644
index 00000000..9a066bc6
--- /dev/null
+++ b/src/buildvm_ppcspe.h
@@ -0,0 +1,1100 @@
1/*
2** This file has been pre-processed with DynASM.
3** http://luajit.org/dynasm.html
4** DynASM version 1.2.1, DynASM ppc version 1.2.1
5** DO NOT EDIT! The original file is in "buildvm_ppc.dasc".
6*/
7
8#if DASM_VERSION != 10201
9#error "Version mismatch between DynASM and included encoding engine"
10#endif
11
12#define DASM_SECTION_CODE_OP 0
13#define DASM_SECTION_CODE_SUB 1
14#define DASM_MAXSECTION 2
15static const unsigned int build_actionlist[462] = {
160x00010001,
170x00060014,
180x7c810808,
190x00060015,
200x7c810808,
210x00060016,
220x7c810808,
230x00060017,
240x7c810808,
250x00060018,
260x7c810808,
270x00060019,
280x7c810808,
290x0006001a,
300x7c810808,
310x0006001b,
320x7c810808,
330x0006001c,
340x7c810808,
350x0006001d,
360x7c810808,
370x0006001e,
380x7c810808,
390x0006001f,
400x7c810808,
410x00060020,
420x7c810808,
430x00060021,
440x7c810808,
450x00060022,
460x7c810808,
470x00060023,
480x7c810808,
490x00060024,
500x7c810808,
510x00060025,
520x7c810808,
530x00060026,
540x7c810808,
550x00060027,
560x7c810808,
570x00060028,
580x7c810808,
590x00060029,
600x00000000,
610x7c810808,
620x0006002a,
630x7c810808,
640x0006002b,
650x7c810808,
660x0006002c,
670x7c810808,
680x0006002d,
690x7c810808,
700x0006002e,
710x7c810808,
720x0006002f,
730x7c810808,
740x00060030,
750x7c810808,
760x00060031,
770x7c810808,
780x00060032,
790x7c810808,
800x00060033,
810x7c810808,
820x00060034,
830x7c810808,
840x00060035,
850x7c810808,
860x00060036,
870x7c810808,
880x00060037,
890x7c810808,
900x00060038,
910x7c810808,
920x00060039,
930x7c810808,
940x0006003a,
950x7c810808,
960x0006003b,
970x7c810808,
980x0006003c,
990x7c810808,
1000x0006003d,
1010x7c810808,
1020x0006003e,
1030x7c810808,
1040x7c810808,
1050x0006003f,
1060x00000000,
1070x7c810808,
1080x7c810808,
1090x00060040,
1100x7c810808,
1110x7c810808,
1120x00060041,
1130x7c810808,
1140x00060042,
1150x7c810808,
1160x7c810808,
1170x00060043,
1180x7c810808,
1190x7c810808,
1200x00060044,
1210x7c810808,
1220x00060045,
1230x7c810808,
1240x7c810808,
1250x00060046,
1260x7c810808,
1270x7c810808,
1280x00060047,
1290x7c810808,
1300x00060048,
1310x7c810808,
1320x7c810808,
1330x00060049,
1340x7c810808,
1350x7c810808,
1360x0006004a,
1370x7c810808,
1380x7c810808,
1390x0006004b,
1400x7c810808,
1410x7c810808,
1420x0006004c,
1430x7c810808,
1440x0006004d,
1450x7c810808,
1460x0006004e,
1470x7c810808,
1480x7c810808,
1490x7c810808,
1500x0006004f,
1510x7c810808,
1520x00060050,
1530x7c810808,
1540x00060051,
1550x7c810808,
1560x00060052,
1570x7c810808,
1580x00060053,
1590x7c810808,
1600x00060054,
1610x7c810808,
1620x00060055,
1630x00000000,
1640x7c810808,
1650x00060056,
1660x7c810808,
1670x00060057,
1680x7c810808,
1690x00060058,
1700x7c810808,
1710x00060059,
1720x7c810808,
1730x0006005a,
1740x7c810808,
1750x0006005b,
1760x7c810808,
1770x0006005c,
1780x7c810808,
1790x0006005d,
1800x7c810808,
1810x0006005e,
1820x7c810808,
1830x0006005f,
1840x7c810808,
1850x00060060,
1860x7c810808,
1870x00060061,
1880x7c810808,
1890x00060062,
1900x00060063,
1910x7c810808,
1920x7c810808,
1930x00060064,
1940x7c810808,
1950x7c810808,
1960x7c810808,
1970x00060065,
1980x7c810808,
1990x7c810808,
2000x7c810808,
2010x00060066,
2020x7c810808,
2030x7c810808,
2040x7c810808,
2050x00060067,
2060x7c810808,
2070x7c810808,
2080x7c810808,
2090x00060068,
2100x7c810808,
2110x7c810808,
2120x00060069,
2130x7c810808,
2140x7c810808,
2150x0006006a,
2160x7c810808,
2170x7c810808,
2180x0006006b,
2190x00000000,
2200x7c810808,
2210x0006006c,
2220x7c810808,
2230x0006006d,
2240x7c810808,
2250x0006006e,
2260x7c810808,
2270x0006006f,
2280x7c810808,
2290x00060070,
2300x7c810808,
2310x7c810808,
2320x00060071,
2330x7c810808,
2340x7c810808,
2350x00060072,
2360x7c810808,
2370x7c810808,
2380x00060073,
2390x7c810808,
2400x7c810808,
2410x00060074,
2420x7c810808,
2430x7c810808,
2440x00060075,
2450x7c810808,
2460x7c810808,
2470x7c810808,
2480x00060076,
2490x7c810808,
2500x7c810808,
2510x7c810808,
2520x7c810808,
2530x00060077,
2540x7c810808,
2550x7c810808,
2560x7c810808,
2570x7c810808,
2580x00060078,
2590x7c810808,
2600x7c810808,
2610x7c810808,
2620x7c810808,
2630x00060079,
2640x7c810808,
2650x7c810808,
2660x7c810808,
2670x7c810808,
2680x0006007a,
2690x7c810808,
2700x7c810808,
2710x7c810808,
2720x7c810808,
2730x0006007b,
2740x7c810808,
2750x0006007c,
2760x7c810808,
2770x0006007d,
2780x7c810808,
2790x7c810808,
2800x7c810808,
2810x0006007e,
2820x7c810808,
2830x7c810808,
2840x7c810808,
2850x0006007f,
2860x7c810808,
2870x7c810808,
2880x7c810808,
2890x00060080,
2900x7c810808,
2910x7c810808,
2920x7c810808,
2930x00060081,
2940x00000000,
2950x7c810808,
2960x7c810808,
2970x7c810808,
2980x00060082,
2990x7c810808,
3000x00060083,
3010x7c810808,
3020x00060084,
3030x00000000,
3040x7c810808,
3050x00000000,
3060x00060085,
3070x7c810808,
3080x00060086,
3090x7c810808,
3100x00060087,
3110x7c810808,
3120x00060088,
3130x00000000,
3140x7c810808,
3150x00000000,
3160x00060089,
3170x7c810808,
3180x0006008a,
3190x00000000,
3200x7c810808,
3210x00000000,
3220x0006008b,
3230x00000000,
3240x7c810808,
3250x00000000,
3260x0006008c,
3270x00000000,
3280x7c810808,
3290x00000000,
3300x0006008d,
3310x7c810808,
3320x0006008e,
3330x7c810808,
3340x0006008f,
3350x7c810808,
3360x00060090,
3370x7c810808,
3380x00060091,
3390x7c810808,
3400x00060092,
3410x7c810808,
3420x00060093,
3430x7c810808,
3440x00060094,
3450x7c810808,
3460x00060095,
3470x7c810808,
3480x00060096,
3490x7c810808,
3500x00000000,
3510x00080000,
3520x00000000,
3530x7c810808,
3540x00000000,
3550x7c810808,
3560x00000000,
3570x7c810808,
3580x00000000,
3590x7c810808,
3600x00000000,
3610x7c810808,
3620x00000000,
3630x7c810808,
3640x00000000,
3650x7c810808,
3660x00000000,
3670x7c810808,
3680x00000000,
3690x7c810808,
3700x00000000,
3710x7c810808,
3720x00000000,
3730x7c810808,
3740x00000000,
3750x7c810808,
3760x00000000,
3770x7c810808,
3780x00000000,
3790x7c810808,
3800x00000000,
3810x7c810808,
3820x00000000,
3830x7c810808,
3840x00000000,
3850x7c810808,
3860x00000000,
3870x7c810808,
3880x00000000,
3890x7c810808,
3900x00000000,
3910x7c810808,
3920x00000000,
3930x7c810808,
3940x00000000,
3950x7c810808,
3960x00000000,
3970x7c810808,
3980x00000000,
3990x7c810808,
4000x00000000,
4010x7c810808,
4020x00000000,
4030x7c810808,
4040x00000000,
4050x7c810808,
4060x00000000,
4070x7c810808,
4080x00000000,
4090x7c810808,
4100x00000000,
4110x7c810808,
4120x00000000,
4130x7c810808,
4140x00000000,
4150x7c810808,
4160x00000000,
4170x7c810808,
4180x00000000,
4190x7c810808,
4200x00000000,
4210x7c810808,
4220x00000000,
4230x7c810808,
4240x00000000,
4250x7c810808,
4260x00000000,
4270x7c810808,
4280x00000000,
4290x7c810808,
4300x00000000,
4310x7c810808,
4320x00000000,
4330x7c810808,
4340x00000000,
4350x7c810808,
4360x00000000,
4370x7c810808,
4380x00000000,
4390x7c810808,
4400x00000000,
4410x7c810808,
4420x00000000,
4430x7c810808,
4440x00000000,
4450x7c810808,
4460x00000000,
4470x7c810808,
4480x00000000,
4490x7c810808,
4500x00000000,
4510x7c810808,
4520x00000000,
4530x7c810808,
4540x00000000,
4550x7c810808,
4560x00000000,
4570x7c810808,
4580x00000000,
4590x7c810808,
4600x00000000,
4610x7c810808,
4620x00000000,
4630x7c810808,
4640x00000000,
4650x7c810808,
4660x00000000,
4670x7c810808,
4680x00000000,
4690x7c810808,
4700x00000000,
4710x7c810808,
4720x00000000,
4730x7c810808,
4740x00000000,
4750x7c810808,
4760x00000000,
4770x00010000
478};
479
480enum {
481 GLOB_vm_returnp,
482 GLOB_vm_returnc,
483 GLOB_vm_return,
484 GLOB_vm_leave_cp,
485 GLOB_vm_leave_unw,
486 GLOB_vm_unwind_c,
487 GLOB_vm_unwind_c_eh,
488 GLOB_vm_unwind_ff,
489 GLOB_vm_unwind_ff_eh,
490 GLOB_vm_growstack_c,
491 GLOB_vm_growstack_l,
492 GLOB_vm_resume,
493 GLOB_vm_pcall,
494 GLOB_vm_call,
495 GLOB_vm_call_dispatch,
496 GLOB_vm_call_dispatch_f,
497 GLOB_vm_cpcall,
498 GLOB_cont_dispatch,
499 GLOB_cont_cat,
500 GLOB_vmeta_tgets,
501 GLOB_vmeta_tgetb,
502 GLOB_vmeta_tgetv,
503 GLOB_vmeta_tsets,
504 GLOB_vmeta_tsetb,
505 GLOB_vmeta_tsetv,
506 GLOB_vmeta_comp,
507 GLOB_cont_nop,
508 GLOB_cont_ra,
509 GLOB_cont_condt,
510 GLOB_cont_condf,
511 GLOB_vmeta_equal,
512 GLOB_vmeta_arith_vn,
513 GLOB_vmeta_arith_nv,
514 GLOB_vmeta_unm,
515 GLOB_vmeta_arith_vv,
516 GLOB_vmeta_binop,
517 GLOB_vmeta_len,
518 GLOB_vmeta_call_ra,
519 GLOB_vmeta_call,
520 GLOB_vmeta_for,
521 GLOB_ff_assert,
522 GLOB_ff_type,
523 GLOB_ff_getmetatable,
524 GLOB_ff_setmetatable,
525 GLOB_ff_rawget,
526 GLOB_ff_tonumber,
527 GLOB_ff_tostring,
528 GLOB_ff_next,
529 GLOB_fff_res2,
530 GLOB_ff_pairs,
531 GLOB_ff_ipairs_aux,
532 GLOB_fff_res0,
533 GLOB_ff_ipairs,
534 GLOB_ff_pcall,
535 GLOB_ff_xpcall,
536 GLOB_ff_coroutine_resume,
537 GLOB_ff_coroutine_wrap_aux,
538 GLOB_ff_coroutine_yield,
539 GLOB_ff_math_abs,
540 GLOB_fff_res1,
541 GLOB_fff_res,
542 GLOB_ff_math_floor,
543 GLOB_ff_math_ceil,
544 GLOB_ff_math_sqrt,
545 GLOB_ff_math_log,
546 GLOB_ff_math_log10,
547 GLOB_ff_math_exp,
548 GLOB_ff_math_sin,
549 GLOB_ff_math_cos,
550 GLOB_ff_math_tan,
551 GLOB_ff_math_asin,
552 GLOB_ff_math_acos,
553 GLOB_ff_math_atan,
554 GLOB_ff_math_sinh,
555 GLOB_ff_math_cosh,
556 GLOB_ff_math_tanh,
557 GLOB_ff_math_atan2,
558 GLOB_ff_math_fmod,
559 GLOB_ff_math_deg,
560 GLOB_ff_math_rad,
561 GLOB_ff_math_ldexp,
562 GLOB_ff_math_frexp,
563 GLOB_ff_math_modf,
564 GLOB_ff_math_pow,
565 GLOB_ff_math_min,
566 GLOB_ff_math_max,
567 GLOB_ff_string_len,
568 GLOB_ff_string_byte,
569 GLOB_ff_string_char,
570 GLOB_fff_newstr,
571 GLOB_ff_string_sub,
572 GLOB_fff_emptystr,
573 GLOB_ff_string_rep,
574 GLOB_ff_string_reverse,
575 GLOB_ff_string_lower,
576 GLOB_ff_string_upper,
577 GLOB_ff_table_getn,
578 GLOB_ff_bit_tobit,
579 GLOB_ff_bit_band,
580 GLOB_ff_bit_bor,
581 GLOB_ff_bit_bxor,
582 GLOB_ff_bit_bswap,
583 GLOB_ff_bit_bnot,
584 GLOB_fff_resbit,
585 GLOB_fff_fallback_bit_op,
586 GLOB_ff_bit_lshift,
587 GLOB_ff_bit_rshift,
588 GLOB_ff_bit_arshift,
589 GLOB_ff_bit_rol,
590 GLOB_ff_bit_ror,
591 GLOB_fff_fallback,
592 GLOB_fff_gcstep,
593 GLOB_vm_record,
594 GLOB_vm_rethook,
595 GLOB_vm_inshook,
596 GLOB_cont_hook,
597 GLOB_vm_hotloop,
598 GLOB_vm_callhook,
599 GLOB_vm_hotcall,
600 GLOB_vm_exit_handler,
601 GLOB_vm_exit_interp,
602 GLOB_vm_floor,
603 GLOB_vm_ceil,
604 GLOB_vm_trunc,
605 GLOB_vm_mod,
606 GLOB_vm_exp,
607 GLOB_vm_exp2,
608 GLOB_vm_pow,
609 GLOB_vm_powi_sse,
610 GLOB_vm_foldfpm,
611 GLOB_vm_foldarith,
612 GLOB__MAX
613};
614static const char *const globnames[] = {
615 "vm_returnp",
616 "vm_returnc",
617 "vm_return",
618 "vm_leave_cp",
619 "vm_leave_unw",
620 "vm_unwind_c",
621 "vm_unwind_c_eh",
622 "vm_unwind_ff",
623 "vm_unwind_ff_eh",
624 "vm_growstack_c",
625 "vm_growstack_l",
626 "vm_resume",
627 "vm_pcall",
628 "vm_call",
629 "vm_call_dispatch",
630 "vm_call_dispatch_f",
631 "vm_cpcall",
632 "cont_dispatch",
633 "cont_cat",
634 "vmeta_tgets",
635 "vmeta_tgetb",
636 "vmeta_tgetv",
637 "vmeta_tsets",
638 "vmeta_tsetb",
639 "vmeta_tsetv",
640 "vmeta_comp",
641 "cont_nop",
642 "cont_ra",
643 "cont_condt",
644 "cont_condf",
645 "vmeta_equal",
646 "vmeta_arith_vn",
647 "vmeta_arith_nv",
648 "vmeta_unm",
649 "vmeta_arith_vv",
650 "vmeta_binop",
651 "vmeta_len",
652 "vmeta_call_ra",
653 "vmeta_call",
654 "vmeta_for",
655 "ff_assert",
656 "ff_type",
657 "ff_getmetatable",
658 "ff_setmetatable",
659 "ff_rawget",
660 "ff_tonumber",
661 "ff_tostring",
662 "ff_next",
663 "fff_res2",
664 "ff_pairs",
665 "ff_ipairs_aux",
666 "fff_res0",
667 "ff_ipairs",
668 "ff_pcall",
669 "ff_xpcall",
670 "ff_coroutine_resume",
671 "ff_coroutine_wrap_aux",
672 "ff_coroutine_yield",
673 "ff_math_abs",
674 "fff_res1",
675 "fff_res",
676 "ff_math_floor",
677 "ff_math_ceil",
678 "ff_math_sqrt",
679 "ff_math_log",
680 "ff_math_log10",
681 "ff_math_exp",
682 "ff_math_sin",
683 "ff_math_cos",
684 "ff_math_tan",
685 "ff_math_asin",
686 "ff_math_acos",
687 "ff_math_atan",
688 "ff_math_sinh",
689 "ff_math_cosh",
690 "ff_math_tanh",
691 "ff_math_atan2",
692 "ff_math_fmod",
693 "ff_math_deg",
694 "ff_math_rad",
695 "ff_math_ldexp",
696 "ff_math_frexp",
697 "ff_math_modf",
698 "ff_math_pow",
699 "ff_math_min",
700 "ff_math_max",
701 "ff_string_len",
702 "ff_string_byte",
703 "ff_string_char",
704 "fff_newstr",
705 "ff_string_sub",
706 "fff_emptystr",
707 "ff_string_rep",
708 "ff_string_reverse",
709 "ff_string_lower",
710 "ff_string_upper",
711 "ff_table_getn",
712 "ff_bit_tobit",
713 "ff_bit_band",
714 "ff_bit_bor",
715 "ff_bit_bxor",
716 "ff_bit_bswap",
717 "ff_bit_bnot",
718 "fff_resbit",
719 "fff_fallback_bit_op",
720 "ff_bit_lshift",
721 "ff_bit_rshift",
722 "ff_bit_arshift",
723 "ff_bit_rol",
724 "ff_bit_ror",
725 "fff_fallback",
726 "fff_gcstep",
727 "vm_record",
728 "vm_rethook",
729 "vm_inshook",
730 "cont_hook",
731 "vm_hotloop",
732 "vm_callhook",
733 "vm_hotcall",
734 "vm_exit_handler",
735 "vm_exit_interp",
736 "vm_floor",
737 "vm_ceil",
738 "vm_trunc",
739 "vm_mod",
740 "vm_exp",
741 "vm_exp2",
742 "vm_pow",
743 "vm_powi_sse",
744 "vm_foldfpm",
745 "vm_foldarith",
746 (const char *)0
747};
748static const char *const extnames[] = {
749 (const char *)0
750};
751#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field))
752#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field))
753#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto))
754
755/* Generate subroutines used by opcodes and other parts of the VM. */
756/* The .code_sub section should be last to help static branch prediction. */
757static void build_subroutines(BuildCtx *ctx)
758{
759 dasm_put(Dst, 0);
760 dasm_put(Dst, 1);
761 dasm_put(Dst, 45);
762 dasm_put(Dst, 91);
763 dasm_put(Dst, 148);
764 dasm_put(Dst, 204);
765 dasm_put(Dst, 279);
766#if LJ_HASJIT
767 dasm_put(Dst, 288);
768#endif
769 dasm_put(Dst, 290);
770#if LJ_HASJIT
771 dasm_put(Dst, 298);
772#endif
773 dasm_put(Dst, 300);
774#if LJ_HASJIT
775 dasm_put(Dst, 304);
776#endif
777 dasm_put(Dst, 306);
778#if LJ_HASJIT
779 dasm_put(Dst, 308);
780#endif
781 dasm_put(Dst, 310);
782#if LJ_HASJIT
783 dasm_put(Dst, 312);
784#endif
785 dasm_put(Dst, 314);
786}
787
788/* Generate the code for a single instruction. */
789static void build_ins(BuildCtx *ctx, BCOp op, int defop)
790{
791 dasm_put(Dst, 335, defop);
792
793 switch (op) {
794
795 /* -- Comparison ops ---------------------------------------------------- */
796
797 /* Remember: all ops branch for a true comparison, fall through otherwise. */
798
799 case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT:
800 dasm_put(Dst, 337);
801 break;
802
803 case BC_ISEQV: case BC_ISNEV:
804 dasm_put(Dst, 339);
805 break;
806
807 case BC_ISEQS: case BC_ISNES:
808 dasm_put(Dst, 341);
809 break;
810
811 case BC_ISEQN: case BC_ISNEN:
812 dasm_put(Dst, 343);
813 break;
814
815 case BC_ISEQP: case BC_ISNEP:
816 dasm_put(Dst, 345);
817 break;
818
819 /* -- Unary test and copy ops ------------------------------------------- */
820
821 case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF:
822 dasm_put(Dst, 347);
823 break;
824
825 /* -- Unary ops --------------------------------------------------------- */
826
827 case BC_MOV:
828 dasm_put(Dst, 349);
829 break;
830 case BC_NOT:
831 dasm_put(Dst, 351);
832 break;
833 case BC_UNM:
834 dasm_put(Dst, 353);
835 break;
836 case BC_LEN:
837 dasm_put(Dst, 355);
838 break;
839
840 /* -- Binary ops -------------------------------------------------------- */
841
842 case BC_ADDVN: case BC_ADDNV: case BC_ADDVV:
843 dasm_put(Dst, 357);
844 break;
845 case BC_SUBVN: case BC_SUBNV: case BC_SUBVV:
846 dasm_put(Dst, 359);
847 break;
848 case BC_MULVN: case BC_MULNV: case BC_MULVV:
849 dasm_put(Dst, 361);
850 break;
851 case BC_DIVVN: case BC_DIVNV: case BC_DIVVV:
852 dasm_put(Dst, 363);
853 break;
854 case BC_MODVN:
855 dasm_put(Dst, 365);
856 break;
857 case BC_MODNV: case BC_MODVV:
858 dasm_put(Dst, 367);
859 break;
860 case BC_POW:
861 dasm_put(Dst, 369);
862 break;
863
864 case BC_CAT:
865 dasm_put(Dst, 371);
866 break;
867
868 /* -- Constant ops ------------------------------------------------------ */
869
870 case BC_KSTR:
871 dasm_put(Dst, 373);
872 break;
873 case BC_KSHORT:
874 dasm_put(Dst, 375);
875 break;
876 case BC_KNUM:
877 dasm_put(Dst, 377);
878 break;
879 case BC_KPRI:
880 dasm_put(Dst, 379);
881 break;
882 case BC_KNIL:
883 dasm_put(Dst, 381);
884 break;
885
886 /* -- Upvalue and function ops ------------------------------------------ */
887
888 case BC_UGET:
889 dasm_put(Dst, 383);
890 break;
891 case BC_USETV:
892 dasm_put(Dst, 385);
893 break;
894 case BC_USETS:
895 dasm_put(Dst, 387);
896 break;
897 case BC_USETN:
898 dasm_put(Dst, 389);
899 break;
900 case BC_USETP:
901 dasm_put(Dst, 391);
902 break;
903 case BC_UCLO:
904 dasm_put(Dst, 393);
905 break;
906
907 case BC_FNEW:
908 dasm_put(Dst, 395);
909 break;
910
911 /* -- Table ops --------------------------------------------------------- */
912
913 case BC_TNEW:
914 dasm_put(Dst, 397);
915 break;
916 case BC_TDUP:
917 dasm_put(Dst, 399);
918 break;
919
920 case BC_GGET:
921 case BC_GSET:
922 dasm_put(Dst, 401);
923 break;
924
925 case BC_TGETV:
926 dasm_put(Dst, 403);
927 break;
928 case BC_TGETS:
929 dasm_put(Dst, 405);
930 break;
931 case BC_TGETB:
932 dasm_put(Dst, 407);
933 break;
934
935 case BC_TSETV:
936 dasm_put(Dst, 409);
937 break;
938 case BC_TSETS:
939 dasm_put(Dst, 411);
940 break;
941 case BC_TSETB:
942 dasm_put(Dst, 413);
943 break;
944
945 case BC_TSETM:
946 dasm_put(Dst, 415);
947 break;
948
949 /* -- Calls and vararg handling ----------------------------------------- */
950
951 case BC_CALLM:
952 dasm_put(Dst, 417);
953 break;
954 case BC_CALL:
955 dasm_put(Dst, 419);
956 break;
957
958 case BC_CALLMT:
959 dasm_put(Dst, 421);
960 break;
961 case BC_CALLT:
962 dasm_put(Dst, 423);
963 break;
964
965 case BC_ITERC:
966 dasm_put(Dst, 425);
967 break;
968
969 case BC_VARG:
970 dasm_put(Dst, 427);
971 break;
972
973 /* -- Returns ----------------------------------------------------------- */
974
975 case BC_RETM:
976 dasm_put(Dst, 429);
977 break;
978
979 case BC_RET:
980 dasm_put(Dst, 431);
981 break;
982
983 case BC_RET0: case BC_RET1:
984 dasm_put(Dst, 433);
985 break;
986
987 /* -- Loops and branches ------------------------------------------------ */
988
989 case BC_FORL:
990#if LJ_HASJIT
991 dasm_put(Dst, 435);
992#endif
993 break;
994
995 case BC_JFORI:
996 case BC_JFORL:
997#if !LJ_HASJIT
998 break;
999#endif
1000 case BC_FORI:
1001 case BC_IFORL:
1002 dasm_put(Dst, 437);
1003 break;
1004
1005 case BC_ITERL:
1006#if LJ_HASJIT
1007 dasm_put(Dst, 439);
1008#endif
1009 break;
1010
1011 case BC_JITERL:
1012#if !LJ_HASJIT
1013 break;
1014#endif
1015 case BC_IITERL:
1016 dasm_put(Dst, 441);
1017 break;
1018
1019 case BC_LOOP:
1020 dasm_put(Dst, 443);
1021#if LJ_HASJIT
1022#endif
1023 break;
1024
1025 case BC_ILOOP:
1026 dasm_put(Dst, 445);
1027 break;
1028
1029 case BC_JLOOP:
1030 dasm_put(Dst, 447);
1031 break;
1032
1033 case BC_JMP:
1034 dasm_put(Dst, 449);
1035 break;
1036
1037 /* -- Function headers -------------------------------------------------- */
1038
1039 case BC_FUNCF:
1040#if LJ_HASJIT
1041 dasm_put(Dst, 451);
1042#endif
1043 case BC_FUNCV: /* NYI: compiled vararg functions. */
1044 break;
1045
1046 case BC_JFUNCF:
1047#if !LJ_HASJIT
1048 break;
1049#endif
1050 case BC_IFUNCF:
1051 dasm_put(Dst, 453);
1052 break;
1053
1054 case BC_JFUNCV:
1055#if !LJ_HASJIT
1056 break;
1057#endif
1058 dasm_put(Dst, 455);
1059 break; /* NYI: compiled vararg functions. */
1060
1061 case BC_IFUNCV:
1062 dasm_put(Dst, 457);
1063 break;
1064
1065 case BC_FUNCC:
1066 case BC_FUNCCW:
1067 dasm_put(Dst, 459);
1068 break;
1069
1070 /* ---------------------------------------------------------------------- */
1071
1072 default:
1073 fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]);
1074 exit(2);
1075 break;
1076 }
1077}
1078
1079static int build_backend(BuildCtx *ctx)
1080{
1081 int op;
1082
1083 dasm_growpc(Dst, BC__MAX);
1084
1085 build_subroutines(ctx);
1086
1087 dasm_put(Dst, 461);
1088 for (op = 0; op < BC__MAX; op++)
1089 build_ins(ctx, (BCOp)op, op);
1090
1091 return BC__MAX;
1092}
1093
1094/* Emit pseudo frame-info for all assembler functions. */
1095static void emit_asm_debug(BuildCtx *ctx)
1096{
1097 /* NYI */
1098 UNUSED(ctx);
1099}
1100
diff --git a/src/lib_jit.c b/src/lib_jit.c
index 4cabb2f7..bfceab62 100644
--- a/src/lib_jit.c
+++ b/src/lib_jit.c
@@ -543,10 +543,12 @@ static uint32_t jit_cpudetect(lua_State *L)
543 luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); 543 luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)");
544#endif 544#endif
545#endif 545#endif
546 UNUSED(L); 546#elif LJ_TARGET_PPC
547 /* Nothing to do. */
547#else 548#else
548#error "Missing CPU detection for this architecture" 549#error "Missing CPU detection for this architecture"
549#endif 550#endif
551 UNUSED(L);
550 return flags; 552 return flags;
551} 553}
552 554