Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: src/mips/deoptimizer-mips.cc

Issue 23608004: Refactor interrupt check patching for OSR. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/deoptimizer-ia32.cc ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 // Copyright 2011 the V8 project authors. All rights reserved. 2 // Copyright 2011 the V8 project authors. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // addiu at, zero_reg, 1 94 // addiu at, zero_reg, 1
95 // beq at, zero_reg, ok ;; Not changed 95 // beq at, zero_reg, ok ;; Not changed
96 // lui t9, <on-stack replacement address> upper 96 // lui t9, <on-stack replacement address> upper
97 // ori t9, <on-stack replacement address> lower 97 // ori t9, <on-stack replacement address> lower
98 // jalr t9 ;; Not changed 98 // jalr t9 ;; Not changed
99 // nop ;; Not changed 99 // nop ;; Not changed
100 // ok-label ----- pc_after points here 100 // ok-label ----- pc_after points here
101 101
102 void Deoptimizer::PatchInterruptCodeAt(Code* unoptimized_code, 102 void Deoptimizer::PatchInterruptCodeAt(Code* unoptimized_code,
103 Address pc_after, 103 Address pc_after,
104 Code* interrupt_code,
105 Code* replacement_code) { 104 Code* replacement_code) {
106 ASSERT(!InterruptCodeIsPatched(unoptimized_code,
107 pc_after,
108 interrupt_code,
109 replacement_code));
110 static const int kInstrSize = Assembler::kInstrSize; 105 static const int kInstrSize = Assembler::kInstrSize;
111 // Replace the sltu instruction with load-imm 1 to at, so beq is not taken. 106 // Replace the sltu instruction with load-imm 1 to at, so beq is not taken.
112 CodePatcher patcher(pc_after - 6 * kInstrSize, 1); 107 CodePatcher patcher(pc_after - 6 * kInstrSize, 1);
113 patcher.masm()->addiu(at, zero_reg, 1); 108 patcher.masm()->addiu(at, zero_reg, 1);
114 // Replace the stack check address in the load-immediate (lui/ori pair) 109 // Replace the stack check address in the load-immediate (lui/ori pair)
115 // with the entry address of the replacement code. 110 // with the entry address of the replacement code.
116 Assembler::set_target_address_at(pc_after - 4 * kInstrSize, 111 Assembler::set_target_address_at(pc_after - 4 * kInstrSize,
117 replacement_code->entry()); 112 replacement_code->entry());
118 113
119 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 114 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
120 unoptimized_code, pc_after - 4 * kInstrSize, replacement_code); 115 unoptimized_code, pc_after - 4 * kInstrSize, replacement_code);
121 } 116 }
122 117
123 118
124 void Deoptimizer::RevertInterruptCodeAt(Code* unoptimized_code, 119 void Deoptimizer::RevertInterruptCodeAt(Code* unoptimized_code,
125 Address pc_after, 120 Address pc_after,
126 Code* interrupt_code, 121 Code* interrupt_code) {
127 Code* replacement_code) {
128 ASSERT(InterruptCodeIsPatched(unoptimized_code,
129 pc_after,
130 interrupt_code,
131 replacement_code));
132 static const int kInstrSize = Assembler::kInstrSize; 122 static const int kInstrSize = Assembler::kInstrSize;
133 // Restore the sltu instruction so beq can be taken again. 123 // Restore the sltu instruction so beq can be taken again.
134 CodePatcher patcher(pc_after - 6 * kInstrSize, 1); 124 CodePatcher patcher(pc_after - 6 * kInstrSize, 1);
135 patcher.masm()->slt(at, a3, zero_reg); 125 patcher.masm()->slt(at, a3, zero_reg);
136 // Restore the original call address. 126 // Restore the original call address.
137 Assembler::set_target_address_at(pc_after - 4 * kInstrSize, 127 Assembler::set_target_address_at(pc_after - 4 * kInstrSize,
138 interrupt_code->entry()); 128 interrupt_code->entry());
139 129
140 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 130 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
141 unoptimized_code, pc_after - 4 * kInstrSize, interrupt_code); 131 unoptimized_code, pc_after - 4 * kInstrSize, interrupt_code);
142 } 132 }
143 133
144 134
145 #ifdef DEBUG 135 #ifdef DEBUG
146 bool Deoptimizer::InterruptCodeIsPatched(Code* unoptimized_code, 136 Deoptimizer::InterruptPatchState Deoptimizer::GetInterruptPatchState(
147 Address pc_after, 137 Isolate* isolate,
148 Code* interrupt_code, 138 Code* unoptimized_code,
149 Code* replacement_code) { 139 Address pc_after) {
150 static const int kInstrSize = Assembler::kInstrSize; 140 static const int kInstrSize = Assembler::kInstrSize;
151 ASSERT(Assembler::IsBeq(Assembler::instr_at(pc_after - 5 * kInstrSize))); 141 ASSERT(Assembler::IsBeq(Assembler::instr_at(pc_after - 5 * kInstrSize)));
152 if (Assembler::IsAddImmediate( 142 if (Assembler::IsAddImmediate(
153 Assembler::instr_at(pc_after - 6 * kInstrSize))) { 143 Assembler::instr_at(pc_after - 6 * kInstrSize))) {
144 Code* osr_builtin =
145 isolate->builtins()->builtin(Builtins::kOnStackReplacement);
154 ASSERT(reinterpret_cast<uint32_t>( 146 ASSERT(reinterpret_cast<uint32_t>(
155 Assembler::target_address_at(pc_after - 4 * kInstrSize)) == 147 Assembler::target_address_at(pc_after - 4 * kInstrSize)) ==
156 reinterpret_cast<uint32_t>(replacement_code->entry())); 148 reinterpret_cast<uint32_t>(osr_builtin->entry()));
157 return true; 149 return PATCHED_FOR_OSR;
158 } else { 150 } else {
151 // Get the interrupt stub code object to match against from cache.
152 Code* interrupt_code = NULL;
153 InterruptStub stub;
154 if (!stub.FindCodeInCache(&interrupt_code, isolate)) UNREACHABLE();
159 ASSERT(reinterpret_cast<uint32_t>( 155 ASSERT(reinterpret_cast<uint32_t>(
160 Assembler::target_address_at(pc_after - 4 * kInstrSize)) == 156 Assembler::target_address_at(pc_after - 4 * kInstrSize)) ==
161 reinterpret_cast<uint32_t>(interrupt_code->entry())); 157 reinterpret_cast<uint32_t>(interrupt_code->entry()));
162 return false; 158 return NOT_PATCHED;
163 } 159 }
164 } 160 }
165 #endif // DEBUG 161 #endif // DEBUG
166 162
167 163
168 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) { 164 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) {
169 ByteArray* translations = data->TranslationByteArray(); 165 ByteArray* translations = data->TranslationByteArray();
170 int length = data->DeoptCount(); 166 int length = data->DeoptCount();
171 for (int i = 0; i < length; i++) { 167 for (int i = 0; i < length; i++) {
172 if (data->AstId(i) == ast_id) { 168 if (data->AstId(i) == ast_id) {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 614
619 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { 615 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) {
620 SetFrameSlot(offset, value); 616 SetFrameSlot(offset, value);
621 } 617 }
622 618
623 619
624 #undef __ 620 #undef __
625 621
626 622
627 } } // namespace v8::internal 623 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/deoptimizer-ia32.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698