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

Side by Side Diff: test/cctest/test-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.cc ('k') | no next file » | 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // Allocate an executable page of memory. 125 // Allocate an executable page of memory.
126 size_t actual_size; 126 size_t actual_size;
127 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 127 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
128 &actual_size, 128 &actual_size,
129 true)); 129 true));
130 CHECK(buffer); 130 CHECK(buffer);
131 Assembler assm(buffer, actual_size); 131 Assembler assm(buffer, actual_size);
132 132
133 // Assemble a simple function that copies argument 2 and returns it. 133 // Assemble a simple function that copies argument 2 and returns it.
134 __ movq(rax, rsi); 134 __ movq(rax, rsi);
135 __ add(rax, rdi); 135 __ addq(rax, rdi);
136 __ ret(0); 136 __ ret(0);
137 137
138 CodeDesc desc; 138 CodeDesc desc;
139 assm.GetCode(&desc); 139 assm.GetCode(&desc);
140 // Call the function from C++. 140 // Call the function from C++.
141 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 141 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
142 CHECK_EQ(5, result); 142 CHECK_EQ(5, result);
143 } 143 }
144 144
145 TEST(AssemblerX64MemoryOperands) { 145 TEST(AssemblerX64MemoryOperands) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 true)); 208 true));
209 CHECK(buffer); 209 CHECK(buffer);
210 Assembler assm(buffer, actual_size); 210 Assembler assm(buffer, actual_size);
211 // Assemble two loops using rax as counter, and verify the ending counts. 211 // Assemble two loops using rax as counter, and verify the ending counts.
212 Label Fail; 212 Label Fail;
213 __ movq(rax, Immediate(-3)); 213 __ movq(rax, Immediate(-3));
214 Label Loop1_test; 214 Label Loop1_test;
215 Label Loop1_body; 215 Label Loop1_body;
216 __ jmp(&Loop1_test); 216 __ jmp(&Loop1_test);
217 __ bind(&Loop1_body); 217 __ bind(&Loop1_body);
218 __ add(rax, Immediate(7)); 218 __ addq(rax, Immediate(7));
219 __ bind(&Loop1_test); 219 __ bind(&Loop1_test);
220 __ cmp(rax, Immediate(20)); 220 __ cmpq(rax, Immediate(20));
221 __ j(less_equal, &Loop1_body); 221 __ j(less_equal, &Loop1_body);
222 // Did the loop terminate with the expected value? 222 // Did the loop terminate with the expected value?
223 __ cmp(rax, Immediate(25)); 223 __ cmpq(rax, Immediate(25));
224 __ j(not_equal, &Fail); 224 __ j(not_equal, &Fail);
225 225
226 Label Loop2_test; 226 Label Loop2_test;
227 Label Loop2_body; 227 Label Loop2_body;
228 __ movq(rax, Immediate(0x11FEED00)); 228 __ movq(rax, Immediate(0x11FEED00));
229 __ jmp(&Loop2_test); 229 __ jmp(&Loop2_test);
230 __ bind(&Loop2_body); 230 __ bind(&Loop2_body);
231 __ add(rax, Immediate(-0x1100)); 231 __ addq(rax, Immediate(-0x1100));
232 __ bind(&Loop2_test); 232 __ bind(&Loop2_test);
233 __ cmp(rax, Immediate(0x11FE8000)); 233 __ cmpq(rax, Immediate(0x11FE8000));
234 __ j(greater, &Loop2_body); 234 __ j(greater, &Loop2_body);
235 // Did the loop terminate with the expected value? 235 // Did the loop terminate with the expected value?
236 __ cmp(rax, Immediate(0x11FE7600)); 236 __ cmpq(rax, Immediate(0x11FE7600));
237 __ j(not_equal, &Fail); 237 __ j(not_equal, &Fail);
238 238
239 __ movq(rax, Immediate(1)); 239 __ movq(rax, Immediate(1));
240 __ ret(0); 240 __ ret(0);
241 __ bind(&Fail); 241 __ bind(&Fail);
242 __ movq(rax, Immediate(0)); 242 __ movq(rax, Immediate(0));
243 __ ret(0); 243 __ ret(0);
244 244
245 CodeDesc desc; 245 CodeDesc desc;
246 assm.GetCode(&desc); 246 assm.GetCode(&desc);
247 // Call the function from C++. 247 // Call the function from C++.
248 int result = FUNCTION_CAST<F0>(buffer)(); 248 int result = FUNCTION_CAST<F0>(buffer)();
249 CHECK_EQ(1, result); 249 CHECK_EQ(1, result);
250 } 250 }
251 251
252 #undef __ 252 #undef __
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698