| Index: src/ia32/deoptimizer-ia32.cc
|
| ===================================================================
|
| --- src/ia32/deoptimizer-ia32.cc (revision 6941)
|
| +++ src/ia32/deoptimizer-ia32.cc (working copy)
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2010 the V8 project authors. All rights reserved.
|
| +// Copyright 2011 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| // met:
|
| @@ -27,6 +27,8 @@
|
|
|
| #include "v8.h"
|
|
|
| +#if defined(V8_TARGET_ARCH_IA32)
|
| +
|
| #include "codegen.h"
|
| #include "deoptimizer.h"
|
| #include "full-codegen.h"
|
| @@ -56,8 +58,9 @@
|
| SafepointTable table(function->code());
|
| for (unsigned i = 0; i < table.length(); i++) {
|
| unsigned pc_offset = table.GetPcOffset(i);
|
| - int deoptimization_index = table.GetDeoptimizationIndex(i);
|
| - int gap_code_size = table.GetGapCodeSize(i);
|
| + SafepointEntry safepoint_entry = table.GetEntry(i);
|
| + int deoptimization_index = safepoint_entry.deoptimization_index();
|
| + int gap_code_size = safepoint_entry.gap_code_size();
|
| #ifdef DEBUG
|
| // Destroy the code which is not supposed to run again.
|
| unsigned instructions = pc_offset - last_pc_offset;
|
| @@ -106,23 +109,25 @@
|
|
|
| void Deoptimizer::PatchStackCheckCode(RelocInfo* rinfo,
|
| Code* replacement_code) {
|
| - // The stack check code matches the pattern (on ia32, for example):
|
| + // The stack check code matches the pattern:
|
| //
|
| // cmp esp, <limit>
|
| // jae ok
|
| // call <stack guard>
|
| + // test eax, <loop nesting depth>
|
| // ok: ...
|
| //
|
| - // We will patch the code to:
|
| + // We will patch away the branch so the code is:
|
| //
|
| // cmp esp, <limit> ;; Not changed
|
| // nop
|
| // nop
|
| // call <on-stack replacment>
|
| + // test eax, <loop nesting depth>
|
| // ok:
|
| Address call_target_address = rinfo->pc();
|
| ASSERT(*(call_target_address - 3) == 0x73 && // jae
|
| - *(call_target_address - 2) == 0x05 && // offset
|
| + *(call_target_address - 2) == 0x07 && // offset
|
| *(call_target_address - 1) == 0xe8); // call
|
| *(call_target_address - 3) = 0x90; // nop
|
| *(call_target_address - 2) = 0x90; // nop
|
| @@ -131,12 +136,14 @@
|
|
|
|
|
| void Deoptimizer::RevertStackCheckCode(RelocInfo* rinfo, Code* check_code) {
|
| + // 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) = 0x05; // offset
|
| + *(call_target_address - 2) = 0x07; // offset
|
| rinfo->set_target_address(check_code->entry());
|
| }
|
|
|
| @@ -616,3 +623,5 @@
|
|
|
|
|
| } } // namespace v8::internal
|
| +
|
| +#endif // V8_TARGET_ARCH_IA32
|
|
|