| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 7681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7692 __ cmp(ebp, 0); | 7692 __ cmp(ebp, 0); |
| 7693 __ j(equal, &skip, not_taken); | 7693 __ j(equal, &skip, not_taken); |
| 7694 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 7694 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 7695 __ bind(&skip); | 7695 __ bind(&skip); |
| 7696 | 7696 |
| 7697 ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); | 7697 ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); |
| 7698 __ ret(0); | 7698 __ ret(0); |
| 7699 } | 7699 } |
| 7700 | 7700 |
| 7701 | 7701 |
| 7702 void ApiGetterEntryStub::Generate(MacroAssembler* masm) { | |
| 7703 Label get_result; | |
| 7704 Label prologue; | |
| 7705 Label promote_scheduled_exception; | |
| 7706 __ EnterApiExitFrame(ExitFrame::MODE_NORMAL, kStackSpace, kArgc); | |
| 7707 ASSERT_EQ(kArgc, 4); | |
| 7708 // The function expects three arguments to be passed but we allocate | |
| 7709 // four to get space for the output cell. The argument slots are filled | |
| 7710 // as follows: | |
| 7711 // | |
| 7712 // 3: output cell | |
| 7713 // 2: arguments pointer | |
| 7714 // 1: name | |
| 7715 // 0: pointer to the output cell | |
| 7716 // | |
| 7717 // Note that this is one more "argument" than the function expects | |
| 7718 // so the out cell will have to be popped explicitly after returning | |
| 7719 // from the function. | |
| 7720 __ mov(Operand(esp, 1 * kPointerSize), ebx); // name. | |
| 7721 __ mov(Operand(esp, 2 * kPointerSize), eax); // arguments pointer. | |
| 7722 __ mov(ebx, esp); | |
| 7723 __ add(Operand(ebx), Immediate(3 * kPointerSize)); | |
| 7724 __ mov(Operand(esp, 0 * kPointerSize), ebx); // output | |
| 7725 __ mov(Operand(esp, 3 * kPointerSize), Immediate(0)); // out cell. | |
| 7726 __ mov(eax, Immediate(ExternalReference(fun()))); | |
| 7727 // Call the api function! | |
| 7728 __ call(Operand(eax)); | |
| 7729 // Check if the function scheduled an exception. | |
| 7730 ExternalReference scheduled_exception_address = | |
| 7731 ExternalReference::scheduled_exception_address(); | |
| 7732 __ cmp(Operand::StaticVariable(scheduled_exception_address), | |
| 7733 Immediate(Factory::the_hole_value())); | |
| 7734 __ j(not_equal, &promote_scheduled_exception, not_taken); | |
| 7735 // The returned value is a pointer to the handle holding the result. | |
| 7736 // Dereference this to get to the handle. | |
| 7737 __ mov(eax, Operand(eax, 0)); | |
| 7738 // Check if the result handle holds 0 | |
| 7739 __ test(eax, Operand(eax)); | |
| 7740 __ j(not_zero, &get_result, taken); | |
| 7741 // It was zero; the result is undefined. | |
| 7742 __ mov(eax, Factory::undefined_value()); | |
| 7743 __ jmp(&prologue); | |
| 7744 // It was non-zero. Dereference to get the result value. | |
| 7745 __ bind(&get_result); | |
| 7746 __ mov(eax, Operand(eax, 0)); | |
| 7747 __ bind(&prologue); | |
| 7748 __ LeaveExitFrame(ExitFrame::MODE_NORMAL); | |
| 7749 __ ret(0); | |
| 7750 __ bind(&promote_scheduled_exception); | |
| 7751 __ TailCallRuntime(ExternalReference(Runtime::kPromoteScheduledException), | |
| 7752 0, | |
| 7753 1); | |
| 7754 } | |
| 7755 | |
| 7756 | |
| 7757 void CEntryStub::GenerateCore(MacroAssembler* masm, | 7702 void CEntryStub::GenerateCore(MacroAssembler* masm, |
| 7758 Label* throw_normal_exception, | 7703 Label* throw_normal_exception, |
| 7759 Label* throw_termination_exception, | 7704 Label* throw_termination_exception, |
| 7760 Label* throw_out_of_memory_exception, | 7705 Label* throw_out_of_memory_exception, |
| 7761 ExitFrame::Mode mode, | 7706 StackFrame::Type frame_type, |
| 7762 bool do_gc, | 7707 bool do_gc, |
| 7763 bool always_allocate_scope) { | 7708 bool always_allocate_scope) { |
| 7764 // eax: result parameter for PerformGC, if any | 7709 // eax: result parameter for PerformGC, if any |
| 7765 // ebx: pointer to C function (C callee-saved) | 7710 // ebx: pointer to C function (C callee-saved) |
| 7766 // ebp: frame pointer (restored after C call) | 7711 // ebp: frame pointer (restored after C call) |
| 7767 // esp: stack pointer (restored after C call) | 7712 // esp: stack pointer (restored after C call) |
| 7768 // edi: number of arguments including receiver (C callee-saved) | 7713 // edi: number of arguments including receiver (C callee-saved) |
| 7769 // esi: pointer to the first argument (C callee-saved) | 7714 // esi: pointer to the first argument (C callee-saved) |
| 7770 | 7715 |
| 7771 if (do_gc) { | 7716 if (do_gc) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 7801 | 7746 |
| 7802 // Check for failure result. | 7747 // Check for failure result. |
| 7803 Label failure_returned; | 7748 Label failure_returned; |
| 7804 ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); | 7749 ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); |
| 7805 __ lea(ecx, Operand(eax, 1)); | 7750 __ lea(ecx, Operand(eax, 1)); |
| 7806 // Lower 2 bits of ecx are 0 iff eax has failure tag. | 7751 // Lower 2 bits of ecx are 0 iff eax has failure tag. |
| 7807 __ test(ecx, Immediate(kFailureTagMask)); | 7752 __ test(ecx, Immediate(kFailureTagMask)); |
| 7808 __ j(zero, &failure_returned, not_taken); | 7753 __ j(zero, &failure_returned, not_taken); |
| 7809 | 7754 |
| 7810 // Exit the JavaScript to C++ exit frame. | 7755 // Exit the JavaScript to C++ exit frame. |
| 7811 __ LeaveExitFrame(mode); | 7756 __ LeaveExitFrame(frame_type); |
| 7812 __ ret(0); | 7757 __ ret(0); |
| 7813 | 7758 |
| 7814 // Handling of failure. | 7759 // Handling of failure. |
| 7815 __ bind(&failure_returned); | 7760 __ bind(&failure_returned); |
| 7816 | 7761 |
| 7817 Label retry; | 7762 Label retry; |
| 7818 // If the returned exception is RETRY_AFTER_GC continue at retry label | 7763 // If the returned exception is RETRY_AFTER_GC continue at retry label |
| 7819 ASSERT(Failure::RETRY_AFTER_GC == 0); | 7764 ASSERT(Failure::RETRY_AFTER_GC == 0); |
| 7820 __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); | 7765 __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); |
| 7821 __ j(zero, &retry, taken); | 7766 __ j(zero, &retry, taken); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7900 // ebx: pointer to C function (C callee-saved) | 7845 // ebx: pointer to C function (C callee-saved) |
| 7901 // ebp: frame pointer (restored after C call) | 7846 // ebp: frame pointer (restored after C call) |
| 7902 // esp: stack pointer (restored after C call) | 7847 // esp: stack pointer (restored after C call) |
| 7903 // esi: current context (C callee-saved) | 7848 // esi: current context (C callee-saved) |
| 7904 // edi: JS function of the caller (C callee-saved) | 7849 // edi: JS function of the caller (C callee-saved) |
| 7905 | 7850 |
| 7906 // NOTE: Invocations of builtins may return failure objects instead | 7851 // NOTE: Invocations of builtins may return failure objects instead |
| 7907 // of a proper result. The builtin entry handles this by performing | 7852 // of a proper result. The builtin entry handles this by performing |
| 7908 // a garbage collection and retrying the builtin (twice). | 7853 // a garbage collection and retrying the builtin (twice). |
| 7909 | 7854 |
| 7910 ExitFrame::Mode mode = is_debug_break | 7855 StackFrame::Type frame_type = is_debug_break ? |
| 7911 ? ExitFrame::MODE_DEBUG | 7856 StackFrame::EXIT_DEBUG : |
| 7912 : ExitFrame::MODE_NORMAL; | 7857 StackFrame::EXIT; |
| 7913 | 7858 |
| 7914 // Enter the exit frame that transitions from JavaScript to C++. | 7859 // Enter the exit frame that transitions from JavaScript to C++. |
| 7915 __ EnterExitFrame(mode); | 7860 __ EnterExitFrame(frame_type); |
| 7916 | 7861 |
| 7917 // eax: result parameter for PerformGC, if any (setup below) | 7862 // eax: result parameter for PerformGC, if any (setup below) |
| 7918 // ebx: pointer to builtin function (C callee-saved) | 7863 // ebx: pointer to builtin function (C callee-saved) |
| 7919 // ebp: frame pointer (restored after C call) | 7864 // ebp: frame pointer (restored after C call) |
| 7920 // esp: stack pointer (restored after C call) | 7865 // esp: stack pointer (restored after C call) |
| 7921 // edi: number of arguments including receiver (C callee-saved) | 7866 // edi: number of arguments including receiver (C callee-saved) |
| 7922 // esi: argv pointer (C callee-saved) | 7867 // esi: argv pointer (C callee-saved) |
| 7923 | 7868 |
| 7924 Label throw_normal_exception; | 7869 Label throw_normal_exception; |
| 7925 Label throw_termination_exception; | 7870 Label throw_termination_exception; |
| 7926 Label throw_out_of_memory_exception; | 7871 Label throw_out_of_memory_exception; |
| 7927 | 7872 |
| 7928 // Call into the runtime system. | 7873 // Call into the runtime system. |
| 7929 GenerateCore(masm, | 7874 GenerateCore(masm, |
| 7930 &throw_normal_exception, | 7875 &throw_normal_exception, |
| 7931 &throw_termination_exception, | 7876 &throw_termination_exception, |
| 7932 &throw_out_of_memory_exception, | 7877 &throw_out_of_memory_exception, |
| 7933 mode, | 7878 frame_type, |
| 7934 false, | 7879 false, |
| 7935 false); | 7880 false); |
| 7936 | 7881 |
| 7937 // Do space-specific GC and retry runtime call. | 7882 // Do space-specific GC and retry runtime call. |
| 7938 GenerateCore(masm, | 7883 GenerateCore(masm, |
| 7939 &throw_normal_exception, | 7884 &throw_normal_exception, |
| 7940 &throw_termination_exception, | 7885 &throw_termination_exception, |
| 7941 &throw_out_of_memory_exception, | 7886 &throw_out_of_memory_exception, |
| 7942 mode, | 7887 frame_type, |
| 7943 true, | 7888 true, |
| 7944 false); | 7889 false); |
| 7945 | 7890 |
| 7946 // Do full GC and retry runtime call one final time. | 7891 // Do full GC and retry runtime call one final time. |
| 7947 Failure* failure = Failure::InternalError(); | 7892 Failure* failure = Failure::InternalError(); |
| 7948 __ mov(eax, Immediate(reinterpret_cast<int32_t>(failure))); | 7893 __ mov(eax, Immediate(reinterpret_cast<int32_t>(failure))); |
| 7949 GenerateCore(masm, | 7894 GenerateCore(masm, |
| 7950 &throw_normal_exception, | 7895 &throw_normal_exception, |
| 7951 &throw_termination_exception, | 7896 &throw_termination_exception, |
| 7952 &throw_out_of_memory_exception, | 7897 &throw_out_of_memory_exception, |
| 7953 mode, | 7898 frame_type, |
| 7954 true, | 7899 true, |
| 7955 true); | 7900 true); |
| 7956 | 7901 |
| 7957 __ bind(&throw_out_of_memory_exception); | 7902 __ bind(&throw_out_of_memory_exception); |
| 7958 GenerateThrowUncatchable(masm, OUT_OF_MEMORY); | 7903 GenerateThrowUncatchable(masm, OUT_OF_MEMORY); |
| 7959 | 7904 |
| 7960 __ bind(&throw_termination_exception); | 7905 __ bind(&throw_termination_exception); |
| 7961 GenerateThrowUncatchable(masm, TERMINATION); | 7906 GenerateThrowUncatchable(masm, TERMINATION); |
| 7962 | 7907 |
| 7963 __ bind(&throw_normal_exception); | 7908 __ bind(&throw_normal_exception); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8123 | 8068 |
| 8124 int CompareStub::MinorKey() { | 8069 int CompareStub::MinorKey() { |
| 8125 // Encode the two parameters in a unique 16 bit value. | 8070 // Encode the two parameters in a unique 16 bit value. |
| 8126 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); | 8071 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); |
| 8127 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); | 8072 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); |
| 8128 } | 8073 } |
| 8129 | 8074 |
| 8130 #undef __ | 8075 #undef __ |
| 8131 | 8076 |
| 8132 } } // namespace v8::internal | 8077 } } // namespace v8::internal |
| OLD | NEW |