| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) { | 547 LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) { |
| 548 LUnallocated* operand = ToUnallocated(reg); | 548 LUnallocated* operand = ToUnallocated(reg); |
| 549 ASSERT(operand->HasFixedPolicy()); | 549 ASSERT(operand->HasFixedPolicy()); |
| 550 return operand; | 550 return operand; |
| 551 } | 551 } |
| 552 | 552 |
| 553 | 553 |
| 554 LPlatformChunk* LChunkBuilder::Build() { | 554 LPlatformChunk* LChunkBuilder::Build() { |
| 555 ASSERT(is_unused()); | 555 ASSERT(is_unused()); |
| 556 chunk_ = new(zone_) LPlatformChunk(info_, graph_); | 556 chunk_ = new(zone_) LPlatformChunk(info_, graph_); |
| 557 HPhase phase("L_Building chunk", chunk_); | 557 LPhase phase("L_Building chunk", chunk_); |
| 558 status_ = BUILDING; | 558 status_ = BUILDING; |
| 559 const ZoneList<HBasicBlock*>* blocks = graph_->blocks(); | 559 const ZoneList<HBasicBlock*>* blocks = graph_->blocks(); |
| 560 for (int i = 0; i < blocks->length(); i++) { | 560 for (int i = 0; i < blocks->length(); i++) { |
| 561 DoBasicBlock(blocks->at(i)); | 561 DoBasicBlock(blocks->at(i)); |
| 562 if (is_aborted()) return NULL; | 562 if (is_aborted()) return NULL; |
| 563 } | 563 } |
| 564 status_ = DONE; | 564 status_ = DONE; |
| 565 return chunk_; | 565 return chunk_; |
| 566 } | 566 } |
| 567 | 567 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { | 870 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { |
| 871 info()->MarkAsDeferredCalling(); | 871 info()->MarkAsDeferredCalling(); |
| 872 LOperand* size = UseRegisterOrConstant(instr->size()); | 872 LOperand* size = UseRegisterOrConstant(instr->size()); |
| 873 LOperand* temp1 = TempRegister(); | 873 LOperand* temp1 = TempRegister(); |
| 874 LOperand* temp2 = TempRegister(); | 874 LOperand* temp2 = TempRegister(); |
| 875 LAllocate* result = new(zone()) LAllocate(size, temp1, temp2); | 875 LAllocate* result = new(zone()) LAllocate(size, temp1, temp2); |
| 876 return AssignPointerMap(DefineAsRegister(result)); | 876 return AssignPointerMap(DefineAsRegister(result)); |
| 877 } | 877 } |
| 878 | 878 |
| 879 | 879 |
| 880 LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) { |
| 881 info()->MarkAsDeferredCalling(); |
| 882 LAllocateObject* result = |
| 883 new(zone()) LAllocateObject(TempRegister(), TempRegister()); |
| 884 return AssignPointerMap(DefineAsRegister(result)); |
| 885 } |
| 886 |
| 887 |
| 880 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { | 888 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { |
| 881 LOperand* function = UseFixed(instr->function(), x1); | 889 LOperand* function = UseFixed(instr->function(), x1); |
| 882 LOperand* receiver = UseFixed(instr->receiver(), x0); | 890 LOperand* receiver = UseFixed(instr->receiver(), x0); |
| 883 LOperand* length = UseFixed(instr->length(), x2); | 891 LOperand* length = UseFixed(instr->length(), x2); |
| 884 LOperand* elements = UseFixed(instr->elements(), x3); | 892 LOperand* elements = UseFixed(instr->elements(), x3); |
| 885 LApplyArguments* result = new(zone()) LApplyArguments(function, | 893 LApplyArguments* result = new(zone()) LApplyArguments(function, |
| 886 receiver, | 894 receiver, |
| 887 length, | 895 length, |
| 888 elements); | 896 elements); |
| 889 return MarkAsCall(DefineFixed(result, x0), instr, CAN_DEOPTIMIZE_EAGERLY); | 897 return MarkAsCall(DefineFixed(result, x0), instr, CAN_DEOPTIMIZE_EAGERLY); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 | 966 |
| 959 if (value->EmitAtUses()) { | 967 if (value->EmitAtUses()) { |
| 960 // TODO(all): Handle this case with CheckElideControlInstruction once | 968 // TODO(all): Handle this case with CheckElideControlInstruction once |
| 961 // we've done the rebase. | 969 // we've done the rebase. |
| 962 HBasicBlock* successor = HConstant::cast(value)->BooleanValue() | 970 HBasicBlock* successor = HConstant::cast(value)->BooleanValue() |
| 963 ? instr->FirstSuccessor() | 971 ? instr->FirstSuccessor() |
| 964 : instr->SecondSuccessor(); | 972 : instr->SecondSuccessor(); |
| 965 return new(zone()) LGoto(successor->block_id()); | 973 return new(zone()) LGoto(successor->block_id()); |
| 966 } | 974 } |
| 967 | 975 |
| 968 Representation rep = value->representation(); | 976 Representation r = value->representation(); |
| 969 HType type = value->type(); | 977 HType type = value->type(); |
| 970 | 978 |
| 971 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean()) { | 979 if (r.IsInteger32() || r.IsSmi() || r.IsDouble()) { |
| 972 ToBooleanStub::Types expected = instr->expected_input_types(); | 980 // These representations have simple checks that cannot deoptimize. |
| 973 LOperand* temp1 = NULL; | 981 return new(zone()) LBranch(UseRegister(value), NULL, NULL); |
| 974 LOperand* temp2 = NULL; | 982 } else { |
| 975 | 983 ASSERT(r.IsTagged()); |
| 976 if (expected.NeedsMap() || expected.IsEmpty()) { | 984 if (type.IsBoolean() || type.IsSmi() || type.IsJSArray() || |
| 977 temp1 = TempRegister(); | 985 type.IsHeapNumber()) { |
| 978 temp2 = TempRegister(); | 986 // These types have simple checks that cannot deoptimize. |
| 987 return new(zone()) LBranch(UseRegister(value), NULL, NULL); |
| 979 } | 988 } |
| 980 | 989 |
| 981 // Tagged values that are not known smis or booleans require a | 990 if (type.IsString()) { |
| 982 // deoptimization environment. | 991 // This type cannot deoptimize, but needs a scratch register. |
| 983 return AssignEnvironment( | 992 return new(zone()) LBranch(UseRegister(value), TempRegister(), NULL); |
| 984 new(zone()) LBranch(UseRegister(value), temp1, temp2)); | 993 } |
| 985 } else { | 994 |
| 986 return new(zone()) LBranch(UseRegister(value), NULL, NULL); | 995 ToBooleanStub::Types expected = instr->expected_input_types(); |
| 996 bool needs_temps = expected.NeedsMap() || expected.IsEmpty(); |
| 997 LOperand* temp1 = needs_temps ? TempRegister() : NULL; |
| 998 LOperand* temp2 = needs_temps ? TempRegister() : NULL; |
| 999 |
| 1000 if (expected.IsGeneric() || expected.IsEmpty()) { |
| 1001 // The generic case cannot deoptimize because it already supports every |
| 1002 // possible input type. |
| 1003 ASSERT(needs_temps); |
| 1004 return new(zone()) LBranch(UseRegister(value), temp1, temp2); |
| 1005 } else { |
| 1006 return AssignEnvironment( |
| 1007 new(zone()) LBranch(UseRegister(value), temp1, temp2)); |
| 1008 } |
| 987 } | 1009 } |
| 988 } | 1010 } |
| 989 | 1011 |
| 990 | 1012 |
| 991 LInstruction* LChunkBuilder::DoCallConstantFunction( | 1013 LInstruction* LChunkBuilder::DoCallConstantFunction( |
| 992 HCallConstantFunction* instr) { | 1014 HCallConstantFunction* instr) { |
| 993 argument_count_ -= instr->argument_count(); | 1015 argument_count_ -= instr->argument_count(); |
| 994 return MarkAsCall(DefineFixed(new(zone()) LCallConstantFunction, x0), instr); | 1016 return MarkAsCall(DefineFixed(new(zone()) LCallConstantFunction, x0), instr); |
| 995 } | 1017 } |
| 996 | 1018 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 | 1207 |
| 1186 | 1208 |
| 1187 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { | 1209 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { |
| 1188 LOperand* value = UseRegister(instr->value()); | 1210 LOperand* value = UseRegister(instr->value()); |
| 1189 LOperand* temp = TempRegister(); | 1211 LOperand* temp = TempRegister(); |
| 1190 LInstruction* result = new(zone()) LCheckMaps(value, temp); | 1212 LInstruction* result = new(zone()) LCheckMaps(value, temp); |
| 1191 return AssignEnvironment(result); | 1213 return AssignEnvironment(result); |
| 1192 } | 1214 } |
| 1193 | 1215 |
| 1194 | 1216 |
| 1195 LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { | 1217 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { |
| 1196 // TODO(all): On newer v8 versions, this hydrogen instruction has been renamed | |
| 1197 // into HCheckHeapObject but still translate into LCheckNonSmi. | |
| 1198 LOperand* value = UseRegisterAtStart(instr->value()); | 1218 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1199 return AssignEnvironment(new(zone()) LCheckNonSmi(value)); | 1219 return AssignEnvironment(new(zone()) LCheckNonSmi(value)); |
| 1200 } | 1220 } |
| 1201 | 1221 |
| 1202 | 1222 |
| 1203 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { | 1223 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { |
| 1204 // TODO(jbramley): The scratch registers are not needed if | 1224 // TODO(jbramley): The scratch registers are not needed if |
| 1205 // instr->CanOmitPrototypeChecks(). Can we safely test that here? | 1225 // instr->CanOmitPrototypeChecks(). Can we safely test that here? |
| 1206 LOperand* temp1 = TempRegister(); | 1226 LOperand* temp1 = TempRegister(); |
| 1207 LOperand* temp2 = TempRegister(); | 1227 LOperand* temp2 = TempRegister(); |
| (...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | 2499 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
| 2480 LOperand* receiver = UseRegister(instr->receiver()); | 2500 LOperand* receiver = UseRegister(instr->receiver()); |
| 2481 LOperand* function = UseRegisterAtStart(instr->function()); | 2501 LOperand* function = UseRegisterAtStart(instr->function()); |
| 2482 LOperand* temp = TempRegister(); | 2502 LOperand* temp = TempRegister(); |
| 2483 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function, temp); | 2503 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function, temp); |
| 2484 return AssignEnvironment(DefineAsRegister(result)); | 2504 return AssignEnvironment(DefineAsRegister(result)); |
| 2485 } | 2505 } |
| 2486 | 2506 |
| 2487 | 2507 |
| 2488 } } // namespace v8::internal | 2508 } } // namespace v8::internal |
| OLD | NEW |