| OLD | NEW |
| 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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 current_block_ = NULL; | 917 current_block_ = NULL; |
| 918 } | 918 } |
| 919 | 919 |
| 920 | 920 |
| 921 void LChunkBuilder::VisitInstruction(HInstruction* current) { | 921 void LChunkBuilder::VisitInstruction(HInstruction* current) { |
| 922 HInstruction* old_current = current_instruction_; | 922 HInstruction* old_current = current_instruction_; |
| 923 current_instruction_ = current; | 923 current_instruction_ = current; |
| 924 | 924 |
| 925 LInstruction* instr = NULL; | 925 LInstruction* instr = NULL; |
| 926 if (current->CanReplaceWithDummyUses()) { | 926 if (current->CanReplaceWithDummyUses()) { |
| 927 HValue* first_operand = current->OperandCount() == 0 | 927 if (current->OperandCount() == 0) { |
| 928 ? graph()->GetConstant1() | 928 instr = DefineAsRegister(new(zone()) LDummy()); |
| 929 : current->OperandAt(0); | 929 } else { |
| 930 instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand))); | 930 instr = DefineAsRegister(new(zone()) |
| 931 LDummyUse(UseAny(current->OperandAt(0)))); |
| 932 } |
| 931 for (int i = 1; i < current->OperandCount(); ++i) { | 933 for (int i = 1; i < current->OperandCount(); ++i) { |
| 932 LInstruction* dummy = | 934 LInstruction* dummy = |
| 933 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); | 935 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); |
| 934 dummy->set_hydrogen_value(current); | 936 dummy->set_hydrogen_value(current); |
| 935 chunk_->AddInstruction(dummy, current_block_); | 937 chunk_->AddInstruction(dummy, current_block_); |
| 936 } | 938 } |
| 937 } else { | 939 } else { |
| 938 instr = current->CompileToLithium(this); | 940 instr = current->CompileToLithium(this); |
| 939 } | 941 } |
| 940 | 942 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 | 1285 |
| 1284 | 1286 |
| 1285 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { | 1287 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { |
| 1286 LOperand* input = UseRegisterAtStart(instr->value()); | 1288 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1287 LMathFloor* result = new(zone()) LMathFloor(input); | 1289 LMathFloor* result = new(zone()) LMathFloor(input); |
| 1288 return AssignEnvironment(DefineAsRegister(result)); | 1290 return AssignEnvironment(DefineAsRegister(result)); |
| 1289 } | 1291 } |
| 1290 | 1292 |
| 1291 | 1293 |
| 1292 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { | 1294 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { |
| 1293 LOperand* context = UseAny(instr->context()); | |
| 1294 LOperand* input = UseRegister(instr->value()); | 1295 LOperand* input = UseRegister(instr->value()); |
| 1295 LOperand* temp = FixedTemp(xmm4); | 1296 LOperand* temp = FixedTemp(xmm4); |
| 1296 LMathRound* result = new(zone()) LMathRound(context, input, temp); | 1297 LMathRound* result = new(zone()) LMathRound(input, temp); |
| 1297 return AssignEnvironment(DefineAsRegister(result)); | 1298 return AssignEnvironment(DefineAsRegister(result)); |
| 1298 } | 1299 } |
| 1299 | 1300 |
| 1300 | 1301 |
| 1301 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { | 1302 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { |
| 1302 LOperand* context = UseAny(instr->context()); // Deferred use. | 1303 LOperand* context = UseAny(instr->context()); // Deferred use. |
| 1303 LOperand* input = UseRegisterAtStart(instr->value()); | 1304 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1304 LMathAbs* result = new(zone()) LMathAbs(context, input); | 1305 LMathAbs* result = new(zone()) LMathAbs(context, input); |
| 1305 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1306 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| 1306 } | 1307 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 | 1349 |
| 1349 | 1350 |
| 1350 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { | 1351 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { |
| 1351 LOperand* input = UseRegisterAtStart(instr->value()); | 1352 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1352 LMathSqrt* result = new(zone()) LMathSqrt(input); | 1353 LMathSqrt* result = new(zone()) LMathSqrt(input); |
| 1353 return DefineSameAsFirst(result); | 1354 return DefineSameAsFirst(result); |
| 1354 } | 1355 } |
| 1355 | 1356 |
| 1356 | 1357 |
| 1357 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { | 1358 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { |
| 1358 LOperand* context = UseAny(instr->context()); | |
| 1359 LOperand* input = UseRegisterAtStart(instr->value()); | 1359 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1360 LOperand* temp = TempRegister(); | 1360 LOperand* temp = TempRegister(); |
| 1361 LMathPowHalf* result = new(zone()) LMathPowHalf(context, input, temp); | 1361 LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); |
| 1362 return DefineSameAsFirst(result); | 1362 return DefineSameAsFirst(result); |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 | 1365 |
| 1366 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { | 1366 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { |
| 1367 ASSERT(instr->key()->representation().IsTagged()); | 1367 ASSERT(instr->key()->representation().IsTagged()); |
| 1368 LOperand* context = UseFixed(instr->context(), esi); | 1368 LOperand* context = UseFixed(instr->context(), esi); |
| 1369 LOperand* key = UseFixed(instr->key(), ecx); | 1369 LOperand* key = UseFixed(instr->key(), ecx); |
| 1370 LCallKeyed* result = new(zone()) LCallKeyed(context, key); | 1370 LCallKeyed* result = new(zone()) LCallKeyed(context, key); |
| 1371 return MarkAsCall(DefineFixed(result, eax), instr); | 1371 return MarkAsCall(DefineFixed(result, eax), instr); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 | 1866 |
| 1867 | 1867 |
| 1868 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { | 1868 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { |
| 1869 LOperand* date = UseFixed(instr->value(), eax); | 1869 LOperand* date = UseFixed(instr->value(), eax); |
| 1870 LDateField* result = | 1870 LDateField* result = |
| 1871 new(zone()) LDateField(date, FixedTemp(ecx), instr->index()); | 1871 new(zone()) LDateField(date, FixedTemp(ecx), instr->index()); |
| 1872 return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY); | 1872 return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY); |
| 1873 } | 1873 } |
| 1874 | 1874 |
| 1875 | 1875 |
| 1876 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) { |
| 1877 LOperand* string = UseRegisterAtStart(instr->string()); |
| 1878 LOperand* index = UseRegisterOrConstantAtStart(instr->index()); |
| 1879 return DefineAsRegister(new(zone()) LSeqStringGetChar(string, index)); |
| 1880 } |
| 1881 |
| 1882 |
| 1876 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { | 1883 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { |
| 1877 LOperand* string = UseRegisterAtStart(instr->string()); | 1884 LOperand* string = UseRegisterAtStart(instr->string()); |
| 1878 LOperand* index = UseRegisterOrConstantAtStart(instr->index()); | 1885 LOperand* index = UseRegisterOrConstantAtStart(instr->index()); |
| 1879 LOperand* value = (instr->encoding() == String::ONE_BYTE_ENCODING) | 1886 LOperand* value = (instr->encoding() == String::ONE_BYTE_ENCODING) |
| 1880 ? UseFixedOrConstant(instr->value(), eax) | 1887 ? UseFixedOrConstant(instr->value(), eax) |
| 1881 : UseRegisterOrConstantAtStart(instr->value()); | 1888 : UseRegisterOrConstantAtStart(instr->value()); |
| 1882 return new(zone()) LSeqStringSetChar(string, index, value); | 1889 return new(zone()) LSeqStringSetChar(string, index, value); |
| 1883 } | 1890 } |
| 1884 | 1891 |
| 1885 | 1892 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 LClampTToUint8NoSSE2* res = | 2109 LClampTToUint8NoSSE2* res = |
| 2103 new(zone()) LClampTToUint8NoSSE2(value, TempRegister(), | 2110 new(zone()) LClampTToUint8NoSSE2(value, TempRegister(), |
| 2104 TempRegister(), TempRegister()); | 2111 TempRegister(), TempRegister()); |
| 2105 return AssignEnvironment(DefineFixed(res, ecx)); | 2112 return AssignEnvironment(DefineFixed(res, ecx)); |
| 2106 } | 2113 } |
| 2107 } | 2114 } |
| 2108 } | 2115 } |
| 2109 | 2116 |
| 2110 | 2117 |
| 2111 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) { | 2118 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) { |
| 2112 LOperand* context = info()->IsStub() | 2119 LOperand* context = info()->IsStub() ? UseFixed(instr->context(), esi) : NULL; |
| 2113 ? UseFixed(instr->context(), esi) | |
| 2114 : NULL; | |
| 2115 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); | 2120 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); |
| 2116 return new(zone()) LReturn(UseFixed(instr->value(), eax), context, | 2121 return new(zone()) LReturn( |
| 2117 parameter_count); | 2122 UseFixed(instr->value(), eax), context, parameter_count); |
| 2118 } | 2123 } |
| 2119 | 2124 |
| 2120 | 2125 |
| 2121 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { | 2126 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { |
| 2122 Representation r = instr->representation(); | 2127 Representation r = instr->representation(); |
| 2123 if (r.IsSmi()) { | 2128 if (r.IsSmi()) { |
| 2124 return DefineAsRegister(new(zone()) LConstantS); | 2129 return DefineAsRegister(new(zone()) LConstantS); |
| 2125 } else if (r.IsInteger32()) { | 2130 } else if (r.IsInteger32()) { |
| 2126 return DefineAsRegister(new(zone()) LConstantI); | 2131 return DefineAsRegister(new(zone()) LConstantI); |
| 2127 } else if (r.IsDouble()) { | 2132 } else if (r.IsDouble()) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 obj = needs_write_barrier_for_map | 2427 obj = needs_write_barrier_for_map |
| 2423 ? UseRegister(instr->object()) | 2428 ? UseRegister(instr->object()) |
| 2424 : UseRegisterAtStart(instr->object()); | 2429 : UseRegisterAtStart(instr->object()); |
| 2425 } | 2430 } |
| 2426 | 2431 |
| 2427 bool can_be_constant = instr->value()->IsConstant() && | 2432 bool can_be_constant = instr->value()->IsConstant() && |
| 2428 HConstant::cast(instr->value())->NotInNewSpace() && | 2433 HConstant::cast(instr->value())->NotInNewSpace() && |
| 2429 !(FLAG_track_double_fields && instr->field_representation().IsDouble()); | 2434 !(FLAG_track_double_fields && instr->field_representation().IsDouble()); |
| 2430 | 2435 |
| 2431 LOperand* val; | 2436 LOperand* val; |
| 2432 if (instr->field_representation().IsByte()) { | 2437 if (instr->field_representation().IsInteger8() || |
| 2438 instr->field_representation().IsUInteger8()) { |
| 2433 // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx). | 2439 // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx). |
| 2434 // Just force the value to be in eax and we're safe here. | 2440 // Just force the value to be in eax and we're safe here. |
| 2435 val = UseFixed(instr->value(), eax); | 2441 val = UseFixed(instr->value(), eax); |
| 2436 } else if (needs_write_barrier) { | 2442 } else if (needs_write_barrier) { |
| 2437 val = UseTempRegister(instr->value()); | 2443 val = UseTempRegister(instr->value()); |
| 2438 } else if (can_be_constant) { | 2444 } else if (can_be_constant) { |
| 2439 val = UseRegisterOrConstant(instr->value()); | 2445 val = UseRegisterOrConstant(instr->value()); |
| 2440 } else if (FLAG_track_fields && instr->field_representation().IsSmi()) { | 2446 } else if (FLAG_track_fields && instr->field_representation().IsSmi()) { |
| 2441 val = UseTempRegister(instr->value()); | 2447 val = UseTempRegister(instr->value()); |
| 2442 } else if (FLAG_track_double_fields && | 2448 } else if (FLAG_track_double_fields && |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2472 LOperand* value = UseFixed(instr->value(), eax); | 2478 LOperand* value = UseFixed(instr->value(), eax); |
| 2473 | 2479 |
| 2474 LStoreNamedGeneric* result = | 2480 LStoreNamedGeneric* result = |
| 2475 new(zone()) LStoreNamedGeneric(context, object, value); | 2481 new(zone()) LStoreNamedGeneric(context, object, value); |
| 2476 return MarkAsCall(result, instr); | 2482 return MarkAsCall(result, instr); |
| 2477 } | 2483 } |
| 2478 | 2484 |
| 2479 | 2485 |
| 2480 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { | 2486 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { |
| 2481 LOperand* context = UseFixed(instr->context(), esi); | 2487 LOperand* context = UseFixed(instr->context(), esi); |
| 2482 LOperand* left = UseOrConstantAtStart(instr->left()); | 2488 LOperand* left = FLAG_new_string_add |
| 2483 LOperand* right = UseOrConstantAtStart(instr->right()); | 2489 ? UseFixed(instr->left(), edx) |
| 2490 : UseOrConstantAtStart(instr->left()); |
| 2491 LOperand* right = FLAG_new_string_add |
| 2492 ? UseFixed(instr->right(), eax) |
| 2493 : UseOrConstantAtStart(instr->right()); |
| 2484 LStringAdd* string_add = new(zone()) LStringAdd(context, left, right); | 2494 LStringAdd* string_add = new(zone()) LStringAdd(context, left, right); |
| 2485 return MarkAsCall(DefineFixed(string_add, eax), instr); | 2495 return MarkAsCall(DefineFixed(string_add, eax), instr); |
| 2486 } | 2496 } |
| 2487 | 2497 |
| 2488 | 2498 |
| 2489 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { | 2499 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { |
| 2490 LOperand* string = UseTempRegister(instr->string()); | 2500 LOperand* string = UseTempRegister(instr->string()); |
| 2491 LOperand* index = UseTempRegister(instr->index()); | 2501 LOperand* index = UseTempRegister(instr->index()); |
| 2492 LOperand* context = UseAny(instr->context()); | 2502 LOperand* context = UseAny(instr->context()); |
| 2493 LStringCharCodeAt* result = | 2503 LStringCharCodeAt* result = |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2743 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2753 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2744 LOperand* object = UseRegister(instr->object()); | 2754 LOperand* object = UseRegister(instr->object()); |
| 2745 LOperand* index = UseTempRegister(instr->index()); | 2755 LOperand* index = UseTempRegister(instr->index()); |
| 2746 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2756 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2747 } | 2757 } |
| 2748 | 2758 |
| 2749 | 2759 |
| 2750 } } // namespace v8::internal | 2760 } } // namespace v8::internal |
| 2751 | 2761 |
| 2752 #endif // V8_TARGET_ARCH_IA32 | 2762 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |