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

Side by Side Diff: runtime/vm/code_patcher_ia32.cc

Issue 829133006: VM: Small generated code size improvements on x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 uword call_address() const { 143 uword call_address() const {
144 return start_; 144 return start_;
145 } 145 }
146 146
147 uword start_; 147 uword start_;
148 148
149 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); 149 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall);
150 }; 150 };
151 151
152 152
153 // The expected pattern of a Dart closure call:
154 // mov EDX, arguments_descriptor_array
155 // call target_address
156 // <- return address
157 class ClosureCall : public ValueObject {
158 public:
159 explicit ClosureCall(uword return_address)
160 : start_(return_address - (kInstr1Size + kInstr2Size)) {
161 ASSERT(IsValid(return_address));
162 ASSERT(kInstr2Size == Assembler::kCallExternalLabelSize);
163 }
164
165 static bool IsValid(uword return_address) {
166 uint8_t* code_bytes = reinterpret_cast<uint8_t*>(
167 return_address - (kInstr1Size + kInstr2Size));
168 return (code_bytes[0] == 0xBA) && (code_bytes[kInstr1Size] == 0xE8);
169 }
170
171 RawArray* arguments_descriptor() const {
172 return *reinterpret_cast<RawArray**>(start_ + 1);
173 }
174
175 private:
176 static const int kInstr1Size = 5; // mov EDX, arguments descriptor array
177 static const int kInstr2Size = 5; // call stub
178
179 uword return_address() const {
180 return start_ + kInstr1Size + kInstr2Size;
181 }
182 uword call_address() const { return start_; }
183
184 uword start_;
185 DISALLOW_IMPLICIT_CONSTRUCTORS(ClosureCall);
186 };
187
188
189
190 RawArray* CodePatcher::GetClosureArgDescAt(uword return_address,
191 const Code& code) {
192 ASSERT(code.ContainsInstructionAt(return_address));
193 ClosureCall call(return_address);
194 return call.arguments_descriptor();
195 }
196
197
198 uword CodePatcher::GetStaticCallTargetAt(uword return_address, 153 uword CodePatcher::GetStaticCallTargetAt(uword return_address,
199 const Code& code) { 154 const Code& code) {
200 ASSERT(code.ContainsInstructionAt(return_address)); 155 ASSERT(code.ContainsInstructionAt(return_address));
201 StaticCall call(return_address); 156 StaticCall call(return_address);
202 return call.target(); 157 return call.target();
203 } 158 }
204 159
205 160
206 void CodePatcher::PatchStaticCallAt(uword return_address, 161 void CodePatcher::PatchStaticCallAt(uword return_address,
207 const Code& code, 162 const Code& code,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 250
296 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { 251 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
297 ASSERT(code.ContainsInstructionAt(pc)); 252 ASSERT(code.ContainsInstructionAt(pc));
298 EdgeCounter counter(pc, code); 253 EdgeCounter counter(pc, code);
299 return counter.edge_counter(); 254 return counter.edge_counter();
300 } 255 }
301 256
302 } // namespace dart 257 } // namespace dart
303 258
304 #endif // defined TARGET_ARCH_IA32 259 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698