| 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 23 matching lines...) Expand all Loading... |
| 34 namespace v8 { | 34 namespace v8 { |
| 35 namespace internal { | 35 namespace internal { |
| 36 | 36 |
| 37 #define DEFINE_COMPILE(type) \ | 37 #define DEFINE_COMPILE(type) \ |
| 38 void L##type::CompileToNative(LCodeGen* generator) { \ | 38 void L##type::CompileToNative(LCodeGen* generator) { \ |
| 39 generator->Do##type(this); \ | 39 generator->Do##type(this); \ |
| 40 } | 40 } |
| 41 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | 41 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
| 42 #undef DEFINE_COMPILE | 42 #undef DEFINE_COMPILE |
| 43 | 43 |
| 44 LOsrEntry::LOsrEntry() { | |
| 45 for (int i = 0; i < Register::NumAllocatableRegisters(); ++i) { | |
| 46 register_spills_[i] = NULL; | |
| 47 } | |
| 48 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) { | |
| 49 double_register_spills_[i] = NULL; | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 | |
| 54 void LOsrEntry::MarkSpilledRegister(int allocation_index, | |
| 55 LOperand* spill_operand) { | |
| 56 ASSERT(spill_operand->IsStackSlot()); | |
| 57 ASSERT(register_spills_[allocation_index] == NULL); | |
| 58 register_spills_[allocation_index] = spill_operand; | |
| 59 } | |
| 60 | |
| 61 | |
| 62 #ifdef DEBUG | 44 #ifdef DEBUG |
| 63 void LInstruction::VerifyCall() { | 45 void LInstruction::VerifyCall() { |
| 64 // Call instructions can use only fixed registers as temporaries and | 46 // Call instructions can use only fixed registers as temporaries and |
| 65 // outputs because all registers are blocked by the calling convention. | 47 // outputs because all registers are blocked by the calling convention. |
| 66 // Inputs operands must use a fixed register or use-at-start policy or | 48 // Inputs operands must use a fixed register or use-at-start policy or |
| 67 // a non-register policy. | 49 // a non-register policy. |
| 68 ASSERT(Output() == NULL || | 50 ASSERT(Output() == NULL || |
| 69 LUnallocated::cast(Output())->HasFixedPolicy() || | 51 LUnallocated::cast(Output())->HasFixedPolicy() || |
| 70 !LUnallocated::cast(Output())->HasRegisterPolicy()); | 52 !LUnallocated::cast(Output())->HasRegisterPolicy()); |
| 71 for (UseIterator it(this); !it.Done(); it.Advance()) { | 53 for (UseIterator it(this); !it.Done(); it.Advance()) { |
| 72 LUnallocated* operand = LUnallocated::cast(it.Current()); | 54 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 73 ASSERT(operand->HasFixedPolicy() || | 55 ASSERT(operand->HasFixedPolicy() || |
| 74 operand->IsUsedAtStart()); | 56 operand->IsUsedAtStart()); |
| 75 } | 57 } |
| 76 for (TempIterator it(this); !it.Done(); it.Advance()) { | 58 for (TempIterator it(this); !it.Done(); it.Advance()) { |
| 77 LUnallocated* operand = LUnallocated::cast(it.Current()); | 59 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 78 ASSERT(operand->HasFixedPolicy() ||!operand->HasRegisterPolicy()); | 60 ASSERT(operand->HasFixedPolicy() ||!operand->HasRegisterPolicy()); |
| 79 } | 61 } |
| 80 } | 62 } |
| 81 #endif | 63 #endif |
| 82 | 64 |
| 83 | 65 |
| 84 void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index, | |
| 85 LOperand* spill_operand) { | |
| 86 ASSERT(spill_operand->IsDoubleStackSlot()); | |
| 87 ASSERT(double_register_spills_[allocation_index] == NULL); | |
| 88 double_register_spills_[allocation_index] = spill_operand; | |
| 89 } | |
| 90 | |
| 91 | |
| 92 void LInstruction::PrintTo(StringStream* stream) { | 66 void LInstruction::PrintTo(StringStream* stream) { |
| 93 stream->Add("%s ", this->Mnemonic()); | 67 stream->Add("%s ", this->Mnemonic()); |
| 94 | 68 |
| 95 PrintOutputOperandTo(stream); | 69 PrintOutputOperandTo(stream); |
| 96 | 70 |
| 97 PrintDataTo(stream); | 71 PrintDataTo(stream); |
| 98 | 72 |
| 99 if (HasEnvironment()) { | 73 if (HasEnvironment()) { |
| 100 stream->Add(" "); | 74 stream->Add(" "); |
| 101 environment()->PrintTo(stream); | 75 environment()->PrintTo(stream); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 return LDoubleStackSlot::Create(index, zone()); | 418 return LDoubleStackSlot::Create(index, zone()); |
| 445 } else { | 419 } else { |
| 446 return LStackSlot::Create(index, zone()); | 420 return LStackSlot::Create(index, zone()); |
| 447 } | 421 } |
| 448 } | 422 } |
| 449 | 423 |
| 450 | 424 |
| 451 LPlatformChunk* LChunkBuilder::Build() { | 425 LPlatformChunk* LChunkBuilder::Build() { |
| 452 ASSERT(is_unused()); | 426 ASSERT(is_unused()); |
| 453 chunk_ = new(zone()) LPlatformChunk(info(), graph()); | 427 chunk_ = new(zone()) LPlatformChunk(info(), graph()); |
| 454 HPhase phase("L_Building chunk", chunk_); | 428 LPhase phase("L_Building chunk", chunk_); |
| 455 status_ = BUILDING; | 429 status_ = BUILDING; |
| 456 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); | 430 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); |
| 457 for (int i = 0; i < blocks->length(); i++) { | 431 for (int i = 0; i < blocks->length(); i++) { |
| 458 HBasicBlock* next = NULL; | 432 HBasicBlock* next = NULL; |
| 459 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 433 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
| 460 DoBasicBlock(blocks->at(i), next); | 434 DoBasicBlock(blocks->at(i), next); |
| 461 if (is_aborted()) return NULL; | 435 if (is_aborted()) return NULL; |
| 462 } | 436 } |
| 463 status_ = DONE; | 437 status_ = DONE; |
| 464 return chunk_; | 438 return chunk_; |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 HValue* value = instr->value(); | 966 HValue* value = instr->value(); |
| 993 if (value->EmitAtUses()) { | 967 if (value->EmitAtUses()) { |
| 994 HBasicBlock* successor = HConstant::cast(value)->BooleanValue() | 968 HBasicBlock* successor = HConstant::cast(value)->BooleanValue() |
| 995 ? instr->FirstSuccessor() | 969 ? instr->FirstSuccessor() |
| 996 : instr->SecondSuccessor(); | 970 : instr->SecondSuccessor(); |
| 997 return new(zone()) LGoto(successor->block_id()); | 971 return new(zone()) LGoto(successor->block_id()); |
| 998 } | 972 } |
| 999 | 973 |
| 1000 LBranch* result = new(zone()) LBranch(UseRegister(value)); | 974 LBranch* result = new(zone()) LBranch(UseRegister(value)); |
| 1001 // Tagged values that are not known smis or booleans require a | 975 // Tagged values that are not known smis or booleans require a |
| 1002 // deoptimization environment. | 976 // deoptimization environment. If the instruction is generic no |
| 977 // environment is needed since all cases are handled. |
| 1003 Representation rep = value->representation(); | 978 Representation rep = value->representation(); |
| 1004 HType type = value->type(); | 979 HType type = value->type(); |
| 1005 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean()) { | 980 ToBooleanStub::Types expected = instr->expected_input_types(); |
| 981 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean() && |
| 982 !expected.IsGeneric()) { |
| 1006 return AssignEnvironment(result); | 983 return AssignEnvironment(result); |
| 1007 } | 984 } |
| 1008 return result; | 985 return result; |
| 1009 } | 986 } |
| 1010 | 987 |
| 1011 | 988 |
| 1012 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { | 989 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { |
| 1013 return new(zone()) LDebugBreak(); | 990 return new(zone()) LDebugBreak(); |
| 1014 } | 991 } |
| 1015 | 992 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 ASSERT(right->representation().IsInteger32()); | 1430 ASSERT(right->representation().IsInteger32()); |
| 1454 if (instr->HasPowerOf2Divisor()) { | 1431 if (instr->HasPowerOf2Divisor()) { |
| 1455 ASSERT(!right->CanBeZero()); | 1432 ASSERT(!right->CanBeZero()); |
| 1456 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), | 1433 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), |
| 1457 UseOrConstant(right)); | 1434 UseOrConstant(right)); |
| 1458 LInstruction* result = DefineAsRegister(mod); | 1435 LInstruction* result = DefineAsRegister(mod); |
| 1459 return (left->CanBeNegative() && | 1436 return (left->CanBeNegative() && |
| 1460 instr->CheckFlag(HValue::kBailoutOnMinusZero)) | 1437 instr->CheckFlag(HValue::kBailoutOnMinusZero)) |
| 1461 ? AssignEnvironment(result) | 1438 ? AssignEnvironment(result) |
| 1462 : result; | 1439 : result; |
| 1463 } else if (instr->has_fixed_right_arg()) { | 1440 } else if (instr->fixed_right_arg().has_value) { |
| 1464 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), | 1441 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), |
| 1465 UseRegisterAtStart(right)); | 1442 UseRegisterAtStart(right)); |
| 1466 return AssignEnvironment(DefineAsRegister(mod)); | 1443 return AssignEnvironment(DefineAsRegister(mod)); |
| 1467 } else if (CpuFeatures::IsSupported(SUDIV)) { | 1444 } else if (CpuFeatures::IsSupported(SUDIV)) { |
| 1468 LModI* mod = new(zone()) LModI(UseRegister(left), | 1445 LModI* mod = new(zone()) LModI(UseRegister(left), |
| 1469 UseRegister(right)); | 1446 UseRegister(right)); |
| 1470 LInstruction* result = DefineAsRegister(mod); | 1447 LInstruction* result = DefineAsRegister(mod); |
| 1471 return (right->CanBeZero() || | 1448 return (right->CanBeZero() || |
| 1472 (left->RangeCanInclude(kMinInt) && | 1449 (left->RangeCanInclude(kMinInt) && |
| 1473 right->RangeCanInclude(-1) && | 1450 right->RangeCanInclude(-1) && |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 return DefineAsRegister( | 1993 return DefineAsRegister( |
| 2017 new(zone()) LInteger32ToDouble(Use(instr->value()))); | 1994 new(zone()) LInteger32ToDouble(Use(instr->value()))); |
| 2018 } | 1995 } |
| 2019 } | 1996 } |
| 2020 } | 1997 } |
| 2021 UNREACHABLE(); | 1998 UNREACHABLE(); |
| 2022 return NULL; | 1999 return NULL; |
| 2023 } | 2000 } |
| 2024 | 2001 |
| 2025 | 2002 |
| 2026 LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { | 2003 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { |
| 2027 LOperand* value = UseRegisterAtStart(instr->value()); | 2004 LOperand* value = UseRegisterAtStart(instr->value()); |
| 2028 return AssignEnvironment(new(zone()) LCheckNonSmi(value)); | 2005 return AssignEnvironment(new(zone()) LCheckNonSmi(value)); |
| 2029 } | 2006 } |
| 2030 | 2007 |
| 2031 | 2008 |
| 2032 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { | 2009 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { |
| 2033 LOperand* value = UseRegisterAtStart(instr->value()); | 2010 LOperand* value = UseRegisterAtStart(instr->value()); |
| 2034 LInstruction* result = new(zone()) LCheckInstanceType(value); | 2011 LInstruction* result = new(zone()) LCheckInstanceType(value); |
| 2035 return AssignEnvironment(result); | 2012 return AssignEnvironment(result); |
| 2036 } | 2013 } |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2413 return AssignPointerMap(DefineAsRegister(result)); | 2390 return AssignPointerMap(DefineAsRegister(result)); |
| 2414 } | 2391 } |
| 2415 | 2392 |
| 2416 | 2393 |
| 2417 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { | 2394 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { |
| 2418 LOperand* string = UseRegisterAtStart(instr->value()); | 2395 LOperand* string = UseRegisterAtStart(instr->value()); |
| 2419 return DefineAsRegister(new(zone()) LStringLength(string)); | 2396 return DefineAsRegister(new(zone()) LStringLength(string)); |
| 2420 } | 2397 } |
| 2421 | 2398 |
| 2422 | 2399 |
| 2400 LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) { |
| 2401 info()->MarkAsDeferredCalling(); |
| 2402 LAllocateObject* result = |
| 2403 new(zone()) LAllocateObject(TempRegister(), TempRegister()); |
| 2404 return AssignPointerMap(DefineAsRegister(result)); |
| 2405 } |
| 2406 |
| 2407 |
| 2423 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { | 2408 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { |
| 2424 info()->MarkAsDeferredCalling(); | 2409 info()->MarkAsDeferredCalling(); |
| 2425 LOperand* size = instr->size()->IsConstant() | 2410 LOperand* size = instr->size()->IsConstant() |
| 2426 ? UseConstant(instr->size()) | 2411 ? UseConstant(instr->size()) |
| 2427 : UseTempRegister(instr->size()); | 2412 : UseTempRegister(instr->size()); |
| 2428 LOperand* temp1 = TempRegister(); | 2413 LOperand* temp1 = TempRegister(); |
| 2429 LOperand* temp2 = TempRegister(); | 2414 LOperand* temp2 = TempRegister(); |
| 2430 LAllocate* result = new(zone()) LAllocate(size, temp1, temp2); | 2415 LAllocate* result = new(zone()) LAllocate(size, temp1, temp2); |
| 2431 return AssignPointerMap(DefineAsRegister(result)); | 2416 return AssignPointerMap(DefineAsRegister(result)); |
| 2432 } | 2417 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2651 | 2636 |
| 2652 | 2637 |
| 2653 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2638 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2654 LOperand* object = UseRegister(instr->object()); | 2639 LOperand* object = UseRegister(instr->object()); |
| 2655 LOperand* index = UseRegister(instr->index()); | 2640 LOperand* index = UseRegister(instr->index()); |
| 2656 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2641 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2657 } | 2642 } |
| 2658 | 2643 |
| 2659 | 2644 |
| 2660 } } // namespace v8::internal | 2645 } } // namespace v8::internal |
| OLD | NEW |