| 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 HBasicBlock* next = NULL; | 436 HBasicBlock* next = NULL; |
| 437 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 437 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
| 438 DoBasicBlock(blocks->at(i), next); | 438 DoBasicBlock(blocks->at(i), next); |
| 439 if (is_aborted()) return NULL; | 439 if (is_aborted()) return NULL; |
| 440 } | 440 } |
| 441 status_ = DONE; | 441 status_ = DONE; |
| 442 return chunk_; | 442 return chunk_; |
| 443 } | 443 } |
| 444 | 444 |
| 445 | 445 |
| 446 void LCodeGen::Abort(BailoutReason reason) { | 446 void LCodeGen::Abort(const char* reason) { |
| 447 info()->set_bailout_reason(reason); | 447 info()->set_bailout_reason(reason); |
| 448 status_ = ABORTED; | 448 status_ = ABORTED; |
| 449 } | 449 } |
| 450 | 450 |
| 451 | 451 |
| 452 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { | 452 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { |
| 453 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, | 453 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, |
| 454 Register::ToAllocationIndex(reg)); | 454 Register::ToAllocationIndex(reg)); |
| 455 } | 455 } |
| 456 | 456 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); | 647 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); |
| 648 return instr; | 648 return instr; |
| 649 } | 649 } |
| 650 | 650 |
| 651 | 651 |
| 652 LUnallocated* LChunkBuilder::TempRegister() { | 652 LUnallocated* LChunkBuilder::TempRegister() { |
| 653 LUnallocated* operand = | 653 LUnallocated* operand = |
| 654 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 654 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
| 655 int vreg = allocator_->GetVirtualRegister(); | 655 int vreg = allocator_->GetVirtualRegister(); |
| 656 if (!allocator_->AllocationOk()) { | 656 if (!allocator_->AllocationOk()) { |
| 657 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); | 657 Abort("Out of virtual registers while trying to allocate temp register."); |
| 658 vreg = 0; | 658 vreg = 0; |
| 659 } | 659 } |
| 660 operand->set_virtual_register(vreg); | 660 operand->set_virtual_register(vreg); |
| 661 return operand; | 661 return operand; |
| 662 } | 662 } |
| 663 | 663 |
| 664 | 664 |
| 665 LOperand* LChunkBuilder::FixedTemp(Register reg) { | 665 LOperand* LChunkBuilder::FixedTemp(Register reg) { |
| 666 LUnallocated* operand = ToUnallocated(reg); | 666 LUnallocated* operand = ToUnallocated(reg); |
| 667 ASSERT(operand->HasFixedPolicy()); | 667 ASSERT(operand->HasFixedPolicy()); |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 ASSERT(instr->right()->representation().IsTagged()); | 1314 ASSERT(instr->right()->representation().IsTagged()); |
| 1315 | 1315 |
| 1316 LOperand* left = UseFixed(instr->left(), rdx); | 1316 LOperand* left = UseFixed(instr->left(), rdx); |
| 1317 LOperand* right = UseFixed(instr->right(), rax); | 1317 LOperand* right = UseFixed(instr->right(), rax); |
| 1318 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); | 1318 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); |
| 1319 return MarkAsCall(DefineFixed(result, rax), instr); | 1319 return MarkAsCall(DefineFixed(result, rax), instr); |
| 1320 } | 1320 } |
| 1321 } | 1321 } |
| 1322 | 1322 |
| 1323 | 1323 |
| 1324 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) { |
| 1325 ASSERT(instr->value()->representation().IsInteger32()); |
| 1326 ASSERT(instr->representation().IsInteger32()); |
| 1327 if (instr->HasNoUses()) return NULL; |
| 1328 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1329 LBitNotI* result = new(zone()) LBitNotI(input); |
| 1330 return DefineSameAsFirst(result); |
| 1331 } |
| 1332 |
| 1333 |
| 1324 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1334 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
| 1325 if (instr->representation().IsDouble()) { | 1335 if (instr->representation().IsDouble()) { |
| 1326 return DoArithmeticD(Token::DIV, instr); | 1336 return DoArithmeticD(Token::DIV, instr); |
| 1327 } else if (instr->representation().IsSmiOrInteger32()) { | 1337 } else if (instr->representation().IsSmiOrInteger32()) { |
| 1328 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1338 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1329 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1339 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1330 if (instr->HasPowerOf2Divisor()) { | 1340 if (instr->HasPowerOf2Divisor()) { |
| 1331 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); | 1341 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); |
| 1332 LOperand* value = UseRegisterAtStart(instr->left()); | 1342 LOperand* value = UseRegisterAtStart(instr->left()); |
| 1333 LDivI* div = | 1343 LDivI* div = |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 LOperand* string = UseRegister(instr->string()); | 1738 LOperand* string = UseRegister(instr->string()); |
| 1729 LOperand* index = UseRegister(instr->index()); | 1739 LOperand* index = UseRegister(instr->index()); |
| 1730 ASSERT(rcx.is_byte_register()); | 1740 ASSERT(rcx.is_byte_register()); |
| 1731 LOperand* value = UseFixed(instr->value(), rcx); | 1741 LOperand* value = UseFixed(instr->value(), rcx); |
| 1732 LSeqStringSetChar* result = | 1742 LSeqStringSetChar* result = |
| 1733 new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value); | 1743 new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value); |
| 1734 return DefineSameAsFirst(result); | 1744 return DefineSameAsFirst(result); |
| 1735 } | 1745 } |
| 1736 | 1746 |
| 1737 | 1747 |
| 1748 LInstruction* LChunkBuilder::DoNumericConstraint(HNumericConstraint* instr) { |
| 1749 return NULL; |
| 1750 } |
| 1751 |
| 1752 |
| 1753 LInstruction* LChunkBuilder::DoInductionVariableAnnotation( |
| 1754 HInductionVariableAnnotation* instr) { |
| 1755 return NULL; |
| 1756 } |
| 1757 |
| 1758 |
| 1738 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1759 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
| 1739 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); | 1760 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); |
| 1740 LOperand* length = Use(instr->length()); | 1761 LOperand* length = Use(instr->length()); |
| 1741 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); | 1762 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); |
| 1742 } | 1763 } |
| 1743 | 1764 |
| 1744 | 1765 |
| 1745 LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation( | 1766 LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation( |
| 1746 HBoundsCheckBaseIndexInformation* instr) { | 1767 HBoundsCheckBaseIndexInformation* instr) { |
| 1747 UNREACHABLE(); | 1768 UNREACHABLE(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 } | 1913 } |
| 1893 | 1914 |
| 1894 | 1915 |
| 1895 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { | 1916 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { |
| 1896 LOperand* value = UseRegisterAtStart(instr->value()); | 1917 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1897 LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); | 1918 LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); |
| 1898 return AssignEnvironment(result); | 1919 return AssignEnvironment(result); |
| 1899 } | 1920 } |
| 1900 | 1921 |
| 1901 | 1922 |
| 1923 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { |
| 1924 LUnallocated* temp = NULL; |
| 1925 if (!instr->CanOmitPrototypeChecks()) temp = TempRegister(); |
| 1926 LCheckPrototypeMaps* result = new(zone()) LCheckPrototypeMaps(temp); |
| 1927 if (instr->CanOmitPrototypeChecks()) return result; |
| 1928 return AssignEnvironment(result); |
| 1929 } |
| 1930 |
| 1931 |
| 1902 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { | 1932 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { |
| 1903 LOperand* value = UseRegisterAtStart(instr->value()); | 1933 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1904 return AssignEnvironment(new(zone()) LCheckFunction(value)); | 1934 return AssignEnvironment(new(zone()) LCheckFunction(value)); |
| 1905 } | 1935 } |
| 1906 | 1936 |
| 1907 | 1937 |
| 1908 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { | 1938 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { |
| 1909 LOperand* value = NULL; | 1939 LOperand* value = NULL; |
| 1910 if (!instr->CanOmitMapChecks()) { | 1940 if (!instr->CanOmitMapChecks()) value = UseRegisterAtStart(instr->value()); |
| 1911 value = UseRegisterAtStart(instr->value()); | |
| 1912 if (instr->has_migration_target()) info()->MarkAsDeferredCalling(); | |
| 1913 } | |
| 1914 LCheckMaps* result = new(zone()) LCheckMaps(value); | 1941 LCheckMaps* result = new(zone()) LCheckMaps(value); |
| 1915 if (!instr->CanOmitMapChecks()) { | 1942 if (instr->CanOmitMapChecks()) return result; |
| 1916 AssignEnvironment(result); | 1943 return AssignEnvironment(result); |
| 1917 if (instr->has_migration_target()) return AssignPointerMap(result); | |
| 1918 } | |
| 1919 return result; | |
| 1920 } | 1944 } |
| 1921 | 1945 |
| 1922 | 1946 |
| 1923 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { | 1947 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { |
| 1924 HValue* value = instr->value(); | 1948 HValue* value = instr->value(); |
| 1925 Representation input_rep = value->representation(); | 1949 Representation input_rep = value->representation(); |
| 1926 LOperand* reg = UseRegister(value); | 1950 LOperand* reg = UseRegister(value); |
| 1927 if (input_rep.IsDouble()) { | 1951 if (input_rep.IsDouble()) { |
| 1928 return DefineAsRegister(new(zone()) LClampDToUint8(reg)); | 1952 return DefineAsRegister(new(zone()) LClampDToUint8(reg)); |
| 1929 } else if (input_rep.IsInteger32()) { | 1953 } else if (input_rep.IsInteger32()) { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2202 new(zone()) LTrapAllocationMemento(object, temp); | 2226 new(zone()) LTrapAllocationMemento(object, temp); |
| 2203 return AssignEnvironment(result); | 2227 return AssignEnvironment(result); |
| 2204 } | 2228 } |
| 2205 | 2229 |
| 2206 | 2230 |
| 2207 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { | 2231 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
| 2208 bool is_in_object = instr->access().IsInobject(); | 2232 bool is_in_object = instr->access().IsInobject(); |
| 2209 bool is_external_location = instr->access().IsExternalMemory() && | 2233 bool is_external_location = instr->access().IsExternalMemory() && |
| 2210 instr->access().offset() == 0; | 2234 instr->access().offset() == 0; |
| 2211 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2235 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
| 2212 bool needs_write_barrier_for_map = instr->has_transition() && | 2236 bool needs_write_barrier_for_map = !instr->transition().is_null() && |
| 2213 instr->NeedsWriteBarrierForMap(); | 2237 instr->NeedsWriteBarrierForMap(); |
| 2214 | 2238 |
| 2215 LOperand* obj; | 2239 LOperand* obj; |
| 2216 if (needs_write_barrier) { | 2240 if (needs_write_barrier) { |
| 2217 obj = is_in_object | 2241 obj = is_in_object |
| 2218 ? UseRegister(instr->object()) | 2242 ? UseRegister(instr->object()) |
| 2219 : UseTempRegister(instr->object()); | 2243 : UseTempRegister(instr->object()); |
| 2220 } else if (is_external_location) { | 2244 } else if (is_external_location) { |
| 2221 ASSERT(!is_in_object); | 2245 ASSERT(!is_in_object); |
| 2222 ASSERT(!needs_write_barrier); | 2246 ASSERT(!needs_write_barrier); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2337 int index = static_cast<int>(instr->index()); | 2361 int index = static_cast<int>(instr->index()); |
| 2338 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); | 2362 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); |
| 2339 return DefineFixed(result, reg); | 2363 return DefineFixed(result, reg); |
| 2340 } | 2364 } |
| 2341 } | 2365 } |
| 2342 | 2366 |
| 2343 | 2367 |
| 2344 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2368 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
| 2345 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2369 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
| 2346 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { | 2370 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
| 2347 Abort(kTooManySpillSlotsNeededForOSR); | 2371 Abort("Too many spill slots needed for OSR"); |
| 2348 spill_index = 0; | 2372 spill_index = 0; |
| 2349 } | 2373 } |
| 2350 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2374 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
| 2351 } | 2375 } |
| 2352 | 2376 |
| 2353 | 2377 |
| 2354 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | 2378 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
| 2355 argument_count_ -= instr->argument_count(); | 2379 argument_count_ -= instr->argument_count(); |
| 2356 return MarkAsCall(DefineFixed(new(zone()) LCallStub, rax), instr); | 2380 return MarkAsCall(DefineFixed(new(zone()) LCallStub, rax), instr); |
| 2357 } | 2381 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2514 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2538 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2515 LOperand* object = UseRegister(instr->object()); | 2539 LOperand* object = UseRegister(instr->object()); |
| 2516 LOperand* index = UseTempRegister(instr->index()); | 2540 LOperand* index = UseTempRegister(instr->index()); |
| 2517 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2541 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2518 } | 2542 } |
| 2519 | 2543 |
| 2520 | 2544 |
| 2521 } } // namespace v8::internal | 2545 } } // namespace v8::internal |
| 2522 | 2546 |
| 2523 #endif // V8_TARGET_ARCH_X64 | 2547 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |