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

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 118380: Add statistics operations and long calls and jumps to x64 macro assembler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 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/x64/macro-assembler-x64.h ('k') | test/cctest/test-assembler-x64.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 movq(kScratchRegister, Immediate(x)); 113 movq(kScratchRegister, Immediate(x));
114 } else if (is_uint32(x)) { 114 } else if (is_uint32(x)) {
115 movl(kScratchRegister, Immediate(x)); 115 movl(kScratchRegister, Immediate(x));
116 } else { 116 } else {
117 movq(kScratchRegister, x, RelocInfo::NONE); 117 movq(kScratchRegister, x, RelocInfo::NONE);
118 } 118 }
119 movq(dst, kScratchRegister); 119 movq(dst, kScratchRegister);
120 } 120 }
121 121
122 122
123 void MacroAssembler::Jump(ExternalReference ext) {
124 movq(kScratchRegister, ext);
125 jmp(kScratchRegister);
126 }
127
128
129 void MacroAssembler::Jump(Address destination, RelocInfo::Mode rmode) {
130 movq(kScratchRegister, destination, rmode);
131 jmp(kScratchRegister);
132 }
133
134
135 void MacroAssembler::Call(ExternalReference ext) {
136 movq(kScratchRegister, ext);
137 call(kScratchRegister);
138 }
139
140
141 void MacroAssembler::Call(Address destination, RelocInfo::Mode rmode) {
142 movq(kScratchRegister, destination, rmode);
143 call(kScratchRegister);
144 }
145
146
123 void MacroAssembler::PushTryHandler(CodeLocation try_location, 147 void MacroAssembler::PushTryHandler(CodeLocation try_location,
124 HandlerType type) { 148 HandlerType type) {
125 // Adjust this code if not the case. 149 // Adjust this code if not the case.
126 ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); 150 ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
127 151
128 // The pc (return address) is already on TOS. This code pushes state, 152 // The pc (return address) is already on TOS. This code pushes state,
129 // frame pointer and current handler. Check that they are expected 153 // frame pointer and current handler. Check that they are expected
130 // next on the stack, in that order. 154 // next on the stack, in that order.
131 ASSERT_EQ(StackHandlerConstants::kStateOffset, 155 ASSERT_EQ(StackHandlerConstants::kStateOffset,
132 StackHandlerConstants::kPCOffset - kPointerSize); 156 StackHandlerConstants::kPCOffset - kPointerSize);
(...skipping 18 matching lines...) Expand all
151 push(Immediate(0)); // NULL frame pointer. 175 push(Immediate(0)); // NULL frame pointer.
152 } 176 }
153 // Save the current handler. 177 // Save the current handler.
154 movq(kScratchRegister, ExternalReference(Top::k_handler_address)); 178 movq(kScratchRegister, ExternalReference(Top::k_handler_address));
155 push(Operand(kScratchRegister, 0)); 179 push(Operand(kScratchRegister, 0));
156 // Link this handler. 180 // Link this handler.
157 movq(Operand(kScratchRegister, 0), rsp); 181 movq(Operand(kScratchRegister, 0), rsp);
158 } 182 }
159 183
160 184
185 void MacroAssembler::Ret() {
186 ret(0);
187 }
188
189
190 void MacroAssembler::SetCounter(StatsCounter* counter, int value) {
191 if (FLAG_native_code_counters && counter->Enabled()) {
192 movq(kScratchRegister, ExternalReference(counter));
193 movl(Operand(kScratchRegister, 0), Immediate(value));
194 }
195 }
196
197
198 void MacroAssembler::IncrementCounter(StatsCounter* counter, int value) {
199 ASSERT(value > 0);
200 if (FLAG_native_code_counters && counter->Enabled()) {
201 movq(kScratchRegister, ExternalReference(counter));
202 Operand operand(kScratchRegister, 0);
203 if (value == 1) {
204 incl(operand);
205 } else {
206 addl(operand, Immediate(value));
207 }
208 }
209 }
210
211
212 void MacroAssembler::DecrementCounter(StatsCounter* counter, int value) {
213 ASSERT(value > 0);
214 if (FLAG_native_code_counters && counter->Enabled()) {
215 movq(kScratchRegister, ExternalReference(counter));
216 Operand operand(kScratchRegister, 0);
217 if (value == 1) {
218 decl(operand);
219 } else {
220 subl(operand, Immediate(value));
221 }
222 }
223 }
224
225
161 #ifdef ENABLE_DEBUGGER_SUPPORT 226 #ifdef ENABLE_DEBUGGER_SUPPORT
162 227
163 void MacroAssembler::PushRegistersFromMemory(RegList regs) { 228 void MacroAssembler::PushRegistersFromMemory(RegList regs) {
164 ASSERT((regs & ~kJSCallerSaved) == 0); 229 ASSERT((regs & ~kJSCallerSaved) == 0);
165 // Push the content of the memory location to the stack. 230 // Push the content of the memory location to the stack.
166 for (int i = 0; i < kNumJSCallerSaved; i++) { 231 for (int i = 0; i < kNumJSCallerSaved; i++) {
167 int r = JSCallerSavedCode(i); 232 int r = JSCallerSavedCode(i);
168 if ((regs & (1 << r)) != 0) { 233 if ((regs & (1 << r)) != 0) {
169 ExternalReference reg_addr = 234 ExternalReference reg_addr =
170 ExternalReference(Debug_Address::Register(i)); 235 ExternalReference(Debug_Address::Register(i));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 push(rbp); 323 push(rbp);
259 movq(rbp, rsp); 324 movq(rbp, rsp);
260 push(rsi); // Context. 325 push(rsi); // Context.
261 push(Immediate(Smi::FromInt(type))); 326 push(Immediate(Smi::FromInt(type)));
262 movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT); 327 movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT);
263 push(kScratchRegister); 328 push(kScratchRegister);
264 if (FLAG_debug_code) { 329 if (FLAG_debug_code) {
265 movq(kScratchRegister, 330 movq(kScratchRegister,
266 Factory::undefined_value(), 331 Factory::undefined_value(),
267 RelocInfo::EMBEDDED_OBJECT); 332 RelocInfo::EMBEDDED_OBJECT);
268 cmp(Operand(rsp, 0), kScratchRegister); 333 cmpq(Operand(rsp, 0), kScratchRegister);
269 Check(not_equal, "code object not properly patched"); 334 Check(not_equal, "code object not properly patched");
270 } 335 }
271 } 336 }
272 337
273 338
274 void MacroAssembler::LeaveFrame(StackFrame::Type type) { 339 void MacroAssembler::LeaveFrame(StackFrame::Type type) {
275 if (FLAG_debug_code) { 340 if (FLAG_debug_code) {
276 movq(kScratchRegister, Immediate(Smi::FromInt(type))); 341 movq(kScratchRegister, Immediate(Smi::FromInt(type)));
277 cmp(Operand(rbp, StandardFrameConstants::kMarkerOffset), kScratchRegister); 342 cmpq(Operand(rbp, StandardFrameConstants::kMarkerOffset), kScratchRegister);
278 Check(equal, "stack frame types must match"); 343 Check(equal, "stack frame types must match");
279 } 344 }
280 movq(rsp, rbp); 345 movq(rsp, rbp);
281 pop(rbp); 346 pop(rbp);
282 } 347 }
283 348
284 349
285 350
286 void MacroAssembler::EnterExitFrame(StackFrame::Type type) { 351 void MacroAssembler::EnterExitFrame(StackFrame::Type type) {
287 ASSERT(type == StackFrame::EXIT || type == StackFrame::EXIT_DEBUG); 352 ASSERT(type == StackFrame::EXIT || type == StackFrame::EXIT_DEBUG);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // CopyRegistersFromStackToMemory() but it isn't! esp is assumed 386 // CopyRegistersFromStackToMemory() but it isn't! esp is assumed
322 // correct here, but computed for the other call. Very error 387 // correct here, but computed for the other call. Very error
323 // prone! FIX THIS. Actually there are deeper problems with 388 // prone! FIX THIS. Actually there are deeper problems with
324 // register saving than this asymmetry (see the bug report 389 // register saving than this asymmetry (see the bug report
325 // associated with this issue). 390 // associated with this issue).
326 PushRegistersFromMemory(kJSCallerSaved); 391 PushRegistersFromMemory(kJSCallerSaved);
327 } 392 }
328 #endif 393 #endif
329 394
330 // Reserve space for two arguments: argc and argv. 395 // Reserve space for two arguments: argc and argv.
331 sub(rsp, Immediate(2 * kPointerSize)); 396 subq(rsp, Immediate(2 * kPointerSize));
332 397
333 // Get the required frame alignment for the OS. 398 // Get the required frame alignment for the OS.
334 static const int kFrameAlignment = OS::ActivationFrameAlignment(); 399 static const int kFrameAlignment = OS::ActivationFrameAlignment();
335 if (kFrameAlignment > 0) { 400 if (kFrameAlignment > 0) {
336 ASSERT(IsPowerOf2(kFrameAlignment)); 401 ASSERT(IsPowerOf2(kFrameAlignment));
337 movq(r10, Immediate(-kFrameAlignment)); 402 movq(r10, Immediate(-kFrameAlignment));
338 and_(rsp, r10); 403 and_(rsp, r10);
339 } 404 }
340 405
341 // Patch the saved entry sp. 406 // Patch the saved entry sp.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 push(rcx); 441 push(rcx);
377 442
378 // Clear the top frame. 443 // Clear the top frame.
379 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); 444 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address);
380 movq(kScratchRegister, c_entry_fp_address); 445 movq(kScratchRegister, c_entry_fp_address);
381 movq(Operand(kScratchRegister, 0), Immediate(0)); 446 movq(Operand(kScratchRegister, 0), Immediate(0));
382 } 447 }
383 448
384 449
385 } } // namespace v8::internal 450 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | test/cctest/test-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698