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() - hydrogen_env->specials_count(); | 936 int value_count = hydrogen_env->length(); |
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; | |
948 int argument_index = *argument_index_accumulator; | 947 int argument_index = *argument_index_accumulator; |
949 for (int i = 0; i < hydrogen_env->length(); ++i) { | 948 for (int i = 0; i < value_count; ++i) { |
950 if (hydrogen_env->is_special_index(i)) continue; | 949 if (hydrogen_env->is_special_index(i)) continue; |
951 | 950 |
952 HValue* value = hydrogen_env->values()->at(i); | 951 HValue* value = hydrogen_env->values()->at(i); |
953 LOperand* op = NULL; | 952 LOperand* op = NULL; |
954 if (value->IsArgumentsObject()) { | 953 if (value->IsArgumentsObject()) { |
955 needs_arguments_object_materialization = true; | |
956 op = NULL; | 954 op = NULL; |
957 } else if (value->IsPushArgument()) { | 955 } else if (value->IsPushArgument()) { |
958 op = new(zone()) LArgument(argument_index++); | 956 op = new(zone()) LArgument(argument_index++); |
959 } else { | 957 } else { |
960 op = UseAny(value); | 958 op = UseAny(value); |
961 } | 959 } |
962 result->AddValue(op, | 960 result->AddValue(op, |
963 value->representation(), | 961 value->representation(), |
964 value->CheckFlag(HInstruction::kUint32)); | 962 value->CheckFlag(HInstruction::kUint32)); |
965 } | 963 } |
966 | 964 |
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 | |
983 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 965 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
984 *argument_index_accumulator = argument_index; | 966 *argument_index_accumulator = argument_index; |
985 } | 967 } |
986 | 968 |
987 return result; | 969 return result; |
988 } | 970 } |
989 | 971 |
990 | 972 |
991 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 973 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
992 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 974 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 | 2509 |
2528 | 2510 |
2529 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2511 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2530 LOperand* object = UseRegister(instr->object()); | 2512 LOperand* object = UseRegister(instr->object()); |
2531 LOperand* index = UseRegister(instr->index()); | 2513 LOperand* index = UseRegister(instr->index()); |
2532 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2514 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2533 } | 2515 } |
2534 | 2516 |
2535 | 2517 |
2536 } } // namespace v8::internal | 2518 } } // namespace v8::internal |
OLD | NEW |