| 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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 } | 929 } |
| 930 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 930 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 931 instr = AssignEnvironment(instr); | 931 instr = AssignEnvironment(instr); |
| 932 } | 932 } |
| 933 chunk_->AddInstruction(instr, current_block_); | 933 chunk_->AddInstruction(instr, current_block_); |
| 934 } | 934 } |
| 935 current_instruction_ = old_current; | 935 current_instruction_ = old_current; |
| 936 } | 936 } |
| 937 | 937 |
| 938 | 938 |
| 939 LEnvironment* LChunkBuilder::CreateEnvironment( | |
| 940 HEnvironment* hydrogen_env, | |
| 941 int* argument_index_accumulator, | |
| 942 ZoneList<HValue*>* objects_to_materialize) { | |
| 943 if (hydrogen_env == NULL) return NULL; | |
| 944 | |
| 945 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), | |
| 946 argument_index_accumulator, | |
| 947 objects_to_materialize); | |
| 948 BailoutId ast_id = hydrogen_env->ast_id(); | |
| 949 ASSERT(!ast_id.IsNone() || | |
| 950 hydrogen_env->frame_type() != JS_FUNCTION); | |
| 951 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | |
| 952 LEnvironment* result = new(zone()) LEnvironment( | |
| 953 hydrogen_env->closure(), | |
| 954 hydrogen_env->frame_type(), | |
| 955 ast_id, | |
| 956 hydrogen_env->parameter_count(), | |
| 957 argument_count_, | |
| 958 value_count, | |
| 959 outer, | |
| 960 hydrogen_env->entry(), | |
| 961 zone()); | |
| 962 int argument_index = *argument_index_accumulator; | |
| 963 int object_index = objects_to_materialize->length(); | |
| 964 for (int i = 0; i < hydrogen_env->length(); ++i) { | |
| 965 if (hydrogen_env->is_special_index(i)) continue; | |
| 966 | |
| 967 LOperand* op; | |
| 968 HValue* value = hydrogen_env->values()->at(i); | |
| 969 if (value->IsArgumentsObject() || value->IsCapturedObject()) { | |
| 970 objects_to_materialize->Add(value, zone()); | |
| 971 op = LEnvironment::materialization_marker(); | |
| 972 } else if (value->IsPushArgument()) { | |
| 973 op = new(zone()) LArgument(argument_index++); | |
| 974 } else { | |
| 975 op = UseAny(value); | |
| 976 } | |
| 977 result->AddValue(op, | |
| 978 value->representation(), | |
| 979 value->CheckFlag(HInstruction::kUint32)); | |
| 980 } | |
| 981 | |
| 982 for (int i = object_index; i < objects_to_materialize->length(); ++i) { | |
| 983 HValue* object_to_materialize = objects_to_materialize->at(i); | |
| 984 int previously_materialized_object = -1; | |
| 985 for (int prev = 0; prev < i; ++prev) { | |
| 986 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { | |
| 987 previously_materialized_object = prev; | |
| 988 break; | |
| 989 } | |
| 990 } | |
| 991 int length = object_to_materialize->OperandCount(); | |
| 992 bool is_arguments = object_to_materialize->IsArgumentsObject(); | |
| 993 if (previously_materialized_object >= 0) { | |
| 994 result->AddDuplicateObject(previously_materialized_object); | |
| 995 continue; | |
| 996 } else { | |
| 997 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); | |
| 998 } | |
| 999 for (int i = is_arguments ? 1 : 0; i < length; ++i) { | |
| 1000 LOperand* op; | |
| 1001 HValue* value = object_to_materialize->OperandAt(i); | |
| 1002 if (value->IsArgumentsObject() || value->IsCapturedObject()) { | |
| 1003 objects_to_materialize->Add(value, zone()); | |
| 1004 op = LEnvironment::materialization_marker(); | |
| 1005 } else { | |
| 1006 ASSERT(!value->IsPushArgument()); | |
| 1007 op = UseAny(value); | |
| 1008 } | |
| 1009 result->AddValue(op, | |
| 1010 value->representation(), | |
| 1011 value->CheckFlag(HInstruction::kUint32)); | |
| 1012 } | |
| 1013 } | |
| 1014 | |
| 1015 if (hydrogen_env->frame_type() == JS_FUNCTION) { | |
| 1016 *argument_index_accumulator = argument_index; | |
| 1017 } | |
| 1018 | |
| 1019 return result; | |
| 1020 } | |
| 1021 | |
| 1022 | |
| 1023 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 939 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 1024 return new(zone()) LGoto(instr->FirstSuccessor()); | 940 return new(zone()) LGoto(instr->FirstSuccessor()); |
| 1025 } | 941 } |
| 1026 | 942 |
| 1027 | 943 |
| 1028 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { | 944 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { |
| 1029 return new(zone()) LDebugBreak(); | 945 return new(zone()) LDebugBreak(); |
| 1030 } | 946 } |
| 1031 | 947 |
| 1032 | 948 |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2609 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2525 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2610 LOperand* object = UseRegister(instr->object()); | 2526 LOperand* object = UseRegister(instr->object()); |
| 2611 LOperand* index = UseTempRegister(instr->index()); | 2527 LOperand* index = UseTempRegister(instr->index()); |
| 2612 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2528 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2613 } | 2529 } |
| 2614 | 2530 |
| 2615 | 2531 |
| 2616 } } // namespace v8::internal | 2532 } } // namespace v8::internal |
| 2617 | 2533 |
| 2618 #endif // V8_TARGET_ARCH_X64 | 2534 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |