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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 const int offset = JavaScriptFrameConstants::kReceiverOffset; | 162 const int offset = JavaScriptFrameConstants::kReceiverOffset; |
163 Memory::Object_at(pp() + offset) = value; | 163 Memory::Object_at(pp() + offset) = value; |
164 } | 164 } |
165 | 165 |
166 | 166 |
167 inline bool JavaScriptFrame::has_adapted_arguments() const { | 167 inline bool JavaScriptFrame::has_adapted_arguments() const { |
168 return IsArgumentsAdaptorFrame(caller_fp()); | 168 return IsArgumentsAdaptorFrame(caller_fp()); |
169 } | 169 } |
170 | 170 |
171 | 171 |
172 inline JavaScriptFrame* JavaScriptFrameIterator::frame() const { | 172 template<typename Iterator> |
| 173 inline JavaScriptFrame* JavaScriptFrameIteratorTemp<Iterator>::frame() const { |
173 // TODO(1233797): The frame hierarchy needs to change. It's | 174 // TODO(1233797): The frame hierarchy needs to change. It's |
174 // problematic that we can't use the safe-cast operator to cast to | 175 // problematic that we can't use the safe-cast operator to cast to |
175 // the JavaScript frame type, because we may encounter arguments | 176 // the JavaScript frame type, because we may encounter arguments |
176 // adaptor frames. | 177 // adaptor frames. |
177 StackFrame* frame = iterator_.frame(); | 178 StackFrame* frame = iterator_.frame(); |
178 ASSERT(frame->is_java_script() || frame->is_arguments_adaptor()); | 179 ASSERT(frame->is_java_script() || frame->is_arguments_adaptor()); |
179 return static_cast<JavaScriptFrame*>(frame); | 180 return static_cast<JavaScriptFrame*>(frame); |
180 } | 181 } |
181 | 182 |
182 | 183 |
| 184 template<typename Iterator> |
| 185 JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp( |
| 186 StackFrame::Id id) { |
| 187 while (!done()) { |
| 188 Advance(); |
| 189 if (frame()->id() == id) return; |
| 190 } |
| 191 } |
| 192 |
| 193 |
| 194 template<typename Iterator> |
| 195 void JavaScriptFrameIteratorTemp<Iterator>::Advance() { |
| 196 do { |
| 197 iterator_.Advance(); |
| 198 } while (!iterator_.done() && !iterator_.frame()->is_java_script()); |
| 199 } |
| 200 |
| 201 |
| 202 template<typename Iterator> |
| 203 void JavaScriptFrameIteratorTemp<Iterator>::AdvanceToArgumentsFrame() { |
| 204 if (!frame()->has_adapted_arguments()) return; |
| 205 iterator_.Advance(); |
| 206 ASSERT(iterator_.frame()->is_arguments_adaptor()); |
| 207 } |
| 208 |
| 209 |
| 210 template<typename Iterator> |
| 211 void JavaScriptFrameIteratorTemp<Iterator>::Reset() { |
| 212 iterator_.Reset(); |
| 213 if (!done()) Advance(); |
| 214 } |
| 215 |
| 216 |
183 } } // namespace v8::internal | 217 } } // namespace v8::internal |
184 | 218 |
185 #endif // V8_FRAMES_INL_H_ | 219 #endif // V8_FRAMES_INL_H_ |
OLD | NEW |