Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 8493008: Tighten the code for MacroAssembler::ThrowUncatchable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, 809 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type,
810 Register value) { 810 Register value) {
811 // Adjust this code if not the case. 811 // Adjust this code if not the case.
812 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); 812 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize);
813 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 813 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
814 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 1 * kPointerSize); 814 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 1 * kPointerSize);
815 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); 815 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize);
816 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 3 * kPointerSize); 816 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 3 * kPointerSize);
817 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); 817 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize);
818 818
819 // eax must hold the exception. 819 // The exception is expected in eax.
820 if (!value.is(eax)) {
821 mov(eax, value);
822 }
823
824 // Drop sp to the top stack handler.
825 ExternalReference handler_address(Isolate::kHandlerAddress,
826 isolate());
827 mov(esp, Operand::StaticVariable(handler_address));
828
829 // Unwind the handlers until the ENTRY handler is found.
830 Label loop, done;
831 bind(&loop);
832 // Load the type of the current stack handler.
833 const int kStateOffset = StackHandlerConstants::kStateOffset;
834 cmp(Operand(esp, kStateOffset), Immediate(StackHandler::ENTRY));
835 j(equal, &done, Label::kNear);
836 // Fetch the next handler in the list.
837 const int kNextOffset = StackHandlerConstants::kNextOffset;
838 mov(esp, Operand(esp, kNextOffset));
839 jmp(&loop);
840 bind(&done);
841
842 // Set the top handler address to next handler past the current ENTRY handler.
843 pop(Operand::StaticVariable(handler_address));
844
845 if (type == OUT_OF_MEMORY) { 820 if (type == OUT_OF_MEMORY) {
846 // Set external caught exception to false. 821 // Set external caught exception to false.
847 ExternalReference external_caught( 822 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress,
848 Isolate::kExternalCaughtExceptionAddress, 823 isolate());
849 isolate()); 824 mov(Operand::StaticVariable(external_caught), Immediate(false));
850 mov(eax, false);
851 mov(Operand::StaticVariable(external_caught), eax);
852 825
853 // Set pending exception and eax to out of memory exception. 826 // Set pending exception and eax to out of memory exception.
854 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, 827 ExternalReference pending_exception(Isolate::kPendingExceptionAddress,
855 isolate()); 828 isolate());
856 mov(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException())); 829 mov(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException()));
857 mov(Operand::StaticVariable(pending_exception), eax); 830 mov(Operand::StaticVariable(pending_exception), eax);
831 } else if (!value.is(eax)) {
832 mov(eax, value);
858 } 833 }
859 834
860 // Discard the context saved in the handler and clear the context pointer. 835 // Drop the stack pointer to the top of the top stack handler.
861 pop(edx); 836 ExternalReference handler_address(Isolate::kHandlerAddress, isolate());
862 Set(esi, Immediate(0)); 837 mov(esp, Operand::StaticVariable(handler_address));
863 838
864 // Restore fp from handler and discard handler state. 839 // Unwind the handlers until the top ENTRY handler is found.
840 Label fetch_next, check_kind;
841 jmp(&check_kind, Label::kNear);
842 bind(&fetch_next);
843 mov(esp, Operand(esp, StackHandlerConstants::kNextOffset));
844
845 bind(&check_kind);
846 cmp(Operand(esp, StackHandlerConstants::kStateOffset),
847 Immediate(StackHandler::ENTRY));
848 j(not_equal, &fetch_next);
849
850 // Set the top handler address to next handler past the top ENTRY handler.
851 pop(Operand::StaticVariable(handler_address));
852
853 // Clear the context and frame pointer (0 was saved in the handler), and
854 // discard the state.
855 pop(esi);
865 pop(ebp); 856 pop(ebp);
866 pop(edx); // State. 857 pop(edx); // State.
867 858
868 ret(0); 859 ret(0);
869 } 860 }
870 861
871 862
872 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, 863 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
873 Register scratch, 864 Register scratch,
874 Label* miss) { 865 Label* miss) {
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset)); 2638 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset));
2648 Check(less_equal, "Live Bytes Count overflow chunk size"); 2639 Check(less_equal, "Live Bytes Count overflow chunk size");
2649 } 2640 }
2650 2641
2651 bind(&done); 2642 bind(&done);
2652 } 2643 }
2653 2644
2654 } } // namespace v8::internal 2645 } } // namespace v8::internal
2655 2646
2656 #endif // V8_TARGET_ARCH_IA32 2647 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698