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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 template<int I, int T> | 604 template<int I, int T> |
605 LInstruction* LChunkBuilder::DefineFixedDouble( | 605 LInstruction* LChunkBuilder::DefineFixedDouble( |
606 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) { | 606 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) { |
607 return Define(instr, ToUnallocated(reg)); | 607 return Define(instr, ToUnallocated(reg)); |
608 } | 608 } |
609 | 609 |
610 | 610 |
611 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 611 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
612 HEnvironment* hydrogen_env = current_block_->last_environment(); | 612 HEnvironment* hydrogen_env = current_block_->last_environment(); |
613 int argument_index_accumulator = 0; | 613 int argument_index_accumulator = 0; |
| 614 ZoneList<HValue*> objects_to_materialize(0, zone()); |
614 instr->set_environment(CreateEnvironment(hydrogen_env, | 615 instr->set_environment(CreateEnvironment(hydrogen_env, |
615 &argument_index_accumulator)); | 616 &argument_index_accumulator, |
| 617 &objects_to_materialize)); |
616 return instr; | 618 return instr; |
617 } | 619 } |
618 | 620 |
619 | 621 |
620 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 622 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
621 HInstruction* hinstr, | 623 HInstruction* hinstr, |
622 CanDeoptimize can_deoptimize) { | 624 CanDeoptimize can_deoptimize) { |
623 info()->MarkAsNonDeferredCalling(); | 625 info()->MarkAsNonDeferredCalling(); |
624 #ifdef DEBUG | 626 #ifdef DEBUG |
625 instr->VerifyCall(); | 627 instr->VerifyCall(); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 } | 911 } |
910 instr->set_hydrogen_value(current); | 912 instr->set_hydrogen_value(current); |
911 chunk_->AddInstruction(instr, current_block_); | 913 chunk_->AddInstruction(instr, current_block_); |
912 } | 914 } |
913 current_instruction_ = old_current; | 915 current_instruction_ = old_current; |
914 } | 916 } |
915 | 917 |
916 | 918 |
917 LEnvironment* LChunkBuilder::CreateEnvironment( | 919 LEnvironment* LChunkBuilder::CreateEnvironment( |
918 HEnvironment* hydrogen_env, | 920 HEnvironment* hydrogen_env, |
919 int* argument_index_accumulator) { | 921 int* argument_index_accumulator, |
| 922 ZoneList<HValue*>* objects_to_materialize) { |
920 if (hydrogen_env == NULL) return NULL; | 923 if (hydrogen_env == NULL) return NULL; |
921 | 924 |
922 LEnvironment* outer = | 925 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), |
923 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 926 argument_index_accumulator, |
| 927 objects_to_materialize); |
924 BailoutId ast_id = hydrogen_env->ast_id(); | 928 BailoutId ast_id = hydrogen_env->ast_id(); |
925 ASSERT(!ast_id.IsNone() || | 929 ASSERT(!ast_id.IsNone() || |
926 hydrogen_env->frame_type() != JS_FUNCTION); | 930 hydrogen_env->frame_type() != JS_FUNCTION); |
927 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 931 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
928 LEnvironment* result = new(zone()) LEnvironment( | 932 LEnvironment* result = new(zone()) LEnvironment( |
929 hydrogen_env->closure(), | 933 hydrogen_env->closure(), |
930 hydrogen_env->frame_type(), | 934 hydrogen_env->frame_type(), |
931 ast_id, | 935 ast_id, |
932 hydrogen_env->parameter_count(), | 936 hydrogen_env->parameter_count(), |
933 argument_count_, | 937 argument_count_, |
934 value_count, | 938 value_count, |
935 outer, | 939 outer, |
936 hydrogen_env->entry(), | 940 hydrogen_env->entry(), |
937 zone()); | 941 zone()); |
938 bool needs_arguments_object_materialization = false; | |
939 int argument_index = *argument_index_accumulator; | 942 int argument_index = *argument_index_accumulator; |
| 943 int object_index = objects_to_materialize->length(); |
940 for (int i = 0; i < hydrogen_env->length(); ++i) { | 944 for (int i = 0; i < hydrogen_env->length(); ++i) { |
941 if (hydrogen_env->is_special_index(i)) continue; | 945 if (hydrogen_env->is_special_index(i)) continue; |
942 | 946 |
| 947 LOperand* op; |
943 HValue* value = hydrogen_env->values()->at(i); | 948 HValue* value = hydrogen_env->values()->at(i); |
944 LOperand* op = NULL; | 949 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
945 if (value->IsArgumentsObject()) { | 950 objects_to_materialize->Add(value, zone()); |
946 needs_arguments_object_materialization = true; | 951 op = LEnvironment::materialization_marker(); |
947 op = NULL; | |
948 } else if (value->IsPushArgument()) { | 952 } else if (value->IsPushArgument()) { |
949 op = new(zone()) LArgument(argument_index++); | 953 op = new(zone()) LArgument(argument_index++); |
950 } else { | 954 } else { |
951 op = UseAny(value); | 955 op = UseAny(value); |
952 } | 956 } |
953 result->AddValue(op, | 957 result->AddValue(op, |
954 value->representation(), | 958 value->representation(), |
955 value->CheckFlag(HInstruction::kUint32)); | 959 value->CheckFlag(HInstruction::kUint32)); |
956 } | 960 } |
957 | 961 |
958 if (needs_arguments_object_materialization) { | 962 for (int i = object_index; i < objects_to_materialize->length(); ++i) { |
959 HArgumentsObject* arguments = hydrogen_env->entry() == NULL | 963 HValue* object_to_materialize = objects_to_materialize->at(i); |
960 ? graph()->GetArgumentsObject() | 964 int previously_materialized_object = -1; |
961 : hydrogen_env->entry()->arguments_object(); | 965 for (int prev = 0; prev < i; ++prev) { |
962 ASSERT(arguments->IsLinked()); | 966 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { |
963 for (int i = 1; i < arguments->arguments_count(); ++i) { | 967 previously_materialized_object = prev; |
964 HValue* value = arguments->arguments_values()->at(i); | 968 break; |
965 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); | 969 } |
966 LOperand* op = UseAny(value); | 970 } |
| 971 int length = object_to_materialize->OperandCount(); |
| 972 bool is_arguments = object_to_materialize->IsArgumentsObject(); |
| 973 if (previously_materialized_object >= 0) { |
| 974 result->AddDuplicateObject(previously_materialized_object); |
| 975 continue; |
| 976 } else { |
| 977 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); |
| 978 } |
| 979 for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
| 980 LOperand* op; |
| 981 HValue* value = object_to_materialize->OperandAt(i); |
| 982 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 983 objects_to_materialize->Add(value, zone()); |
| 984 op = LEnvironment::materialization_marker(); |
| 985 } else { |
| 986 ASSERT(!value->IsPushArgument()); |
| 987 op = UseAny(value); |
| 988 } |
967 result->AddValue(op, | 989 result->AddValue(op, |
968 value->representation(), | 990 value->representation(), |
969 value->CheckFlag(HInstruction::kUint32)); | 991 value->CheckFlag(HInstruction::kUint32)); |
970 } | 992 } |
971 } | 993 } |
972 | 994 |
973 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 995 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
974 *argument_index_accumulator = argument_index; | 996 *argument_index_accumulator = argument_index; |
975 } | 997 } |
976 | 998 |
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 | 2510 |
2489 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | 2511 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
2490 // There are no real uses of the arguments object. | 2512 // There are no real uses of the arguments object. |
2491 // arguments.length and element access are supported directly on | 2513 // arguments.length and element access are supported directly on |
2492 // stack arguments, and any real arguments object use causes a bailout. | 2514 // stack arguments, and any real arguments object use causes a bailout. |
2493 // So this value is never used. | 2515 // So this value is never used. |
2494 return NULL; | 2516 return NULL; |
2495 } | 2517 } |
2496 | 2518 |
2497 | 2519 |
| 2520 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { |
| 2521 // There are no real uses of a captured object. |
| 2522 return NULL; |
| 2523 } |
| 2524 |
| 2525 |
2498 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { | 2526 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { |
2499 info()->MarkAsRequiresFrame(); | 2527 info()->MarkAsRequiresFrame(); |
2500 LOperand* args = UseRegister(instr->arguments()); | 2528 LOperand* args = UseRegister(instr->arguments()); |
2501 LOperand* length; | 2529 LOperand* length; |
2502 LOperand* index; | 2530 LOperand* index; |
2503 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { | 2531 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { |
2504 length = UseRegisterOrConstant(instr->length()); | 2532 length = UseRegisterOrConstant(instr->length()); |
2505 index = UseOrConstant(instr->index()); | 2533 index = UseOrConstant(instr->index()); |
2506 } else { | 2534 } else { |
2507 length = UseTempRegister(instr->length()); | 2535 length = UseTempRegister(instr->length()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2639 | 2667 |
2640 | 2668 |
2641 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2669 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2642 LOperand* object = UseRegister(instr->object()); | 2670 LOperand* object = UseRegister(instr->object()); |
2643 LOperand* index = UseRegister(instr->index()); | 2671 LOperand* index = UseRegister(instr->index()); |
2644 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2672 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2645 } | 2673 } |
2646 | 2674 |
2647 | 2675 |
2648 } } // namespace v8::internal | 2676 } } // namespace v8::internal |
OLD | NEW |