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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 movl(kScratchRegister, Immediate(x)); | 66 movl(kScratchRegister, Immediate(x)); |
67 } else { | 67 } else { |
68 movq(kScratchRegister, x, RelocInfo::NONE); | 68 movq(kScratchRegister, x, RelocInfo::NONE); |
69 } | 69 } |
70 movq(dst, kScratchRegister); | 70 movq(dst, kScratchRegister); |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 void MacroAssembler::PushTryHandler(CodeLocation try_location, | 74 void MacroAssembler::PushTryHandler(CodeLocation try_location, |
75 HandlerType type) { | 75 HandlerType type) { |
76 // The pc (return address) is already on TOS. | 76 // Adjust this code if not the case. |
77 // This code pushes state, code, frame pointer and parameter pointer. | 77 ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); |
78 // Check that they are expected next on the stack, int that order. | 78 |
| 79 // The pc (return address) is already on TOS. This code pushes state, |
| 80 // frame pointer and current handler. Check that they are expected |
| 81 // next on the stack, in that order. |
79 ASSERT_EQ(StackHandlerConstants::kStateOffset, | 82 ASSERT_EQ(StackHandlerConstants::kStateOffset, |
80 StackHandlerConstants::kPCOffset - kPointerSize); | 83 StackHandlerConstants::kPCOffset - kPointerSize); |
81 ASSERT_EQ(StackHandlerConstants::kCodeOffset, | 84 ASSERT_EQ(StackHandlerConstants::kFPOffset, |
82 StackHandlerConstants::kStateOffset - kPointerSize); | 85 StackHandlerConstants::kStateOffset - kPointerSize); |
83 ASSERT_EQ(StackHandlerConstants::kFPOffset, | 86 ASSERT_EQ(StackHandlerConstants::kNextOffset, |
84 StackHandlerConstants::kCodeOffset - kPointerSize); | |
85 ASSERT_EQ(StackHandlerConstants::kPPOffset, | |
86 StackHandlerConstants::kFPOffset - kPointerSize); | 87 StackHandlerConstants::kFPOffset - kPointerSize); |
87 | 88 |
88 if (try_location == IN_JAVASCRIPT) { | 89 if (try_location == IN_JAVASCRIPT) { |
89 if (type == TRY_CATCH_HANDLER) { | 90 if (type == TRY_CATCH_HANDLER) { |
90 push(Immediate(StackHandler::TRY_CATCH)); | 91 push(Immediate(StackHandler::TRY_CATCH)); |
91 } else { | 92 } else { |
92 push(Immediate(StackHandler::TRY_FINALLY)); | 93 push(Immediate(StackHandler::TRY_FINALLY)); |
93 } | 94 } |
94 push(Immediate(Smi::FromInt(StackHandler::kCodeNotPresent))); | |
95 push(rbp); | 95 push(rbp); |
96 push(rdi); | |
97 } else { | 96 } else { |
98 ASSERT(try_location == IN_JS_ENTRY); | 97 ASSERT(try_location == IN_JS_ENTRY); |
99 // The parameter pointer is meaningless here and ebp does not | 98 // The frame pointer does not point to a JS frame so we save NULL |
100 // point to a JS frame. So we save NULL for both pp and ebp. We | 99 // for rbp. We expect the code throwing an exception to check rbp |
101 // expect the code throwing an exception to check ebp before | 100 // before dereferencing it to restore the context. |
102 // dereferencing it to restore the context. | |
103 push(Immediate(StackHandler::ENTRY)); | 101 push(Immediate(StackHandler::ENTRY)); |
104 push(Immediate(Smi::FromInt(StackHandler::kCodeNotPresent))); | 102 push(Immediate(0)); // NULL frame pointer. |
105 push(Immediate(0)); // NULL frame pointer | |
106 push(Immediate(0)); // NULL parameter pointer | |
107 } | 103 } |
| 104 // Save the current handler. |
108 movq(kScratchRegister, ExternalReference(Top::k_handler_address)); | 105 movq(kScratchRegister, ExternalReference(Top::k_handler_address)); |
109 // Cached TOS. | 106 push(Operand(kScratchRegister, 0)); |
110 movq(rax, Operand(kScratchRegister, 0)); | |
111 // Link this handler. | 107 // Link this handler. |
112 movq(Operand(kScratchRegister, 0), rsp); | 108 movq(Operand(kScratchRegister, 0), rsp); |
113 } | 109 } |
114 | 110 |
115 | 111 |
116 } } // namespace v8::internal | 112 } } // namespace v8::internal |
OLD | NEW |