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

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 13841003: Separate Math Lithium operations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 7 years, 8 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/ia32/lithium-ia32.h ('k') | src/mips/lithium-codegen-mips.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 base_object()->PrintTo(stream); 313 base_object()->PrintTo(stream);
314 stream->Add(" + %d", offset()); 314 stream->Add(" + %d", offset());
315 } 315 }
316 316
317 317
318 void LCallConstantFunction::PrintDataTo(StringStream* stream) { 318 void LCallConstantFunction::PrintDataTo(StringStream* stream) {
319 stream->Add("#%d / ", arity()); 319 stream->Add("#%d / ", arity());
320 } 320 }
321 321
322 322
323 void LUnaryMathOperation::PrintDataTo(StringStream* stream) {
324 stream->Add("/%s ", hydrogen()->OpName());
325 value()->PrintTo(stream);
326 }
327
328
329 void LMathExp::PrintDataTo(StringStream* stream) {
330 value()->PrintTo(stream);
331 }
332
333
334 void LMathPowHalf::PrintDataTo(StringStream* stream) {
335 stream->Add("/pow_half ");
336 value()->PrintTo(stream);
337 }
338
339
340 void LMathRound::PrintDataTo(StringStream* stream) {
341 stream->Add("/round ");
342 value()->PrintTo(stream);
343 }
344
345
346 void LLoadContextSlot::PrintDataTo(StringStream* stream) { 323 void LLoadContextSlot::PrintDataTo(StringStream* stream) {
347 context()->PrintTo(stream); 324 context()->PrintTo(stream);
348 stream->Add("[%d]", slot_index()); 325 stream->Add("[%d]", slot_index());
349 } 326 }
350 327
351 328
352 void LStoreContextSlot::PrintDataTo(StringStream* stream) { 329 void LStoreContextSlot::PrintDataTo(StringStream* stream) {
353 context()->PrintTo(stream); 330 context()->PrintTo(stream);
354 stream->Add("[%d] <- ", slot_index()); 331 stream->Add("[%d] <- ", slot_index());
355 value()->PrintTo(stream); 332 value()->PrintTo(stream);
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { 1178 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1202 LOperand* context = UseFixed(instr->context(), esi); 1179 LOperand* context = UseFixed(instr->context(), esi);
1203 LOperand* function = UseFixed(instr->function(), edi); 1180 LOperand* function = UseFixed(instr->function(), edi);
1204 argument_count_ -= instr->argument_count(); 1181 argument_count_ -= instr->argument_count();
1205 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); 1182 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function);
1206 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY); 1183 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1207 } 1184 }
1208 1185
1209 1186
1210 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { 1187 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1211 BuiltinFunctionId op = instr->op(); 1188 switch (instr->op()) {
1212 if (op == kMathLog) { 1189 case kMathFloor: return DoMathFloor(instr);
1213 ASSERT(instr->representation().IsDouble()); 1190 case kMathRound: return DoMathRound(instr);
1214 ASSERT(instr->value()->representation().IsDouble()); 1191 case kMathAbs: return DoMathAbs(instr);
1215 LOperand* context = UseAny(instr->context()); // Not actually used. 1192 case kMathLog: return DoMathLog(instr);
1216 LOperand* input = UseRegisterAtStart(instr->value()); 1193 case kMathSin: return DoMathSin(instr);
1217 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(context, 1194 case kMathCos: return DoMathCos(instr);
1218 input); 1195 case kMathTan: return DoMathTan(instr);
1219 return DefineSameAsFirst(result); 1196 case kMathExp: return DoMathExp(instr);
1220 } else if (op == kMathExp) { 1197 case kMathSqrt: return DoMathSqrt(instr);
1221 ASSERT(instr->representation().IsDouble()); 1198 case kMathPowHalf: return DoMathPowHalf(instr);
1222 ASSERT(instr->value()->representation().IsDouble()); 1199 default:
1223 LOperand* value = UseTempRegister(instr->value()); 1200 UNREACHABLE();
1224 LOperand* temp1 = TempRegister(); 1201 return NULL;
1225 LOperand* temp2 = TempRegister();
1226 LMathExp* result = new(zone()) LMathExp(value, temp1, temp2);
1227 return DefineAsRegister(result);
1228 } else if (op == kMathSin || op == kMathCos || op == kMathTan) {
1229 LOperand* context = UseFixed(instr->context(), esi);
1230 LOperand* input = UseFixedDouble(instr->value(), xmm1);
1231 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(context,
1232 input);
1233 return MarkAsCall(DefineFixedDouble(result, xmm1), instr);
1234 } else {
1235 LOperand* context = UseAny(instr->context()); // Deferred use by MathAbs.
1236 LOperand* input = NULL;
1237 if (op == kMathPowHalf) {
1238 input = UseRegisterAtStart(instr->value());
1239 LOperand* temp = TempRegister();
1240 LMathPowHalf* result = new(zone()) LMathPowHalf(context, input, temp);
1241 return DefineSameAsFirst(result);
1242 } else if (op == kMathRound) {
1243 input = UseRegister(instr->value());
1244 LOperand* temp = FixedTemp(xmm4);
1245 LMathRound* result = new(zone()) LMathRound(context, input, temp);
1246 return AssignEnvironment(DefineAsRegister(result));
1247 } else {
1248 input = UseRegisterAtStart(instr->value());
1249 }
1250 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(context,
1251 input);
1252 switch (op) {
1253 case kMathAbs:
1254 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
1255 case kMathFloor:
1256 return AssignEnvironment(DefineAsRegister(result));
1257 case kMathSqrt:
1258 return DefineSameAsFirst(result);
1259 default:
1260 UNREACHABLE();
1261 return NULL;
1262 }
1263 } 1202 }
1264 } 1203 }
1265 1204
1266 1205
1206 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) {
1207 LOperand* input = UseRegisterAtStart(instr->value());
1208 LMathFloor* result = new(zone()) LMathFloor(input);
1209 return AssignEnvironment(DefineAsRegister(result));
1210 }
1211
1212
1213 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) {
1214 LOperand* context = UseAny(instr->context());
1215 LOperand* input = UseRegister(instr->value());
1216 LOperand* temp = FixedTemp(xmm4);
1217 LMathRound* result = new(zone()) LMathRound(context, input, temp);
1218 return AssignEnvironment(DefineAsRegister(result));
1219 }
1220
1221
1222 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) {
1223 LOperand* context = UseAny(instr->context()); // Deferred use.
1224 LOperand* input = UseRegisterAtStart(instr->value());
1225 LMathAbs* result = new(zone()) LMathAbs(context, input);
1226 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
1227 }
1228
1229
1230 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) {
1231 ASSERT(instr->representation().IsDouble());
1232 ASSERT(instr->value()->representation().IsDouble());
1233 LOperand* input = UseRegisterAtStart(instr->value());
1234 LMathLog* result = new(zone()) LMathLog(input);
1235 return DefineSameAsFirst(result);
1236 }
1237
1238
1239 LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) {
1240 LOperand* input = UseFixedDouble(instr->value(), xmm1);
1241 LMathSin* result = new(zone()) LMathSin(input);
1242 return MarkAsCall(DefineFixedDouble(result, xmm1), instr);
1243 }
1244
1245
1246 LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) {
1247 LOperand* input = UseFixedDouble(instr->value(), xmm1);
1248 LMathCos* result = new(zone()) LMathCos(input);
1249 return MarkAsCall(DefineFixedDouble(result, xmm1), instr);
1250 }
1251
1252
1253 LInstruction* LChunkBuilder::DoMathTan(HUnaryMathOperation* instr) {
1254 LOperand* input = UseFixedDouble(instr->value(), xmm1);
1255 LMathTan* result = new(zone()) LMathTan(input);
1256 return MarkAsCall(DefineFixedDouble(result, xmm1), instr);
1257 }
1258
1259
1260 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
1261 ASSERT(instr->representation().IsDouble());
1262 ASSERT(instr->value()->representation().IsDouble());
1263 LOperand* value = UseTempRegister(instr->value());
1264 LOperand* temp1 = TempRegister();
1265 LOperand* temp2 = TempRegister();
1266 LMathExp* result = new(zone()) LMathExp(value, temp1, temp2);
1267 return DefineAsRegister(result);
1268 }
1269
1270
1271 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) {
1272 LOperand* input = UseRegisterAtStart(instr->value());
1273 LMathSqrt* result = new(zone()) LMathSqrt(input);
1274 return DefineSameAsFirst(result);
1275 }
1276
1277
1278 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) {
1279 LOperand* context = UseAny(instr->context());
1280 LOperand* input = UseRegisterAtStart(instr->value());
1281 LOperand* temp = TempRegister();
1282 LMathPowHalf* result = new(zone()) LMathPowHalf(context, input, temp);
1283 return DefineSameAsFirst(result);
1284 }
1285
1286
1267 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { 1287 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
1268 ASSERT(instr->key()->representation().IsTagged()); 1288 ASSERT(instr->key()->representation().IsTagged());
1269 LOperand* context = UseFixed(instr->context(), esi); 1289 LOperand* context = UseFixed(instr->context(), esi);
1270 LOperand* key = UseFixed(instr->key(), ecx); 1290 LOperand* key = UseFixed(instr->key(), ecx);
1271 argument_count_ -= instr->argument_count(); 1291 argument_count_ -= instr->argument_count();
1272 LCallKeyed* result = new(zone()) LCallKeyed(context, key); 1292 LCallKeyed* result = new(zone()) LCallKeyed(context, key);
1273 return MarkAsCall(DefineFixed(result, eax), instr); 1293 return MarkAsCall(DefineFixed(result, eax), instr);
1274 } 1294 }
1275 1295
1276 1296
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2704 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2724 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2705 LOperand* object = UseRegister(instr->object()); 2725 LOperand* object = UseRegister(instr->object());
2706 LOperand* index = UseTempRegister(instr->index()); 2726 LOperand* index = UseTempRegister(instr->index());
2707 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2727 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2708 } 2728 }
2709 2729
2710 2730
2711 } } // namespace v8::internal 2731 } } // namespace v8::internal
2712 2732
2713 #endif // V8_TARGET_ARCH_IA32 2733 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/mips/lithium-codegen-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698