OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 Code* replacement_code) { | 2036 Code* replacement_code) { |
2037 // Iterate over the back edge table and patch every interrupt | 2037 // Iterate over the back edge table and patch every interrupt |
2038 // call to an unconditional call to the replacement code. | 2038 // call to an unconditional call to the replacement code. |
2039 ASSERT(unoptimized_code->kind() == Code::FUNCTION); | 2039 ASSERT(unoptimized_code->kind() == Code::FUNCTION); |
2040 int loop_nesting_level = unoptimized_code->allow_osr_at_loop_nesting_level(); | 2040 int loop_nesting_level = unoptimized_code->allow_osr_at_loop_nesting_level(); |
2041 Address back_edge_cursor = unoptimized_code->instruction_start() + | 2041 Address back_edge_cursor = unoptimized_code->instruction_start() + |
2042 unoptimized_code->back_edge_table_offset(); | 2042 unoptimized_code->back_edge_table_offset(); |
2043 uint32_t table_length = Memory::uint32_at(back_edge_cursor); | 2043 uint32_t table_length = Memory::uint32_at(back_edge_cursor); |
2044 back_edge_cursor += kIntSize; | 2044 back_edge_cursor += kIntSize; |
2045 for (uint32_t i = 0; i < table_length; ++i) { | 2045 for (uint32_t i = 0; i < table_length; ++i) { |
2046 uint8_t loop_depth = Memory::uint8_at(back_edge_cursor + 2 * kIntSize); | 2046 uint32_t loop_depth = Memory::uint32_at(back_edge_cursor + 2 * kIntSize); |
2047 if (loop_depth == loop_nesting_level) { | 2047 if (static_cast<int>(loop_depth) == loop_nesting_level) { |
2048 // Loop back edge has the loop depth that we want to patch. | 2048 // Loop back edge has the loop depth that we want to patch. |
2049 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); | 2049 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); |
2050 Address pc_after = unoptimized_code->instruction_start() + pc_offset; | 2050 Address pc_after = unoptimized_code->instruction_start() + pc_offset; |
2051 PatchInterruptCodeAt(unoptimized_code, | 2051 PatchInterruptCodeAt(unoptimized_code, |
2052 pc_after, | 2052 pc_after, |
2053 interrupt_code, | 2053 interrupt_code, |
2054 replacement_code); | 2054 replacement_code); |
2055 } | 2055 } |
2056 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; | 2056 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; |
2057 } | 2057 } |
(...skipping 10 matching lines...) Expand all Loading... |
2068 Code* replacement_code) { | 2068 Code* replacement_code) { |
2069 // Iterate over the back edge table and revert the patched interrupt calls. | 2069 // Iterate over the back edge table and revert the patched interrupt calls. |
2070 ASSERT(unoptimized_code->kind() == Code::FUNCTION); | 2070 ASSERT(unoptimized_code->kind() == Code::FUNCTION); |
2071 ASSERT(unoptimized_code->back_edges_patched_for_osr()); | 2071 ASSERT(unoptimized_code->back_edges_patched_for_osr()); |
2072 int loop_nesting_level = unoptimized_code->allow_osr_at_loop_nesting_level(); | 2072 int loop_nesting_level = unoptimized_code->allow_osr_at_loop_nesting_level(); |
2073 Address back_edge_cursor = unoptimized_code->instruction_start() + | 2073 Address back_edge_cursor = unoptimized_code->instruction_start() + |
2074 unoptimized_code->back_edge_table_offset(); | 2074 unoptimized_code->back_edge_table_offset(); |
2075 uint32_t table_length = Memory::uint32_at(back_edge_cursor); | 2075 uint32_t table_length = Memory::uint32_at(back_edge_cursor); |
2076 back_edge_cursor += kIntSize; | 2076 back_edge_cursor += kIntSize; |
2077 for (uint32_t i = 0; i < table_length; ++i) { | 2077 for (uint32_t i = 0; i < table_length; ++i) { |
2078 uint8_t loop_depth = Memory::uint8_at(back_edge_cursor + 2 * kIntSize); | 2078 uint32_t loop_depth = Memory::uint32_at(back_edge_cursor + 2 * kIntSize); |
2079 if (loop_depth <= loop_nesting_level) { | 2079 if (static_cast<int>(loop_depth) <= loop_nesting_level) { |
2080 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); | 2080 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); |
2081 Address pc_after = unoptimized_code->instruction_start() + pc_offset; | 2081 Address pc_after = unoptimized_code->instruction_start() + pc_offset; |
2082 RevertInterruptCodeAt(unoptimized_code, | 2082 RevertInterruptCodeAt(unoptimized_code, |
2083 pc_after, | 2083 pc_after, |
2084 interrupt_code, | 2084 interrupt_code, |
2085 replacement_code); | 2085 replacement_code); |
2086 } | 2086 } |
2087 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; | 2087 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; |
2088 } | 2088 } |
2089 unoptimized_code->set_back_edges_patched_for_osr(false); | 2089 unoptimized_code->set_back_edges_patched_for_osr(false); |
2090 #ifdef DEBUG | 2090 #ifdef DEBUG |
2091 // Assert that none of the back edges are patched anymore. | 2091 // Assert that none of the back edges are patched anymore. |
2092 Deoptimizer::VerifyInterruptCode( | 2092 Deoptimizer::VerifyInterruptCode( |
2093 unoptimized_code, interrupt_code, replacement_code, -1); | 2093 unoptimized_code, interrupt_code, replacement_code, -1); |
2094 #endif // DEBUG | 2094 #endif // DEBUG |
2095 } | 2095 } |
2096 | 2096 |
2097 | 2097 |
2098 #ifdef DEBUG | 2098 #ifdef DEBUG |
2099 void Deoptimizer::VerifyInterruptCode(Code* unoptimized_code, | 2099 void Deoptimizer::VerifyInterruptCode(Code* unoptimized_code, |
2100 Code* interrupt_code, | 2100 Code* interrupt_code, |
2101 Code* replacement_code, | 2101 Code* replacement_code, |
2102 int loop_nesting_level) { | 2102 int loop_nesting_level) { |
2103 CHECK(unoptimized_code->kind() == Code::FUNCTION); | 2103 CHECK(unoptimized_code->kind() == Code::FUNCTION); |
2104 Address back_edge_cursor = unoptimized_code->instruction_start() + | 2104 Address back_edge_cursor = unoptimized_code->instruction_start() + |
2105 unoptimized_code->back_edge_table_offset(); | 2105 unoptimized_code->back_edge_table_offset(); |
2106 uint32_t table_length = Memory::uint32_at(back_edge_cursor); | 2106 uint32_t table_length = Memory::uint32_at(back_edge_cursor); |
2107 back_edge_cursor += kIntSize; | 2107 back_edge_cursor += kIntSize; |
2108 for (uint32_t i = 0; i < table_length; ++i) { | 2108 for (uint32_t i = 0; i < table_length; ++i) { |
2109 uint8_t loop_depth = Memory::uint8_at(back_edge_cursor + 2 * kIntSize); | 2109 uint32_t loop_depth = Memory::uint32_at(back_edge_cursor + 2 * kIntSize); |
2110 CHECK_LE(loop_depth, Code::kMaxLoopNestingMarker); | 2110 CHECK_LE(static_cast<int>(loop_depth), Code::kMaxLoopNestingMarker); |
2111 // Assert that all back edges for shallower loops (and only those) | 2111 // Assert that all back edges for shallower loops (and only those) |
2112 // have already been patched. | 2112 // have already been patched. |
2113 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); | 2113 uint32_t pc_offset = Memory::uint32_at(back_edge_cursor + kIntSize); |
2114 Address pc_after = unoptimized_code->instruction_start() + pc_offset; | 2114 Address pc_after = unoptimized_code->instruction_start() + pc_offset; |
2115 CHECK_EQ((loop_depth <= loop_nesting_level), | 2115 CHECK_EQ((static_cast<int>(loop_depth) <= loop_nesting_level), |
2116 InterruptCodeIsPatched(unoptimized_code, | 2116 InterruptCodeIsPatched(unoptimized_code, |
2117 pc_after, | 2117 pc_after, |
2118 interrupt_code, | 2118 interrupt_code, |
2119 replacement_code)); | 2119 replacement_code)); |
2120 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; | 2120 back_edge_cursor += FullCodeGenerator::kBackEdgeEntrySize; |
2121 } | 2121 } |
2122 } | 2122 } |
2123 #endif // DEBUG | 2123 #endif // DEBUG |
2124 | 2124 |
2125 | 2125 |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2773 | 2773 |
2774 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 2774 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
2775 v->VisitPointer(BitCast<Object**>(&function_)); | 2775 v->VisitPointer(BitCast<Object**>(&function_)); |
2776 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 2776 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
2777 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 2777 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
2778 } | 2778 } |
2779 | 2779 |
2780 #endif // ENABLE_DEBUGGER_SUPPORT | 2780 #endif // ENABLE_DEBUGGER_SUPPORT |
2781 | 2781 |
2782 } } // namespace v8::internal | 2782 } } // namespace v8::internal |
OLD | NEW |