| 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 } | 927 } |
| 928 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 928 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 929 instr = AssignEnvironment(instr); | 929 instr = AssignEnvironment(instr); |
| 930 } | 930 } |
| 931 chunk_->AddInstruction(instr, current_block_); | 931 chunk_->AddInstruction(instr, current_block_); |
| 932 } | 932 } |
| 933 current_instruction_ = old_current; | 933 current_instruction_ = old_current; |
| 934 } | 934 } |
| 935 | 935 |
| 936 | 936 |
| 937 LEnvironment* LChunkBuilder::CreateEnvironment( | |
| 938 HEnvironment* hydrogen_env, | |
| 939 int* argument_index_accumulator, | |
| 940 ZoneList<HValue*>* objects_to_materialize) { | |
| 941 if (hydrogen_env == NULL) return NULL; | |
| 942 | |
| 943 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), | |
| 944 argument_index_accumulator, | |
| 945 objects_to_materialize); | |
| 946 BailoutId ast_id = hydrogen_env->ast_id(); | |
| 947 ASSERT(!ast_id.IsNone() || | |
| 948 hydrogen_env->frame_type() != JS_FUNCTION); | |
| 949 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | |
| 950 LEnvironment* result = new(zone()) LEnvironment( | |
| 951 hydrogen_env->closure(), | |
| 952 hydrogen_env->frame_type(), | |
| 953 ast_id, | |
| 954 hydrogen_env->parameter_count(), | |
| 955 argument_count_, | |
| 956 value_count, | |
| 957 outer, | |
| 958 hydrogen_env->entry(), | |
| 959 zone()); | |
| 960 int argument_index = *argument_index_accumulator; | |
| 961 int object_index = objects_to_materialize->length(); | |
| 962 for (int i = 0; i < hydrogen_env->length(); ++i) { | |
| 963 if (hydrogen_env->is_special_index(i)) continue; | |
| 964 | |
| 965 LOperand* op; | |
| 966 HValue* value = hydrogen_env->values()->at(i); | |
| 967 if (value->IsArgumentsObject() || value->IsCapturedObject()) { | |
| 968 objects_to_materialize->Add(value, zone()); | |
| 969 op = LEnvironment::materialization_marker(); | |
| 970 } else if (value->IsPushArgument()) { | |
| 971 op = new(zone()) LArgument(argument_index++); | |
| 972 } else { | |
| 973 op = UseAny(value); | |
| 974 } | |
| 975 result->AddValue(op, | |
| 976 value->representation(), | |
| 977 value->CheckFlag(HInstruction::kUint32)); | |
| 978 } | |
| 979 | |
| 980 for (int i = object_index; i < objects_to_materialize->length(); ++i) { | |
| 981 HValue* object_to_materialize = objects_to_materialize->at(i); | |
| 982 int previously_materialized_object = -1; | |
| 983 for (int prev = 0; prev < i; ++prev) { | |
| 984 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { | |
| 985 previously_materialized_object = prev; | |
| 986 break; | |
| 987 } | |
| 988 } | |
| 989 int length = object_to_materialize->OperandCount(); | |
| 990 bool is_arguments = object_to_materialize->IsArgumentsObject(); | |
| 991 if (previously_materialized_object >= 0) { | |
| 992 result->AddDuplicateObject(previously_materialized_object); | |
| 993 continue; | |
| 994 } else { | |
| 995 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); | |
| 996 } | |
| 997 for (int i = is_arguments ? 1 : 0; i < length; ++i) { | |
| 998 LOperand* op; | |
| 999 HValue* value = object_to_materialize->OperandAt(i); | |
| 1000 if (value->IsArgumentsObject() || value->IsCapturedObject()) { | |
| 1001 objects_to_materialize->Add(value, zone()); | |
| 1002 op = LEnvironment::materialization_marker(); | |
| 1003 } else { | |
| 1004 ASSERT(!value->IsPushArgument()); | |
| 1005 op = UseAny(value); | |
| 1006 } | |
| 1007 result->AddValue(op, | |
| 1008 value->representation(), | |
| 1009 value->CheckFlag(HInstruction::kUint32)); | |
| 1010 } | |
| 1011 } | |
| 1012 | |
| 1013 if (hydrogen_env->frame_type() == JS_FUNCTION) { | |
| 1014 *argument_index_accumulator = argument_index; | |
| 1015 } | |
| 1016 | |
| 1017 return result; | |
| 1018 } | |
| 1019 | |
| 1020 | |
| 1021 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 937 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 1022 return new(zone()) LGoto(instr->FirstSuccessor()); | 938 return new(zone()) LGoto(instr->FirstSuccessor()); |
| 1023 } | 939 } |
| 1024 | 940 |
| 1025 | 941 |
| 1026 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 942 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
| 1027 LInstruction* goto_instr = CheckElideControlInstruction(instr); | 943 LInstruction* goto_instr = CheckElideControlInstruction(instr); |
| 1028 if (goto_instr != NULL) return goto_instr; | 944 if (goto_instr != NULL) return goto_instr; |
| 1029 | 945 |
| 1030 HValue* value = instr->value(); | 946 HValue* value = instr->value(); |
| (...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2575 | 2491 |
| 2576 | 2492 |
| 2577 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2493 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2578 LOperand* object = UseRegister(instr->object()); | 2494 LOperand* object = UseRegister(instr->object()); |
| 2579 LOperand* index = UseRegister(instr->index()); | 2495 LOperand* index = UseRegister(instr->index()); |
| 2580 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2496 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2581 } | 2497 } |
| 2582 | 2498 |
| 2583 | 2499 |
| 2584 } } // namespace v8::internal | 2500 } } // namespace v8::internal |
| OLD | NEW |