OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/disasm.h" | 10 #include "src/disasm.h" |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 } | 683 } |
684 ASSERT_EQ(0, | 684 ASSERT_EQ(0, |
685 static_cast<int>(addr - start) % table_entry_size_); | 685 static_cast<int>(addr - start) % table_entry_size_); |
686 return static_cast<int>(addr - start) / table_entry_size_; | 686 return static_cast<int>(addr - start) / table_entry_size_; |
687 } | 687 } |
688 | 688 |
689 | 689 |
690 int Deoptimizer::GetOutputInfo(DeoptimizationOutputData* data, | 690 int Deoptimizer::GetOutputInfo(DeoptimizationOutputData* data, |
691 BailoutId id, | 691 BailoutId id, |
692 SharedFunctionInfo* shared) { | 692 SharedFunctionInfo* shared) { |
693 // TODO(kasperl): For now, we do a simple linear search for the PC | |
694 // offset associated with the given node id. This should probably be | |
695 // changed to a binary search. | |
696 int length = data->DeoptPoints(); | 693 int length = data->DeoptPoints(); |
697 for (int i = 0; i < length; i++) { | 694 int low = 0, high = length - 1, mid; |
698 if (data->AstId(i) == id) { | 695 while (low <= high) { |
699 return data->PcAndState(i)->value(); | 696 mid = low + (high - low) / 2; |
700 } | 697 if (id == data->AstId(mid)) { |
| 698 return data->PcAndState(mid)->value(); |
| 699 } else if (id < data->AstId(mid)) { |
| 700 high = mid - 1; |
| 701 } else { |
| 702 low = mid + 1; |
| 703 } |
701 } | 704 } |
702 PrintF(stderr, "[couldn't find pc offset for node=%d]\n", id.ToInt()); | 705 PrintF(stderr, "[couldn't find pc offset for node=%d]\n", id.ToInt()); |
703 PrintF(stderr, "[method: %s]\n", shared->DebugName()->ToCString().get()); | 706 PrintF(stderr, "[method: %s]\n", shared->DebugName()->ToCString().get()); |
704 // Print the source code if available. | 707 // Print the source code if available. |
705 HeapStringAllocator string_allocator; | 708 HeapStringAllocator string_allocator; |
706 StringStream stream(&string_allocator); | 709 StringStream stream(&string_allocator); |
707 shared->SourceCodePrint(&stream, -1); | 710 shared->SourceCodePrint(&stream, -1); |
708 PrintF(stderr, "[source:\n%s\n]", stream.ToCString().get()); | 711 PrintF(stderr, "[source:\n%s\n]", stream.ToCString().get()); |
709 | 712 |
710 FATAL("unable to find pc offset during deoptimization"); | 713 FATAL("unable to find pc offset during deoptimization"); |
(...skipping 2871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3582 } | 3585 } |
3583 | 3586 |
3584 | 3587 |
3585 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 3588 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
3586 v->VisitPointer(BitCast<Object**>(&function_)); | 3589 v->VisitPointer(BitCast<Object**>(&function_)); |
3587 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 3590 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
3588 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 3591 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
3589 } | 3592 } |
3590 | 3593 |
3591 } } // namespace v8::internal | 3594 } } // namespace v8::internal |
OLD | NEW |