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

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

Issue 11437016: Use count-based profiling exclusively. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments Created 8 years 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 | « no previous file | src/arm/full-codegen-arm.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 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 ReplaceCodeForRelatedFunctions(function, code); 107 ReplaceCodeForRelatedFunctions(function, code);
108 108
109 if (FLAG_trace_deopt) { 109 if (FLAG_trace_deopt) {
110 PrintF("[forced deoptimization: "); 110 PrintF("[forced deoptimization: ");
111 function->PrintName(); 111 function->PrintName();
112 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); 112 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function));
113 } 113 }
114 } 114 }
115 115
116 116
117 static const int32_t kBranchBeforeStackCheck = 0x2a000001;
118 static const int32_t kBranchBeforeInterrupt = 0x5a000004; 117 static const int32_t kBranchBeforeInterrupt = 0x5a000004;
119 118
120 119
121 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code, 120 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code,
122 Address pc_after, 121 Address pc_after,
123 Code* check_code, 122 Code* check_code,
124 Code* replacement_code) { 123 Code* replacement_code) {
125 const int kInstrSize = Assembler::kInstrSize; 124 const int kInstrSize = Assembler::kInstrSize;
126 // The call of the stack guard check has the following form: 125 // The back edge bookkeeping code matches the pattern:
127 // e1 5d 00 0c cmp sp, <limit> 126 //
128 // 2a 00 00 01 bcs ok 127 // <decrement profiling counter>
128 // 2a 00 00 01 bpl ok
129 // e5 9f c? ?? ldr ip, [pc, <stack guard address>] 129 // e5 9f c? ?? ldr ip, [pc, <stack guard address>]
130 // e1 2f ff 3c blx ip 130 // e1 2f ff 3c blx ip
131 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp); 131 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp);
132 ASSERT(Assembler::IsLdrPcImmediateOffset( 132 ASSERT(Assembler::IsLdrPcImmediateOffset(
133 Assembler::instr_at(pc_after - 2 * kInstrSize))); 133 Assembler::instr_at(pc_after - 2 * kInstrSize)));
134 if (FLAG_count_based_interrupts) { 134 ASSERT_EQ(kBranchBeforeInterrupt,
135 ASSERT_EQ(kBranchBeforeInterrupt, 135 Memory::int32_at(pc_after - 3 * kInstrSize));
136 Memory::int32_at(pc_after - 3 * kInstrSize));
137 } else {
138 ASSERT_EQ(kBranchBeforeStackCheck,
139 Memory::int32_at(pc_after - 3 * kInstrSize));
140 }
141 136
142 // We patch the code to the following form: 137 // We patch the code to the following form:
143 // e1 5d 00 0c cmp sp, <limit> 138 //
139 // <decrement profiling counter>
144 // e1 a0 00 00 mov r0, r0 (NOP) 140 // e1 a0 00 00 mov r0, r0 (NOP)
145 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>] 141 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>]
146 // e1 2f ff 3c blx ip 142 // e1 2f ff 3c blx ip
147 // and overwrite the constant containing the 143 // and overwrite the constant containing the
148 // address of the stack check stub. 144 // address of the stack check stub.
149 145
150 // Replace conditional jump with NOP. 146 // Replace conditional jump with NOP.
151 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); 147 CodePatcher patcher(pc_after - 3 * kInstrSize, 1);
152 patcher.masm()->nop(); 148 patcher.masm()->nop();
153 149
(...skipping 16 matching lines...) Expand all
170 Address pc_after, 166 Address pc_after,
171 Code* check_code, 167 Code* check_code,
172 Code* replacement_code) { 168 Code* replacement_code) {
173 const int kInstrSize = Assembler::kInstrSize; 169 const int kInstrSize = Assembler::kInstrSize;
174 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp); 170 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp);
175 ASSERT(Assembler::IsLdrPcImmediateOffset( 171 ASSERT(Assembler::IsLdrPcImmediateOffset(
176 Assembler::instr_at(pc_after - 2 * kInstrSize))); 172 Assembler::instr_at(pc_after - 2 * kInstrSize)));
177 173
178 // Replace NOP with conditional jump. 174 // Replace NOP with conditional jump.
179 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); 175 CodePatcher patcher(pc_after - 3 * kInstrSize, 1);
180 if (FLAG_count_based_interrupts) { 176 patcher.masm()->b(+16, pl);
181 patcher.masm()->b(+16, pl); 177 ASSERT_EQ(kBranchBeforeInterrupt,
182 ASSERT_EQ(kBranchBeforeInterrupt, 178 Memory::int32_at(pc_after - 3 * kInstrSize));
183 Memory::int32_at(pc_after - 3 * kInstrSize));
184 } else {
185 patcher.masm()->b(+4, cs);
186 ASSERT_EQ(kBranchBeforeStackCheck,
187 Memory::int32_at(pc_after - 3 * kInstrSize));
188 }
189 179
190 // Replace the stack check address in the constant pool 180 // Replace the stack check address in the constant pool
191 // with the entry address of the replacement code. 181 // with the entry address of the replacement code.
192 uint32_t stack_check_address_offset = Memory::uint16_at(pc_after - 182 uint32_t stack_check_address_offset = Memory::uint16_at(pc_after -
193 2 * kInstrSize) & 0xfff; 183 2 * kInstrSize) & 0xfff;
194 Address stack_check_address_pointer = pc_after + stack_check_address_offset; 184 Address stack_check_address_pointer = pc_after + stack_check_address_offset;
195 ASSERT(Memory::uint32_at(stack_check_address_pointer) == 185 ASSERT(Memory::uint32_at(stack_check_address_pointer) ==
196 reinterpret_cast<uint32_t>(replacement_code->entry())); 186 reinterpret_cast<uint32_t>(replacement_code->entry()));
197 Memory::uint32_at(stack_check_address_pointer) = 187 Memory::uint32_at(stack_check_address_pointer) =
198 reinterpret_cast<uint32_t>(check_code->entry()); 188 reinterpret_cast<uint32_t>(check_code->entry());
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 __ push(ip); 1180 __ push(ip);
1191 __ b(&done); 1181 __ b(&done);
1192 ASSERT(masm()->pc_offset() - start == table_entry_size_); 1182 ASSERT(masm()->pc_offset() - start == table_entry_size_);
1193 } 1183 }
1194 __ bind(&done); 1184 __ bind(&done);
1195 } 1185 }
1196 1186
1197 #undef __ 1187 #undef __
1198 1188
1199 } } // namespace v8::internal 1189 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698