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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 LEnvironment* LChunkBuilder::CreateEnvironment( | 926 LEnvironment* LChunkBuilder::CreateEnvironment( |
927 HEnvironment* hydrogen_env, | 927 HEnvironment* hydrogen_env, |
928 int* argument_index_accumulator) { | 928 int* argument_index_accumulator) { |
929 if (hydrogen_env == NULL) return NULL; | 929 if (hydrogen_env == NULL) return NULL; |
930 | 930 |
931 LEnvironment* outer = | 931 LEnvironment* outer = |
932 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 932 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
933 BailoutId ast_id = hydrogen_env->ast_id(); | 933 BailoutId ast_id = hydrogen_env->ast_id(); |
934 ASSERT(!ast_id.IsNone() || | 934 ASSERT(!ast_id.IsNone() || |
935 hydrogen_env->frame_type() != JS_FUNCTION); | 935 hydrogen_env->frame_type() != JS_FUNCTION); |
936 int value_count = hydrogen_env->length(); | 936 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
937 LEnvironment* result = new(zone()) LEnvironment( | 937 LEnvironment* result = new(zone()) LEnvironment( |
938 hydrogen_env->closure(), | 938 hydrogen_env->closure(), |
939 hydrogen_env->frame_type(), | 939 hydrogen_env->frame_type(), |
940 ast_id, | 940 ast_id, |
941 hydrogen_env->parameter_count(), | 941 hydrogen_env->parameter_count(), |
942 argument_count_, | 942 argument_count_, |
943 value_count, | 943 value_count, |
944 outer, | 944 outer, |
945 hydrogen_env->entry(), | 945 hydrogen_env->entry(), |
946 zone()); | 946 zone()); |
| 947 bool needs_arguments_object_materialization = false; |
947 int argument_index = *argument_index_accumulator; | 948 int argument_index = *argument_index_accumulator; |
948 for (int i = 0; i < value_count; ++i) { | 949 for (int i = 0; i < hydrogen_env->length(); ++i) { |
949 if (hydrogen_env->is_special_index(i)) continue; | 950 if (hydrogen_env->is_special_index(i)) continue; |
950 | 951 |
951 HValue* value = hydrogen_env->values()->at(i); | 952 HValue* value = hydrogen_env->values()->at(i); |
952 LOperand* op = NULL; | 953 LOperand* op = NULL; |
953 if (value->IsArgumentsObject()) { | 954 if (value->IsArgumentsObject()) { |
| 955 needs_arguments_object_materialization = true; |
954 op = NULL; | 956 op = NULL; |
955 } else if (value->IsPushArgument()) { | 957 } else if (value->IsPushArgument()) { |
956 op = new(zone()) LArgument(argument_index++); | 958 op = new(zone()) LArgument(argument_index++); |
957 } else { | 959 } else { |
958 op = UseAny(value); | 960 op = UseAny(value); |
959 } | 961 } |
960 result->AddValue(op, | 962 result->AddValue(op, |
961 value->representation(), | 963 value->representation(), |
962 value->CheckFlag(HInstruction::kUint32)); | 964 value->CheckFlag(HInstruction::kUint32)); |
963 } | 965 } |
964 | 966 |
| 967 if (needs_arguments_object_materialization) { |
| 968 HArgumentsObject* arguments = hydrogen_env->entry() == NULL |
| 969 ? graph()->GetArgumentsObject() |
| 970 : hydrogen_env->entry()->arguments_object(); |
| 971 ASSERT(arguments->IsLinked()); |
| 972 for (int i = 1; i < arguments->arguments_count(); ++i) { |
| 973 HValue* value = arguments->arguments_values()->at(i); |
| 974 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); |
| 975 ASSERT(HInstruction::cast(value)->IsLinked()); |
| 976 LOperand* op = UseAny(value); |
| 977 result->AddValue(op, |
| 978 value->representation(), |
| 979 value->CheckFlag(HInstruction::kUint32)); |
| 980 } |
| 981 } |
| 982 |
965 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 983 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
966 *argument_index_accumulator = argument_index; | 984 *argument_index_accumulator = argument_index; |
967 } | 985 } |
968 | 986 |
969 return result; | 987 return result; |
970 } | 988 } |
971 | 989 |
972 | 990 |
973 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 991 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
974 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 992 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 | 2527 |
2510 | 2528 |
2511 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2529 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2512 LOperand* object = UseRegister(instr->object()); | 2530 LOperand* object = UseRegister(instr->object()); |
2513 LOperand* index = UseRegister(instr->index()); | 2531 LOperand* index = UseRegister(instr->index()); |
2514 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2532 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2515 } | 2533 } |
2516 | 2534 |
2517 | 2535 |
2518 } } // namespace v8::internal | 2536 } } // namespace v8::internal |
OLD | NEW |