| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 CallKind call_kind); | 271 CallKind call_kind); |
| 272 | 272 |
| 273 // Invoke the JavaScript function in the given register. Changes the | 273 // Invoke the JavaScript function in the given register. Changes the |
| 274 // current context to the context in the function before invoking. | 274 // current context to the context in the function before invoking. |
| 275 void InvokeFunction(Register function, | 275 void InvokeFunction(Register function, |
| 276 const ParameterCount& actual, | 276 const ParameterCount& actual, |
| 277 InvokeFlag flag, | 277 InvokeFlag flag, |
| 278 const CallWrapper& call_wrapper, | 278 const CallWrapper& call_wrapper, |
| 279 CallKind call_kind); | 279 CallKind call_kind); |
| 280 | 280 |
| 281 void InvokeFunction(JSFunction* function, | 281 void InvokeFunction(Handle<JSFunction> function, |
| 282 const ParameterCount& actual, | 282 const ParameterCount& actual, |
| 283 InvokeFlag flag, | 283 InvokeFlag flag, |
| 284 const CallWrapper& call_wrapper, | 284 const CallWrapper& call_wrapper, |
| 285 CallKind call_kind); | 285 CallKind call_kind); |
| 286 | 286 |
| 287 // Invoke specified builtin JavaScript function. Adds an entry to | 287 // Invoke specified builtin JavaScript function. Adds an entry to |
| 288 // the unresolved list if the name does not resolve. | 288 // the unresolved list if the name does not resolve. |
| 289 void InvokeBuiltin(Builtins::JavaScript id, | 289 void InvokeBuiltin(Builtins::JavaScript id, |
| 290 InvokeFlag flag, | 290 InvokeFlag flag, |
| 291 const CallWrapper& call_wrapper = NullCallWrapper()); | 291 const CallWrapper& call_wrapper = NullCallWrapper()); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 // hash - holds the index's hash. Clobbered. | 625 // hash - holds the index's hash. Clobbered. |
| 626 // index - holds the overwritten index on exit. | 626 // index - holds the overwritten index on exit. |
| 627 void IndexFromHash(Register hash, Register index); | 627 void IndexFromHash(Register hash, Register index); |
| 628 | 628 |
| 629 // --------------------------------------------------------------------------- | 629 // --------------------------------------------------------------------------- |
| 630 // Runtime calls | 630 // Runtime calls |
| 631 | 631 |
| 632 // Call a code stub. Generate the code if necessary. | 632 // Call a code stub. Generate the code if necessary. |
| 633 void CallStub(CodeStub* stub, unsigned ast_id = kNoASTId); | 633 void CallStub(CodeStub* stub, unsigned ast_id = kNoASTId); |
| 634 | 634 |
| 635 // Call a code stub and return the code object called. Try to generate | |
| 636 // the code if necessary. Do not perform a GC but instead return a retry | |
| 637 // after GC failure. | |
| 638 MUST_USE_RESULT MaybeObject* TryCallStub(CodeStub* stub); | |
| 639 | |
| 640 // Tail call a code stub (jump). Generate the code if necessary. | 635 // Tail call a code stub (jump). Generate the code if necessary. |
| 641 void TailCallStub(CodeStub* stub); | 636 void TailCallStub(CodeStub* stub); |
| 642 | 637 |
| 643 // Tail call a code stub (jump) and return the code object called. Try to | |
| 644 // generate the code if necessary. Do not perform a GC but instead return | |
| 645 // a retry after GC failure. | |
| 646 MUST_USE_RESULT MaybeObject* TryTailCallStub(CodeStub* stub); | |
| 647 | |
| 648 // Return from a code stub after popping its arguments. | 638 // Return from a code stub after popping its arguments. |
| 649 void StubReturn(int argc); | 639 void StubReturn(int argc); |
| 650 | 640 |
| 651 // Call a runtime routine. | 641 // Call a runtime routine. |
| 652 void CallRuntime(const Runtime::Function* f, int num_arguments); | 642 void CallRuntime(const Runtime::Function* f, int num_arguments); |
| 653 void CallRuntimeSaveDoubles(Runtime::FunctionId id); | 643 void CallRuntimeSaveDoubles(Runtime::FunctionId id); |
| 654 | 644 |
| 655 // Call a runtime function, returning the CodeStub object called. | |
| 656 // Try to generate the stub code if necessary. Do not perform a GC | |
| 657 // but instead return a retry after GC failure. | |
| 658 MUST_USE_RESULT MaybeObject* TryCallRuntime(const Runtime::Function* f, | |
| 659 int num_arguments); | |
| 660 | |
| 661 // Convenience function: Same as above, but takes the fid instead. | 645 // Convenience function: Same as above, but takes the fid instead. |
| 662 void CallRuntime(Runtime::FunctionId id, int num_arguments); | 646 void CallRuntime(Runtime::FunctionId id, int num_arguments); |
| 663 | 647 |
| 664 // Convenience function: Same as above, but takes the fid instead. | |
| 665 MUST_USE_RESULT MaybeObject* TryCallRuntime(Runtime::FunctionId id, | |
| 666 int num_arguments); | |
| 667 | |
| 668 // Convenience function: call an external reference. | 648 // Convenience function: call an external reference. |
| 669 void CallExternalReference(ExternalReference ref, int num_arguments); | 649 void CallExternalReference(ExternalReference ref, int num_arguments); |
| 670 | 650 |
| 671 // Tail call of a runtime routine (jump). | 651 // Tail call of a runtime routine (jump). |
| 672 // Like JumpToExternalReference, but also takes care of passing the number | 652 // Like JumpToExternalReference, but also takes care of passing the number |
| 673 // of parameters. | 653 // of parameters. |
| 674 void TailCallExternalReference(const ExternalReference& ext, | 654 void TailCallExternalReference(const ExternalReference& ext, |
| 675 int num_arguments, | 655 int num_arguments, |
| 676 int result_size); | 656 int result_size); |
| 677 | 657 |
| 678 // Tail call of a runtime routine (jump). Try to generate the code if | |
| 679 // necessary. Do not perform a GC but instead return a retry after GC failure. | |
| 680 MUST_USE_RESULT MaybeObject* TryTailCallExternalReference( | |
| 681 const ExternalReference& ext, int num_arguments, int result_size); | |
| 682 | |
| 683 // Convenience function: tail call a runtime routine (jump). | 658 // Convenience function: tail call a runtime routine (jump). |
| 684 void TailCallRuntime(Runtime::FunctionId fid, | 659 void TailCallRuntime(Runtime::FunctionId fid, |
| 685 int num_arguments, | 660 int num_arguments, |
| 686 int result_size); | 661 int result_size); |
| 687 | 662 |
| 688 // Convenience function: tail call a runtime routine (jump). Try to generate | |
| 689 // the code if necessary. Do not perform a GC but instead return a retry after | |
| 690 // GC failure. | |
| 691 MUST_USE_RESULT MaybeObject* TryTailCallRuntime(Runtime::FunctionId fid, | |
| 692 int num_arguments, | |
| 693 int result_size); | |
| 694 | |
| 695 // Before calling a C-function from generated code, align arguments on stack. | 663 // Before calling a C-function from generated code, align arguments on stack. |
| 696 // After aligning the frame, arguments must be stored in esp[0], esp[4], | 664 // After aligning the frame, arguments must be stored in esp[0], esp[4], |
| 697 // etc., not pushed. The argument count assumes all arguments are word sized. | 665 // etc., not pushed. The argument count assumes all arguments are word sized. |
| 698 // Some compilers/platforms require the stack to be aligned when calling | 666 // Some compilers/platforms require the stack to be aligned when calling |
| 699 // C++ code. | 667 // C++ code. |
| 700 // Needs a scratch register to do some arithmetic. This register will be | 668 // Needs a scratch register to do some arithmetic. This register will be |
| 701 // trashed. | 669 // trashed. |
| 702 void PrepareCallCFunction(int num_arguments, Register scratch); | 670 void PrepareCallCFunction(int num_arguments, Register scratch); |
| 703 | 671 |
| 704 // Calls a C function and cleans up the space for arguments allocated | 672 // Calls a C function and cleans up the space for arguments allocated |
| 705 // by PrepareCallCFunction. The called function is not allowed to trigger a | 673 // by PrepareCallCFunction. The called function is not allowed to trigger a |
| 706 // garbage collection, since that might move the code and invalidate the | 674 // garbage collection, since that might move the code and invalidate the |
| 707 // return address (unless this is somehow accounted for by the called | 675 // return address (unless this is somehow accounted for by the called |
| 708 // function). | 676 // function). |
| 709 void CallCFunction(ExternalReference function, int num_arguments); | 677 void CallCFunction(ExternalReference function, int num_arguments); |
| 710 void CallCFunction(Register function, int num_arguments); | 678 void CallCFunction(Register function, int num_arguments); |
| 711 | 679 |
| 712 // Prepares stack to put arguments (aligns and so on). Reserves | 680 // Prepares stack to put arguments (aligns and so on). Reserves |
| 713 // space for return value if needed (assumes the return value is a handle). | 681 // space for return value if needed (assumes the return value is a handle). |
| 714 // Arguments must be stored in ApiParameterOperand(0), ApiParameterOperand(1) | 682 // Arguments must be stored in ApiParameterOperand(0), ApiParameterOperand(1) |
| 715 // etc. Saves context (esi). If space was reserved for return value then | 683 // etc. Saves context (esi). If space was reserved for return value then |
| 716 // stores the pointer to the reserved slot into esi. | 684 // stores the pointer to the reserved slot into esi. |
| 717 void PrepareCallApiFunction(int argc); | 685 void PrepareCallApiFunction(int argc); |
| 718 | 686 |
| 719 // Calls an API function. Allocates HandleScope, extracts | 687 // Calls an API function. Allocates HandleScope, extracts returned value |
| 720 // returned value from handle and propagates exceptions. | 688 // from handle and propagates exceptions. Clobbers ebx, edi and |
| 721 // Clobbers ebx, edi and caller-save registers. Restores context. | 689 // caller-save registers. Restores context. On return removes |
| 722 // On return removes stack_space * kPointerSize (GCed). | 690 // stack_space * kPointerSize (GCed). |
| 723 MaybeObject* TryCallApiFunctionAndReturn(ApiFunction* function, | 691 void CallApiFunctionAndReturn(Address function_address, int stack_space); |
| 724 int stack_space); | |
| 725 | 692 |
| 726 // Jump to a runtime routine. | 693 // Jump to a runtime routine. |
| 727 void JumpToExternalReference(const ExternalReference& ext); | 694 void JumpToExternalReference(const ExternalReference& ext); |
| 728 | 695 |
| 729 MaybeObject* TryJumpToExternalReference(const ExternalReference& ext); | |
| 730 | |
| 731 | |
| 732 // --------------------------------------------------------------------------- | 696 // --------------------------------------------------------------------------- |
| 733 // Utilities | 697 // Utilities |
| 734 | 698 |
| 735 void Ret(); | 699 void Ret(); |
| 736 | 700 |
| 737 // Return and drop arguments from stack, where the number of arguments | 701 // Return and drop arguments from stack, where the number of arguments |
| 738 // may be bigger than 2^16 - 1. Requires a scratch register. | 702 // may be bigger than 2^16 - 1. Requires a scratch register. |
| 739 void Ret(int bytes_dropped, Register scratch); | 703 void Ret(int bytes_dropped, Register scratch); |
| 740 | 704 |
| 741 // Emit code to discard a non-negative number of pointer-sized elements | 705 // Emit code to discard a non-negative number of pointer-sized elements |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 } \ | 922 } \ |
| 959 masm-> | 923 masm-> |
| 960 #else | 924 #else |
| 961 #define ACCESS_MASM(masm) masm-> | 925 #define ACCESS_MASM(masm) masm-> |
| 962 #endif | 926 #endif |
| 963 | 927 |
| 964 | 928 |
| 965 } } // namespace v8::internal | 929 } } // namespace v8::internal |
| 966 | 930 |
| 967 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 931 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| OLD | NEW |