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

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

Issue 9837004: Port count-based profiler to ARM (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 8 years, 9 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/arm/assembler-arm.cc ('k') | 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 function->ReplaceCode(function->shared()->code()); 101 function->ReplaceCode(function->shared()->code());
102 102
103 if (FLAG_trace_deopt) { 103 if (FLAG_trace_deopt) {
104 PrintF("[forced deoptimization: "); 104 PrintF("[forced deoptimization: ");
105 function->PrintName(); 105 function->PrintName();
106 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); 106 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function));
107 } 107 }
108 } 108 }
109 109
110 110
111 static const int32_t kBranchBeforeStackCheck = 0x2a000001;
112 static const int32_t kBranchBeforeInterrupt = 0x5a000004;
113
114
111 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code, 115 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code,
112 Address pc_after, 116 Address pc_after,
113 Code* check_code, 117 Code* check_code,
114 Code* replacement_code) { 118 Code* replacement_code) {
115 const int kInstrSize = Assembler::kInstrSize; 119 const int kInstrSize = Assembler::kInstrSize;
116 // The call of the stack guard check has the following form: 120 // The call of the stack guard check has the following form:
117 // e1 5d 00 0c cmp sp, <limit> 121 // e1 5d 00 0c cmp sp, <limit>
118 // 2a 00 00 01 bcs ok 122 // 2a 00 00 01 bcs ok
119 // e5 9f c? ?? ldr ip, [pc, <stack guard address>] 123 // e5 9f c? ?? ldr ip, [pc, <stack guard address>]
120 // e1 2f ff 3c blx ip 124 // e1 2f ff 3c blx ip
121 ASSERT(Memory::int32_at(pc_after - kInstrSize) == 125 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp);
122 (al | B24 | B21 | 15*B16 | 15*B12 | 15*B8 | BLX | ip.code()));
123 ASSERT(Assembler::IsLdrPcImmediateOffset( 126 ASSERT(Assembler::IsLdrPcImmediateOffset(
124 Assembler::instr_at(pc_after - 2 * kInstrSize))); 127 Assembler::instr_at(pc_after - 2 * kInstrSize)));
128 if (FLAG_count_based_interrupts) {
129 ASSERT_EQ(kBranchBeforeInterrupt,
130 Memory::int32_at(pc_after - 3 * kInstrSize));
131 } else {
132 ASSERT_EQ(kBranchBeforeStackCheck,
133 Memory::int32_at(pc_after - 3 * kInstrSize));
134 }
125 135
126 // We patch the code to the following form: 136 // We patch the code to the following form:
127 // e1 5d 00 0c cmp sp, <limit> 137 // e1 5d 00 0c cmp sp, <limit>
128 // e1 a0 00 00 mov r0, r0 (NOP) 138 // e1 a0 00 00 mov r0, r0 (NOP)
129 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>] 139 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>]
130 // e1 2f ff 3c blx ip 140 // e1 2f ff 3c blx ip
131 // and overwrite the constant containing the 141 // and overwrite the constant containing the
132 // address of the stack check stub. 142 // address of the stack check stub.
133 143
134 // Replace conditional jump with NOP. 144 // Replace conditional jump with NOP.
(...skipping 13 matching lines...) Expand all
148 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( 158 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch(
149 unoptimized_code, pc_after - 2 * kInstrSize, replacement_code); 159 unoptimized_code, pc_after - 2 * kInstrSize, replacement_code);
150 } 160 }
151 161
152 162
153 void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code, 163 void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code,
154 Address pc_after, 164 Address pc_after,
155 Code* check_code, 165 Code* check_code,
156 Code* replacement_code) { 166 Code* replacement_code) {
157 const int kInstrSize = Assembler::kInstrSize; 167 const int kInstrSize = Assembler::kInstrSize;
158 ASSERT(Memory::uint32_at(pc_after - kInstrSize) == 0xe12fff3c); 168 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp);
159 ASSERT(Memory::uint8_at(pc_after - kInstrSize - 1) == 0xe5); 169 ASSERT(Assembler::IsLdrPcImmediateOffset(
160 ASSERT(Memory::uint8_at(pc_after - kInstrSize - 2) == 0x9f); 170 Assembler::instr_at(pc_after - 2 * kInstrSize)));
161 171
162 // Replace NOP with conditional jump. 172 // Replace NOP with conditional jump.
163 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); 173 CodePatcher patcher(pc_after - 3 * kInstrSize, 1);
164 patcher.masm()->b(+4, cs); 174 if (FLAG_count_based_interrupts) {
175 patcher.masm()->b(+16, pl);
176 ASSERT_EQ(kBranchBeforeInterrupt,
177 Memory::int32_at(pc_after - 3 * kInstrSize));
178 } else {
179 patcher.masm()->b(+4, cs);
180 ASSERT_EQ(kBranchBeforeStackCheck,
181 Memory::int32_at(pc_after - 3 * kInstrSize));
182 }
165 183
166 // Replace the stack check address in the constant pool 184 // Replace the stack check address in the constant pool
167 // with the entry address of the replacement code. 185 // with the entry address of the replacement code.
168 uint32_t stack_check_address_offset = Memory::uint16_at(pc_after - 186 uint32_t stack_check_address_offset = Memory::uint16_at(pc_after -
169 2 * kInstrSize) & 0xfff; 187 2 * kInstrSize) & 0xfff;
170 Address stack_check_address_pointer = pc_after + stack_check_address_offset; 188 Address stack_check_address_pointer = pc_after + stack_check_address_offset;
171 ASSERT(Memory::uint32_at(stack_check_address_pointer) == 189 ASSERT(Memory::uint32_at(stack_check_address_pointer) ==
172 reinterpret_cast<uint32_t>(replacement_code->entry())); 190 reinterpret_cast<uint32_t>(replacement_code->entry()));
173 Memory::uint32_at(stack_check_address_pointer) = 191 Memory::uint32_at(stack_check_address_pointer) =
174 reinterpret_cast<uint32_t>(check_code->entry()); 192 reinterpret_cast<uint32_t>(check_code->entry());
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 __ push(ip); 969 __ push(ip);
952 __ b(&done); 970 __ b(&done);
953 ASSERT(masm()->pc_offset() - start == table_entry_size_); 971 ASSERT(masm()->pc_offset() - start == table_entry_size_);
954 } 972 }
955 __ bind(&done); 973 __ bind(&done);
956 } 974 }
957 975
958 #undef __ 976 #undef __
959 977
960 } } // namespace v8::internal 978 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/assembler-arm.cc ('k') | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698