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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 PrintF("[forced deoptimization: "); | 117 PrintF("[forced deoptimization: "); |
| 118 function->PrintName(); | 118 function->PrintName(); |
| 119 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); | 119 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 void Deoptimizer::PatchStackCheckCodeAt(Address pc_after, | 124 void Deoptimizer::PatchStackCheckCodeAt(Address pc_after, |
| 125 Code* check_code, | 125 Code* check_code, |
| 126 Code* replacement_code) { | 126 Code* replacement_code) { |
| 127 UNIMPLEMENTED(); | 127 // The call of the stack guard check has the following form: |
| 128 // e1 5d 00 0c cmp sp, <limit> | |
| 129 // 2a ?? ?? ?? bcs ok | |
|
Søren Thygesen Gjesse
2011/02/04 13:54:27
?? ?? ?? -> 00 00 01, the restoring puts in 1 here
Karl Klose
2011/02/04 18:06:49
Done.
| |
| 130 // e5 9f c? ?? ldr ip, [pc, <stack guard address>] | |
| 131 // e1 2f ff 3c blx ip | |
| 132 ASSERT(Memory::uint32_at(pc_after - 4) == 0xe12fff3c); | |
|
Søren Thygesen Gjesse
2011/02/04 13:54:27
0xe12fff3c -> al | B24 | B21 | 15*B16 | 15*B12 | 1
Søren Thygesen Gjesse
2011/02/04 13:54:27
4 -> kInstrSize
Karl Klose
2011/02/04 18:06:49
Done.
Karl Klose
2011/02/04 18:06:49
Done.
| |
| 133 ASSERT(Memory::uint8_at(pc_after - 5) == 0xe5); | |
|
Søren Thygesen Gjesse
2011/02/04 13:54:27
Use Assembler::IsLdrPcImmediateOffset() to check t
Karl Klose
2011/02/04 18:06:49
Done.
| |
| 134 ASSERT(Memory::uint8_at(pc_after - 6) == 0x9f); | |
| 135 | |
| 136 // We patch the code to the following form: | |
| 137 // e1 5d 00 0c cmp sp, <limit> | |
| 138 // e1 a0 00 00 mov r0, r0 (NOP) | |
| 139 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>] | |
| 140 // e1 2f ff 3c blx ip | |
| 141 // and overwrite the constant containing the | |
| 142 // address of the stack check stub. | |
| 143 | |
| 144 // Replace conditional jump with NOP. | |
| 145 Memory::uint32_at(pc_after - 12) = 0xe1a00000; | |
|
Søren Thygesen Gjesse
2011/02/04 13:54:27
I think you should be able to use the code patcher
Karl Klose
2011/02/04 18:06:49
Done.
| |
| 146 | |
| 147 // Replace the stack check address in the constant pool | |
| 148 // with the entry address of the replacement code. | |
| 149 uint32_t stack_check_address_offset = Memory::uint16_at(pc_after - 8) & | |
| 150 0xfff; | |
| 151 Address stack_check_address_pointer = pc_after + stack_check_address_offset; | |
| 152 ASSERT(Memory::uint32_at(stack_check_address_pointer) == | |
| 153 reinterpret_cast<uint32_t>(check_code->entry())); | |
| 154 Memory::uint32_at(stack_check_address_pointer) = | |
| 155 reinterpret_cast<uint32_t>(replacement_code->entry()); | |
| 128 } | 156 } |
| 129 | 157 |
| 130 | 158 |
| 131 void Deoptimizer::RevertStackCheckCodeAt(Address pc_after, | 159 void Deoptimizer::RevertStackCheckCodeAt(Address pc_after, |
| 132 Code* check_code, | 160 Code* check_code, |
| 133 Code* replacement_code) { | 161 Code* replacement_code) { |
| 134 UNIMPLEMENTED(); | 162 ASSERT(Memory::uint32_at(pc_after - 4) == 0xe12fff3c); |
| 163 ASSERT(Memory::uint8_at(pc_after - 5) == 0xe5); | |
| 164 ASSERT(Memory::uint8_at(pc_after - 6) == 0x9f); | |
| 165 | |
| 166 // Replace NOP with conditional jump. | |
| 167 Memory::uint32_at(pc_after - 12) = 0x2a000001; | |
|
Søren Thygesen Gjesse
2011/02/04 13:54:27
Use CodePatcher if possible, or at least:
0x2a000
Karl Klose
2011/02/04 18:06:49
I used the CodePatcher.
| |
| 168 | |
| 169 // Replace the stack check address in the constant pool | |
| 170 // with the entry address of the replacement code. | |
| 171 uint32_t stack_check_address_offset = Memory::uint16_at(pc_after - 8) & | |
| 172 0xfff; | |
| 173 Address stack_check_address_pointer = pc_after + stack_check_address_offset; | |
| 174 ASSERT(Memory::uint32_at(stack_check_address_pointer) == | |
| 175 reinterpret_cast<uint32_t>(replacement_code->entry())); | |
| 176 Memory::uint32_at(stack_check_address_pointer) = | |
| 177 reinterpret_cast<uint32_t>(check_code->entry()); | |
| 135 } | 178 } |
| 136 | 179 |
| 137 | 180 |
| 138 void Deoptimizer::DoComputeOsrOutputFrame() { | 181 void Deoptimizer::DoComputeOsrOutputFrame() { |
| 139 UNIMPLEMENTED(); | 182 UNIMPLEMENTED(); |
| 140 } | 183 } |
| 141 | 184 |
| 142 | 185 |
| 143 // This code is very similar to ia32 code, but relies on register names (fp, sp) | 186 // This code is very similar to ia32 code, but relies on register names (fp, sp) |
| 144 // and how the frame is laid out. | 187 // and how the frame is laid out. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 __ push(ip); | 550 __ push(ip); |
| 508 __ b(&done); | 551 __ b(&done); |
| 509 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 552 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
| 510 } | 553 } |
| 511 __ bind(&done); | 554 __ bind(&done); |
| 512 } | 555 } |
| 513 | 556 |
| 514 #undef __ | 557 #undef __ |
| 515 | 558 |
| 516 } } // namespace v8::internal | 559 } } // namespace v8::internal |
| OLD | NEW |