| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 StackFrameIterator::StackFrameIterator(bool use_top, Address fp, Address sp) | 79 StackFrameIterator::StackFrameIterator(bool use_top, Address fp, Address sp) |
| 80 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) | 80 : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) |
| 81 frame_(NULL), handler_(NULL), | 81 frame_(NULL), handler_(NULL), |
| 82 thread_(use_top ? Top::GetCurrentThread() : NULL), | 82 thread_(use_top ? Top::GetCurrentThread() : NULL), |
| 83 fp_(use_top ? NULL : fp), sp_(sp), | 83 fp_(use_top ? NULL : fp), sp_(sp), |
| 84 advance_(use_top ? &StackFrameIterator::AdvanceWithHandler : | 84 advance_(use_top ? &StackFrameIterator::AdvanceWithHandler : |
| 85 &StackFrameIterator::AdvanceWithoutHandler) { | 85 &StackFrameIterator::AdvanceWithoutHandler) { |
| 86 if (use_top || fp != NULL) { | 86 if (use_top || fp != NULL) { |
| 87 Reset(); | 87 Reset(); |
| 88 } | 88 } |
| 89 JavaScriptFrame_.DisableHeapAccess(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 #undef INITIALIZE_SINGLETON | 92 #undef INITIALIZE_SINGLETON |
| 92 | 93 |
| 93 | 94 |
| 94 void StackFrameIterator::AdvanceWithHandler() { | 95 void StackFrameIterator::AdvanceWithHandler() { |
| 95 ASSERT(!done()); | 96 ASSERT(!done()); |
| 96 // Compute the state of the calling frame before restoring | 97 // Compute the state of the calling frame before restoring |
| 97 // callee-saved registers and unwinding handlers. This allows the | 98 // callee-saved registers and unwinding handlers. This allows the |
| 98 // frame code that computes the caller state to access the top | 99 // frame code that computes the caller state to access the top |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 bool SafeStackFrameIterator::CanIterateHandles(StackFrame* frame, | 225 bool SafeStackFrameIterator::CanIterateHandles(StackFrame* frame, |
| 225 StackHandler* handler) { | 226 StackHandler* handler) { |
| 226 // If StackIterator iterates over StackHandles, verify that | 227 // If StackIterator iterates over StackHandles, verify that |
| 227 // StackHandlerIterator can be instantiated (see StackHandlerIterator | 228 // StackHandlerIterator can be instantiated (see StackHandlerIterator |
| 228 // constructor.) | 229 // constructor.) |
| 229 return !is_valid_top_ || (frame->sp() <= handler->address()); | 230 return !is_valid_top_ || (frame->sp() <= handler->address()); |
| 230 } | 231 } |
| 231 | 232 |
| 232 | 233 |
| 233 bool SafeStackFrameIterator::IsValidFrame(StackFrame* frame) const { | 234 bool SafeStackFrameIterator::IsValidFrame(StackFrame* frame) const { |
| 234 return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()) && | 235 return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()); |
| 235 // JavaScriptFrame uses function shared info to advance, hence it must | |
| 236 // point to a valid function object. | |
| 237 (!frame->is_java_script() || | |
| 238 reinterpret_cast<JavaScriptFrame*>(frame)->is_at_function()); | |
| 239 } | 236 } |
| 240 | 237 |
| 241 | 238 |
| 242 bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) { | 239 bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) { |
| 243 StackFrame::State state; | 240 StackFrame::State state; |
| 244 if (frame->is_entry() || frame->is_entry_construct()) { | 241 if (frame->is_entry() || frame->is_entry_construct()) { |
| 245 // See EntryFrame::GetCallerState. It computes the caller FP address | 242 // See EntryFrame::GetCallerState. It computes the caller FP address |
| 246 // and calls ExitFrame::GetStateForFramePointer on it. We need to be | 243 // and calls ExitFrame::GetStateForFramePointer on it. We need to be |
| 247 // sure that caller FP address is valid. | 244 // sure that caller FP address is valid. |
| 248 Address caller_fp = Memory::Address_at( | 245 Address caller_fp = Memory::Address_at( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 274 } | 271 } |
| 275 | 272 |
| 276 | 273 |
| 277 // ------------------------------------------------------------------------- | 274 // ------------------------------------------------------------------------- |
| 278 | 275 |
| 279 | 276 |
| 280 #ifdef ENABLE_LOGGING_AND_PROFILING | 277 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 281 SafeStackTraceFrameIterator::SafeStackTraceFrameIterator( | 278 SafeStackTraceFrameIterator::SafeStackTraceFrameIterator( |
| 282 Address fp, Address sp, Address low_bound, Address high_bound) : | 279 Address fp, Address sp, Address low_bound, Address high_bound) : |
| 283 SafeJavaScriptFrameIterator(fp, sp, low_bound, high_bound) { | 280 SafeJavaScriptFrameIterator(fp, sp, low_bound, high_bound) { |
| 284 if (!done() && !frame()->is_at_function()) Advance(); | 281 if (!done() && !frame()->is_java_script()) Advance(); |
| 285 } | 282 } |
| 286 | 283 |
| 287 | 284 |
| 288 void SafeStackTraceFrameIterator::Advance() { | 285 void SafeStackTraceFrameIterator::Advance() { |
| 289 while (true) { | 286 while (true) { |
| 290 SafeJavaScriptFrameIterator::Advance(); | 287 SafeJavaScriptFrameIterator::Advance(); |
| 291 if (done()) return; | 288 if (done()) return; |
| 292 if (frame()->is_at_function()) return; | 289 if (frame()->is_java_script()) return; |
| 293 } | 290 } |
| 294 } | 291 } |
| 295 #endif | 292 #endif |
| 296 | 293 |
| 297 | 294 |
| 298 // ------------------------------------------------------------------------- | 295 // ------------------------------------------------------------------------- |
| 299 | 296 |
| 300 | 297 |
| 301 void StackHandler::Cook(Code* code) { | 298 void StackHandler::Cook(Code* code) { |
| 302 ASSERT(MarkCompactCollector::IsCompacting()); | 299 ASSERT(MarkCompactCollector::IsCompacting()); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 reg_code[i++] = r; | 731 reg_code[i++] = r; |
| 735 | 732 |
| 736 ASSERT(i == kNumJSCallerSaved); | 733 ASSERT(i == kNumJSCallerSaved); |
| 737 } | 734 } |
| 738 ASSERT(0 <= n && n < kNumJSCallerSaved); | 735 ASSERT(0 <= n && n < kNumJSCallerSaved); |
| 739 return reg_code[n]; | 736 return reg_code[n]; |
| 740 } | 737 } |
| 741 | 738 |
| 742 | 739 |
| 743 } } // namespace v8::internal | 740 } } // namespace v8::internal |
| OLD | NEW |