OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/stack_frame.h" | 5 #include "vm/stack_frame.h" |
6 | 6 |
7 #include "platform/memory_sanitizer.h" | 7 #include "platform/memory_sanitizer.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/deopt_instructions.h" | 9 #include "vm/deopt_instructions.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 264 |
265 bool StackFrame::IsValid() const { | 265 bool StackFrame::IsValid() const { |
266 if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { | 266 if (IsEntryFrame() || IsExitFrame() || IsStubFrame()) { |
267 return true; | 267 return true; |
268 } | 268 } |
269 return (LookupDartCode() != Code::null()); | 269 return (LookupDartCode() != Code::null()); |
270 } | 270 } |
271 | 271 |
272 | 272 |
273 void StackFrameIterator::SetupLastExitFrameData() { | 273 void StackFrameIterator::SetupLastExitFrameData() { |
274 uword exit_marker = Thread::Current()->top_exit_frame_info(); | 274 ASSERT(thread_ != NULL); |
| 275 uword exit_marker = thread_->top_exit_frame_info(); |
275 frames_.fp_ = exit_marker; | 276 frames_.fp_ = exit_marker; |
276 } | 277 } |
277 | 278 |
278 | 279 |
279 void StackFrameIterator::SetupNextExitFrameData() { | 280 void StackFrameIterator::SetupNextExitFrameData() { |
280 uword exit_address = entry_.fp() + (kExitLinkSlotFromEntryFp * kWordSize); | 281 uword exit_address = entry_.fp() + (kExitLinkSlotFromEntryFp * kWordSize); |
281 uword exit_marker = *reinterpret_cast<uword*>(exit_address); | 282 uword exit_marker = *reinterpret_cast<uword*>(exit_address); |
282 frames_.fp_ = exit_marker; | 283 frames_.fp_ = exit_marker; |
283 frames_.sp_ = 0; | 284 frames_.sp_ = 0; |
284 frames_.pc_ = 0; | 285 frames_.pc_ = 0; |
285 } | 286 } |
286 | 287 |
287 | 288 |
288 // Tell MemorySanitizer that generated code initializes part of the stack. | 289 // Tell MemorySanitizer that generated code initializes part of the stack. |
289 // TODO(koda): Limit to frames that are actually written by generated code. | 290 // TODO(koda): Limit to frames that are actually written by generated code. |
290 static void UnpoisonStack(Isolate* isolate, uword fp) { | 291 static void UnpoisonStack(Isolate* isolate, uword fp) { |
291 ASSERT(fp != 0); | 292 ASSERT(fp != 0); |
292 uword size = isolate->GetSpecifiedStackSize(); | 293 uword size = isolate->GetSpecifiedStackSize(); |
293 MSAN_UNPOISON(reinterpret_cast<void*>(fp - size), 2 * size); | 294 MSAN_UNPOISON(reinterpret_cast<void*>(fp - size), 2 * size); |
294 } | 295 } |
295 | 296 |
296 | 297 |
297 StackFrameIterator::StackFrameIterator(bool validate, Isolate* isolate) | 298 StackFrameIterator::StackFrameIterator(bool validate, |
| 299 Isolate* isolate, |
| 300 Thread* thread) |
298 : validate_(validate), | 301 : validate_(validate), |
299 entry_(isolate), | 302 entry_(isolate), |
300 exit_(isolate), | 303 exit_(isolate), |
301 frames_(isolate), | 304 frames_(isolate), |
302 current_frame_(NULL), | 305 current_frame_(NULL), |
303 isolate_(isolate) { | 306 isolate_(isolate), |
| 307 thread_(thread) { |
304 ASSERT((isolate_ == Isolate::Current()) || | 308 ASSERT((isolate_ == Isolate::Current()) || |
305 OS::AllowStackFrameIteratorFromAnotherThread()); | 309 OS::AllowStackFrameIteratorFromAnotherThread()); |
306 SetupLastExitFrameData(); // Setup data for last exit frame. | 310 SetupLastExitFrameData(); // Setup data for last exit frame. |
307 } | 311 } |
308 | 312 |
309 | 313 |
310 StackFrameIterator::StackFrameIterator(uword last_fp, bool validate, | 314 StackFrameIterator::StackFrameIterator(uword last_fp, bool validate, |
311 Isolate* isolate) | 315 Isolate* isolate, Thread* thread) |
312 : validate_(validate), | 316 : validate_(validate), |
313 entry_(isolate), | 317 entry_(isolate), |
314 exit_(isolate), | 318 exit_(isolate), |
315 frames_(isolate), | 319 frames_(isolate), |
316 current_frame_(NULL), | 320 current_frame_(NULL), |
317 isolate_(isolate) { | 321 isolate_(isolate), |
| 322 thread_(thread) { |
318 ASSERT((isolate_ == Isolate::Current()) || | 323 ASSERT((isolate_ == Isolate::Current()) || |
319 OS::AllowStackFrameIteratorFromAnotherThread()); | 324 OS::AllowStackFrameIteratorFromAnotherThread()); |
320 frames_.fp_ = last_fp; | 325 frames_.fp_ = last_fp; |
321 frames_.sp_ = 0; | 326 frames_.sp_ = 0; |
322 frames_.pc_ = 0; | 327 frames_.pc_ = 0; |
323 } | 328 } |
324 | 329 |
325 | 330 |
326 StackFrameIterator::StackFrameIterator(uword fp, uword sp, uword pc, | 331 StackFrameIterator::StackFrameIterator(uword fp, uword sp, uword pc, |
327 bool validate, Isolate* isolate) | 332 bool validate, Isolate* isolate, |
| 333 Thread* thread) |
328 : validate_(validate), | 334 : validate_(validate), |
329 entry_(isolate), | 335 entry_(isolate), |
330 exit_(isolate), | 336 exit_(isolate), |
331 frames_(isolate), | 337 frames_(isolate), |
332 current_frame_(NULL), | 338 current_frame_(NULL), |
333 isolate_(isolate) { | 339 isolate_(isolate), |
| 340 thread_(thread) { |
334 ASSERT((isolate_ == Isolate::Current()) || | 341 ASSERT((isolate_ == Isolate::Current()) || |
335 OS::AllowStackFrameIteratorFromAnotherThread()); | 342 OS::AllowStackFrameIteratorFromAnotherThread()); |
336 frames_.fp_ = fp; | 343 frames_.fp_ = fp; |
337 frames_.sp_ = sp; | 344 frames_.sp_ = sp; |
338 frames_.pc_ = pc; | 345 frames_.pc_ = pc; |
339 } | 346 } |
340 | 347 |
341 | 348 |
342 StackFrame* StackFrameIterator::NextFrame() { | 349 StackFrame* StackFrameIterator::NextFrame() { |
343 // When we are at the start of iteration after having created an | 350 // When we are at the start of iteration after having created an |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { | 503 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { |
497 return (index - num_materializations_); | 504 return (index - num_materializations_); |
498 } | 505 } |
499 } | 506 } |
500 UNREACHABLE(); | 507 UNREACHABLE(); |
501 return 0; | 508 return 0; |
502 } | 509 } |
503 | 510 |
504 | 511 |
505 } // namespace dart | 512 } // namespace dart |
OLD | NEW |