OLD | NEW |
1 // Copyright 2010 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 21 matching lines...) Expand all Loading... |
33 #include "deoptimizer.h" | 33 #include "deoptimizer.h" |
34 #include "full-codegen.h" | 34 #include "full-codegen.h" |
35 #include "safepoint-table.h" | 35 #include "safepoint-table.h" |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
40 | 40 |
41 int Deoptimizer::table_entry_size_ = 10; | 41 int Deoptimizer::table_entry_size_ = 10; |
42 | 42 |
| 43 |
| 44 int Deoptimizer::patch_size() { |
| 45 return Assembler::kCallInstructionLength; |
| 46 } |
| 47 |
| 48 |
43 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { | 49 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { |
44 AssertNoAllocation no_allocation; | 50 AssertNoAllocation no_allocation; |
45 | 51 |
46 if (!function->IsOptimized()) return; | 52 if (!function->IsOptimized()) return; |
47 | 53 |
48 // Get the optimized code. | 54 // Get the optimized code. |
49 Code* code = function->code(); | 55 Code* code = function->code(); |
50 | 56 |
51 // Invalidate the relocation information, as it will become invalid by the | 57 // Invalidate the relocation information, as it will become invalid by the |
52 // code patching below, and is not needed any more. | 58 // code patching below, and is not needed any more. |
(...skipping 12 matching lines...) Expand all Loading... |
65 // Destroy the code which is not supposed to run again. | 71 // Destroy the code which is not supposed to run again. |
66 unsigned instructions = pc_offset - last_pc_offset; | 72 unsigned instructions = pc_offset - last_pc_offset; |
67 CodePatcher destroyer(code->instruction_start() + last_pc_offset, | 73 CodePatcher destroyer(code->instruction_start() + last_pc_offset, |
68 instructions); | 74 instructions); |
69 for (unsigned i = 0; i < instructions; i++) { | 75 for (unsigned i = 0; i < instructions; i++) { |
70 destroyer.masm()->int3(); | 76 destroyer.masm()->int3(); |
71 } | 77 } |
72 #endif | 78 #endif |
73 last_pc_offset = pc_offset; | 79 last_pc_offset = pc_offset; |
74 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { | 80 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { |
75 CodePatcher patcher( | 81 last_pc_offset += gap_code_size; |
76 code->instruction_start() + pc_offset + gap_code_size, | 82 CodePatcher patcher(code->instruction_start() + last_pc_offset, |
77 Assembler::kCallInstructionLength); | 83 patch_size()); |
78 patcher.masm()->Call(GetDeoptimizationEntry(deoptimization_index, LAZY), | 84 patcher.masm()->Call(GetDeoptimizationEntry(deoptimization_index, LAZY), |
79 RelocInfo::NONE); | 85 RelocInfo::NONE); |
80 last_pc_offset += gap_code_size + Assembler::kCallInstructionLength; | 86 last_pc_offset += patch_size(); |
81 } | 87 } |
82 } | 88 } |
83 #ifdef DEBUG | 89 #ifdef DEBUG |
84 // Destroy the code which is not supposed to run again. | 90 // Destroy the code which is not supposed to run again. |
85 CHECK(code->safepoint_table_start() >= last_pc_offset); | 91 CHECK(code->safepoint_table_start() >= last_pc_offset); |
86 unsigned instructions = code->safepoint_table_start() - last_pc_offset; | 92 unsigned instructions = code->safepoint_table_start() - last_pc_offset; |
87 CodePatcher destroyer(code->instruction_start() + last_pc_offset, | 93 CodePatcher destroyer(code->instruction_start() + last_pc_offset, |
88 instructions); | 94 instructions); |
89 for (unsigned i = 0; i < instructions; i++) { | 95 for (unsigned i = 0; i < instructions; i++) { |
90 destroyer.masm()->int3(); | 96 destroyer.masm()->int3(); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } | 506 } |
501 __ bind(&done); | 507 __ bind(&done); |
502 } | 508 } |
503 | 509 |
504 #undef __ | 510 #undef __ |
505 | 511 |
506 | 512 |
507 } } // namespace v8::internal | 513 } } // namespace v8::internal |
508 | 514 |
509 #endif // V8_TARGET_ARCH_X64 | 515 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |