OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 j(not_zero, &ok, taken); | 496 j(not_zero, &ok, taken); |
497 mov(scratch, Operand(op1)); | 497 mov(scratch, Operand(op1)); |
498 or_(scratch, Operand(op2)); | 498 or_(scratch, Operand(op2)); |
499 j(sign, then_label, not_taken); | 499 j(sign, then_label, not_taken); |
500 bind(&ok); | 500 bind(&ok); |
501 } | 501 } |
502 | 502 |
503 | 503 |
504 void MacroAssembler::CallStub(CodeStub* stub) { | 504 void MacroAssembler::CallStub(CodeStub* stub) { |
505 ASSERT(allow_stub_calls()); // calls are not allowed in some stubs | 505 ASSERT(allow_stub_calls()); // calls are not allowed in some stubs |
506 call(stub->GetCode(), code_target); | 506 call(stub->GetCode(), RelocInfo::CODE_TARGET); |
507 } | 507 } |
508 | 508 |
509 | 509 |
510 void MacroAssembler::StubReturn(int argc) { | 510 void MacroAssembler::StubReturn(int argc) { |
511 ASSERT(argc >= 1 && generating_stub()); | 511 ASSERT(argc >= 1 && generating_stub()); |
512 ret((argc - 1) * kPointerSize); | 512 ret((argc - 1) * kPointerSize); |
513 } | 513 } |
514 | 514 |
515 | 515 |
516 void MacroAssembler::IllegalOperation() { | 516 void MacroAssembler::IllegalOperation() { |
(...skipping 30 matching lines...) Expand all Loading... |
547 // smarter. | 547 // smarter. |
548 mov(Operand(eax), Immediate(num_arguments)); | 548 mov(Operand(eax), Immediate(num_arguments)); |
549 JumpToBuiltin(ext); | 549 JumpToBuiltin(ext); |
550 } | 550 } |
551 | 551 |
552 | 552 |
553 void MacroAssembler::JumpToBuiltin(const ExternalReference& ext) { | 553 void MacroAssembler::JumpToBuiltin(const ExternalReference& ext) { |
554 // Set the entry point and jump to the C entry runtime stub. | 554 // Set the entry point and jump to the C entry runtime stub. |
555 mov(Operand(ebx), Immediate(ext)); | 555 mov(Operand(ebx), Immediate(ext)); |
556 CEntryStub ces; | 556 CEntryStub ces; |
557 jmp(ces.GetCode(), code_target); | 557 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); |
558 } | 558 } |
559 | 559 |
560 | 560 |
561 void MacroAssembler::InvokePrologue(const ParameterCount& expected, | 561 void MacroAssembler::InvokePrologue(const ParameterCount& expected, |
562 const ParameterCount& actual, | 562 const ParameterCount& actual, |
563 Handle<Code> code_constant, | 563 Handle<Code> code_constant, |
564 const Operand& code_operand, | 564 const Operand& code_operand, |
565 Label* done, | 565 Label* done, |
566 InvokeFlag flag) { | 566 InvokeFlag flag) { |
567 bool definitely_matches = false; | 567 bool definitely_matches = false; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 Handle<Code> adaptor = | 606 Handle<Code> adaptor = |
607 Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)); | 607 Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)); |
608 if (!code_constant.is_null()) { | 608 if (!code_constant.is_null()) { |
609 mov(Operand(edx), Immediate(code_constant)); | 609 mov(Operand(edx), Immediate(code_constant)); |
610 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); | 610 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); |
611 } else if (!code_operand.is_reg(edx)) { | 611 } else if (!code_operand.is_reg(edx)) { |
612 mov(edx, code_operand); | 612 mov(edx, code_operand); |
613 } | 613 } |
614 | 614 |
615 if (flag == CALL_FUNCTION) { | 615 if (flag == CALL_FUNCTION) { |
616 call(adaptor, code_target); | 616 call(adaptor, RelocInfo::CODE_TARGET); |
617 jmp(done); | 617 jmp(done); |
618 } else { | 618 } else { |
619 jmp(adaptor, code_target); | 619 jmp(adaptor, RelocInfo::CODE_TARGET); |
620 } | 620 } |
621 bind(&invoke); | 621 bind(&invoke); |
622 } | 622 } |
623 } | 623 } |
624 | 624 |
625 | 625 |
626 void MacroAssembler::InvokeCode(const Operand& code, | 626 void MacroAssembler::InvokeCode(const Operand& code, |
627 const ParameterCount& expected, | 627 const ParameterCount& expected, |
628 const ParameterCount& actual, | 628 const ParameterCount& actual, |
629 InvokeFlag flag) { | 629 InvokeFlag flag) { |
630 Label done; | 630 Label done; |
631 InvokePrologue(expected, actual, Handle<Code>::null(), code, &done, flag); | 631 InvokePrologue(expected, actual, Handle<Code>::null(), code, &done, flag); |
632 if (flag == CALL_FUNCTION) { | 632 if (flag == CALL_FUNCTION) { |
633 call(code); | 633 call(code); |
634 } else { | 634 } else { |
635 ASSERT(flag == JUMP_FUNCTION); | 635 ASSERT(flag == JUMP_FUNCTION); |
636 jmp(code); | 636 jmp(code); |
637 } | 637 } |
638 bind(&done); | 638 bind(&done); |
639 } | 639 } |
640 | 640 |
641 | 641 |
642 void MacroAssembler::InvokeCode(Handle<Code> code, | 642 void MacroAssembler::InvokeCode(Handle<Code> code, |
643 const ParameterCount& expected, | 643 const ParameterCount& expected, |
644 const ParameterCount& actual, | 644 const ParameterCount& actual, |
645 RelocMode rmode, | 645 RelocInfo::Mode rmode, |
646 InvokeFlag flag) { | 646 InvokeFlag flag) { |
647 Label done; | 647 Label done; |
648 Operand dummy(eax); | 648 Operand dummy(eax); |
649 InvokePrologue(expected, actual, code, dummy, &done, flag); | 649 InvokePrologue(expected, actual, code, dummy, &done, flag); |
650 if (flag == CALL_FUNCTION) { | 650 if (flag == CALL_FUNCTION) { |
651 call(code, rmode); | 651 call(code, rmode); |
652 } else { | 652 } else { |
653 ASSERT(flag == JUMP_FUNCTION); | 653 ASSERT(flag == JUMP_FUNCTION); |
654 jmp(code, rmode); | 654 jmp(code, rmode); |
655 } | 655 } |
(...skipping 20 matching lines...) Expand all Loading... |
676 bool resolved; | 676 bool resolved; |
677 Handle<Code> code = ResolveBuiltin(id, &resolved); | 677 Handle<Code> code = ResolveBuiltin(id, &resolved); |
678 | 678 |
679 // Calls are not allowed in some stubs. | 679 // Calls are not allowed in some stubs. |
680 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); | 680 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); |
681 | 681 |
682 // Rely on the assertion to check that the number of provided | 682 // Rely on the assertion to check that the number of provided |
683 // arguments match the expected number of arguments. Fake a | 683 // arguments match the expected number of arguments. Fake a |
684 // parameter count to avoid emitting code to do the check. | 684 // parameter count to avoid emitting code to do the check. |
685 ParameterCount expected(0); | 685 ParameterCount expected(0); |
686 InvokeCode(Handle<Code>(code), expected, expected, code_target, flag); | 686 InvokeCode(Handle<Code>(code), expected, expected, |
| 687 RelocInfo::CODE_TARGET, flag); |
687 | 688 |
688 const char* name = Builtins::GetName(id); | 689 const char* name = Builtins::GetName(id); |
689 int argc = Builtins::GetArgumentsCount(id); | 690 int argc = Builtins::GetArgumentsCount(id); |
690 | 691 |
691 if (!resolved) { | 692 if (!resolved) { |
692 uint32_t flags = | 693 uint32_t flags = |
693 Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | | 694 Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | |
694 Bootstrapper::FixupFlagsIsPCRelative::encode(true); | 695 Bootstrapper::FixupFlagsIsPCRelative::encode(true); |
695 Unresolved entry = { pc_offset() - sizeof(int32_t), flags, name }; | 696 Unresolved entry = { pc_offset() - sizeof(int32_t), flags, name }; |
696 unresolved_.Add(entry); | 697 unresolved_.Add(entry); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 // Indicate that code has changed. | 824 // Indicate that code has changed. |
824 CPU::FlushICache(address_, size_); | 825 CPU::FlushICache(address_, size_); |
825 | 826 |
826 // Check that the code was patched as expected. | 827 // Check that the code was patched as expected. |
827 ASSERT(masm_.pc_ == address_ + size_); | 828 ASSERT(masm_.pc_ == address_ + size_); |
828 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 829 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
829 } | 830 } |
830 | 831 |
831 | 832 |
832 } } // namespace v8::internal | 833 } } // namespace v8::internal |
OLD | NEW |