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

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

Issue 887013003: [x64] Assembler support for internal references and RIP relative addressing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/x64/disasm-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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <cstdlib>
29 #include <iostream>
29 30
30 #include "src/v8.h" 31 #include "src/v8.h"
31 32
32 #include "src/base/platform/platform.h" 33 #include "src/base/platform/platform.h"
33 #include "src/factory.h" 34 #include "src/factory.h"
34 #include "src/macro-assembler.h" 35 #include "src/macro-assembler.h"
35 #include "src/ostreams.h" 36 #include "src/ostreams.h"
36 #include "src/serialize.h" 37 #include "src/serialize.h"
37 #include "test/cctest/cctest.h" 38 #include "test/cctest/cctest.h"
38 39
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 Handle<Code> code = isolate->factory()->NewCode( 1180 Handle<Code> code = isolate->factory()->NewCode(
1180 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1181 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1181 #ifdef OBJECT_PRINT 1182 #ifdef OBJECT_PRINT
1182 OFStream os(stdout); 1183 OFStream os(stdout);
1183 code->Print(os); 1184 code->Print(os);
1184 #endif 1185 #endif
1185 1186
1186 F8 f = FUNCTION_CAST<F8>(code->entry()); 1187 F8 f = FUNCTION_CAST<F8>(code->entry());
1187 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f)); 1188 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f));
1188 } 1189 }
1190
1191
1192 TEST(AssemblerX64JumpTables1) {
1193 // Test jump tables with forward jumps.
1194 CcTest::InitializeVM();
1195 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1196 HandleScope scope(isolate);
1197 MacroAssembler assm(isolate, nullptr, 0);
1198
1199 const int kNumCases = 512;
1200 int values[kNumCases];
1201 isolate->random_number_generator()->NextBytes(values, sizeof(values));
1202 Label labels[kNumCases];
1203
1204 Label done, table;
1205 __ leaq(arg2, Operand(&table));
1206 __ jmp(Operand(arg2, arg1, times_8, 0));
1207 __ ud2();
1208 __ bind(&table);
1209 for (int i = 0; i < kNumCases; ++i) {
1210 __ dq(&labels[i]);
1211 }
1212
1213 for (int i = 0; i < kNumCases; ++i) {
1214 __ bind(&labels[i]);
1215 __ movq(rax, Immediate(values[i]));
1216 __ jmp(&done);
1217 }
1218
1219 __ bind(&done);
1220 __ ret(0);
1221
1222 CodeDesc desc;
1223 assm.GetCode(&desc);
1224 Handle<Code> code = isolate->factory()->NewCode(
1225 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1226 #ifdef OBJECT_PRINT
1227 code->Print(std::cout);
1228 #endif
1229
1230 F1 f = FUNCTION_CAST<F1>(code->entry());
1231 for (int i = 0; i < kNumCases; ++i) {
1232 int res = f(i);
1233 PrintF("f(%d) = %d\n", i, res);
1234 CHECK_EQ(values[i], res);
1235 }
1236 }
1237
1238
1239 TEST(AssemblerX64JumpTables2) {
1240 // Test jump tables with backwards jumps.
1241 CcTest::InitializeVM();
1242 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1243 HandleScope scope(isolate);
1244 MacroAssembler assm(isolate, nullptr, 0);
1245
1246 const int kNumCases = 512;
1247 int values[kNumCases];
1248 isolate->random_number_generator()->NextBytes(values, sizeof(values));
1249 Label labels[kNumCases];
1250
1251 Label done, table;
1252 __ leaq(arg2, Operand(&table));
1253 __ jmp(Operand(arg2, arg1, times_8, 0));
1254 __ ud2();
1255
1256 for (int i = 0; i < kNumCases; ++i) {
1257 __ bind(&labels[i]);
1258 __ movq(rax, Immediate(values[i]));
1259 __ jmp(&done);
1260 }
1261
1262 __ bind(&done);
1263 __ ret(0);
1264
1265 __ bind(&table);
1266 for (int i = 0; i < kNumCases; ++i) {
1267 __ dq(&labels[i]);
1268 }
1269
1270 CodeDesc desc;
1271 assm.GetCode(&desc);
1272 Handle<Code> code = isolate->factory()->NewCode(
1273 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1274 #ifdef OBJECT_PRINT
1275 code->Print(std::cout);
1276 #endif
1277
1278 F1 f = FUNCTION_CAST<F1>(code->entry());
1279 for (int i = 0; i < kNumCases; ++i) {
1280 int res = f(i);
1281 PrintF("f(%d) = %d\n", i, res);
1282 CHECK_EQ(values[i], res);
1283 }
1284 }
1285
1189 #undef __ 1286 #undef __
OLDNEW
« no previous file with comments | « src/x64/disasm-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698