OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
Jakob Kummerow
2011/09/15 15:41:09
2011
| |
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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 { | 96 class FrameScope { |
97 public: | 97 public: |
98 explicit FrameScope(MacroAssembler* masm, StackFrame::Type type) | 98 explicit FrameScope(MacroAssembler* masm, StackFrame::Type type) |
99 : masm_(masm), type_(type) { | 99 : masm_(masm), type_(type), old_has_frame_(masm->has_frame()) { |
100 ASSERT(!masm->has_frame()); | |
101 masm->set_has_frame(true); | 100 masm->set_has_frame(true); |
102 if (type != StackFrame::MANUAL && type_ != StackFrame::NONE) { | 101 if (type != StackFrame::MANUAL && type_ != StackFrame::NONE) { |
103 masm->EnterFrame(type); | 102 masm->EnterFrame(type); |
104 } | 103 } |
105 } | 104 } |
106 | 105 |
107 ~FrameScope() { | 106 ~FrameScope() { |
108 if (type_ != StackFrame::MANUAL && type_ != StackFrame::NONE) { | 107 if (type_ != StackFrame::MANUAL && type_ != StackFrame::NONE) { |
109 masm_->LeaveFrame(type_); | 108 masm_->LeaveFrame(type_); |
110 } | 109 } |
111 masm_->set_has_frame(false); | 110 masm_->set_has_frame(old_has_frame_); |
112 } | 111 } |
113 | 112 |
114 // Normally we generate the leave-frame code when this object goes | 113 // 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 | 114 // 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 | 115 // 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 | 116 // 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. | 117 // the code will be generated again when it goes out of scope. |
119 void GenerateLeaveFrame() { | 118 void GenerateLeaveFrame() { |
120 masm_->LeaveFrame(type_); | 119 masm_->LeaveFrame(type_); |
121 } | 120 } |
122 | 121 |
123 private: | 122 private: |
124 MacroAssembler* masm_; | 123 MacroAssembler* masm_; |
125 StackFrame::Type type_; | 124 StackFrame::Type type_; |
125 bool old_has_frame_; | |
126 }; | 126 }; |
127 | 127 |
128 | 128 |
129 class AllowExternalCallThatCantCauseGC: public FrameScope { | 129 class AllowExternalCallThatCantCauseGC: public FrameScope { |
130 public: | 130 public: |
131 explicit AllowExternalCallThatCantCauseGC(MacroAssembler* masm) | 131 explicit AllowExternalCallThatCantCauseGC(MacroAssembler* masm) |
132 : FrameScope(masm, StackFrame::NONE) { } | 132 : FrameScope(masm, StackFrame::NONE) { } |
133 }; | 133 }; |
134 | 134 |
135 | 135 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 class Comment { | 168 class Comment { |
169 public: | 169 public: |
170 Comment(MacroAssembler*, const char*) {} | 170 Comment(MacroAssembler*, const char*) {} |
171 }; | 171 }; |
172 | 172 |
173 #endif // DEBUG | 173 #endif // DEBUG |
174 | 174 |
175 } } // namespace v8::internal | 175 } } // namespace v8::internal |
176 | 176 |
177 #endif // V8_MACRO_ASSEMBLER_H_ | 177 #endif // V8_MACRO_ASSEMBLER_H_ |
OLD | NEW |