Extract platform independent part of RevertStackCheckCode.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6349046

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6572 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8fe563cb
...@@ -112,16 +112,16 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) { ...@@ -112,16 +112,16 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
} }
void Deoptimizer::PatchStackCheckAt(Address pc_after, void Deoptimizer::PatchStackCheckCodeAt(Address pc_after,
Code* check_code, Code* check_code,
Code* replacement_code) { Code* replacement_code) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code, void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
Code* check_code, Code* check_code,
Code* replacement_code) { Code* replacement_code) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
...@@ -823,7 +823,26 @@ void Deoptimizer::PatchStackCheckCode(Code* unoptimized_code, ...@@ -823,7 +823,26 @@ void Deoptimizer::PatchStackCheckCode(Code* unoptimized_code,
for (uint32_t i = 0; i < table_length; ++i) { for (uint32_t i = 0; i < table_length; ++i) {
uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize); uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize);
Address pc_after = unoptimized_code->instruction_start() + pc_offset; Address pc_after = unoptimized_code->instruction_start() + pc_offset;
PatchStackCheckAt(pc_after, check_code, replacement_code); PatchStackCheckCodeAt(pc_after, check_code, replacement_code);
stack_check_cursor += 2 * kIntSize;
}
}
void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code,
Code* check_code,
Code* replacement_code) {
// Iterate over the stack check table and revert the patched
// stack check calls.
ASSERT(unoptimized_code->kind() == Code::FUNCTION);
Address stack_check_cursor = unoptimized_code->instruction_start() +
unoptimized_code->stack_check_table_start();
uint32_t table_length = Memory::uint32_at(stack_check_cursor);
stack_check_cursor += kIntSize;
for (uint32_t i = 0; i < table_length; ++i) {
uint32_t pc_offset = Memory::uint32_at(stack_check_cursor + kIntSize);
Address pc_after = unoptimized_code->instruction_start() + pc_offset;
RevertStackCheckCodeAt(pc_after, check_code, replacement_code);
stack_check_cursor += 2 * kIntSize; stack_check_cursor += 2 * kIntSize;
} }
} }
......
...@@ -136,9 +136,9 @@ class Deoptimizer : public Malloced { ...@@ -136,9 +136,9 @@ class Deoptimizer : public Malloced {
// Patch stack guard check at instruction before pc_after in // Patch stack guard check at instruction before pc_after in
// the unoptimized code to unconditionally call replacement_code. // the unoptimized code to unconditionally call replacement_code.
static void PatchStackCheckAt(Address pc_after, static void PatchStackCheckCodeAt(Address pc_after,
Code* check_code, Code* check_code,
Code* replacement_code); Code* replacement_code);
// Change all patched stack guard checks in the unoptimized code // Change all patched stack guard checks in the unoptimized code
// back to a normal stack guard check. // back to a normal stack guard check.
...@@ -146,6 +146,12 @@ class Deoptimizer : public Malloced { ...@@ -146,6 +146,12 @@ class Deoptimizer : public Malloced {
Code* check_code, Code* check_code,
Code* replacement_code); Code* replacement_code);
// Change all patched stack guard checks in the unoptimized code
// back to a normal stack guard check.
static void RevertStackCheckCodeAt(Address pc_after,
Code* check_code,
Code* replacement_code);
~Deoptimizer(); ~Deoptimizer();
void InsertHeapNumberValues(int index, JavaScriptFrame* frame); void InsertHeapNumberValues(int index, JavaScriptFrame* frame);
......
...@@ -147,9 +147,9 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) { ...@@ -147,9 +147,9 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
} }
void Deoptimizer::PatchStackCheckAt(Address pc_after, void Deoptimizer::PatchStackCheckCodeAt(Address pc_after,
Code* check_code, Code* check_code,
Code* replacement_code) { Code* replacement_code) {
Address call_target_address = pc_after - kPointerSize; Address call_target_address = pc_after - kPointerSize;
ASSERT(check_code->entry() == ASSERT(check_code->entry() ==
Assembler::target_address_at(call_target_address)); Assembler::target_address_at(call_target_address));
...@@ -179,26 +179,21 @@ void Deoptimizer::PatchStackCheckAt(Address pc_after, ...@@ -179,26 +179,21 @@ void Deoptimizer::PatchStackCheckAt(Address pc_after,
} }
void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code, void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
Code* check_code, Code* check_code,
Code* replacement_code) { Code* replacement_code) {
// Iterate the unoptimized code and revert all the patched stack checks. Address call_target_address = pc_after - kPointerSize;
for (RelocIterator it(unoptimized_code, RelocInfo::kCodeTargetMask); ASSERT(replacement_code->entry() ==
!it.done(); Assembler::target_address_at(call_target_address));
it.next()) { // Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to
RelocInfo* rinfo = it.rinfo(); // restore the conditional branch.
if (rinfo->target_address() == replacement_code->entry()) { ASSERT(*(call_target_address - 3) == 0x90 && // nop
// Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to *(call_target_address - 2) == 0x90 && // nop
// restore the conditional branch. *(call_target_address - 1) == 0xe8); // call
Address call_target_address = rinfo->pc(); *(call_target_address - 3) = 0x73; // jae
ASSERT(*(call_target_address - 3) == 0x90 && // nop *(call_target_address - 2) = 0x07; // offset
*(call_target_address - 2) == 0x90 && // nop Assembler::set_target_address_at(call_target_address,
*(call_target_address - 1) == 0xe8); // call check_code->entry());
*(call_target_address - 3) = 0x73; // jae
*(call_target_address - 2) = 0x07; // offset
rinfo->set_target_address(check_code->entry());
}
}
} }
......
...@@ -107,16 +107,16 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) { ...@@ -107,16 +107,16 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
} }
void Deoptimizer::PatchStackCheckAt(Address pc_after, void Deoptimizer::PatchStackCheckCodeAt(Address pc_after,
Code* check_code, Code* check_code,
Code* replacement_code) { Code* replacement_code) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code, void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
Code* check_code, Code* check_code,
Code* replacement_code) { Code* replacement_code) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment