| 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 | 585 |
| 586 LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) { | 586 LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) { |
| 587 LUnallocated* operand = ToUnallocated(reg); | 587 LUnallocated* operand = ToUnallocated(reg); |
| 588 ASSERT(operand->HasFixedPolicy()); | 588 ASSERT(operand->HasFixedPolicy()); |
| 589 return operand; | 589 return operand; |
| 590 } | 590 } |
| 591 | 591 |
| 592 | 592 |
| 593 LPlatformChunk* LChunkBuilder::Build() { | 593 LPlatformChunk* LChunkBuilder::Build() { |
| 594 ASSERT(is_unused()); | 594 ASSERT(is_unused()); |
| 595 chunk_ = new(zone_) LPlatformChunk(info_, graph_); | 595 chunk_ = new(zone()) LPlatformChunk(info_, graph_); |
| 596 LPhase phase("L_Building chunk", chunk_); | 596 LPhase phase("L_Building chunk", chunk_); |
| 597 status_ = BUILDING; | 597 status_ = BUILDING; |
| 598 | 598 |
| 599 // If compiling for OSR, reserve space for the unoptimized frame, | 599 // If compiling for OSR, reserve space for the unoptimized frame, |
| 600 // which will be subsumed into this frame. | 600 // which will be subsumed into this frame. |
| 601 if (graph()->has_osr()) { | 601 if (graph()->has_osr()) { |
| 602 // TODO(all): GetNextSpillIndex just increments a field. It has no other | 602 // TODO(all): GetNextSpillIndex just increments a field. It has no other |
| 603 // side effects, so we should get rid of this loop. | 603 // side effects, so we should get rid of this loop. |
| 604 for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { | 604 for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { |
| 605 chunk_->GetNextSpillIndex(); | 605 chunk_->GetNextSpillIndex(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 HEnvironment* hydrogen_env = current_block_->last_environment(); | 761 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 762 int argument_index_accumulator = 0; | 762 int argument_index_accumulator = 0; |
| 763 ZoneList<HValue*> objects_to_materialize(0, zone()); | 763 ZoneList<HValue*> objects_to_materialize(0, zone()); |
| 764 instr->set_environment(CreateEnvironment(hydrogen_env, | 764 instr->set_environment(CreateEnvironment(hydrogen_env, |
| 765 &argument_index_accumulator, | 765 &argument_index_accumulator, |
| 766 &objects_to_materialize)); | 766 &objects_to_materialize)); |
| 767 return instr; | 767 return instr; |
| 768 } | 768 } |
| 769 | 769 |
| 770 | 770 |
| 771 LEnvironment* LChunkBuilder::CreateEnvironment( | |
| 772 HEnvironment* hydrogen_env, | |
| 773 int* argument_index_accumulator, | |
| 774 ZoneList<HValue*>* objects_to_materialize) { | |
| 775 if (hydrogen_env == NULL) return NULL; | |
| 776 | |
| 777 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), | |
| 778 argument_index_accumulator, | |
| 779 objects_to_materialize); | |
| 780 BailoutId ast_id = hydrogen_env->ast_id(); | |
| 781 ASSERT(!ast_id.IsNone() || (hydrogen_env->frame_type() != JS_FUNCTION)); | |
| 782 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | |
| 783 | |
| 784 LEnvironment* result = new(zone()) LEnvironment( | |
| 785 hydrogen_env->closure(), | |
| 786 hydrogen_env->frame_type(), | |
| 787 ast_id, | |
| 788 hydrogen_env->parameter_count(), | |
| 789 argument_count(), | |
| 790 value_count, | |
| 791 outer, | |
| 792 hydrogen_env->entry(), | |
| 793 zone()); | |
| 794 | |
| 795 int argument_index = *argument_index_accumulator; | |
| 796 int object_index = objects_to_materialize->length(); | |
| 797 for (int i = 0; i < hydrogen_env->length(); ++i) { | |
| 798 if (hydrogen_env->is_special_index(i)) continue; | |
| 799 | |
| 800 LOperand* op; | |
| 801 HValue* value = hydrogen_env->values()->at(i); | |
| 802 if (value->IsArgumentsObject() || value->IsCapturedObject()) { | |
| 803 objects_to_materialize->Add(value, zone()); | |
| 804 op = LEnvironment::materialization_marker(); | |
| 805 } else if (value->IsPushArgument()) { | |
| 806 op = new(zone()) LArgument(argument_index++); | |
| 807 } else { | |
| 808 op = UseAny(value); | |
| 809 } | |
| 810 result->AddValue(op, | |
| 811 value->representation(), | |
| 812 value->CheckFlag(HInstruction::kUint32)); | |
| 813 } | |
| 814 | |
| 815 for (int i = object_index; i < objects_to_materialize->length(); ++i) { | |
| 816 HValue* object_to_materialize = objects_to_materialize->at(i); | |
| 817 int previously_materialized_object = -1; | |
| 818 for (int prev = 0; prev < i; ++prev) { | |
| 819 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { | |
| 820 previously_materialized_object = prev; | |
| 821 break; | |
| 822 } | |
| 823 } | |
| 824 int length = object_to_materialize->OperandCount(); | |
| 825 bool is_arguments = object_to_materialize->IsArgumentsObject(); | |
| 826 if (previously_materialized_object >= 0) { | |
| 827 result->AddDuplicateObject(previously_materialized_object); | |
| 828 continue; | |
| 829 } else { | |
| 830 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); | |
| 831 } | |
| 832 for (int i = is_arguments ? 1 : 0; i < length; ++i) { | |
| 833 LOperand* op; | |
| 834 HValue* value = object_to_materialize->OperandAt(i); | |
| 835 if (value->IsArgumentsObject() || value->IsCapturedObject()) { | |
| 836 objects_to_materialize->Add(value, zone()); | |
| 837 op = LEnvironment::materialization_marker(); | |
| 838 } else { | |
| 839 ASSERT(!value->IsPushArgument()); | |
| 840 op = UseAny(value); | |
| 841 } | |
| 842 result->AddValue(op, | |
| 843 value->representation(), | |
| 844 value->CheckFlag(HInstruction::kUint32)); | |
| 845 } | |
| 846 } | |
| 847 | |
| 848 if (hydrogen_env->frame_type() == JS_FUNCTION) { | |
| 849 *argument_index_accumulator = argument_index; | |
| 850 } | |
| 851 | |
| 852 return result; | |
| 853 } | |
| 854 | |
| 855 | |
| 856 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { | 771 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { |
| 857 // The control instruction marking the end of a block that completed | 772 // The control instruction marking the end of a block that completed |
| 858 // abruptly (e.g., threw an exception). There is nothing specific to do. | 773 // abruptly (e.g., threw an exception). There is nothing specific to do. |
| 859 return NULL; | 774 return NULL; |
| 860 } | 775 } |
| 861 | 776 |
| 862 | 777 |
| 863 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 778 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| 864 HArithmeticBinaryOperation* instr) { | 779 HArithmeticBinaryOperation* instr) { |
| 865 ASSERT(instr->representation().IsDouble()); | 780 ASSERT(instr->representation().IsDouble()); |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 } | 1416 } |
| 1502 | 1417 |
| 1503 | 1418 |
| 1504 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | 1419 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
| 1505 HEnvironment* outer = current_block_->last_environment(); | 1420 HEnvironment* outer = current_block_->last_environment(); |
| 1506 HConstant* undefined = graph()->GetConstantUndefined(); | 1421 HConstant* undefined = graph()->GetConstantUndefined(); |
| 1507 HEnvironment* inner = outer->CopyForInlining(instr->closure(), | 1422 HEnvironment* inner = outer->CopyForInlining(instr->closure(), |
| 1508 instr->arguments_count(), | 1423 instr->arguments_count(), |
| 1509 instr->function(), | 1424 instr->function(), |
| 1510 undefined, | 1425 undefined, |
| 1511 instr->inlining_kind(), | 1426 instr->inlining_kind()); |
| 1512 instr->undefined_receiver()); | |
| 1513 // Only replay binding of arguments object if it wasn't removed from graph. | 1427 // Only replay binding of arguments object if it wasn't removed from graph. |
| 1514 if ((instr->arguments_var() != NULL) && | 1428 if ((instr->arguments_var() != NULL) && |
| 1515 instr->arguments_object()->IsLinked()) { | 1429 instr->arguments_object()->IsLinked()) { |
| 1516 inner->Bind(instr->arguments_var(), instr->arguments_object()); | 1430 inner->Bind(instr->arguments_var(), instr->arguments_object()); |
| 1517 } | 1431 } |
| 1518 inner->set_entry(instr); | 1432 inner->set_entry(instr); |
| 1519 current_block_->UpdateEnvironment(inner); | 1433 current_block_->UpdateEnvironment(inner); |
| 1520 chunk_->AddInlinedClosure(instr->closure()); | 1434 chunk_->AddInlinedClosure(instr->closure()); |
| 1521 return NULL; | 1435 return NULL; |
| 1522 } | 1436 } |
| (...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2567 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | 2481 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
| 2568 LOperand* receiver = UseRegister(instr->receiver()); | 2482 LOperand* receiver = UseRegister(instr->receiver()); |
| 2569 LOperand* function = UseRegisterAtStart(instr->function()); | 2483 LOperand* function = UseRegisterAtStart(instr->function()); |
| 2570 LOperand* temp = TempRegister(); | 2484 LOperand* temp = TempRegister(); |
| 2571 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function, temp); | 2485 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function, temp); |
| 2572 return AssignEnvironment(DefineAsRegister(result)); | 2486 return AssignEnvironment(DefineAsRegister(result)); |
| 2573 } | 2487 } |
| 2574 | 2488 |
| 2575 | 2489 |
| 2576 } } // namespace v8::internal | 2490 } } // namespace v8::internal |
| OLD | NEW |