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 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 LEnvironment* LChunkBuilder::CreateEnvironment( | 983 LEnvironment* LChunkBuilder::CreateEnvironment( |
984 HEnvironment* hydrogen_env, | 984 HEnvironment* hydrogen_env, |
985 int* argument_index_accumulator) { | 985 int* argument_index_accumulator) { |
986 if (hydrogen_env == NULL) return NULL; | 986 if (hydrogen_env == NULL) return NULL; |
987 | 987 |
988 LEnvironment* outer = | 988 LEnvironment* outer = |
989 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 989 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
990 BailoutId ast_id = hydrogen_env->ast_id(); | 990 BailoutId ast_id = hydrogen_env->ast_id(); |
991 ASSERT(!ast_id.IsNone() || | 991 ASSERT(!ast_id.IsNone() || |
992 hydrogen_env->frame_type() != JS_FUNCTION); | 992 hydrogen_env->frame_type() != JS_FUNCTION); |
993 int value_count = hydrogen_env->length(); | 993 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
994 LEnvironment* result = | 994 LEnvironment* result = |
995 new(zone()) LEnvironment(hydrogen_env->closure(), | 995 new(zone()) LEnvironment(hydrogen_env->closure(), |
996 hydrogen_env->frame_type(), | 996 hydrogen_env->frame_type(), |
997 ast_id, | 997 ast_id, |
998 hydrogen_env->parameter_count(), | 998 hydrogen_env->parameter_count(), |
999 argument_count_, | 999 argument_count_, |
1000 value_count, | 1000 value_count, |
1001 outer, | 1001 outer, |
1002 hydrogen_env->entry(), | 1002 hydrogen_env->entry(), |
1003 zone()); | 1003 zone()); |
| 1004 bool needs_arguments_object_materialization = false; |
1004 int argument_index = *argument_index_accumulator; | 1005 int argument_index = *argument_index_accumulator; |
1005 for (int i = 0; i < value_count; ++i) { | 1006 for (int i = 0; i < hydrogen_env->length(); ++i) { |
1006 if (hydrogen_env->is_special_index(i)) continue; | 1007 if (hydrogen_env->is_special_index(i)) continue; |
1007 | 1008 |
1008 HValue* value = hydrogen_env->values()->at(i); | 1009 HValue* value = hydrogen_env->values()->at(i); |
1009 LOperand* op = NULL; | 1010 LOperand* op = NULL; |
1010 if (value->IsArgumentsObject()) { | 1011 if (value->IsArgumentsObject()) { |
| 1012 needs_arguments_object_materialization = true; |
1011 op = NULL; | 1013 op = NULL; |
1012 } else if (value->IsPushArgument()) { | 1014 } else if (value->IsPushArgument()) { |
1013 op = new(zone()) LArgument(argument_index++); | 1015 op = new(zone()) LArgument(argument_index++); |
1014 } else { | 1016 } else { |
1015 op = UseAny(value); | 1017 op = UseAny(value); |
1016 } | 1018 } |
1017 result->AddValue(op, | 1019 result->AddValue(op, |
1018 value->representation(), | 1020 value->representation(), |
1019 value->CheckFlag(HInstruction::kUint32)); | 1021 value->CheckFlag(HInstruction::kUint32)); |
1020 } | 1022 } |
1021 | 1023 |
| 1024 if (needs_arguments_object_materialization) { |
| 1025 HArgumentsObject* arguments = hydrogen_env->entry() == NULL |
| 1026 ? graph()->GetArgumentsObject() |
| 1027 : hydrogen_env->entry()->arguments_object(); |
| 1028 ASSERT(arguments->IsLinked()); |
| 1029 for (int i = 1; i < arguments->arguments_count(); ++i) { |
| 1030 HValue* value = arguments->arguments_values()->at(i); |
| 1031 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); |
| 1032 ASSERT(HInstruction::cast(value)->IsLinked()); |
| 1033 LOperand* op = UseAny(value); |
| 1034 result->AddValue(op, |
| 1035 value->representation(), |
| 1036 value->CheckFlag(HInstruction::kUint32)); |
| 1037 } |
| 1038 } |
| 1039 |
1022 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 1040 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
1023 *argument_index_accumulator = argument_index; | 1041 *argument_index_accumulator = argument_index; |
1024 } | 1042 } |
1025 | 1043 |
1026 return result; | 1044 return result; |
1027 } | 1045 } |
1028 | 1046 |
1029 | 1047 |
1030 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 1048 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
1031 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 1049 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2792 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2810 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2793 LOperand* object = UseRegister(instr->object()); | 2811 LOperand* object = UseRegister(instr->object()); |
2794 LOperand* index = UseTempRegister(instr->index()); | 2812 LOperand* index = UseTempRegister(instr->index()); |
2795 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2813 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2796 } | 2814 } |
2797 | 2815 |
2798 | 2816 |
2799 } } // namespace v8::internal | 2817 } } // namespace v8::internal |
2800 | 2818 |
2801 #endif // V8_TARGET_ARCH_IA32 | 2819 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |