| 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 "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/deopt_instructions.h" | 8 #include "vm/deopt_instructions.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 entry_.fp_ = frames_.fp_; | 358 entry_.fp_ = frames_.fp_; |
| 359 entry_.pc_ = frames_.pc_; | 359 entry_.pc_ = frames_.pc_; |
| 360 SetupNextExitFrameData(); // Setup data for next exit frame in chain. | 360 SetupNextExitFrameData(); // Setup data for next exit frame in chain. |
| 361 ASSERT(entry_.IsValid()); | 361 ASSERT(entry_.IsValid()); |
| 362 return &entry_; | 362 return &entry_; |
| 363 } | 363 } |
| 364 | 364 |
| 365 | 365 |
| 366 InlinedFunctionsIterator::InlinedFunctionsIterator(const Code& code, uword pc) | 366 InlinedFunctionsIterator::InlinedFunctionsIterator(const Code& code, uword pc) |
| 367 : index_(0), | 367 : index_(0), |
| 368 num_materializations_(0), |
| 368 code_(Code::Handle(code.raw())), | 369 code_(Code::Handle(code.raw())), |
| 369 deopt_info_(DeoptInfo::Handle()), | 370 deopt_info_(DeoptInfo::Handle()), |
| 370 function_(Function::Handle()), | 371 function_(Function::Handle()), |
| 371 pc_(pc), | 372 pc_(pc), |
| 372 deopt_instructions_(), | 373 deopt_instructions_(), |
| 373 object_table_(Array::Handle()) { | 374 object_table_(Array::Handle()) { |
| 374 ASSERT(code_.is_optimized()); | 375 ASSERT(code_.is_optimized()); |
| 375 ASSERT(pc_ != 0); | 376 ASSERT(pc_ != 0); |
| 376 ASSERT(code.ContainsInstructionAt(pc)); | 377 ASSERT(code.ContainsInstructionAt(pc)); |
| 377 intptr_t deopt_reason = kDeoptUnknown; | 378 intptr_t deopt_reason = kDeoptUnknown; |
| 378 deopt_info_ = code_.GetDeoptInfoAtPc(pc, &deopt_reason); | 379 deopt_info_ = code_.GetDeoptInfoAtPc(pc, &deopt_reason); |
| 379 if (deopt_info_.IsNull()) { | 380 if (deopt_info_.IsNull()) { |
| 380 // This is the case when a call without deopt info in optimized code | 381 // This is the case when a call without deopt info in optimized code |
| 381 // throws an exception. (e.g. in the parameter copying prologue). | 382 // throws an exception. (e.g. in the parameter copying prologue). |
| 382 // In that case there won't be any inlined frames. | 383 // In that case there won't be any inlined frames. |
| 383 function_ = code_.function(); | 384 function_ = code_.function(); |
| 384 } else { | 385 } else { |
| 385 // Unpack deopt info into instructions (translate away suffixes). | 386 // Unpack deopt info into instructions (translate away suffixes). |
| 386 const Array& deopt_table = Array::Handle(code_.deopt_info_array()); | 387 const Array& deopt_table = Array::Handle(code_.deopt_info_array()); |
| 387 ASSERT(!deopt_table.IsNull()); | 388 ASSERT(!deopt_table.IsNull()); |
| 388 deopt_info_.ToInstructions(deopt_table, &deopt_instructions_); | 389 deopt_info_.ToInstructions(deopt_table, &deopt_instructions_); |
| 390 num_materializations_ = deopt_info_.NumMaterializations(); |
| 389 object_table_ = code_.object_table(); | 391 object_table_ = code_.object_table(); |
| 390 Advance(); | 392 Advance(); |
| 391 } | 393 } |
| 392 } | 394 } |
| 393 | 395 |
| 394 | 396 |
| 395 void InlinedFunctionsIterator::Advance() { | 397 void InlinedFunctionsIterator::Advance() { |
| 396 // Iterate over the deopt instructions and determine the inlined | 398 // Iterate over the deopt instructions and determine the inlined |
| 397 // functions if any and iterate over them. | 399 // functions if any and iterate over them. |
| 398 ASSERT(!Done()); | 400 ASSERT(!Done()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 419 | 421 |
| 420 // Finds the potential offset for the current function's FP if the | 422 // Finds the potential offset for the current function's FP if the |
| 421 // current frame were to be deoptimized. | 423 // current frame were to be deoptimized. |
| 422 intptr_t InlinedFunctionsIterator::GetDeoptFpOffset() const { | 424 intptr_t InlinedFunctionsIterator::GetDeoptFpOffset() const { |
| 423 ASSERT(deopt_instructions_.length() != 0); | 425 ASSERT(deopt_instructions_.length() != 0); |
| 424 for (intptr_t index = index_; | 426 for (intptr_t index = index_; |
| 425 index < deopt_instructions_.length(); | 427 index < deopt_instructions_.length(); |
| 426 index++) { | 428 index++) { |
| 427 DeoptInstr* deopt_instr = deopt_instructions_[index]; | 429 DeoptInstr* deopt_instr = deopt_instructions_[index]; |
| 428 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { | 430 if (deopt_instr->kind() == DeoptInstr::kCallerFp) { |
| 429 return index; | 431 return (index - num_materializations_); |
| 430 } | 432 } |
| 431 } | 433 } |
| 432 UNREACHABLE(); | 434 UNREACHABLE(); |
| 433 return 0; | 435 return 0; |
| 434 } | 436 } |
| 435 | 437 |
| 436 | 438 |
| 437 } // namespace dart | 439 } // namespace dart |
| OLD | NEW |