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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 LEnvironment* LChunkBuilder::CreateEnvironment( | 922 LEnvironment* LChunkBuilder::CreateEnvironment( |
923 HEnvironment* hydrogen_env, | 923 HEnvironment* hydrogen_env, |
924 int* argument_index_accumulator) { | 924 int* argument_index_accumulator) { |
925 if (hydrogen_env == NULL) return NULL; | 925 if (hydrogen_env == NULL) return NULL; |
926 | 926 |
927 LEnvironment* outer = | 927 LEnvironment* outer = |
928 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 928 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
929 BailoutId ast_id = hydrogen_env->ast_id(); | 929 BailoutId ast_id = hydrogen_env->ast_id(); |
930 ASSERT(!ast_id.IsNone() || | 930 ASSERT(!ast_id.IsNone() || |
931 hydrogen_env->frame_type() != JS_FUNCTION); | 931 hydrogen_env->frame_type() != JS_FUNCTION); |
932 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 932 int value_count = hydrogen_env->length(); |
933 LEnvironment* result = new(zone()) LEnvironment( | 933 LEnvironment* result = new(zone()) LEnvironment( |
934 hydrogen_env->closure(), | 934 hydrogen_env->closure(), |
935 hydrogen_env->frame_type(), | 935 hydrogen_env->frame_type(), |
936 ast_id, | 936 ast_id, |
937 hydrogen_env->parameter_count(), | 937 hydrogen_env->parameter_count(), |
938 argument_count_, | 938 argument_count_, |
939 value_count, | 939 value_count, |
940 outer, | 940 outer, |
941 hydrogen_env->entry(), | 941 hydrogen_env->entry(), |
942 zone()); | 942 zone()); |
943 bool needs_arguments_object_materialization = false; | |
944 int argument_index = *argument_index_accumulator; | 943 int argument_index = *argument_index_accumulator; |
945 for (int i = 0; i < hydrogen_env->length(); ++i) { | 944 for (int i = 0; i < value_count; ++i) { |
946 if (hydrogen_env->is_special_index(i)) continue; | 945 if (hydrogen_env->is_special_index(i)) continue; |
947 | 946 |
948 HValue* value = hydrogen_env->values()->at(i); | 947 HValue* value = hydrogen_env->values()->at(i); |
949 LOperand* op = NULL; | 948 LOperand* op = NULL; |
950 if (value->IsArgumentsObject()) { | 949 if (value->IsArgumentsObject()) { |
951 needs_arguments_object_materialization = true; | |
952 op = NULL; | 950 op = NULL; |
953 } else if (value->IsPushArgument()) { | 951 } else if (value->IsPushArgument()) { |
954 op = new(zone()) LArgument(argument_index++); | 952 op = new(zone()) LArgument(argument_index++); |
955 } else { | 953 } else { |
956 op = UseAny(value); | 954 op = UseAny(value); |
957 } | 955 } |
958 result->AddValue(op, | 956 result->AddValue(op, |
959 value->representation(), | 957 value->representation(), |
960 value->CheckFlag(HInstruction::kUint32)); | 958 value->CheckFlag(HInstruction::kUint32)); |
961 } | 959 } |
962 | 960 |
963 if (needs_arguments_object_materialization) { | |
964 HArgumentsObject* arguments = hydrogen_env->entry() == NULL | |
965 ? graph()->GetArgumentsObject() | |
966 : hydrogen_env->entry()->arguments_object(); | |
967 ASSERT(arguments->IsLinked()); | |
968 for (int i = 1; i < arguments->arguments_count(); ++i) { | |
969 HValue* value = arguments->arguments_values()->at(i); | |
970 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); | |
971 LOperand* op = UseAny(value); | |
972 result->AddValue(op, | |
973 value->representation(), | |
974 value->CheckFlag(HInstruction::kUint32)); | |
975 } | |
976 } | |
977 | |
978 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 961 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
979 *argument_index_accumulator = argument_index; | 962 *argument_index_accumulator = argument_index; |
980 } | 963 } |
981 | 964 |
982 return result; | 965 return result; |
983 } | 966 } |
984 | 967 |
985 | 968 |
986 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 969 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
987 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 970 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 | 2646 |
2664 | 2647 |
2665 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2648 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2666 LOperand* object = UseRegister(instr->object()); | 2649 LOperand* object = UseRegister(instr->object()); |
2667 LOperand* index = UseRegister(instr->index()); | 2650 LOperand* index = UseRegister(instr->index()); |
2668 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2651 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2669 } | 2652 } |
2670 | 2653 |
2671 | 2654 |
2672 } } // namespace v8::internal | 2655 } } // namespace v8::internal |
OLD | NEW |