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

Side by Side Diff: test/cctest/test-assembler-x64.cc

Issue 113841: Implement memory operands for instructions in the x64 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/assembler-x64-inl.h ('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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 true)); 146 true));
147 CHECK(buffer); 147 CHECK(buffer);
148 Assembler assm(buffer, actual_size); 148 Assembler assm(buffer, actual_size);
149 149
150 // Assemble a simple function that copies argument 2 and returns it. 150 // Assemble a simple function that copies argument 2 and returns it.
151 __ push(rbp); 151 __ push(rbp);
152 __ mov(rbp, rsp); 152 __ mov(rbp, rsp);
153 __ push(rsi); // Value at (rbp - 8) 153 __ push(rsi); // Value at (rbp - 8)
154 __ push(rsi); // Value at (rbp - 16) 154 __ push(rsi); // Value at (rbp - 16)
155 __ push(rdi); // Value at (rbp - 24) 155 __ push(rdi); // Value at (rbp - 24)
156 // const int kStackElementSize = 8; 156 const int kStackElementSize = 8;
157 // __ mov(rax, Operand(rbp,-3 * kStackElementSize)); 157 __ mov(rax, Operand(rbp, -3 * kStackElementSize));
158 __ pop(rax); 158 __ pop(rsi);
159 __ pop(rax); 159 __ pop(rsi);
160 __ pop(rax); 160 __ pop(rsi);
161 __ pop(rbp); 161 __ pop(rbp);
162 __ nop(); 162 __ nop();
163 __ ret(0); 163 __ ret(0);
164 164
165 CodeDesc desc; 165 CodeDesc desc;
166 assm.GetCode(&desc); 166 assm.GetCode(&desc);
167 // Call the function from C++. 167 // Call the function from C++.
168 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 168 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
169 CHECK_EQ(2, result); 169 CHECK_EQ(3, result);
170 } 170 }
171 171
172 TEST(AssemblerX64ControlFlow) { 172 TEST(AssemblerX64ControlFlow) {
173 // Allocate an executable page of memory. 173 // Allocate an executable page of memory.
174 size_t actual_size; 174 size_t actual_size;
175 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 175 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
176 &actual_size, 176 &actual_size,
177 true)); 177 true));
178 CHECK(buffer); 178 CHECK(buffer);
179 Assembler assm(buffer, actual_size); 179 Assembler assm(buffer, actual_size);
(...skipping 10 matching lines...) Expand all
190 __ ret(0); 190 __ ret(0);
191 191
192 CodeDesc desc; 192 CodeDesc desc;
193 assm.GetCode(&desc); 193 assm.GetCode(&desc);
194 // Call the function from C++. 194 // Call the function from C++.
195 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 195 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
196 CHECK_EQ(3, result); 196 CHECK_EQ(3, result);
197 } 197 }
198 198
199 #undef __ 199 #undef __
OLDNEW
« no previous file with comments | « src/x64/assembler-x64-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698