OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 6729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6740 __ cmpq(rbp, Immediate(0)); | 6740 __ cmpq(rbp, Immediate(0)); |
6741 __ j(equal, &skip); | 6741 __ j(equal, &skip); |
6742 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 6742 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
6743 __ bind(&skip); | 6743 __ bind(&skip); |
6744 __ ret(0); | 6744 __ ret(0); |
6745 } | 6745 } |
6746 | 6746 |
6747 | 6747 |
6748 void CEntryStub::GenerateCore(MacroAssembler* masm, | 6748 void CEntryStub::GenerateCore(MacroAssembler* masm, |
6749 Label* throw_normal_exception, | 6749 Label* throw_normal_exception, |
| 6750 Label* throw_termination_exception, |
6750 Label* throw_out_of_memory_exception, | 6751 Label* throw_out_of_memory_exception, |
6751 StackFrame::Type frame_type, | 6752 StackFrame::Type frame_type, |
6752 bool do_gc, | 6753 bool do_gc, |
6753 bool always_allocate_scope) { | 6754 bool always_allocate_scope) { |
6754 // rax: result parameter for PerformGC, if any. | 6755 // rax: result parameter for PerformGC, if any. |
6755 // rbx: pointer to C function (C callee-saved). | 6756 // rbx: pointer to C function (C callee-saved). |
6756 // rbp: frame pointer (restored after C call). | 6757 // rbp: frame pointer (restored after C call). |
6757 // rsp: stack pointer (restored after C call). | 6758 // rsp: stack pointer (restored after C call). |
6758 // r14: number of arguments including receiver (C callee-saved). | 6759 // r14: number of arguments including receiver (C callee-saved). |
6759 // r15: pointer to the first argument (C callee-saved). | 6760 // r15: pointer to the first argument (C callee-saved). |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6812 | 6813 |
6813 // Handling of failure. | 6814 // Handling of failure. |
6814 __ bind(&failure_returned); | 6815 __ bind(&failure_returned); |
6815 | 6816 |
6816 Label retry; | 6817 Label retry; |
6817 // If the returned exception is RETRY_AFTER_GC continue at retry label | 6818 // If the returned exception is RETRY_AFTER_GC continue at retry label |
6818 ASSERT(Failure::RETRY_AFTER_GC == 0); | 6819 ASSERT(Failure::RETRY_AFTER_GC == 0); |
6819 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); | 6820 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); |
6820 __ j(zero, &retry); | 6821 __ j(zero, &retry); |
6821 | 6822 |
6822 Label continue_exception; | 6823 // Special handling of out of memory exceptions. |
6823 // If the returned failure is EXCEPTION then promote Top::pending_exception(). | 6824 __ movq(kScratchRegister, Failure::OutOfMemoryException(), RelocInfo::NONE); |
6824 __ movq(kScratchRegister, Failure::Exception(), RelocInfo::NONE); | |
6825 __ cmpq(rax, kScratchRegister); | 6825 __ cmpq(rax, kScratchRegister); |
6826 __ j(not_equal, &continue_exception); | 6826 __ j(equal, throw_out_of_memory_exception); |
6827 | 6827 |
6828 // Retrieve the pending exception and clear the variable. | 6828 // Retrieve the pending exception and clear the variable. |
6829 ExternalReference pending_exception_address(Top::k_pending_exception_address); | 6829 ExternalReference pending_exception_address(Top::k_pending_exception_address); |
6830 __ movq(kScratchRegister, pending_exception_address); | 6830 __ movq(kScratchRegister, pending_exception_address); |
6831 __ movq(rax, Operand(kScratchRegister, 0)); | 6831 __ movq(rax, Operand(kScratchRegister, 0)); |
6832 __ movq(rdx, ExternalReference::the_hole_value_location()); | 6832 __ movq(rdx, ExternalReference::the_hole_value_location()); |
6833 __ movq(rdx, Operand(rdx, 0)); | 6833 __ movq(rdx, Operand(rdx, 0)); |
6834 __ movq(Operand(kScratchRegister, 0), rdx); | 6834 __ movq(Operand(kScratchRegister, 0), rdx); |
6835 | 6835 |
6836 __ bind(&continue_exception); | 6836 // Special handling of termination exceptions which are uncatchable |
6837 // Special handling of out of memory exception. | 6837 // by javascript code. |
6838 __ movq(kScratchRegister, Failure::OutOfMemoryException(), RelocInfo::NONE); | 6838 __ Cmp(rax, Factory::termination_exception()); |
6839 __ cmpq(rax, kScratchRegister); | 6839 __ j(equal, throw_termination_exception); |
6840 __ j(equal, throw_out_of_memory_exception); | |
6841 | 6840 |
6842 // Handle normal exception. | 6841 // Handle normal exception. |
6843 __ jmp(throw_normal_exception); | 6842 __ jmp(throw_normal_exception); |
6844 | 6843 |
6845 // Retry. | 6844 // Retry. |
6846 __ bind(&retry); | 6845 __ bind(&retry); |
6847 } | 6846 } |
6848 | 6847 |
6849 | 6848 |
6850 void CEntryStub::GenerateThrowOutOfMemory(MacroAssembler* masm) { | 6849 void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, |
| 6850 UncatchableExceptionType type) { |
6851 // Fetch top stack handler. | 6851 // Fetch top stack handler. |
6852 ExternalReference handler_address(Top::k_handler_address); | 6852 ExternalReference handler_address(Top::k_handler_address); |
6853 __ movq(kScratchRegister, handler_address); | 6853 __ movq(kScratchRegister, handler_address); |
6854 __ movq(rsp, Operand(kScratchRegister, 0)); | 6854 __ movq(rsp, Operand(kScratchRegister, 0)); |
6855 | 6855 |
6856 // Unwind the handlers until the ENTRY handler is found. | 6856 // Unwind the handlers until the ENTRY handler is found. |
6857 Label loop, done; | 6857 Label loop, done; |
6858 __ bind(&loop); | 6858 __ bind(&loop); |
6859 // Load the type of the current stack handler. | 6859 // Load the type of the current stack handler. |
6860 __ cmpq(Operand(rsp, StackHandlerConstants::kStateOffset), | 6860 const int kStateOffset = StackHandlerConstants::kStateOffset; |
6861 Immediate(StackHandler::ENTRY)); | 6861 __ cmpq(Operand(rsp, kStateOffset), Immediate(StackHandler::ENTRY)); |
6862 __ j(equal, &done); | 6862 __ j(equal, &done); |
6863 // Fetch the next handler in the list. | 6863 // Fetch the next handler in the list. |
6864 ASSERT(StackHandlerConstants::kNextOffset == 0); | 6864 const int kNextOffset = StackHandlerConstants::kNextOffset; |
6865 __ pop(rsp); | 6865 __ movq(rsp, Operand(rsp, kNextOffset)); |
6866 __ jmp(&loop); | 6866 __ jmp(&loop); |
6867 __ bind(&done); | 6867 __ bind(&done); |
6868 | 6868 |
6869 // Set the top handler address to next handler past the current ENTRY handler. | 6869 // Set the top handler address to next handler past the current ENTRY handler. |
6870 __ pop(rax); | 6870 __ movq(kScratchRegister, handler_address); |
6871 __ store_rax(handler_address); | 6871 __ pop(Operand(kScratchRegister, 0)); |
6872 | 6872 |
6873 // Set external caught exception to false. | 6873 if (type == OUT_OF_MEMORY) { |
6874 __ movq(rax, Immediate(false)); | 6874 // Set external caught exception to false. |
6875 ExternalReference external_caught(Top::k_external_caught_exception_address); | 6875 ExternalReference external_caught(Top::k_external_caught_exception_address); |
6876 __ store_rax(external_caught); | 6876 __ movq(rax, Immediate(false)); |
| 6877 __ store_rax(external_caught); |
6877 | 6878 |
6878 // Set pending exception and rax to out of memory exception. | 6879 // Set pending exception and rax to out of memory exception. |
6879 __ movq(rax, Failure::OutOfMemoryException(), RelocInfo::NONE); | 6880 ExternalReference pending_exception(Top::k_pending_exception_address); |
6880 ExternalReference pending_exception(Top::k_pending_exception_address); | 6881 __ movq(rax, Failure::OutOfMemoryException(), RelocInfo::NONE); |
6881 __ store_rax(pending_exception); | 6882 __ store_rax(pending_exception); |
| 6883 } |
6882 | 6884 |
6883 // Clear the context pointer; | 6885 // Clear the context pointer. |
6884 __ xor_(rsi, rsi); | 6886 __ xor_(rsi, rsi); |
6885 | 6887 |
6886 // Restore registers from handler. | 6888 // Restore registers from handler. |
6887 ASSERT_EQ(StackHandlerConstants::kNextOffset + kPointerSize, | 6889 ASSERT_EQ(StackHandlerConstants::kNextOffset + kPointerSize, |
6888 StackHandlerConstants::kFPOffset); | 6890 StackHandlerConstants::kFPOffset); |
6889 __ pop(rbp); // FP | 6891 __ pop(rbp); // FP |
6890 ASSERT_EQ(StackHandlerConstants::kFPOffset + kPointerSize, | 6892 ASSERT_EQ(StackHandlerConstants::kFPOffset + kPointerSize, |
6891 StackHandlerConstants::kStateOffset); | 6893 StackHandlerConstants::kStateOffset); |
6892 __ pop(rdx); // State | 6894 __ pop(rdx); // State |
6893 | 6895 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6949 // a failure result if the collect_garbage argument to GenerateCore | 6951 // a failure result if the collect_garbage argument to GenerateCore |
6950 // is true. This failure result can be the result of code | 6952 // is true. This failure result can be the result of code |
6951 // generated by a previous call to GenerateCore. The value | 6953 // generated by a previous call to GenerateCore. The value |
6952 // of rax is then passed to Runtime::PerformGC. | 6954 // of rax is then passed to Runtime::PerformGC. |
6953 // rbx: pointer to builtin function (C callee-saved). | 6955 // rbx: pointer to builtin function (C callee-saved). |
6954 // rbp: frame pointer of exit frame (restored after C call). | 6956 // rbp: frame pointer of exit frame (restored after C call). |
6955 // rsp: stack pointer (restored after C call). | 6957 // rsp: stack pointer (restored after C call). |
6956 // r14: number of arguments including receiver (C callee-saved). | 6958 // r14: number of arguments including receiver (C callee-saved). |
6957 // r15: argv pointer (C callee-saved). | 6959 // r15: argv pointer (C callee-saved). |
6958 | 6960 |
| 6961 Label throw_normal_exception; |
| 6962 Label throw_termination_exception; |
6959 Label throw_out_of_memory_exception; | 6963 Label throw_out_of_memory_exception; |
6960 Label throw_normal_exception; | |
6961 | 6964 |
6962 // Call into the runtime system. | 6965 // Call into the runtime system. |
6963 GenerateCore(masm, | 6966 GenerateCore(masm, |
6964 &throw_normal_exception, | 6967 &throw_normal_exception, |
| 6968 &throw_termination_exception, |
6965 &throw_out_of_memory_exception, | 6969 &throw_out_of_memory_exception, |
6966 frame_type, | 6970 frame_type, |
6967 false, | 6971 false, |
6968 false); | 6972 false); |
6969 | 6973 |
6970 // Do space-specific GC and retry runtime call. | 6974 // Do space-specific GC and retry runtime call. |
6971 GenerateCore(masm, | 6975 GenerateCore(masm, |
6972 &throw_normal_exception, | 6976 &throw_normal_exception, |
| 6977 &throw_termination_exception, |
6973 &throw_out_of_memory_exception, | 6978 &throw_out_of_memory_exception, |
6974 frame_type, | 6979 frame_type, |
6975 true, | 6980 true, |
6976 false); | 6981 false); |
6977 | 6982 |
6978 // Do full GC and retry runtime call one final time. | 6983 // Do full GC and retry runtime call one final time. |
6979 Failure* failure = Failure::InternalError(); | 6984 Failure* failure = Failure::InternalError(); |
6980 __ movq(rax, failure, RelocInfo::NONE); | 6985 __ movq(rax, failure, RelocInfo::NONE); |
6981 GenerateCore(masm, | 6986 GenerateCore(masm, |
6982 &throw_normal_exception, | 6987 &throw_normal_exception, |
| 6988 &throw_termination_exception, |
6983 &throw_out_of_memory_exception, | 6989 &throw_out_of_memory_exception, |
6984 frame_type, | 6990 frame_type, |
6985 true, | 6991 true, |
6986 true); | 6992 true); |
6987 | 6993 |
6988 __ bind(&throw_out_of_memory_exception); | 6994 __ bind(&throw_out_of_memory_exception); |
6989 GenerateThrowOutOfMemory(masm); | 6995 GenerateThrowUncatchable(masm, OUT_OF_MEMORY); |
6990 // control flow for generated will not return. | 6996 |
| 6997 __ bind(&throw_termination_exception); |
| 6998 GenerateThrowUncatchable(masm, TERMINATION); |
6991 | 6999 |
6992 __ bind(&throw_normal_exception); | 7000 __ bind(&throw_normal_exception); |
6993 GenerateThrowTOS(masm); | 7001 GenerateThrowTOS(masm); |
6994 } | 7002 } |
6995 | 7003 |
6996 | 7004 |
6997 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 7005 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
6998 Label invoke, exit; | 7006 Label invoke, exit; |
6999 #ifdef ENABLE_LOGGING_AND_PROFILING | 7007 #ifdef ENABLE_LOGGING_AND_PROFILING |
7000 Label not_outermost_js, not_outermost_js_2; | 7008 Label not_outermost_js, not_outermost_js_2; |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7690 int CompareStub::MinorKey() { | 7698 int CompareStub::MinorKey() { |
7691 // Encode the two parameters in a unique 16 bit value. | 7699 // Encode the two parameters in a unique 16 bit value. |
7692 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); | 7700 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); |
7693 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); | 7701 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); |
7694 } | 7702 } |
7695 | 7703 |
7696 | 7704 |
7697 #undef __ | 7705 #undef __ |
7698 | 7706 |
7699 } } // namespace v8::internal | 7707 } } // namespace v8::internal |
OLD | NEW |