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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 276 |
277 void StackFrameIterator::SetupNextExitFrameData() { | 277 void StackFrameIterator::SetupNextExitFrameData() { |
278 uword exit_address = entry_.fp() + (kExitLinkSlotFromEntryFp * kWordSize); | 278 uword exit_address = entry_.fp() + (kExitLinkSlotFromEntryFp * kWordSize); |
279 uword exit_marker = *reinterpret_cast<uword*>(exit_address); | 279 uword exit_marker = *reinterpret_cast<uword*>(exit_address); |
280 frames_.fp_ = exit_marker; | 280 frames_.fp_ = exit_marker; |
281 frames_.sp_ = 0; | 281 frames_.sp_ = 0; |
282 frames_.pc_ = 0; | 282 frames_.pc_ = 0; |
283 } | 283 } |
284 | 284 |
285 | 285 |
286 // TODO(johnmccutchan): Remove |isolate| argument. | |
287 // Tell MemorySanitizer that generated code initializes part of the stack. | 286 // Tell MemorySanitizer that generated code initializes part of the stack. |
288 // TODO(koda): Limit to frames that are actually written by generated code. | 287 // TODO(koda): Limit to frames that are actually written by generated code. |
289 static void UnpoisonStack(Isolate* isolate, uword fp) { | 288 static void UnpoisonStack(uword fp) { |
290 ASSERT(fp != 0); | 289 ASSERT(fp != 0); |
291 uword size = isolate->GetSpecifiedStackSize(); | 290 uword size = OSThread::GetSpecifiedStackSize(); |
292 MSAN_UNPOISON(reinterpret_cast<void*>(fp - size), 2 * size); | 291 MSAN_UNPOISON(reinterpret_cast<void*>(fp - size), 2 * size); |
293 } | 292 } |
294 | 293 |
295 | 294 |
296 StackFrameIterator::StackFrameIterator(bool validate, Thread* thread) | 295 StackFrameIterator::StackFrameIterator(bool validate, Thread* thread) |
297 : validate_(validate), | 296 : validate_(validate), |
298 entry_(thread), | 297 entry_(thread), |
299 exit_(thread), | 298 exit_(thread), |
300 frames_(thread), | 299 frames_(thread), |
301 current_frame_(NULL), | 300 current_frame_(NULL), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 // top_exit_frame_info will be 0 and so we would return NULL. | 347 // top_exit_frame_info will be 0 and so we would return NULL. |
349 | 348 |
350 // current_frame_ will also be NULL, when we are at the end of having | 349 // current_frame_ will also be NULL, when we are at the end of having |
351 // iterated through all the frames. If NextFrame is called at this | 350 // iterated through all the frames. If NextFrame is called at this |
352 // point, we will try and set up the next exit frame, but since we are | 351 // point, we will try and set up the next exit frame, but since we are |
353 // at the end of the iteration, fp_ will be 0 and we would return NULL. | 352 // at the end of the iteration, fp_ will be 0 and we would return NULL. |
354 if (current_frame_ == NULL) { | 353 if (current_frame_ == NULL) { |
355 if (!HasNextFrame()) { | 354 if (!HasNextFrame()) { |
356 return NULL; | 355 return NULL; |
357 } | 356 } |
358 UnpoisonStack(thread_->isolate(), frames_.fp_); | 357 UnpoisonStack(frames_.fp_); |
359 if (frames_.pc_ == 0) { | 358 if (frames_.pc_ == 0) { |
360 // Iteration starts from an exit frame given by its fp. | 359 // Iteration starts from an exit frame given by its fp. |
361 current_frame_ = NextExitFrame(); | 360 current_frame_ = NextExitFrame(); |
362 } else if (*(reinterpret_cast<uword*>( | 361 } else if (*(reinterpret_cast<uword*>( |
363 frames_.fp_ + (kSavedCallerFpSlotFromFp * kWordSize))) == 0) { | 362 frames_.fp_ + (kSavedCallerFpSlotFromFp * kWordSize))) == 0) { |
364 // Iteration starts from an entry frame given by its fp, sp, and pc. | 363 // Iteration starts from an entry frame given by its fp, sp, and pc. |
365 current_frame_ = NextEntryFrame(); | 364 current_frame_ = NextEntryFrame(); |
366 } else { | 365 } else { |
367 // Iteration starts from a Dart or stub frame given by its fp, sp, and pc. | 366 // Iteration starts from a Dart or stub frame given by its fp, sp, and pc. |
368 current_frame_ = frames_.NextFrame(validate_); | 367 current_frame_ = frames_.NextFrame(validate_); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { | 494 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { |
496 return (index - num_materializations_); | 495 return (index - num_materializations_); |
497 } | 496 } |
498 } | 497 } |
499 UNREACHABLE(); | 498 UNREACHABLE(); |
500 return 0; | 499 return 0; |
501 } | 500 } |
502 | 501 |
503 | 502 |
504 } // namespace dart | 503 } // namespace dart |
OLD | NEW |