| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return reinterpret_cast<Object**>(address() + offset); | 111 return reinterpret_cast<Object**>(address() + offset); |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 inline Object** StackHandler::code_address() const { | 115 inline Object** StackHandler::code_address() const { |
| 116 const int offset = StackHandlerConstants::kCodeOffset; | 116 const int offset = StackHandlerConstants::kCodeOffset; |
| 117 return reinterpret_cast<Object**>(address() + offset); | 117 return reinterpret_cast<Object**>(address() + offset); |
| 118 } | 118 } |
| 119 | 119 |
| 120 | 120 |
| 121 inline StackFrame::StackFrame(StackFrameIterator* iterator) | 121 inline StackFrame::StackFrame(StackFrameIteratorBase* iterator) |
| 122 : iterator_(iterator), isolate_(iterator_->isolate()) { | 122 : iterator_(iterator), isolate_(iterator_->isolate()) { |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 inline StackHandler* StackFrame::top_handler() const { | 126 inline StackHandler* StackFrame::top_handler() const { |
| 127 return iterator_->handler(); | 127 return iterator_->handler(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 | 130 |
| 131 inline Code* StackFrame::LookupCode() const { | 131 inline Code* StackFrame::LookupCode() const { |
| 132 return GetContainingCode(isolate(), pc()); | 132 return GetContainingCode(isolate(), pc()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 | 135 |
| 136 inline Code* StackFrame::GetContainingCode(Isolate* isolate, Address pc) { | 136 inline Code* StackFrame::GetContainingCode(Isolate* isolate, Address pc) { |
| 137 return isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code; | 137 return isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code; |
| 138 } | 138 } |
| 139 | 139 |
| 140 | 140 |
| 141 inline EntryFrame::EntryFrame(StackFrameIterator* iterator) | 141 inline EntryFrame::EntryFrame(StackFrameIteratorBase* iterator) |
| 142 : StackFrame(iterator) { | 142 : StackFrame(iterator) { |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 inline EntryConstructFrame::EntryConstructFrame(StackFrameIterator* iterator) | 146 inline EntryConstructFrame::EntryConstructFrame( |
| 147 StackFrameIteratorBase* iterator) |
| 147 : EntryFrame(iterator) { | 148 : EntryFrame(iterator) { |
| 148 } | 149 } |
| 149 | 150 |
| 150 | 151 |
| 151 inline ExitFrame::ExitFrame(StackFrameIterator* iterator) | 152 inline ExitFrame::ExitFrame(StackFrameIteratorBase* iterator) |
| 152 : StackFrame(iterator) { | 153 : StackFrame(iterator) { |
| 153 } | 154 } |
| 154 | 155 |
| 155 | 156 |
| 156 inline StandardFrame::StandardFrame(StackFrameIterator* iterator) | 157 inline StandardFrame::StandardFrame(StackFrameIteratorBase* iterator) |
| 157 : StackFrame(iterator) { | 158 : StackFrame(iterator) { |
| 158 } | 159 } |
| 159 | 160 |
| 160 | 161 |
| 161 inline Object* StandardFrame::GetExpression(int index) const { | 162 inline Object* StandardFrame::GetExpression(int index) const { |
| 162 return Memory::Object_at(GetExpressionAddress(index)); | 163 return Memory::Object_at(GetExpressionAddress(index)); |
| 163 } | 164 } |
| 164 | 165 |
| 165 | 166 |
| 166 inline void StandardFrame::SetExpression(int index, Object* value) { | 167 inline void StandardFrame::SetExpression(int index, Object* value) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 196 } | 197 } |
| 197 | 198 |
| 198 | 199 |
| 199 inline bool StandardFrame::IsConstructFrame(Address fp) { | 200 inline bool StandardFrame::IsConstructFrame(Address fp) { |
| 200 Object* marker = | 201 Object* marker = |
| 201 Memory::Object_at(fp + StandardFrameConstants::kMarkerOffset); | 202 Memory::Object_at(fp + StandardFrameConstants::kMarkerOffset); |
| 202 return marker == Smi::FromInt(StackFrame::CONSTRUCT); | 203 return marker == Smi::FromInt(StackFrame::CONSTRUCT); |
| 203 } | 204 } |
| 204 | 205 |
| 205 | 206 |
| 206 inline JavaScriptFrame::JavaScriptFrame(StackFrameIterator* iterator) | 207 inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator) |
| 207 : StandardFrame(iterator) { | 208 : StandardFrame(iterator) { |
| 208 } | 209 } |
| 209 | 210 |
| 210 | 211 |
| 211 Address JavaScriptFrame::GetParameterSlot(int index) const { | 212 Address JavaScriptFrame::GetParameterSlot(int index) const { |
| 212 int param_count = ComputeParametersCount(); | 213 int param_count = ComputeParametersCount(); |
| 213 ASSERT(-1 <= index && index < param_count); | 214 ASSERT(-1 <= index && index < param_count); |
| 214 int parameter_offset = (param_count - index - 1) * kPointerSize; | 215 int parameter_offset = (param_count - index - 1) * kPointerSize; |
| 215 return caller_sp() + parameter_offset; | 216 return caller_sp() + parameter_offset; |
| 216 } | 217 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 265 } |
| 265 | 266 |
| 266 | 267 |
| 267 inline Object* JavaScriptFrame::function() const { | 268 inline Object* JavaScriptFrame::function() const { |
| 268 Object* result = function_slot_object(); | 269 Object* result = function_slot_object(); |
| 269 ASSERT(result->IsJSFunction()); | 270 ASSERT(result->IsJSFunction()); |
| 270 return result; | 271 return result; |
| 271 } | 272 } |
| 272 | 273 |
| 273 | 274 |
| 274 inline StubFrame::StubFrame(StackFrameIterator* iterator) | 275 inline StubFrame::StubFrame(StackFrameIteratorBase* iterator) |
| 275 : StandardFrame(iterator) { | 276 : StandardFrame(iterator) { |
| 276 } | 277 } |
| 277 | 278 |
| 278 | 279 |
| 279 inline OptimizedFrame::OptimizedFrame(StackFrameIterator* iterator) | 280 inline OptimizedFrame::OptimizedFrame(StackFrameIteratorBase* iterator) |
| 280 : JavaScriptFrame(iterator) { | 281 : JavaScriptFrame(iterator) { |
| 281 } | 282 } |
| 282 | 283 |
| 283 | 284 |
| 284 inline ArgumentsAdaptorFrame::ArgumentsAdaptorFrame( | 285 inline ArgumentsAdaptorFrame::ArgumentsAdaptorFrame( |
| 285 StackFrameIterator* iterator) : JavaScriptFrame(iterator) { | 286 StackFrameIteratorBase* iterator) : JavaScriptFrame(iterator) { |
| 286 } | 287 } |
| 287 | 288 |
| 288 | 289 |
| 289 inline InternalFrame::InternalFrame(StackFrameIterator* iterator) | 290 inline InternalFrame::InternalFrame(StackFrameIteratorBase* iterator) |
| 290 : StandardFrame(iterator) { | 291 : StandardFrame(iterator) { |
| 291 } | 292 } |
| 292 | 293 |
| 293 | 294 |
| 294 inline StubFailureTrampolineFrame::StubFailureTrampolineFrame( | 295 inline StubFailureTrampolineFrame::StubFailureTrampolineFrame( |
| 295 StackFrameIterator* iterator) : StandardFrame(iterator) { | 296 StackFrameIteratorBase* iterator) : StandardFrame(iterator) { |
| 296 } | 297 } |
| 297 | 298 |
| 298 | 299 |
| 299 inline ConstructFrame::ConstructFrame(StackFrameIterator* iterator) | 300 inline ConstructFrame::ConstructFrame(StackFrameIteratorBase* iterator) |
| 300 : InternalFrame(iterator) { | 301 : InternalFrame(iterator) { |
| 301 } | 302 } |
| 302 | 303 |
| 303 | 304 |
| 304 template<typename Iterator> | 305 inline JavaScriptFrameIterator::JavaScriptFrameIterator( |
| 305 inline JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp( | |
| 306 Isolate* isolate) | 306 Isolate* isolate) |
| 307 : iterator_(isolate) { | 307 : iterator_(isolate) { |
| 308 if (!done()) Advance(); | 308 if (!done()) Advance(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 | 311 |
| 312 template<typename Iterator> | 312 inline JavaScriptFrameIterator::JavaScriptFrameIterator( |
| 313 inline JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp( | |
| 314 Isolate* isolate, ThreadLocalTop* top) | 313 Isolate* isolate, ThreadLocalTop* top) |
| 315 : iterator_(isolate, top) { | 314 : iterator_(isolate, top) { |
| 316 if (!done()) Advance(); | 315 if (!done()) Advance(); |
| 317 } | 316 } |
| 318 | 317 |
| 319 | 318 |
| 320 template<typename Iterator> | 319 inline JavaScriptFrame* JavaScriptFrameIterator::frame() const { |
| 321 inline JavaScriptFrame* JavaScriptFrameIteratorTemp<Iterator>::frame() const { | |
| 322 // TODO(1233797): The frame hierarchy needs to change. It's | 320 // TODO(1233797): The frame hierarchy needs to change. It's |
| 323 // problematic that we can't use the safe-cast operator to cast to | 321 // problematic that we can't use the safe-cast operator to cast to |
| 324 // the JavaScript frame type, because we may encounter arguments | 322 // the JavaScript frame type, because we may encounter arguments |
| 325 // adaptor frames. | 323 // adaptor frames. |
| 326 StackFrame* frame = iterator_.frame(); | 324 StackFrame* frame = iterator_.frame(); |
| 327 ASSERT(frame->is_java_script() || frame->is_arguments_adaptor()); | 325 ASSERT(frame->is_java_script() || frame->is_arguments_adaptor()); |
| 328 return static_cast<JavaScriptFrame*>(frame); | 326 return static_cast<JavaScriptFrame*>(frame); |
| 329 } | 327 } |
| 330 | 328 |
| 331 | 329 |
| 332 template<typename Iterator> | 330 inline JavaScriptFrame* SafeStackFrameIterator::frame() const { |
| 333 JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp( | 331 ASSERT(!done()); |
| 334 Isolate* isolate, StackFrame::Id id) | 332 ASSERT(frame_->is_java_script()); |
| 335 : iterator_(isolate) { | 333 return static_cast<JavaScriptFrame*>(frame_); |
| 336 AdvanceToId(id); | |
| 337 } | 334 } |
| 338 | 335 |
| 339 | 336 |
| 340 template<typename Iterator> | |
| 341 void JavaScriptFrameIteratorTemp<Iterator>::Advance() { | |
| 342 do { | |
| 343 iterator_.Advance(); | |
| 344 } while (!iterator_.done() && !iterator_.frame()->is_java_script()); | |
| 345 } | |
| 346 | |
| 347 | |
| 348 template<typename Iterator> | |
| 349 void JavaScriptFrameIteratorTemp<Iterator>::AdvanceToArgumentsFrame() { | |
| 350 if (!frame()->has_adapted_arguments()) return; | |
| 351 iterator_.Advance(); | |
| 352 ASSERT(iterator_.frame()->is_arguments_adaptor()); | |
| 353 } | |
| 354 | |
| 355 | |
| 356 template<typename Iterator> | |
| 357 void JavaScriptFrameIteratorTemp<Iterator>::AdvanceToId(StackFrame::Id id) { | |
| 358 while (!done()) { | |
| 359 Advance(); | |
| 360 if (frame()->id() == id) return; | |
| 361 } | |
| 362 } | |
| 363 | |
| 364 | |
| 365 template<typename Iterator> | |
| 366 void JavaScriptFrameIteratorTemp<Iterator>::Reset() { | |
| 367 iterator_.Reset(); | |
| 368 if (!done()) Advance(); | |
| 369 } | |
| 370 | |
| 371 | |
| 372 } } // namespace v8::internal | 337 } } // namespace v8::internal |
| 373 | 338 |
| 374 #endif // V8_FRAMES_INL_H_ | 339 #endif // V8_FRAMES_INL_H_ |
| OLD | NEW |