OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 #include "mips/assembler-mips-inl.h" | 86 #include "mips/assembler-mips-inl.h" |
87 #include "code.h" // must be after assembler_*.h | 87 #include "code.h" // must be after assembler_*.h |
88 #include "mips/macro-assembler-mips.h" | 88 #include "mips/macro-assembler-mips.h" |
89 #else | 89 #else |
90 #error Unsupported target architecture. | 90 #error Unsupported target architecture. |
91 #endif | 91 #endif |
92 | 92 |
93 namespace v8 { | 93 namespace v8 { |
94 namespace internal { | 94 namespace internal { |
95 | 95 |
| 96 class FrameScope { |
| 97 public: |
| 98 explicit FrameScope(MacroAssembler* masm, StackFrame::Type type) |
| 99 : masm_(masm), type_(type) { |
| 100 ASSERT(!masm->has_frame()); |
| 101 masm->set_has_frame(true); |
| 102 if (type != StackFrame::MANUAL && type_ != StackFrame::NONE) { |
| 103 masm->EnterFrame(type); |
| 104 } |
| 105 } |
| 106 |
| 107 ~FrameScope() { |
| 108 if (type_ != StackFrame::MANUAL && type_ != StackFrame::NONE) { |
| 109 masm_->LeaveFrame(type_); |
| 110 } |
| 111 masm_->set_has_frame(false); |
| 112 } |
| 113 |
| 114 // Normally we generate the leave-frame code when this object goes |
| 115 // out of scope. Sometimes we may need to generate the code somewhere else |
| 116 // in addition. Calling this will achieve that, but the object stays in |
| 117 // scope, the MacroAssembler is still marked as being in a frame scope, and |
| 118 // the code will be generated again when it goes out of scope. |
| 119 void GenerateLeaveFrame() { |
| 120 masm_->LeaveFrame(type_); |
| 121 } |
| 122 |
| 123 private: |
| 124 MacroAssembler* masm_; |
| 125 StackFrame::Type type_; |
| 126 }; |
| 127 |
| 128 |
| 129 class AllowExternalCallThatCantCauseGC: public FrameScope { |
| 130 public: |
| 131 explicit AllowExternalCallThatCantCauseGC(MacroAssembler* masm) |
| 132 : FrameScope(masm, StackFrame::NONE) { } |
| 133 }; |
| 134 |
| 135 |
| 136 class NoCurrentFrameScope { |
| 137 public: |
| 138 explicit NoCurrentFrameScope(MacroAssembler* masm) |
| 139 : masm_(masm), saved_(masm->has_frame()) { |
| 140 masm->set_has_frame(false); |
| 141 } |
| 142 |
| 143 ~NoCurrentFrameScope() { |
| 144 masm_->set_has_frame(saved_); |
| 145 } |
| 146 |
| 147 private: |
| 148 MacroAssembler* masm_; |
| 149 bool saved_; |
| 150 }; |
| 151 |
| 152 |
96 // Support for "structured" code comments. | 153 // Support for "structured" code comments. |
97 #ifdef DEBUG | 154 #ifdef DEBUG |
98 | 155 |
99 class Comment { | 156 class Comment { |
100 public: | 157 public: |
101 Comment(MacroAssembler* masm, const char* msg); | 158 Comment(MacroAssembler* masm, const char* msg); |
102 ~Comment(); | 159 ~Comment(); |
103 | 160 |
104 private: | 161 private: |
105 MacroAssembler* masm_; | 162 MacroAssembler* masm_; |
106 const char* msg_; | 163 const char* msg_; |
107 }; | 164 }; |
108 | 165 |
109 #else | 166 #else |
110 | 167 |
111 class Comment { | 168 class Comment { |
112 public: | 169 public: |
113 Comment(MacroAssembler*, const char*) {} | 170 Comment(MacroAssembler*, const char*) {} |
114 }; | 171 }; |
115 | 172 |
116 #endif // DEBUG | 173 #endif // DEBUG |
117 | 174 |
118 } } // namespace v8::internal | 175 } } // namespace v8::internal |
119 | 176 |
120 #endif // V8_MACRO_ASSEMBLER_H_ | 177 #endif // V8_MACRO_ASSEMBLER_H_ |
OLD | NEW |