Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 ASSERT(RelocInfo::kMinRelocCommentSize == | 124 ASSERT(RelocInfo::kMinRelocCommentSize == |
| 125 pos_before - reloc_info_writer.pos()); | 125 pos_before - reloc_info_writer.pos()); |
| 126 } | 126 } |
| 127 // Replace relocation information on the code object. | 127 // Replace relocation information on the code object. |
| 128 code->set_relocation_info(*new_reloc); | 128 code->set_relocation_info(*new_reloc); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 | 132 |
| 133 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { | 133 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { |
| 134 HandleScope scope; | 134 HandleScope scope; |
|
Vitaly Repeshko
2011/03/25 12:57:51
Is this really needed?
Mads Ager (chromium)
2011/03/25 13:09:26
No you are right. That is not needed. I have extra
Mads Ager (chromium)
2011/03/25 13:15:53
I was wrong. We need it. The code patcher allocate
Vitaly Repeshko
2011/03/25 13:25:03
Is it only the self-reference code handle or are t
Mads Ager (chromium)
2011/03/25 13:37:42
That is the only one that I found by quick inspect
Vitaly Repeshko
2011/03/25 13:45:21
Sure. The performance is not a concern here. I jus
| |
| 135 AssertNoAllocation no_allocation; | 135 AssertNoAllocation no_allocation; |
| 136 | 136 |
| 137 if (!function->IsOptimized()) return; | 137 if (!function->IsOptimized()) return; |
|
Vitaly Repeshko
2011/03/25 12:57:51
I don't know how often this happens, but it still
Mads Ager (chromium)
2011/03/25 13:09:26
Done.
| |
| 138 | 138 |
| 139 // Get the optimized code. | 139 // Get the optimized code. |
| 140 Code* code = function->code(); | 140 Code* code = function->code(); |
| 141 Address code_start_address = code->instruction_start(); | 141 Address code_start_address = code->instruction_start(); |
| 142 | 142 |
| 143 // We will overwrite the code's relocation info in-place. Relocation info | 143 // We will overwrite the code's relocation info in-place. Relocation info |
| 144 // is written backward. The relocation info is the payload of a byte | 144 // is written backward. The relocation info is the payload of a byte |
| 145 // array. Later on we will slide this to the start of the byte array and | 145 // array. Later on we will slide this to the start of the byte array and |
| 146 // create a filler object in the remaining space. | 146 // create a filler object in the remaining space. |
| 147 ByteArray* reloc_info = code->relocation_info(); | 147 ByteArray* reloc_info = code->relocation_info(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 ZapCodeRange(prev_address, | 183 ZapCodeRange(prev_address, |
| 184 code_start_address + code->safepoint_table_offset()); | 184 code_start_address + code->safepoint_table_offset()); |
| 185 | 185 |
| 186 // Move the relocation info to the beginning of the byte array. | 186 // Move the relocation info to the beginning of the byte array. |
| 187 int new_reloc_size = reloc_end_address - reloc_info_writer.pos(); | 187 int new_reloc_size = reloc_end_address - reloc_info_writer.pos(); |
| 188 memmove(code->relocation_start(), reloc_info_writer.pos(), new_reloc_size); | 188 memmove(code->relocation_start(), reloc_info_writer.pos(), new_reloc_size); |
| 189 | 189 |
| 190 // The relocation info is in place, update the size. | 190 // The relocation info is in place, update the size. |
| 191 reloc_info->set_length(new_reloc_size); | 191 reloc_info->set_length(new_reloc_size); |
| 192 | 192 |
| 193 Isolate* isolate = code->GetIsolate(); | |
|
Vitaly Repeshko
2011/03/25 12:57:51
Move this up and use the isolate in HandleScope if
Mads Ager (chromium)
2011/03/25 13:09:26
Done.
| |
| 194 | |
| 193 // Handle the junk part after the new relocation info. We will create | 195 // Handle the junk part after the new relocation info. We will create |
| 194 // a non-live object in the extra space at the end of the former reloc info. | 196 // a non-live object in the extra space at the end of the former reloc info. |
| 195 Address junk_address = reloc_info->address() + reloc_info->Size(); | 197 Address junk_address = reloc_info->address() + reloc_info->Size(); |
| 196 ASSERT(junk_address <= reloc_end_address); | 198 ASSERT(junk_address <= reloc_end_address); |
| 197 HEAP->CreateFillerObjectAt(junk_address, reloc_end_address - junk_address); | 199 isolate->heap()->CreateFillerObjectAt(junk_address, |
| 200 reloc_end_address - junk_address); | |
| 198 | 201 |
| 199 // Add the deoptimizing code to the list. | 202 // Add the deoptimizing code to the list. |
| 200 DeoptimizingCodeListNode* node = new DeoptimizingCodeListNode(code); | 203 DeoptimizingCodeListNode* node = new DeoptimizingCodeListNode(code); |
| 201 DeoptimizerData* data = code->GetIsolate()->deoptimizer_data(); | 204 DeoptimizerData* data = isolate->deoptimizer_data(); |
| 202 node->set_next(data->deoptimizing_code_list_); | 205 node->set_next(data->deoptimizing_code_list_); |
| 203 data->deoptimizing_code_list_ = node; | 206 data->deoptimizing_code_list_ = node; |
| 204 | 207 |
| 205 // Set the code for the function to non-optimized version. | 208 // Set the code for the function to non-optimized version. |
| 206 function->ReplaceCode(function->shared()->code()); | 209 function->ReplaceCode(function->shared()->code()); |
| 207 | 210 |
| 208 if (FLAG_trace_deopt) { | 211 if (FLAG_trace_deopt) { |
| 209 PrintF("[forced deoptimization: "); | 212 PrintF("[forced deoptimization: "); |
| 210 function->PrintName(); | 213 function->PrintName(); |
| 211 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); | 214 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 } | 745 } |
| 743 __ bind(&done); | 746 __ bind(&done); |
| 744 } | 747 } |
| 745 | 748 |
| 746 #undef __ | 749 #undef __ |
| 747 | 750 |
| 748 | 751 |
| 749 } } // namespace v8::internal | 752 } } // namespace v8::internal |
| 750 | 753 |
| 751 #endif // V8_TARGET_ARCH_IA32 | 754 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |