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

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

Issue 900223006: [ia32] Assembler support for internal references. (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/ia32/disasm-ia32.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 Handle<Code> code = isolate->factory()->NewCode( 1036 Handle<Code> code = isolate->factory()->NewCode(
1037 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1037 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1038 #ifdef OBJECT_PRINT 1038 #ifdef OBJECT_PRINT
1039 OFStream os(stdout); 1039 OFStream os(stdout);
1040 code->Print(os); 1040 code->Print(os);
1041 #endif 1041 #endif
1042 1042
1043 F10 f = FUNCTION_CAST<F10>(code->entry()); 1043 F10 f = FUNCTION_CAST<F10>(code->entry());
1044 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f)); 1044 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f));
1045 } 1045 }
1046
1047
1048 TEST(AssemblerIa32JumpTables1) {
1049 // Test jump tables with forward jumps.
1050 CcTest::InitializeVM();
1051 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1052 HandleScope scope(isolate);
1053 Assembler assm(isolate, nullptr, 0);
1054
1055 const int kNumCases = 512;
1056 int values[kNumCases];
1057 isolate->random_number_generator()->NextBytes(values, sizeof(values));
1058 Label labels[kNumCases];
1059
1060 Label done, table;
1061 __ mov(eax, Operand(esp, 4));
1062 __ jmp(Operand::JumpTable(eax, times_4, &table));
1063 __ ud2();
1064 __ bind(&table);
1065 for (int i = 0; i < kNumCases; ++i) {
1066 __ dd(&labels[i]);
1067 }
1068
1069 for (int i = 0; i < kNumCases; ++i) {
1070 __ bind(&labels[i]);
1071 __ mov(eax, Immediate(values[i]));
1072 __ jmp(&done);
1073 }
1074
1075 __ bind(&done);
1076 __ ret(0);
1077
1078 CodeDesc desc;
1079 assm.GetCode(&desc);
1080 Handle<Code> code = isolate->factory()->NewCode(
1081 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1082 #ifdef OBJECT_PRINT
1083 OFStream os(stdout);
1084 code->Print(os);
1085 #endif
1086 F1 f = FUNCTION_CAST<F1>(code->entry());
1087 for (int i = 0; i < kNumCases; ++i) {
1088 int res = f(i);
1089 ::printf("f(%d) = %d\n", i, res);
1090 CHECK_EQ(values[i], res);
1091 }
1092 }
1093
1094
1095 TEST(AssemblerIa32JumpTables2) {
1096 // Test jump tables with backward jumps.
1097 CcTest::InitializeVM();
1098 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1099 HandleScope scope(isolate);
1100 Assembler assm(isolate, nullptr, 0);
1101
1102 const int kNumCases = 512;
1103 int values[kNumCases];
1104 isolate->random_number_generator()->NextBytes(values, sizeof(values));
1105 Label labels[kNumCases];
1106
1107 Label done, table;
1108 __ mov(eax, Operand(esp, 4));
1109 __ jmp(Operand::JumpTable(eax, times_4, &table));
1110 __ ud2();
1111
1112 for (int i = 0; i < kNumCases; ++i) {
1113 __ bind(&labels[i]);
1114 __ mov(eax, Immediate(values[i]));
1115 __ jmp(&done);
1116 }
1117
1118 __ bind(&table);
1119 for (int i = 0; i < kNumCases; ++i) {
1120 __ dd(&labels[i]);
1121 }
1122
1123 __ bind(&done);
1124 __ ret(0);
1125
1126 CodeDesc desc;
1127 assm.GetCode(&desc);
1128 Handle<Code> code = isolate->factory()->NewCode(
1129 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1130 #ifdef OBJECT_PRINT
1131 OFStream os(stdout);
1132 code->Print(os);
1133 #endif
1134 F1 f = FUNCTION_CAST<F1>(code->entry());
1135 for (int i = 0; i < kNumCases; ++i) {
1136 int res = f(i);
1137 ::printf("f(%d) = %d\n", i, res);
1138 CHECK_EQ(values[i], res);
1139 }
1140 }
1141
1046 #undef __ 1142 #undef __
OLDNEW
« no previous file with comments | « src/ia32/disasm-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698