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
This commit is contained in:
parent
8fe563cba6
commit
8152635387
@ -112,16 +112,16 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::PatchStackCheckAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
void Deoptimizer::PatchStackCheckCodeAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
@ -823,7 +823,26 @@ void Deoptimizer::PatchStackCheckCode(Code* unoptimized_code,
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -136,9 +136,9 @@ class Deoptimizer : public Malloced {
|
||||
|
||||
// Patch stack guard check at instruction before pc_after in
|
||||
// the unoptimized code to unconditionally call replacement_code.
|
||||
static void PatchStackCheckAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code);
|
||||
static void PatchStackCheckCodeAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code);
|
||||
|
||||
// Change all patched stack guard checks in the unoptimized code
|
||||
// back to a normal stack guard check.
|
||||
@ -146,6 +146,12 @@ class Deoptimizer : public Malloced {
|
||||
Code* check_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();
|
||||
|
||||
void InsertHeapNumberValues(int index, JavaScriptFrame* frame);
|
||||
|
@ -147,9 +147,9 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::PatchStackCheckAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
void Deoptimizer::PatchStackCheckCodeAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
Address call_target_address = pc_after - kPointerSize;
|
||||
ASSERT(check_code->entry() ==
|
||||
Assembler::target_address_at(call_target_address));
|
||||
@ -179,26 +179,21 @@ void Deoptimizer::PatchStackCheckAt(Address pc_after,
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
// Iterate the unoptimized code and revert all the patched stack checks.
|
||||
for (RelocIterator it(unoptimized_code, RelocInfo::kCodeTargetMask);
|
||||
!it.done();
|
||||
it.next()) {
|
||||
RelocInfo* rinfo = it.rinfo();
|
||||
if (rinfo->target_address() == replacement_code->entry()) {
|
||||
// Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to
|
||||
// restore the conditional branch.
|
||||
Address call_target_address = rinfo->pc();
|
||||
ASSERT(*(call_target_address - 3) == 0x90 && // nop
|
||||
*(call_target_address - 2) == 0x90 && // nop
|
||||
*(call_target_address - 1) == 0xe8); // call
|
||||
*(call_target_address - 3) = 0x73; // jae
|
||||
*(call_target_address - 2) = 0x07; // offset
|
||||
rinfo->set_target_address(check_code->entry());
|
||||
}
|
||||
}
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
Address call_target_address = pc_after - kPointerSize;
|
||||
ASSERT(replacement_code->entry() ==
|
||||
Assembler::target_address_at(call_target_address));
|
||||
// Replace the nops from patching (Deoptimizer::PatchStackCheckCode) to
|
||||
// restore the conditional branch.
|
||||
ASSERT(*(call_target_address - 3) == 0x90 && // nop
|
||||
*(call_target_address - 2) == 0x90 && // nop
|
||||
*(call_target_address - 1) == 0xe8); // call
|
||||
*(call_target_address - 3) = 0x73; // jae
|
||||
*(call_target_address - 2) = 0x07; // offset
|
||||
Assembler::set_target_address_at(call_target_address,
|
||||
check_code->entry());
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,16 +107,16 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::PatchStackCheckAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
void Deoptimizer::PatchStackCheckCodeAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
||||
void Deoptimizer::RevertStackCheckCode(Code* unoptimized_code,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
void Deoptimizer::RevertStackCheckCodeAt(Address pc_after,
|
||||
Code* check_code,
|
||||
Code* replacement_code) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user