| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 UNREACHABLE(); | 813 UNREACHABLE(); |
| 814 return false; | 814 return false; |
| 815 } | 815 } |
| 816 } | 816 } |
| 817 | 817 |
| 818 if (!duplicate) *input_offset -= kPointerSize; | 818 if (!duplicate) *input_offset -= kPointerSize; |
| 819 return true; | 819 return true; |
| 820 } | 820 } |
| 821 | 821 |
| 822 | 822 |
| 823 void Deoptimizer::PatchStackCheckCode(Code* unoptimized_code, |
| 824 Code* check_code, |
| 825 Code* replacement_code) { |
| 826 // Iterate over the stack check table and patch every stack check |
| 827 // call to an unconditional call to the replacement code. |
| 828 ASSERT(unoptimized_code->kind() == Code::FUNCTION); |
| 829 Address stack_check_cursor = unoptimized_code->instruction_start() + |
| 830 unoptimized_code->stack_check_table_start(); |
| 831 uint32_t table_length = Memory::uint32_at(stack_check_cursor); |
| 832 stack_check_cursor += kIntSize; |
| 833 for (uint32_t i = 0; i < table_length; ++i) { |
| 834 uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize); |
| 835 Address pc_after = unoptimized_code->instruction_start() + pc_offset; |
| 836 PatchStackCheckCodeAt(pc_after, check_code, replacement_code); |
| 837 stack_check_cursor += 2 * kIntSize; |
| 838 } |
| 839 } |
| 840 |
| 841 |
| 842 void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code, |
| 843 Code* check_code, |
| 844 Code* replacement_code) { |
| 845 // Iterate over the stack check table and revert the patched |
| 846 // stack check calls. |
| 847 ASSERT(unoptimized_code->kind() == Code::FUNCTION); |
| 848 Address stack_check_cursor = unoptimized_code->instruction_start() + |
| 849 unoptimized_code->stack_check_table_start(); |
| 850 uint32_t table_length = Memory::uint32_at(stack_check_cursor); |
| 851 stack_check_cursor += kIntSize; |
| 852 for (uint32_t i = 0; i < table_length; ++i) { |
| 853 uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize); |
| 854 Address pc_after = unoptimized_code->instruction_start() + pc_offset; |
| 855 RevertStackCheckCodeAt(pc_after, check_code, replacement_code); |
| 856 stack_check_cursor += 2 * kIntSize; |
| 857 } |
| 858 } |
| 859 |
| 860 |
| 823 unsigned Deoptimizer::ComputeInputFrameSize() const { | 861 unsigned Deoptimizer::ComputeInputFrameSize() const { |
| 824 unsigned fixed_size = ComputeFixedSize(function_); | 862 unsigned fixed_size = ComputeFixedSize(function_); |
| 825 // The fp-to-sp delta already takes the context and the function | 863 // The fp-to-sp delta already takes the context and the function |
| 826 // into account so we have to avoid double counting them (-2). | 864 // into account so we have to avoid double counting them (-2). |
| 827 unsigned result = fixed_size + fp_to_sp_delta_ - (2 * kPointerSize); | 865 unsigned result = fixed_size + fp_to_sp_delta_ - (2 * kPointerSize); |
| 828 #ifdef DEBUG | 866 #ifdef DEBUG |
| 829 if (bailout_type_ == OSR) { | 867 if (bailout_type_ == OSR) { |
| 830 // TODO(kasperl): It would be nice if we could verify that the | 868 // TODO(kasperl): It would be nice if we could verify that the |
| 831 // size matches with the stack height we can compute based on the | 869 // size matches with the stack height we can compute based on the |
| 832 // environment at the OSR entry. The code for that his built into | 870 // environment at the OSR entry. The code for that his built into |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 } | 1196 } |
| 1159 | 1197 |
| 1160 | 1198 |
| 1161 DeoptimizingCodeListNode::~DeoptimizingCodeListNode() { | 1199 DeoptimizingCodeListNode::~DeoptimizingCodeListNode() { |
| 1162 GlobalHandles* global_handles = Isolate::Current()->global_handles(); | 1200 GlobalHandles* global_handles = Isolate::Current()->global_handles(); |
| 1163 global_handles->Destroy(reinterpret_cast<Object**>(code_.location())); | 1201 global_handles->Destroy(reinterpret_cast<Object**>(code_.location())); |
| 1164 } | 1202 } |
| 1165 | 1203 |
| 1166 | 1204 |
| 1167 } } // namespace v8::internal | 1205 } } // namespace v8::internal |
| OLD | NEW |