Lines 47-56
Link Here
|
47 |
StackFrame::methodjitStaticAsserts() |
47 |
StackFrame::methodjitStaticAsserts() |
48 |
{ |
48 |
{ |
49 |
/* Static assert for x86 trampolines in MethodJIT.cpp. */ |
49 |
/* Static assert for x86 trampolines in MethodJIT.cpp. */ |
50 |
#if defined(JS_CPU_X86) |
50 |
#if defined(JS_CPU_X86) || defined(JS_CPU_X32) |
51 |
JS_STATIC_ASSERT(offsetof(StackFrame, rval_) == 0x18); |
51 |
JS_STATIC_ASSERT(offsetof(StackFrame, rval_) == 0x18); |
52 |
JS_STATIC_ASSERT(offsetof(StackFrame, rval_) + 4 == 0x1C); |
52 |
JS_STATIC_ASSERT(offsetof(StackFrame, rval_) + 4 == 0x1C); |
53 |
JS_STATIC_ASSERT(offsetof(StackFrame, ncode_) == 0x14); |
53 |
JS_STATIC_ASSERT(offsetof(StackFrame, ncode_) == 0x14); |
|
|
54 |
#elif defined(JS_CPU_ARM) |
54 |
/* ARM uses decimal literals. */ |
55 |
/* ARM uses decimal literals. */ |
55 |
JS_STATIC_ASSERT(offsetof(StackFrame, rval_) == 24); |
56 |
JS_STATIC_ASSERT(offsetof(StackFrame, rval_) == 24); |
56 |
JS_STATIC_ASSERT(offsetof(StackFrame, rval_) + 4 == 28); |
57 |
JS_STATIC_ASSERT(offsetof(StackFrame, rval_) + 4 == 28); |
Lines 135-141
Link Here
|
135 |
|
136 |
|
136 |
JS_STATIC_ASSERT(offsetof(FrameRegs, sp) == 0); |
137 |
JS_STATIC_ASSERT(offsetof(FrameRegs, sp) == 0); |
137 |
|
138 |
|
138 |
#if defined(__linux__) && defined(JS_CPU_X64) |
139 |
#if defined(__linux__) && ( defined(JS_CPU_X64) || defined(JS_CPU_X32) ) |
|
|
140 |
|
139 |
# define SYMBOL_STRING_RELOC(name) #name "@plt" |
141 |
# define SYMBOL_STRING_RELOC(name) #name "@plt" |
140 |
#else |
142 |
#else |
141 |
# define SYMBOL_STRING_RELOC(name) SYMBOL_STRING(name) |
143 |
# define SYMBOL_STRING_RELOC(name) SYMBOL_STRING(name) |
Lines 427-432
Link Here
|
427 |
"jmp " SYMBOL_STRING_RELOC(JaegerInterpoline) "\n" |
429 |
"jmp " SYMBOL_STRING_RELOC(JaegerInterpoline) "\n" |
428 |
CFI(".cfi_endproc" "\n") |
430 |
CFI(".cfi_endproc" "\n") |
429 |
); |
431 |
); |
|
|
432 |
|
433 |
# elif defined(JS_CPU_X32) |
434 |
|
435 |
/* |
436 |
* *** DANGER *** |
437 |
* If these assertions break, update the constants below. |
438 |
* *** DANGER *** |
439 |
*/ |
440 |
JS_STATIC_ASSERT(offsetof(VMFrame, savedRBX) == 0x34); |
441 |
JS_STATIC_ASSERT(offsetof(VMFrame, scratch) == 0xC); |
442 |
JS_STATIC_ASSERT(VMFrame::offsetOfFp == 0x1C); |
443 |
|
444 |
asm ( |
445 |
".text\n" |
446 |
".globl " SYMBOL_STRING(JaegerTrampoline) "\n" |
447 |
SYMBOL_STRING(JaegerTrampoline) ":" "\n" |
448 |
/* Prologue. */ |
449 |
CFI(".cfi_startproc" "\n") |
450 |
CFI(".cfi_def_cfa rsp, 8" "\n") |
451 |
"pushq %rbp" "\n" |
452 |
CFI(".cfi_def_cfa_offset 16" "\n") |
453 |
CFI(".cfi_offset rbp, -16" "\n") |
454 |
"movq %rsp, %rbp" "\n" |
455 |
CFI(".cfi_def_cfa_register rbp" "\n") |
456 |
/* Save non-volatile registers. */ |
457 |
"pushq %r12" "\n" |
458 |
CFI(".cfi_offset r12, -24" "\n") |
459 |
"pushq %r13" "\n" |
460 |
CFI(".cfi_offset r13, -32" "\n") |
461 |
"pushq %r14" "\n" |
462 |
CFI(".cfi_offset r14, -40" "\n") |
463 |
"pushq %r15" "\n" |
464 |
CFI(".cfi_offset r15, -48" "\n") |
465 |
"pushq %rbx" "\n" |
466 |
CFI(".cfi_offset rbx, -56" "\n") |
467 |
|
468 |
/* Build the JIT frame. |
469 |
* rdi = cx |
470 |
* rsi = fp |
471 |
* rcx = inlineCallCount |
472 |
* fp must go into rbx |
473 |
*/ |
474 |
"pushq $0x0" "\n" /* stubRejoin */ |
475 |
"pushq %rsi" "\n" /* entryncode */ |
476 |
"pushq %rsi" "\n" /* entryfp */ |
477 |
"pushq %rcx" "\n" /* inlineCallCount */ |
478 |
"pushq %rdi" "\n" /* cx */ |
479 |
"pushq %rsi" "\n" /* fp */ |
480 |
"movq %rsi, %rbx" "\n" |
481 |
|
482 |
/* Space for the rest of the VMFrame. */ |
483 |
"subq $0x28, %rsp" "\n" |
484 |
|
485 |
/* This is actually part of the VMFrame. */ |
486 |
"pushq %r8" "\n" |
487 |
|
488 |
/* Set cx->regs and set the active frame. Save rdx and align frame in one. */ |
489 |
"pushq %rdx" "\n" |
490 |
"movq %rsp, %rdi" "\n" |
491 |
"call " SYMBOL_STRING_VMFRAME(PushActiveVMFrame) "\n" |
492 |
|
493 |
/* Jump into the JIT'd code. */ |
494 |
"jmp *0(%rsp)" "\n" |
495 |
CFI(".cfi_endproc" "\n") |
496 |
); |
497 |
|
498 |
asm ( |
499 |
".text\n" |
500 |
/* See "Special rules for JaegerThrowpoline and friends", above. */ |
501 |
CFI(".cfi_startproc" "\n") |
502 |
CFI(".cfi_def_cfa rbp, 16" "\n") |
503 |
CFI(".cfi_offset rbp, -16" "\n") |
504 |
CFI(".cfi_offset r12, -24" "\n") |
505 |
CFI(".cfi_offset r13, -32" "\n") |
506 |
CFI(".cfi_offset r14, -40" "\n") |
507 |
CFI(".cfi_offset r15, -48" "\n") |
508 |
CFI(".cfi_offset rbx, -56" "\n") |
509 |
CFI("nop" "\n") |
510 |
".globl " SYMBOL_STRING(JaegerTrampolineReturn) "\n" |
511 |
SYMBOL_STRING(JaegerTrampolineReturn) ":" "\n" |
512 |
"or %rdi, %rsi" "\n" |
513 |
"movq %rsi, 0x30(%rbx)" "\n" |
514 |
"movq %rsp, %rdi" "\n" |
515 |
"call " SYMBOL_STRING_VMFRAME(PopActiveVMFrame) "\n" |
516 |
|
517 |
"addq $0x34, %rsp" "\n" |
518 |
"popq %rbx" "\n" |
519 |
"popq %r15" "\n" |
520 |
"popq %r14" "\n" |
521 |
"popq %r13" "\n" |
522 |
"popq %r12" "\n" |
523 |
"popq %rbp" "\n" |
524 |
CFI(".cfi_def_cfa rsp, 8" "\n") |
525 |
"movq $1, %rax" "\n" |
526 |
"ret" "\n" |
527 |
CFI(".cfi_endproc" "\n") |
528 |
); |
529 |
|
530 |
asm ( |
531 |
".text\n" |
532 |
/* See "Special rules for JaegerThrowpoline and friends", above. */ |
533 |
CFI(".cfi_startproc" "\n") |
534 |
CFI(".cfi_def_cfa rbp, 16" "\n") |
535 |
CFI(".cfi_offset rbp, -16" "\n") |
536 |
CFI(".cfi_offset r12, -24" "\n") |
537 |
CFI(".cfi_offset r13, -32" "\n") |
538 |
CFI(".cfi_offset r14, -40" "\n") |
539 |
CFI(".cfi_offset r15, -48" "\n") |
540 |
CFI(".cfi_offset rbx, -56" "\n") |
541 |
CFI("nop" "\n") |
542 |
".globl " SYMBOL_STRING(JaegerThrowpoline) "\n" |
543 |
SYMBOL_STRING(JaegerThrowpoline) ":" "\n" |
544 |
"movq %rsp, %rdi" "\n" |
545 |
"call " SYMBOL_STRING_RELOC(js_InternalThrow) "\n" |
546 |
"testq %rax, %rax" "\n" |
547 |
"je throwpoline_exit" "\n" |
548 |
"jmp *%rax" "\n" |
549 |
"throwpoline_exit:" "\n" |
550 |
"movq %rsp, %rdi" "\n" |
551 |
"call " SYMBOL_STRING_VMFRAME(PopActiveVMFrame) "\n" |
552 |
"addq $0x34, %rsp" "\n" |
553 |
"popq %rbx" "\n" |
554 |
"popq %r15" "\n" |
555 |
"popq %r14" "\n" |
556 |
"popq %r13" "\n" |
557 |
"popq %r12" "\n" |
558 |
"popq %rbp" "\n" |
559 |
CFI(".cfi_def_cfa rsp, 8" "\n") |
560 |
"xorq %rax,%rax" "\n" |
561 |
"ret" "\n" |
562 |
CFI(".cfi_endproc" "\n") |
563 |
); |
564 |
|
565 |
asm ( |
566 |
".text\n" |
567 |
/* See "Special rules for JaegerThrowpoline and friends", above. */ |
568 |
CFI(".cfi_startproc" "\n") |
569 |
CFI(".cfi_def_cfa rbp, 16" "\n") |
570 |
CFI(".cfi_offset rbp, -16" "\n") |
571 |
CFI(".cfi_offset r12, -24" "\n") |
572 |
CFI(".cfi_offset r13, -32" "\n") |
573 |
CFI(".cfi_offset r14, -40" "\n") |
574 |
CFI(".cfi_offset r15, -48" "\n") |
575 |
CFI(".cfi_offset rbx, -56" "\n") |
576 |
CFI("nop" "\n") |
577 |
".globl " SYMBOL_STRING(JaegerInterpoline) "\n" |
578 |
SYMBOL_STRING(JaegerInterpoline) ":" "\n" |
579 |
"movq %rsp, %rcx" "\n" |
580 |
"movq %rax, %rdx" "\n" |
581 |
"call " SYMBOL_STRING_RELOC(js_InternalInterpret) "\n" |
582 |
"movq 0x1C(%rsp), %rbx" "\n" /* Load frame */ |
583 |
"movq 0x30(%rbx), %rsi" "\n" /* Load rval payload */ |
584 |
"movq 0x30(%rbx), %rdi" "\n" /* Load rval type */ |
585 |
"movq 0xC(%rsp), %rcx" "\n" /* Load scratch -> argc */ |
586 |
"testq %rax, %rax" "\n" |
587 |
"je interpoline_exit" "\n" |
588 |
"jmp *%rax" "\n" |
589 |
"interpoline_exit:" "\n" |
590 |
"movq %rsp, %rdi" "\n" |
591 |
"call " SYMBOL_STRING_VMFRAME(PopActiveVMFrame) "\n" |
592 |
"addq $0x34, %rsp" "\n" |
593 |
"popq %rbx" "\n" |
594 |
"popq %r15" "\n" |
595 |
"popq %r14" "\n" |
596 |
"popq %r13" "\n" |
597 |
"popq %r12" "\n" |
598 |
"popq %rbp" "\n" |
599 |
CFI(".cfi_def_cfa rsp, 8" "\n") |
600 |
"xorq %rax,%rax" "\n" |
601 |
"ret" "\n" |
602 |
CFI(".cfi_endproc" "\n") |
603 |
); |
604 |
|
605 |
asm ( |
606 |
".text\n" |
607 |
/* See "Special rules for JaegerThrowpoline and friends", above. */ |
608 |
CFI(".cfi_startproc" "\n") |
609 |
CFI(".cfi_def_cfa rbp, 16" "\n") |
610 |
CFI(".cfi_offset rbp, -16" "\n") |
611 |
CFI(".cfi_offset r12, -24" "\n") |
612 |
CFI(".cfi_offset r13, -32" "\n") |
613 |
CFI(".cfi_offset r14, -40" "\n") |
614 |
CFI(".cfi_offset r15, -48" "\n") |
615 |
CFI(".cfi_offset rbx, -56" "\n") |
616 |
CFI("nop" "\n") |
617 |
".globl " SYMBOL_STRING(JaegerInterpolineScripted) "\n" |
618 |
SYMBOL_STRING(JaegerInterpolineScripted) ":" "\n" |
619 |
"movq 0x20(%rbx), %rbx" "\n" /* load prev */ |
620 |
"movq %rbx, 0x1C(%rsp)" "\n" |
621 |
"jmp " SYMBOL_STRING_RELOC(JaegerInterpoline) "\n" |
622 |
CFI(".cfi_endproc" "\n") |
623 |
); |
430 |
|
624 |
|
431 |
# elif defined(JS_CPU_X86) |
625 |
# elif defined(JS_CPU_X86) |
432 |
|
626 |
|