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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 LInstruction* LChunkBuilder::DefineFixedDouble( | 656 LInstruction* LChunkBuilder::DefineFixedDouble( |
657 LTemplateInstruction<1, I, T>* instr, | 657 LTemplateInstruction<1, I, T>* instr, |
658 XMMRegister reg) { | 658 XMMRegister reg) { |
659 return Define(instr, ToUnallocated(reg)); | 659 return Define(instr, ToUnallocated(reg)); |
660 } | 660 } |
661 | 661 |
662 | 662 |
663 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 663 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
664 HEnvironment* hydrogen_env = current_block_->last_environment(); | 664 HEnvironment* hydrogen_env = current_block_->last_environment(); |
665 int argument_index_accumulator = 0; | 665 int argument_index_accumulator = 0; |
| 666 ZoneList<HValue*> objects_to_materialize(0, zone()); |
666 instr->set_environment(CreateEnvironment(hydrogen_env, | 667 instr->set_environment(CreateEnvironment(hydrogen_env, |
667 &argument_index_accumulator)); | 668 &argument_index_accumulator, |
| 669 &objects_to_materialize)); |
668 return instr; | 670 return instr; |
669 } | 671 } |
670 | 672 |
671 | 673 |
672 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 674 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
673 HInstruction* hinstr, | 675 HInstruction* hinstr, |
674 CanDeoptimize can_deoptimize) { | 676 CanDeoptimize can_deoptimize) { |
675 info()->MarkAsNonDeferredCalling(); | 677 info()->MarkAsNonDeferredCalling(); |
676 | 678 |
677 #ifdef DEBUG | 679 #ifdef DEBUG |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 } | 966 } |
965 instr->set_hydrogen_value(current); | 967 instr->set_hydrogen_value(current); |
966 chunk_->AddInstruction(instr, current_block_); | 968 chunk_->AddInstruction(instr, current_block_); |
967 } | 969 } |
968 current_instruction_ = old_current; | 970 current_instruction_ = old_current; |
969 } | 971 } |
970 | 972 |
971 | 973 |
972 LEnvironment* LChunkBuilder::CreateEnvironment( | 974 LEnvironment* LChunkBuilder::CreateEnvironment( |
973 HEnvironment* hydrogen_env, | 975 HEnvironment* hydrogen_env, |
974 int* argument_index_accumulator) { | 976 int* argument_index_accumulator, |
| 977 ZoneList<HValue*>* objects_to_materialize) { |
975 if (hydrogen_env == NULL) return NULL; | 978 if (hydrogen_env == NULL) return NULL; |
976 | 979 |
977 LEnvironment* outer = | 980 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), |
978 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 981 argument_index_accumulator, |
| 982 objects_to_materialize); |
979 BailoutId ast_id = hydrogen_env->ast_id(); | 983 BailoutId ast_id = hydrogen_env->ast_id(); |
980 ASSERT(!ast_id.IsNone() || | 984 ASSERT(!ast_id.IsNone() || |
981 hydrogen_env->frame_type() != JS_FUNCTION); | 985 hydrogen_env->frame_type() != JS_FUNCTION); |
982 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 986 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
983 LEnvironment* result = | 987 LEnvironment* result = |
984 new(zone()) LEnvironment(hydrogen_env->closure(), | 988 new(zone()) LEnvironment(hydrogen_env->closure(), |
985 hydrogen_env->frame_type(), | 989 hydrogen_env->frame_type(), |
986 ast_id, | 990 ast_id, |
987 hydrogen_env->parameter_count(), | 991 hydrogen_env->parameter_count(), |
988 argument_count_, | 992 argument_count_, |
989 value_count, | 993 value_count, |
990 outer, | 994 outer, |
991 hydrogen_env->entry(), | 995 hydrogen_env->entry(), |
992 zone()); | 996 zone()); |
993 bool needs_arguments_object_materialization = false; | |
994 int argument_index = *argument_index_accumulator; | 997 int argument_index = *argument_index_accumulator; |
| 998 int object_index = objects_to_materialize->length(); |
995 for (int i = 0; i < hydrogen_env->length(); ++i) { | 999 for (int i = 0; i < hydrogen_env->length(); ++i) { |
996 if (hydrogen_env->is_special_index(i)) continue; | 1000 if (hydrogen_env->is_special_index(i)) continue; |
997 | 1001 |
| 1002 LOperand* op; |
998 HValue* value = hydrogen_env->values()->at(i); | 1003 HValue* value = hydrogen_env->values()->at(i); |
999 LOperand* op = NULL; | 1004 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
1000 if (value->IsArgumentsObject()) { | 1005 objects_to_materialize->Add(value, zone()); |
1001 needs_arguments_object_materialization = true; | 1006 op = LEnvironment::materialization_marker(); |
1002 op = NULL; | |
1003 } else if (value->IsPushArgument()) { | 1007 } else if (value->IsPushArgument()) { |
1004 op = new(zone()) LArgument(argument_index++); | 1008 op = new(zone()) LArgument(argument_index++); |
1005 } else { | 1009 } else { |
1006 op = UseAny(value); | 1010 op = UseAny(value); |
1007 } | 1011 } |
1008 result->AddValue(op, | 1012 result->AddValue(op, |
1009 value->representation(), | 1013 value->representation(), |
1010 value->CheckFlag(HInstruction::kUint32)); | 1014 value->CheckFlag(HInstruction::kUint32)); |
1011 } | 1015 } |
1012 | 1016 |
1013 if (needs_arguments_object_materialization) { | 1017 for (int i = object_index; i < objects_to_materialize->length(); ++i) { |
1014 HArgumentsObject* arguments = hydrogen_env->entry() == NULL | 1018 HValue* object_to_materialize = objects_to_materialize->at(i); |
1015 ? graph()->GetArgumentsObject() | 1019 int previously_materialized_object = -1; |
1016 : hydrogen_env->entry()->arguments_object(); | 1020 for (int prev = 0; prev < i; ++prev) { |
1017 ASSERT(arguments->IsLinked()); | 1021 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { |
1018 for (int i = 1; i < arguments->arguments_count(); ++i) { | 1022 previously_materialized_object = prev; |
1019 HValue* value = arguments->arguments_values()->at(i); | 1023 break; |
1020 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); | 1024 } |
1021 LOperand* op = UseAny(value); | 1025 } |
| 1026 int length = object_to_materialize->OperandCount(); |
| 1027 bool is_arguments = object_to_materialize->IsArgumentsObject(); |
| 1028 if (previously_materialized_object >= 0) { |
| 1029 result->AddDuplicateObject(previously_materialized_object); |
| 1030 continue; |
| 1031 } else { |
| 1032 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); |
| 1033 } |
| 1034 for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
| 1035 LOperand* op; |
| 1036 HValue* value = object_to_materialize->OperandAt(i); |
| 1037 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 1038 objects_to_materialize->Add(value, zone()); |
| 1039 op = LEnvironment::materialization_marker(); |
| 1040 } else { |
| 1041 ASSERT(!value->IsPushArgument()); |
| 1042 op = UseAny(value); |
| 1043 } |
1022 result->AddValue(op, | 1044 result->AddValue(op, |
1023 value->representation(), | 1045 value->representation(), |
1024 value->CheckFlag(HInstruction::kUint32)); | 1046 value->CheckFlag(HInstruction::kUint32)); |
1025 } | 1047 } |
1026 } | 1048 } |
1027 | 1049 |
1028 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 1050 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
1029 *argument_index_accumulator = argument_index; | 1051 *argument_index_accumulator = argument_index; |
1030 } | 1052 } |
1031 | 1053 |
(...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 | 2638 |
2617 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | 2639 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
2618 // There are no real uses of the arguments object. | 2640 // There are no real uses of the arguments object. |
2619 // arguments.length and element access are supported directly on | 2641 // arguments.length and element access are supported directly on |
2620 // stack arguments, and any real arguments object use causes a bailout. | 2642 // stack arguments, and any real arguments object use causes a bailout. |
2621 // So this value is never used. | 2643 // So this value is never used. |
2622 return NULL; | 2644 return NULL; |
2623 } | 2645 } |
2624 | 2646 |
2625 | 2647 |
| 2648 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { |
| 2649 // There are no real uses of a captured object. |
| 2650 return NULL; |
| 2651 } |
| 2652 |
| 2653 |
2626 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { | 2654 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { |
2627 info()->MarkAsRequiresFrame(); | 2655 info()->MarkAsRequiresFrame(); |
2628 LOperand* args = UseRegister(instr->arguments()); | 2656 LOperand* args = UseRegister(instr->arguments()); |
2629 LOperand* length; | 2657 LOperand* length; |
2630 LOperand* index; | 2658 LOperand* index; |
2631 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { | 2659 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { |
2632 length = UseRegisterOrConstant(instr->length()); | 2660 length = UseRegisterOrConstant(instr->length()); |
2633 index = UseOrConstant(instr->index()); | 2661 index = UseOrConstant(instr->index()); |
2634 } else { | 2662 } else { |
2635 length = UseTempRegister(instr->length()); | 2663 length = UseTempRegister(instr->length()); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2777 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2805 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2778 LOperand* object = UseRegister(instr->object()); | 2806 LOperand* object = UseRegister(instr->object()); |
2779 LOperand* index = UseTempRegister(instr->index()); | 2807 LOperand* index = UseTempRegister(instr->index()); |
2780 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2808 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2781 } | 2809 } |
2782 | 2810 |
2783 | 2811 |
2784 } } // namespace v8::internal | 2812 } } // namespace v8::internal |
2785 | 2813 |
2786 #endif // V8_TARGET_ARCH_IA32 | 2814 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |