Chromium Code Reviews| 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 void Deoptimizer::PatchStackCheckCode(Code* unoptimized_code, | 813 void Deoptimizer::PatchStackCheckCode(Code* unoptimized_code, |
| 814 Code* check_code, | 814 Code* check_code, |
| 815 Code* replacement_code) { | 815 Code* replacement_code) { |
| 816 // Iterate over the stack check table and patch every stack check | 816 // Iterate over the stack check table and patch every stack check |
| 817 // call to an unconditional call to the replacement code. | 817 // call to an unconditional call to the replacement code. |
| 818 ASSERT(unoptimized_code->kind() == Code::FUNCTION); | 818 ASSERT(unoptimized_code->kind() == Code::FUNCTION); |
| 819 Address stack_check_cursor = unoptimized_code->instruction_start() + | 819 Address stack_check_cursor = unoptimized_code->instruction_start() + |
| 820 unoptimized_code->stack_check_table_offset(); | 820 unoptimized_code->stack_check_table_offset(); |
| 821 uint32_t table_length = Memory::uint32_at(stack_check_cursor); | 821 uint32_t table_length = Memory::uint32_at(stack_check_cursor); |
| 822 stack_check_cursor += kIntSize; | 822 stack_check_cursor += kIntSize; |
| 823 Address first_site = 0; | |
| 824 Address last_site = 0; | |
| 823 for (uint32_t i = 0; i < table_length; ++i) { | 825 for (uint32_t i = 0; i < table_length; ++i) { |
| 824 uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize); | 826 uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize); |
| 825 Address pc_after = unoptimized_code->instruction_start() + pc_offset; | 827 Address pc_after = unoptimized_code->instruction_start() + pc_offset; |
| 826 PatchStackCheckCodeAt(pc_after, check_code, replacement_code); | 828 PatchStackCheckCodeAt(pc_after, check_code, replacement_code); |
| 827 stack_check_cursor += 2 * kIntSize; | 829 stack_check_cursor += 2 * kIntSize; |
| 830 if (first_site == 0) { | |
| 831 first_site = pc_after; | |
| 832 } | |
| 833 last_site = pc_after; | |
| 834 } | |
| 835 if (table_length > 0) { | |
| 836 // Flush instruction cache for the patched code blocks. | |
| 837 uint32_t length = last_site - first_site + patch_size(); | |
|
Søren Thygesen Gjesse
2011/02/04 13:54:27
If you use the CodePatcher the i-cache flushing is
Karl Klose
2011/02/04 18:06:49
Done. I used the code patcher and removed the flus
| |
| 838 CPU::FlushICache(first_site - patch_size(), length); | |
| 828 } | 839 } |
| 829 } | 840 } |
| 830 | 841 |
| 831 | 842 |
| 832 void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code, | 843 void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code, |
| 833 Code* check_code, | 844 Code* check_code, |
| 834 Code* replacement_code) { | 845 Code* replacement_code) { |
| 835 // Iterate over the stack check table and revert the patched | 846 // Iterate over the stack check table and revert the patched |
| 836 // stack check calls. | 847 // stack check calls. |
| 837 ASSERT(unoptimized_code->kind() == Code::FUNCTION); | 848 ASSERT(unoptimized_code->kind() == Code::FUNCTION); |
| 838 Address stack_check_cursor = unoptimized_code->instruction_start() + | 849 Address stack_check_cursor = unoptimized_code->instruction_start() + |
| 839 unoptimized_code->stack_check_table_offset(); | 850 unoptimized_code->stack_check_table_offset(); |
| 840 uint32_t table_length = Memory::uint32_at(stack_check_cursor); | 851 uint32_t table_length = Memory::uint32_at(stack_check_cursor); |
| 841 stack_check_cursor += kIntSize; | 852 stack_check_cursor += kIntSize; |
| 853 Address first_site = 0; | |
| 854 Address last_site = 0; | |
| 842 for (uint32_t i = 0; i < table_length; ++i) { | 855 for (uint32_t i = 0; i < table_length; ++i) { |
| 843 uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize); | 856 uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize); |
| 844 Address pc_after = unoptimized_code->instruction_start() + pc_offset; | 857 Address pc_after = unoptimized_code->instruction_start() + pc_offset; |
| 845 RevertStackCheckCodeAt(pc_after, check_code, replacement_code); | 858 RevertStackCheckCodeAt(pc_after, check_code, replacement_code); |
| 846 stack_check_cursor += 2 * kIntSize; | 859 stack_check_cursor += 2 * kIntSize; |
| 860 if (first_site == 0) { | |
| 861 first_site = pc_after; | |
| 862 } | |
| 863 last_site = pc_after; | |
| 864 } | |
| 865 if (table_length > 0) { | |
| 866 // Flush instruction cache for the patched code blocks. | |
| 867 uint32_t length = last_site - first_site + patch_size(); | |
|
Søren Thygesen Gjesse
2011/02/04 13:54:27
Ditto.
Karl Klose
2011/02/04 18:06:49
Done. I used the code patcher and removed the flus
| |
| 868 CPU::FlushICache(first_site - patch_size(), length); | |
| 847 } | 869 } |
| 848 } | 870 } |
| 849 | 871 |
| 850 | 872 |
| 851 unsigned Deoptimizer::ComputeInputFrameSize() const { | 873 unsigned Deoptimizer::ComputeInputFrameSize() const { |
| 852 unsigned fixed_size = ComputeFixedSize(function_); | 874 unsigned fixed_size = ComputeFixedSize(function_); |
| 853 // The fp-to-sp delta already takes the context and the function | 875 // The fp-to-sp delta already takes the context and the function |
| 854 // into account so we have to avoid double counting them (-2). | 876 // into account so we have to avoid double counting them (-2). |
| 855 unsigned result = fixed_size + fp_to_sp_delta_ - (2 * kPointerSize); | 877 unsigned result = fixed_size + fp_to_sp_delta_ - (2 * kPointerSize); |
| 856 #ifdef DEBUG | 878 #ifdef DEBUG |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1176 Deoptimizer::HandleWeakDeoptimizedCode); | 1198 Deoptimizer::HandleWeakDeoptimizedCode); |
| 1177 } | 1199 } |
| 1178 | 1200 |
| 1179 | 1201 |
| 1180 DeoptimizingCodeListNode::~DeoptimizingCodeListNode() { | 1202 DeoptimizingCodeListNode::~DeoptimizingCodeListNode() { |
| 1181 GlobalHandles::Destroy(reinterpret_cast<Object**>(code_.location())); | 1203 GlobalHandles::Destroy(reinterpret_cast<Object**>(code_.location())); |
| 1182 } | 1204 } |
| 1183 | 1205 |
| 1184 | 1206 |
| 1185 } } // namespace v8::internal | 1207 } } // namespace v8::internal |
| OLD | NEW |