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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 LEnvironment* LChunkBuilder::CreateEnvironment( | 930 LEnvironment* LChunkBuilder::CreateEnvironment( |
931 HEnvironment* hydrogen_env, | 931 HEnvironment* hydrogen_env, |
932 int* argument_index_accumulator) { | 932 int* argument_index_accumulator) { |
933 if (hydrogen_env == NULL) return NULL; | 933 if (hydrogen_env == NULL) return NULL; |
934 | 934 |
935 LEnvironment* outer = | 935 LEnvironment* outer = |
936 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 936 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
937 BailoutId ast_id = hydrogen_env->ast_id(); | 937 BailoutId ast_id = hydrogen_env->ast_id(); |
938 ASSERT(!ast_id.IsNone() || | 938 ASSERT(!ast_id.IsNone() || |
939 hydrogen_env->frame_type() != JS_FUNCTION); | 939 hydrogen_env->frame_type() != JS_FUNCTION); |
940 int value_count = hydrogen_env->length(); | 940 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
941 LEnvironment* result = new(zone()) LEnvironment( | 941 LEnvironment* result = new(zone()) LEnvironment( |
942 hydrogen_env->closure(), | 942 hydrogen_env->closure(), |
943 hydrogen_env->frame_type(), | 943 hydrogen_env->frame_type(), |
944 ast_id, | 944 ast_id, |
945 hydrogen_env->parameter_count(), | 945 hydrogen_env->parameter_count(), |
946 argument_count_, | 946 argument_count_, |
947 value_count, | 947 value_count, |
948 outer, | 948 outer, |
949 hydrogen_env->entry(), | 949 hydrogen_env->entry(), |
950 zone()); | 950 zone()); |
| 951 bool needs_arguments_object_materialization = false; |
951 int argument_index = *argument_index_accumulator; | 952 int argument_index = *argument_index_accumulator; |
952 for (int i = 0; i < value_count; ++i) { | 953 for (int i = 0; i < hydrogen_env->length(); ++i) { |
953 if (hydrogen_env->is_special_index(i)) continue; | 954 if (hydrogen_env->is_special_index(i)) continue; |
954 | 955 |
955 HValue* value = hydrogen_env->values()->at(i); | 956 HValue* value = hydrogen_env->values()->at(i); |
956 LOperand* op = NULL; | 957 LOperand* op = NULL; |
957 if (value->IsArgumentsObject()) { | 958 if (value->IsArgumentsObject()) { |
| 959 needs_arguments_object_materialization = true; |
958 op = NULL; | 960 op = NULL; |
959 } else if (value->IsPushArgument()) { | 961 } else if (value->IsPushArgument()) { |
960 op = new(zone()) LArgument(argument_index++); | 962 op = new(zone()) LArgument(argument_index++); |
961 } else { | 963 } else { |
962 op = UseAny(value); | 964 op = UseAny(value); |
963 } | 965 } |
964 result->AddValue(op, | 966 result->AddValue(op, |
965 value->representation(), | 967 value->representation(), |
966 value->CheckFlag(HInstruction::kUint32)); | 968 value->CheckFlag(HInstruction::kUint32)); |
967 } | 969 } |
968 | 970 |
| 971 if (needs_arguments_object_materialization) { |
| 972 HArgumentsObject* arguments = hydrogen_env->entry() == NULL |
| 973 ? graph()->GetArgumentsObject() |
| 974 : hydrogen_env->entry()->arguments_object(); |
| 975 ASSERT(arguments->IsLinked()); |
| 976 for (int i = 1; i < arguments->arguments_count(); ++i) { |
| 977 HValue* value = arguments->arguments_values()->at(i); |
| 978 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); |
| 979 ASSERT(HInstruction::cast(value)->IsLinked()); |
| 980 LOperand* op = UseAny(value); |
| 981 result->AddValue(op, |
| 982 value->representation(), |
| 983 value->CheckFlag(HInstruction::kUint32)); |
| 984 } |
| 985 } |
| 986 |
969 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 987 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
970 *argument_index_accumulator = argument_index; | 988 *argument_index_accumulator = argument_index; |
971 } | 989 } |
972 | 990 |
973 return result; | 991 return result; |
974 } | 992 } |
975 | 993 |
976 | 994 |
977 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 995 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
978 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 996 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2586 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2604 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2587 LOperand* object = UseRegister(instr->object()); | 2605 LOperand* object = UseRegister(instr->object()); |
2588 LOperand* index = UseTempRegister(instr->index()); | 2606 LOperand* index = UseTempRegister(instr->index()); |
2589 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2607 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2590 } | 2608 } |
2591 | 2609 |
2592 | 2610 |
2593 } } // namespace v8::internal | 2611 } } // namespace v8::internal |
2594 | 2612 |
2595 #endif // V8_TARGET_ARCH_X64 | 2613 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |