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() - hydrogen_env->specials_count(); | 940 int value_count = hydrogen_env->length(); |
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; | |
952 int argument_index = *argument_index_accumulator; | 951 int argument_index = *argument_index_accumulator; |
953 for (int i = 0; i < hydrogen_env->length(); ++i) { | 952 for (int i = 0; i < value_count; ++i) { |
954 if (hydrogen_env->is_special_index(i)) continue; | 953 if (hydrogen_env->is_special_index(i)) continue; |
955 | 954 |
956 HValue* value = hydrogen_env->values()->at(i); | 955 HValue* value = hydrogen_env->values()->at(i); |
957 LOperand* op = NULL; | 956 LOperand* op = NULL; |
958 if (value->IsArgumentsObject()) { | 957 if (value->IsArgumentsObject()) { |
959 needs_arguments_object_materialization = true; | |
960 op = NULL; | 958 op = NULL; |
961 } else if (value->IsPushArgument()) { | 959 } else if (value->IsPushArgument()) { |
962 op = new(zone()) LArgument(argument_index++); | 960 op = new(zone()) LArgument(argument_index++); |
963 } else { | 961 } else { |
964 op = UseAny(value); | 962 op = UseAny(value); |
965 } | 963 } |
966 result->AddValue(op, | 964 result->AddValue(op, |
967 value->representation(), | 965 value->representation(), |
968 value->CheckFlag(HInstruction::kUint32)); | 966 value->CheckFlag(HInstruction::kUint32)); |
969 } | 967 } |
970 | 968 |
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 LOperand* op = UseAny(value); | |
980 result->AddValue(op, | |
981 value->representation(), | |
982 value->CheckFlag(HInstruction::kUint32)); | |
983 } | |
984 } | |
985 | |
986 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 969 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
987 *argument_index_accumulator = argument_index; | 970 *argument_index_accumulator = argument_index; |
988 } | 971 } |
989 | 972 |
990 return result; | 973 return result; |
991 } | 974 } |
992 | 975 |
993 | 976 |
994 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 977 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
995 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 978 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2586 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2604 LOperand* object = UseRegister(instr->object()); | 2587 LOperand* object = UseRegister(instr->object()); |
2605 LOperand* index = UseTempRegister(instr->index()); | 2588 LOperand* index = UseTempRegister(instr->index()); |
2606 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2589 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2607 } | 2590 } |
2608 | 2591 |
2609 | 2592 |
2610 } } // namespace v8::internal | 2593 } } // namespace v8::internal |
2611 | 2594 |
2612 #endif // V8_TARGET_ARCH_X64 | 2595 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |