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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 HBasicBlock* next = NULL; | 430 HBasicBlock* next = NULL; |
431 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 431 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
432 DoBasicBlock(blocks->at(i), next); | 432 DoBasicBlock(blocks->at(i), next); |
433 if (is_aborted()) return NULL; | 433 if (is_aborted()) return NULL; |
434 } | 434 } |
435 status_ = DONE; | 435 status_ = DONE; |
436 return chunk_; | 436 return chunk_; |
437 } | 437 } |
438 | 438 |
439 | 439 |
440 void LChunkBuilder::Abort(BailoutReason reason) { | 440 void LChunkBuilder::Abort(const char* reason) { |
441 info()->set_bailout_reason(reason); | 441 info()->set_bailout_reason(reason); |
442 status_ = ABORTED; | 442 status_ = ABORTED; |
443 } | 443 } |
444 | 444 |
445 | 445 |
446 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { | 446 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { |
447 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, | 447 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, |
448 Register::ToAllocationIndex(reg)); | 448 Register::ToAllocationIndex(reg)); |
449 } | 449 } |
450 | 450 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); | 638 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); |
639 return instr; | 639 return instr; |
640 } | 640 } |
641 | 641 |
642 | 642 |
643 LUnallocated* LChunkBuilder::TempRegister() { | 643 LUnallocated* LChunkBuilder::TempRegister() { |
644 LUnallocated* operand = | 644 LUnallocated* operand = |
645 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 645 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
646 int vreg = allocator_->GetVirtualRegister(); | 646 int vreg = allocator_->GetVirtualRegister(); |
647 if (!allocator_->AllocationOk()) { | 647 if (!allocator_->AllocationOk()) { |
648 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); | 648 Abort("Out of virtual registers while trying to allocate temp register."); |
649 vreg = 0; | 649 vreg = 0; |
650 } | 650 } |
651 operand->set_virtual_register(vreg); | 651 operand->set_virtual_register(vreg); |
652 return operand; | 652 return operand; |
653 } | 653 } |
654 | 654 |
655 | 655 |
656 LOperand* LChunkBuilder::FixedTemp(Register reg) { | 656 LOperand* LChunkBuilder::FixedTemp(Register reg) { |
657 LUnallocated* operand = ToUnallocated(reg); | 657 LUnallocated* operand = ToUnallocated(reg); |
658 ASSERT(operand->HasFixedPolicy()); | 658 ASSERT(operand->HasFixedPolicy()); |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 ASSERT(instr->right()->representation().IsTagged()); | 1318 ASSERT(instr->right()->representation().IsTagged()); |
1319 | 1319 |
1320 LOperand* left = UseFixed(instr->left(), r1); | 1320 LOperand* left = UseFixed(instr->left(), r1); |
1321 LOperand* right = UseFixed(instr->right(), r0); | 1321 LOperand* right = UseFixed(instr->right(), r0); |
1322 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); | 1322 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); |
1323 return MarkAsCall(DefineFixed(result, r0), instr); | 1323 return MarkAsCall(DefineFixed(result, r0), instr); |
1324 } | 1324 } |
1325 } | 1325 } |
1326 | 1326 |
1327 | 1327 |
| 1328 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) { |
| 1329 ASSERT(instr->value()->representation().IsInteger32()); |
| 1330 ASSERT(instr->representation().IsInteger32()); |
| 1331 if (instr->HasNoUses()) return NULL; |
| 1332 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1333 return DefineAsRegister(new(zone()) LBitNotI(value)); |
| 1334 } |
| 1335 |
| 1336 |
1328 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1337 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
1329 if (instr->representation().IsDouble()) { | 1338 if (instr->representation().IsDouble()) { |
1330 return DoArithmeticD(Token::DIV, instr); | 1339 return DoArithmeticD(Token::DIV, instr); |
1331 } else if (instr->representation().IsSmiOrInteger32()) { | 1340 } else if (instr->representation().IsSmiOrInteger32()) { |
1332 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1341 ASSERT(instr->left()->representation().Equals(instr->representation())); |
1333 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1342 ASSERT(instr->right()->representation().Equals(instr->representation())); |
1334 if (instr->HasPowerOf2Divisor()) { | 1343 if (instr->HasPowerOf2Divisor()) { |
1335 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); | 1344 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero)); |
1336 LOperand* value = UseRegisterAtStart(instr->left()); | 1345 LOperand* value = UseRegisterAtStart(instr->left()); |
1337 LDivI* div = | 1346 LDivI* div = |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { | 1825 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { |
1817 LOperand* string = UseRegister(instr->string()); | 1826 LOperand* string = UseRegister(instr->string()); |
1818 LOperand* index = UseRegister(instr->index()); | 1827 LOperand* index = UseRegister(instr->index()); |
1819 LOperand* value = UseTempRegister(instr->value()); | 1828 LOperand* value = UseTempRegister(instr->value()); |
1820 LSeqStringSetChar* result = | 1829 LSeqStringSetChar* result = |
1821 new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value); | 1830 new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value); |
1822 return DefineAsRegister(result); | 1831 return DefineAsRegister(result); |
1823 } | 1832 } |
1824 | 1833 |
1825 | 1834 |
| 1835 LInstruction* LChunkBuilder::DoNumericConstraint(HNumericConstraint* instr) { |
| 1836 return NULL; |
| 1837 } |
| 1838 |
| 1839 |
| 1840 LInstruction* LChunkBuilder::DoInductionVariableAnnotation( |
| 1841 HInductionVariableAnnotation* instr) { |
| 1842 return NULL; |
| 1843 } |
| 1844 |
| 1845 |
1826 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1846 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
1827 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); | 1847 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); |
1828 LOperand* length = UseRegister(instr->length()); | 1848 LOperand* length = UseRegister(instr->length()); |
1829 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); | 1849 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); |
1830 } | 1850 } |
1831 | 1851 |
1832 | 1852 |
1833 LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation( | 1853 LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation( |
1834 HBoundsCheckBaseIndexInformation* instr) { | 1854 HBoundsCheckBaseIndexInformation* instr) { |
1835 UNREACHABLE(); | 1855 UNREACHABLE(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 } | 2009 } |
1990 | 2010 |
1991 | 2011 |
1992 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { | 2012 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { |
1993 LOperand* value = UseRegisterAtStart(instr->value()); | 2013 LOperand* value = UseRegisterAtStart(instr->value()); |
1994 LInstruction* result = new(zone()) LCheckInstanceType(value); | 2014 LInstruction* result = new(zone()) LCheckInstanceType(value); |
1995 return AssignEnvironment(result); | 2015 return AssignEnvironment(result); |
1996 } | 2016 } |
1997 | 2017 |
1998 | 2018 |
| 2019 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { |
| 2020 LUnallocated* temp1 = NULL; |
| 2021 LOperand* temp2 = NULL; |
| 2022 if (!instr->CanOmitPrototypeChecks()) { |
| 2023 temp1 = TempRegister(); |
| 2024 temp2 = TempRegister(); |
| 2025 } |
| 2026 LCheckPrototypeMaps* result = new(zone()) LCheckPrototypeMaps(temp1, temp2); |
| 2027 if (instr->CanOmitPrototypeChecks()) return result; |
| 2028 return AssignEnvironment(result); |
| 2029 } |
| 2030 |
| 2031 |
1999 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { | 2032 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { |
2000 LOperand* value = UseRegisterAtStart(instr->value()); | 2033 LOperand* value = UseRegisterAtStart(instr->value()); |
2001 return AssignEnvironment(new(zone()) LCheckFunction(value)); | 2034 return AssignEnvironment(new(zone()) LCheckFunction(value)); |
2002 } | 2035 } |
2003 | 2036 |
2004 | 2037 |
2005 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { | 2038 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { |
2006 LOperand* value = NULL; | 2039 LOperand* value = NULL; |
2007 if (!instr->CanOmitMapChecks()) { | 2040 if (!instr->CanOmitMapChecks()) value = UseRegisterAtStart(instr->value()); |
2008 value = UseRegisterAtStart(instr->value()); | 2041 LInstruction* result = new(zone()) LCheckMaps(value); |
2009 if (instr->has_migration_target()) info()->MarkAsDeferredCalling(); | 2042 if (instr->CanOmitMapChecks()) return result; |
2010 } | 2043 return AssignEnvironment(result); |
2011 LCheckMaps* result = new(zone()) LCheckMaps(value); | |
2012 if (!instr->CanOmitMapChecks()) { | |
2013 AssignEnvironment(result); | |
2014 if (instr->has_migration_target()) return AssignPointerMap(result); | |
2015 } | |
2016 return result; | |
2017 } | 2044 } |
2018 | 2045 |
2019 | 2046 |
2020 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { | 2047 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { |
2021 HValue* value = instr->value(); | 2048 HValue* value = instr->value(); |
2022 Representation input_rep = value->representation(); | 2049 Representation input_rep = value->representation(); |
2023 LOperand* reg = UseRegister(value); | 2050 LOperand* reg = UseRegister(value); |
2024 if (input_rep.IsDouble()) { | 2051 if (input_rep.IsDouble()) { |
2025 return DefineAsRegister(new(zone()) LClampDToUint8(reg)); | 2052 return DefineAsRegister(new(zone()) LClampDToUint8(reg)); |
2026 } else if (input_rep.IsInteger32()) { | 2053 } else if (input_rep.IsInteger32()) { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2288 LOperand* temp = TempRegister(); | 2315 LOperand* temp = TempRegister(); |
2289 LTrapAllocationMemento* result = | 2316 LTrapAllocationMemento* result = |
2290 new(zone()) LTrapAllocationMemento(object, temp); | 2317 new(zone()) LTrapAllocationMemento(object, temp); |
2291 return AssignEnvironment(result); | 2318 return AssignEnvironment(result); |
2292 } | 2319 } |
2293 | 2320 |
2294 | 2321 |
2295 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { | 2322 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
2296 bool is_in_object = instr->access().IsInobject(); | 2323 bool is_in_object = instr->access().IsInobject(); |
2297 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2324 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
2298 bool needs_write_barrier_for_map = instr->has_transition() && | 2325 bool needs_write_barrier_for_map = !instr->transition().is_null() && |
2299 instr->NeedsWriteBarrierForMap(); | 2326 instr->NeedsWriteBarrierForMap(); |
2300 | 2327 |
2301 LOperand* obj; | 2328 LOperand* obj; |
2302 if (needs_write_barrier) { | 2329 if (needs_write_barrier) { |
2303 obj = is_in_object | 2330 obj = is_in_object |
2304 ? UseRegister(instr->object()) | 2331 ? UseRegister(instr->object()) |
2305 : UseTempRegister(instr->object()); | 2332 : UseTempRegister(instr->object()); |
2306 } else { | 2333 } else { |
2307 obj = needs_write_barrier_for_map | 2334 obj = needs_write_barrier_for_map |
2308 ? UseRegister(instr->object()) | 2335 ? UseRegister(instr->object()) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2408 int index = static_cast<int>(instr->index()); | 2435 int index = static_cast<int>(instr->index()); |
2409 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); | 2436 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); |
2410 return DefineFixed(result, reg); | 2437 return DefineFixed(result, reg); |
2411 } | 2438 } |
2412 } | 2439 } |
2413 | 2440 |
2414 | 2441 |
2415 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2442 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2416 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2443 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
2417 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { | 2444 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
2418 Abort(kTooManySpillSlotsNeededForOSR); | 2445 Abort("Too many spill slots needed for OSR"); |
2419 spill_index = 0; | 2446 spill_index = 0; |
2420 } | 2447 } |
2421 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2448 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
2422 } | 2449 } |
2423 | 2450 |
2424 | 2451 |
2425 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | 2452 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
2426 argument_count_ -= instr->argument_count(); | 2453 argument_count_ -= instr->argument_count(); |
2427 return MarkAsCall(DefineFixed(new(zone()) LCallStub, r0), instr); | 2454 return MarkAsCall(DefineFixed(new(zone()) LCallStub, r0), instr); |
2428 } | 2455 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 | 2608 |
2582 | 2609 |
2583 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2610 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2584 LOperand* object = UseRegister(instr->object()); | 2611 LOperand* object = UseRegister(instr->object()); |
2585 LOperand* index = UseRegister(instr->index()); | 2612 LOperand* index = UseRegister(instr->index()); |
2586 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2613 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2587 } | 2614 } |
2588 | 2615 |
2589 | 2616 |
2590 } } // namespace v8::internal | 2617 } } // namespace v8::internal |
OLD | NEW |