| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 HBasicBlock* next = NULL; | 435 HBasicBlock* next = NULL; |
| 436 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 436 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
| 437 DoBasicBlock(blocks->at(i), next); | 437 DoBasicBlock(blocks->at(i), next); |
| 438 if (is_aborted()) return NULL; | 438 if (is_aborted()) return NULL; |
| 439 } | 439 } |
| 440 status_ = DONE; | 440 status_ = DONE; |
| 441 return chunk_; | 441 return chunk_; |
| 442 } | 442 } |
| 443 | 443 |
| 444 | 444 |
| 445 void LCodeGen::Abort(BailoutReason reason) { | 445 void LCodeGen::Abort(const char* reason) { |
| 446 info()->set_bailout_reason(reason); | 446 info()->set_bailout_reason(reason); |
| 447 status_ = ABORTED; | 447 status_ = ABORTED; |
| 448 } | 448 } |
| 449 | 449 |
| 450 | 450 |
| 451 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { | 451 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { |
| 452 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, | 452 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, |
| 453 Register::ToAllocationIndex(reg)); | 453 Register::ToAllocationIndex(reg)); |
| 454 } | 454 } |
| 455 | 455 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); | 643 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); |
| 644 return instr; | 644 return instr; |
| 645 } | 645 } |
| 646 | 646 |
| 647 | 647 |
| 648 LUnallocated* LChunkBuilder::TempRegister() { | 648 LUnallocated* LChunkBuilder::TempRegister() { |
| 649 LUnallocated* operand = | 649 LUnallocated* operand = |
| 650 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 650 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
| 651 int vreg = allocator_->GetVirtualRegister(); | 651 int vreg = allocator_->GetVirtualRegister(); |
| 652 if (!allocator_->AllocationOk()) { | 652 if (!allocator_->AllocationOk()) { |
| 653 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); | 653 Abort("Out of virtual registers while trying to allocate temp register."); |
| 654 vreg = 0; | 654 vreg = 0; |
| 655 } | 655 } |
| 656 operand->set_virtual_register(vreg); | 656 operand->set_virtual_register(vreg); |
| 657 return operand; | 657 return operand; |
| 658 } | 658 } |
| 659 | 659 |
| 660 | 660 |
| 661 LOperand* LChunkBuilder::FixedTemp(Register reg) { | 661 LOperand* LChunkBuilder::FixedTemp(Register reg) { |
| 662 LUnallocated* operand = ToUnallocated(reg); | 662 LUnallocated* operand = ToUnallocated(reg); |
| 663 ASSERT(operand->HasFixedPolicy()); | 663 ASSERT(operand->HasFixedPolicy()); |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 ASSERT(instr->right()->representation().IsTagged()); | 1320 ASSERT(instr->right()->representation().IsTagged()); |
| 1321 | 1321 |
| 1322 LOperand* left = UseFixed(instr->left(), a1); | 1322 LOperand* left = UseFixed(instr->left(), a1); |
| 1323 LOperand* right = UseFixed(instr->right(), a0); | 1323 LOperand* right = UseFixed(instr->right(), a0); |
| 1324 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); | 1324 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); |
| 1325 return MarkAsCall(DefineFixed(result, v0), instr); | 1325 return MarkAsCall(DefineFixed(result, v0), instr); |
| 1326 } | 1326 } |
| 1327 } | 1327 } |
| 1328 | 1328 |
| 1329 | 1329 |
| 1330 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) { |
| 1331 ASSERT(instr->value()->representation().IsInteger32()); |
| 1332 ASSERT(instr->representation().IsInteger32()); |
| 1333 if (instr->HasNoUses()) return NULL; |
| 1334 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1335 return DefineAsRegister(new(zone()) LBitNotI(value)); |
| 1336 } |
| 1337 |
| 1338 |
| 1330 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1339 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
| 1331 if (instr->representation().IsDouble()) { | 1340 if (instr->representation().IsDouble()) { |
| 1332 return DoArithmeticD(Token::DIV, instr); | 1341 return DoArithmeticD(Token::DIV, instr); |
| 1333 } else if (instr->representation().IsSmiOrInteger32()) { | 1342 } else if (instr->representation().IsSmiOrInteger32()) { |
| 1334 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1343 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1335 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1344 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1336 LOperand* dividend = UseRegister(instr->left()); | 1345 LOperand* dividend = UseRegister(instr->left()); |
| 1337 LOperand* divisor = UseRegister(instr->right()); | 1346 LOperand* divisor = UseRegister(instr->right()); |
| 1338 LDivI* div = new(zone()) LDivI(dividend, divisor); | 1347 LDivI* div = new(zone()) LDivI(dividend, divisor); |
| 1339 return AssignEnvironment(DefineAsRegister(div)); | 1348 return AssignEnvironment(DefineAsRegister(div)); |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { | 1746 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { |
| 1738 LOperand* string = UseRegister(instr->string()); | 1747 LOperand* string = UseRegister(instr->string()); |
| 1739 LOperand* index = UseRegister(instr->index()); | 1748 LOperand* index = UseRegister(instr->index()); |
| 1740 LOperand* value = UseTempRegister(instr->value()); | 1749 LOperand* value = UseTempRegister(instr->value()); |
| 1741 LSeqStringSetChar* result = | 1750 LSeqStringSetChar* result = |
| 1742 new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value); | 1751 new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value); |
| 1743 return DefineAsRegister(result); | 1752 return DefineAsRegister(result); |
| 1744 } | 1753 } |
| 1745 | 1754 |
| 1746 | 1755 |
| 1756 LInstruction* LChunkBuilder::DoNumericConstraint(HNumericConstraint* instr) { |
| 1757 return NULL; |
| 1758 } |
| 1759 |
| 1760 |
| 1761 LInstruction* LChunkBuilder::DoInductionVariableAnnotation( |
| 1762 HInductionVariableAnnotation* instr) { |
| 1763 return NULL; |
| 1764 } |
| 1765 |
| 1766 |
| 1747 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1767 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
| 1748 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); | 1768 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); |
| 1749 LOperand* length = UseRegister(instr->length()); | 1769 LOperand* length = UseRegister(instr->length()); |
| 1750 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); | 1770 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); |
| 1751 } | 1771 } |
| 1752 | 1772 |
| 1753 | 1773 |
| 1754 LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation( | 1774 LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation( |
| 1755 HBoundsCheckBaseIndexInformation* instr) { | 1775 HBoundsCheckBaseIndexInformation* instr) { |
| 1756 UNREACHABLE(); | 1776 UNREACHABLE(); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 } | 1930 } |
| 1911 | 1931 |
| 1912 | 1932 |
| 1913 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { | 1933 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { |
| 1914 LOperand* value = UseRegisterAtStart(instr->value()); | 1934 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1915 LInstruction* result = new(zone()) LCheckInstanceType(value); | 1935 LInstruction* result = new(zone()) LCheckInstanceType(value); |
| 1916 return AssignEnvironment(result); | 1936 return AssignEnvironment(result); |
| 1917 } | 1937 } |
| 1918 | 1938 |
| 1919 | 1939 |
| 1940 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { |
| 1941 LUnallocated* temp1 = NULL; |
| 1942 LOperand* temp2 = NULL; |
| 1943 if (!instr->CanOmitPrototypeChecks()) { |
| 1944 temp1 = TempRegister(); |
| 1945 temp2 = TempRegister(); |
| 1946 } |
| 1947 LCheckPrototypeMaps* result = new(zone()) LCheckPrototypeMaps(temp1, temp2); |
| 1948 if (instr->CanOmitPrototypeChecks()) return result; |
| 1949 return AssignEnvironment(result); |
| 1950 } |
| 1951 |
| 1952 |
| 1920 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { | 1953 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { |
| 1921 LOperand* value = UseRegisterAtStart(instr->value()); | 1954 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1922 return AssignEnvironment(new(zone()) LCheckFunction(value)); | 1955 return AssignEnvironment(new(zone()) LCheckFunction(value)); |
| 1923 } | 1956 } |
| 1924 | 1957 |
| 1925 | 1958 |
| 1926 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { | 1959 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { |
| 1927 LOperand* value = NULL; | 1960 LOperand* value = NULL; |
| 1928 if (!instr->CanOmitMapChecks()) { | 1961 if (!instr->CanOmitMapChecks()) value = UseRegisterAtStart(instr->value()); |
| 1929 value = UseRegisterAtStart(instr->value()); | 1962 LInstruction* result = new(zone()) LCheckMaps(value); |
| 1930 if (instr->has_migration_target()) info()->MarkAsDeferredCalling(); | 1963 if (instr->CanOmitMapChecks()) return result; |
| 1931 } | 1964 return AssignEnvironment(result); |
| 1932 LCheckMaps* result = new(zone()) LCheckMaps(value); | |
| 1933 if (!instr->CanOmitMapChecks()) { | |
| 1934 AssignEnvironment(result); | |
| 1935 if (instr->has_migration_target()) return AssignPointerMap(result); | |
| 1936 } | |
| 1937 return result; | |
| 1938 } | 1965 } |
| 1939 | 1966 |
| 1940 | 1967 |
| 1941 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { | 1968 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { |
| 1942 HValue* value = instr->value(); | 1969 HValue* value = instr->value(); |
| 1943 Representation input_rep = value->representation(); | 1970 Representation input_rep = value->representation(); |
| 1944 LOperand* reg = UseRegister(value); | 1971 LOperand* reg = UseRegister(value); |
| 1945 if (input_rep.IsDouble()) { | 1972 if (input_rep.IsDouble()) { |
| 1946 // Revisit this decision, here and 8 lines below. | 1973 // Revisit this decision, here and 8 lines below. |
| 1947 return DefineAsRegister(new(zone()) LClampDToUint8(reg, FixedTemp(f22))); | 1974 return DefineAsRegister(new(zone()) LClampDToUint8(reg, FixedTemp(f22))); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2211 LOperand* temp = TempRegister(); | 2238 LOperand* temp = TempRegister(); |
| 2212 LTrapAllocationMemento* result = | 2239 LTrapAllocationMemento* result = |
| 2213 new(zone()) LTrapAllocationMemento(object, temp); | 2240 new(zone()) LTrapAllocationMemento(object, temp); |
| 2214 return AssignEnvironment(result); | 2241 return AssignEnvironment(result); |
| 2215 } | 2242 } |
| 2216 | 2243 |
| 2217 | 2244 |
| 2218 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { | 2245 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
| 2219 bool is_in_object = instr->access().IsInobject(); | 2246 bool is_in_object = instr->access().IsInobject(); |
| 2220 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2247 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
| 2221 bool needs_write_barrier_for_map = instr->has_transition() && | 2248 bool needs_write_barrier_for_map = !instr->transition().is_null() && |
| 2222 instr->NeedsWriteBarrierForMap(); | 2249 instr->NeedsWriteBarrierForMap(); |
| 2223 | 2250 |
| 2224 LOperand* obj; | 2251 LOperand* obj; |
| 2225 if (needs_write_barrier) { | 2252 if (needs_write_barrier) { |
| 2226 obj = is_in_object | 2253 obj = is_in_object |
| 2227 ? UseRegister(instr->object()) | 2254 ? UseRegister(instr->object()) |
| 2228 : UseTempRegister(instr->object()); | 2255 : UseTempRegister(instr->object()); |
| 2229 } else { | 2256 } else { |
| 2230 obj = needs_write_barrier_for_map | 2257 obj = needs_write_barrier_for_map |
| 2231 ? UseRegister(instr->object()) | 2258 ? UseRegister(instr->object()) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2331 int index = static_cast<int>(instr->index()); | 2358 int index = static_cast<int>(instr->index()); |
| 2332 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); | 2359 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); |
| 2333 return DefineFixed(result, reg); | 2360 return DefineFixed(result, reg); |
| 2334 } | 2361 } |
| 2335 } | 2362 } |
| 2336 | 2363 |
| 2337 | 2364 |
| 2338 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2365 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
| 2339 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2366 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
| 2340 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { | 2367 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
| 2341 Abort(kTooManySpillSlotsNeededForOSR); | 2368 Abort("Too many spill slots needed for OSR"); |
| 2342 spill_index = 0; | 2369 spill_index = 0; |
| 2343 } | 2370 } |
| 2344 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2371 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
| 2345 } | 2372 } |
| 2346 | 2373 |
| 2347 | 2374 |
| 2348 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | 2375 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
| 2349 argument_count_ -= instr->argument_count(); | 2376 argument_count_ -= instr->argument_count(); |
| 2350 return MarkAsCall(DefineFixed(new(zone()) LCallStub, v0), instr); | 2377 return MarkAsCall(DefineFixed(new(zone()) LCallStub, v0), instr); |
| 2351 } | 2378 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2504 | 2531 |
| 2505 | 2532 |
| 2506 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2533 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2507 LOperand* object = UseRegister(instr->object()); | 2534 LOperand* object = UseRegister(instr->object()); |
| 2508 LOperand* index = UseRegister(instr->index()); | 2535 LOperand* index = UseRegister(instr->index()); |
| 2509 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2536 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2510 } | 2537 } |
| 2511 | 2538 |
| 2512 | 2539 |
| 2513 } } // namespace v8::internal | 2540 } } // namespace v8::internal |
| OLD | NEW |