| 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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 } | 856 } |
| 857 | 857 |
| 858 | 858 |
| 859 void LChunkBuilder::VisitInstruction(HInstruction* current) { | 859 void LChunkBuilder::VisitInstruction(HInstruction* current) { |
| 860 HInstruction* old_current = current_instruction_; | 860 HInstruction* old_current = current_instruction_; |
| 861 current_instruction_ = current; | 861 current_instruction_ = current; |
| 862 if (current->has_position()) position_ = current->position(); | 862 if (current->has_position()) position_ = current->position(); |
| 863 | 863 |
| 864 LInstruction* instr = NULL; | 864 LInstruction* instr = NULL; |
| 865 if (current->CanReplaceWithDummyUses()) { | 865 if (current->CanReplaceWithDummyUses()) { |
| 866 HValue* first_operand = current->OperandCount() == 0 | 866 if (current->OperandCount() == 0) { |
| 867 ? graph()->GetConstant1() | 867 instr = DefineAsRegister(new(zone()) LDummy()); |
| 868 : current->OperandAt(0); | 868 } else { |
| 869 instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand))); | 869 instr = DefineAsRegister(new(zone()) |
| 870 LDummyUse(UseAny(current->OperandAt(0)))); |
| 871 } |
| 870 for (int i = 1; i < current->OperandCount(); ++i) { | 872 for (int i = 1; i < current->OperandCount(); ++i) { |
| 871 LInstruction* dummy = | 873 LInstruction* dummy = |
| 872 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); | 874 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); |
| 873 dummy->set_hydrogen_value(current); | 875 dummy->set_hydrogen_value(current); |
| 874 chunk_->AddInstruction(dummy, current_block_); | 876 chunk_->AddInstruction(dummy, current_block_); |
| 875 } | 877 } |
| 876 } else { | 878 } else { |
| 877 instr = current->CompileToLithium(this); | 879 instr = current->CompileToLithium(this); |
| 878 } | 880 } |
| 879 | 881 |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 } | 1776 } |
| 1775 | 1777 |
| 1776 | 1778 |
| 1777 LInstruction* LChunkBuilder::DoCompareHoleAndBranch( | 1779 LInstruction* LChunkBuilder::DoCompareHoleAndBranch( |
| 1778 HCompareHoleAndBranch* instr) { | 1780 HCompareHoleAndBranch* instr) { |
| 1779 LOperand* value = UseRegisterAtStart(instr->value()); | 1781 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1780 return new(zone()) LCmpHoleAndBranch(value); | 1782 return new(zone()) LCmpHoleAndBranch(value); |
| 1781 } | 1783 } |
| 1782 | 1784 |
| 1783 | 1785 |
| 1786 LInstruction* LChunkBuilder::DoCompareMinusZeroAndBranch( |
| 1787 HCompareMinusZeroAndBranch* instr) { |
| 1788 LInstruction* goto_instr = CheckElideControlInstruction(instr); |
| 1789 if (goto_instr != NULL) return goto_instr; |
| 1790 LOperand* value = UseRegister(instr->value()); |
| 1791 LOperand* scratch = TempRegister(); |
| 1792 return new(zone()) LCompareMinusZeroAndBranch(value, scratch); |
| 1793 } |
| 1794 |
| 1795 |
| 1784 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { | 1796 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { |
| 1785 ASSERT(instr->value()->representation().IsTagged()); | 1797 ASSERT(instr->value()->representation().IsTagged()); |
| 1786 LOperand* value = UseRegisterAtStart(instr->value()); | 1798 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1787 LOperand* temp = TempRegister(); | 1799 LOperand* temp = TempRegister(); |
| 1788 return new(zone()) LIsObjectAndBranch(value, temp); | 1800 return new(zone()) LIsObjectAndBranch(value, temp); |
| 1789 } | 1801 } |
| 1790 | 1802 |
| 1791 | 1803 |
| 1792 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { | 1804 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { |
| 1793 ASSERT(instr->value()->representation().IsTagged()); | 1805 ASSERT(instr->value()->representation().IsTagged()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 | 1889 |
| 1878 | 1890 |
| 1879 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { | 1891 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { |
| 1880 LOperand* object = UseFixed(instr->value(), r0); | 1892 LOperand* object = UseFixed(instr->value(), r0); |
| 1881 LDateField* result = | 1893 LDateField* result = |
| 1882 new(zone()) LDateField(object, FixedTemp(r1), instr->index()); | 1894 new(zone()) LDateField(object, FixedTemp(r1), instr->index()); |
| 1883 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY); | 1895 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY); |
| 1884 } | 1896 } |
| 1885 | 1897 |
| 1886 | 1898 |
| 1899 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) { |
| 1900 LOperand* string = UseRegisterAtStart(instr->string()); |
| 1901 LOperand* index = UseRegisterOrConstantAtStart(instr->index()); |
| 1902 return DefineAsRegister(new(zone()) LSeqStringGetChar(string, index)); |
| 1903 } |
| 1904 |
| 1905 |
| 1887 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { | 1906 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { |
| 1888 LOperand* string = UseRegister(instr->string()); | 1907 LOperand* string = UseRegister(instr->string()); |
| 1889 LOperand* index = UseRegisterOrConstant(instr->index()); | 1908 LOperand* index = UseRegisterOrConstant(instr->index()); |
| 1890 LOperand* value = UseRegister(instr->value()); | 1909 LOperand* value = UseRegister(instr->value()); |
| 1891 return new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value); | 1910 return new(zone()) LSeqStringSetChar(string, index, value); |
| 1892 } | 1911 } |
| 1893 | 1912 |
| 1894 | 1913 |
| 1895 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1914 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
| 1896 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); | 1915 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); |
| 1897 LOperand* length = UseRegister(instr->length()); | 1916 LOperand* length = UseRegister(instr->length()); |
| 1898 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); | 1917 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); |
| 1899 } | 1918 } |
| 1900 | 1919 |
| 1901 | 1920 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 2026 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| 2008 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 2027 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
| 2009 return DefineAsRegister(new(zone()) LSmiTag(value)); | 2028 return DefineAsRegister(new(zone()) LSmiTag(value)); |
| 2010 } else { | 2029 } else { |
| 2011 LNumberTagI* result = new(zone()) LNumberTagI(value); | 2030 LNumberTagI* result = new(zone()) LNumberTagI(value); |
| 2012 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); | 2031 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); |
| 2013 } | 2032 } |
| 2014 } else if (to.IsSmi()) { | 2033 } else if (to.IsSmi()) { |
| 2015 HValue* val = instr->value(); | 2034 HValue* val = instr->value(); |
| 2016 LOperand* value = UseRegister(val); | 2035 LOperand* value = UseRegister(val); |
| 2017 LInstruction* result = | 2036 LInstruction* result = val->CheckFlag(HInstruction::kUint32) |
| 2018 DefineSameAsFirst(new(zone()) LInteger32ToSmi(value)); | 2037 ? DefineSameAsFirst(new(zone()) LUint32ToSmi(value)) |
| 2038 : DefineSameAsFirst(new(zone()) LInteger32ToSmi(value)); |
| 2019 if (val->HasRange() && val->range()->IsInSmiRange()) { | 2039 if (val->HasRange() && val->range()->IsInSmiRange()) { |
| 2020 return result; | 2040 return result; |
| 2021 } | 2041 } |
| 2022 return AssignEnvironment(result); | 2042 return AssignEnvironment(result); |
| 2023 } else { | 2043 } else { |
| 2024 ASSERT(to.IsDouble()); | 2044 ASSERT(to.IsDouble()); |
| 2025 if (instr->value()->CheckFlag(HInstruction::kUint32)) { | 2045 if (instr->value()->CheckFlag(HInstruction::kUint32)) { |
| 2026 return DefineAsRegister( | 2046 return DefineAsRegister( |
| 2027 new(zone()) LUint32ToDouble(UseRegister(instr->value()))); | 2047 new(zone()) LUint32ToDouble(UseRegister(instr->value()))); |
| 2028 } else { | 2048 } else { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2396 LOperand* obj = UseFixed(instr->object(), r1); | 2416 LOperand* obj = UseFixed(instr->object(), r1); |
| 2397 LOperand* val = UseFixed(instr->value(), r0); | 2417 LOperand* val = UseFixed(instr->value(), r0); |
| 2398 | 2418 |
| 2399 LInstruction* result = new(zone()) LStoreNamedGeneric(context, obj, val); | 2419 LInstruction* result = new(zone()) LStoreNamedGeneric(context, obj, val); |
| 2400 return MarkAsCall(result, instr); | 2420 return MarkAsCall(result, instr); |
| 2401 } | 2421 } |
| 2402 | 2422 |
| 2403 | 2423 |
| 2404 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { | 2424 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { |
| 2405 LOperand* context = UseFixed(instr->context(), cp); | 2425 LOperand* context = UseFixed(instr->context(), cp); |
| 2406 LOperand* left = UseRegisterAtStart(instr->left()); | 2426 LOperand* left = FLAG_new_string_add |
| 2407 LOperand* right = UseRegisterAtStart(instr->right()); | 2427 ? UseFixed(instr->left(), r1) |
| 2428 : UseRegisterAtStart(instr->left()); |
| 2429 LOperand* right = FLAG_new_string_add |
| 2430 ? UseFixed(instr->right(), r0) |
| 2431 : UseRegisterAtStart(instr->right()); |
| 2408 return MarkAsCall( | 2432 return MarkAsCall( |
| 2409 DefineFixed(new(zone()) LStringAdd(context, left, right), r0), | 2433 DefineFixed(new(zone()) LStringAdd(context, left, right), r0), |
| 2410 instr); | 2434 instr); |
| 2411 } | 2435 } |
| 2412 | 2436 |
| 2413 | 2437 |
| 2414 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { | 2438 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { |
| 2415 LOperand* string = UseTempRegister(instr->string()); | 2439 LOperand* string = UseTempRegister(instr->string()); |
| 2416 LOperand* index = UseTempRegister(instr->index()); | 2440 LOperand* index = UseTempRegister(instr->index()); |
| 2417 LOperand* context = UseAny(instr->context()); | 2441 LOperand* context = UseAny(instr->context()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2468 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { | 2492 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { |
| 2469 LParameter* result = new(zone()) LParameter; | 2493 LParameter* result = new(zone()) LParameter; |
| 2470 if (instr->kind() == HParameter::STACK_PARAMETER) { | 2494 if (instr->kind() == HParameter::STACK_PARAMETER) { |
| 2471 int spill_index = chunk()->GetParameterStackSlot(instr->index()); | 2495 int spill_index = chunk()->GetParameterStackSlot(instr->index()); |
| 2472 return DefineAsSpilled(result, spill_index); | 2496 return DefineAsSpilled(result, spill_index); |
| 2473 } else { | 2497 } else { |
| 2474 ASSERT(info()->IsStub()); | 2498 ASSERT(info()->IsStub()); |
| 2475 CodeStubInterfaceDescriptor* descriptor = | 2499 CodeStubInterfaceDescriptor* descriptor = |
| 2476 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); | 2500 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); |
| 2477 int index = static_cast<int>(instr->index()); | 2501 int index = static_cast<int>(instr->index()); |
| 2478 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); | 2502 Register reg = descriptor->GetParameterRegister(index); |
| 2479 return DefineFixed(result, reg); | 2503 return DefineFixed(result, reg); |
| 2480 } | 2504 } |
| 2481 } | 2505 } |
| 2482 | 2506 |
| 2483 | 2507 |
| 2484 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2508 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
| 2485 // Use an index that corresponds to the location in the unoptimized frame, | 2509 // Use an index that corresponds to the location in the unoptimized frame, |
| 2486 // which the optimized frame will subsume. | 2510 // which the optimized frame will subsume. |
| 2487 int env_index = instr->index(); | 2511 int env_index = instr->index(); |
| 2488 int spill_index = 0; | 2512 int spill_index = 0; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2658 | 2682 |
| 2659 | 2683 |
| 2660 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2684 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2661 LOperand* object = UseRegister(instr->object()); | 2685 LOperand* object = UseRegister(instr->object()); |
| 2662 LOperand* index = UseRegister(instr->index()); | 2686 LOperand* index = UseRegister(instr->index()); |
| 2663 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2687 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2664 } | 2688 } |
| 2665 | 2689 |
| 2666 | 2690 |
| 2667 } } // namespace v8::internal | 2691 } } // namespace v8::internal |
| OLD | NEW |