| 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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 LClobberDoubles* clobber = new(zone()) LClobberDoubles(); | 993 LClobberDoubles* clobber = new(zone()) LClobberDoubles(); |
| 994 clobber->set_hydrogen_value(current); | 994 clobber->set_hydrogen_value(current); |
| 995 chunk_->AddInstruction(clobber, current_block_); | 995 chunk_->AddInstruction(clobber, current_block_); |
| 996 } | 996 } |
| 997 chunk_->AddInstruction(instr, current_block_); | 997 chunk_->AddInstruction(instr, current_block_); |
| 998 } | 998 } |
| 999 current_instruction_ = old_current; | 999 current_instruction_ = old_current; |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 | 1002 |
| 1003 LEnvironment* LChunkBuilder::CreateEnvironment( | |
| 1004 HEnvironment* hydrogen_env, | |
| 1005 int* argument_index_accumulator, | |
| 1006 ZoneList<HValue*>* objects_to_materialize) { | |
| 1007 if (hydrogen_env == NULL) return NULL; | |
| 1008 | |
| 1009 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), | |
| 1010 argument_index_accumulator, | |
| 1011 objects_to_materialize); | |
| 1012 BailoutId ast_id = hydrogen_env->ast_id(); | |
| 1013 ASSERT(!ast_id.IsNone() || | |
| 1014 hydrogen_env->frame_type() != JS_FUNCTION); | |
| 1015 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | |
| 1016 LEnvironment* result = | |
| 1017 new(zone()) LEnvironment(hydrogen_env->closure(), | |
| 1018 hydrogen_env->frame_type(), | |
| 1019 ast_id, | |
| 1020 hydrogen_env->parameter_count(), | |
| 1021 argument_count_, | |
| 1022 value_count, | |
| 1023 outer, | |
| 1024 hydrogen_env->entry(), | |
| 1025 zone()); | |
| 1026 int argument_index = *argument_index_accumulator; | |
| 1027 int object_index = objects_to_materialize->length(); | |
| 1028 for (int i = 0; i < hydrogen_env->length(); ++i) { | |
| 1029 if (hydrogen_env->is_special_index(i)) continue; | |
| 1030 | |
| 1031 LOperand* op; | |
| 1032 HValue* value = hydrogen_env->values()->at(i); | |
| 1033 if (value->IsArgumentsObject() || value->IsCapturedObject()) { | |
| 1034 objects_to_materialize->Add(value, zone()); | |
| 1035 op = LEnvironment::materialization_marker(); | |
| 1036 } else if (value->IsPushArgument()) { | |
| 1037 op = new(zone()) LArgument(argument_index++); | |
| 1038 } else { | |
| 1039 op = UseAny(value); | |
| 1040 } | |
| 1041 result->AddValue(op, | |
| 1042 value->representation(), | |
| 1043 value->CheckFlag(HInstruction::kUint32)); | |
| 1044 } | |
| 1045 | |
| 1046 for (int i = object_index; i < objects_to_materialize->length(); ++i) { | |
| 1047 HValue* object_to_materialize = objects_to_materialize->at(i); | |
| 1048 int previously_materialized_object = -1; | |
| 1049 for (int prev = 0; prev < i; ++prev) { | |
| 1050 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { | |
| 1051 previously_materialized_object = prev; | |
| 1052 break; | |
| 1053 } | |
| 1054 } | |
| 1055 int length = object_to_materialize->OperandCount(); | |
| 1056 bool is_arguments = object_to_materialize->IsArgumentsObject(); | |
| 1057 if (previously_materialized_object >= 0) { | |
| 1058 result->AddDuplicateObject(previously_materialized_object); | |
| 1059 continue; | |
| 1060 } else { | |
| 1061 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); | |
| 1062 } | |
| 1063 for (int i = is_arguments ? 1 : 0; i < length; ++i) { | |
| 1064 LOperand* op; | |
| 1065 HValue* value = object_to_materialize->OperandAt(i); | |
| 1066 if (value->IsArgumentsObject() || value->IsCapturedObject()) { | |
| 1067 objects_to_materialize->Add(value, zone()); | |
| 1068 op = LEnvironment::materialization_marker(); | |
| 1069 } else { | |
| 1070 ASSERT(!value->IsPushArgument()); | |
| 1071 op = UseAny(value); | |
| 1072 } | |
| 1073 result->AddValue(op, | |
| 1074 value->representation(), | |
| 1075 value->CheckFlag(HInstruction::kUint32)); | |
| 1076 } | |
| 1077 } | |
| 1078 | |
| 1079 if (hydrogen_env->frame_type() == JS_FUNCTION) { | |
| 1080 *argument_index_accumulator = argument_index; | |
| 1081 } | |
| 1082 | |
| 1083 return result; | |
| 1084 } | |
| 1085 | |
| 1086 | |
| 1087 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 1003 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 1088 return new(zone()) LGoto(instr->FirstSuccessor()); | 1004 return new(zone()) LGoto(instr->FirstSuccessor()); |
| 1089 } | 1005 } |
| 1090 | 1006 |
| 1091 | 1007 |
| 1092 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 1008 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
| 1093 LInstruction* goto_instr = CheckElideControlInstruction(instr); | 1009 LInstruction* goto_instr = CheckElideControlInstruction(instr); |
| 1094 if (goto_instr != NULL) return goto_instr; | 1010 if (goto_instr != NULL) return goto_instr; |
| 1095 | 1011 |
| 1096 ToBooleanStub::Types expected = instr->expected_input_types(); | 1012 ToBooleanStub::Types expected = instr->expected_input_types(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 new(zone()) LInstanceOfKnownGlobal( | 1075 new(zone()) LInstanceOfKnownGlobal( |
| 1160 UseFixed(instr->context(), esi), | 1076 UseFixed(instr->context(), esi), |
| 1161 UseFixed(instr->left(), InstanceofStub::left()), | 1077 UseFixed(instr->left(), InstanceofStub::left()), |
| 1162 FixedTemp(edi)); | 1078 FixedTemp(edi)); |
| 1163 return MarkAsCall(DefineFixed(result, eax), instr); | 1079 return MarkAsCall(DefineFixed(result, eax), instr); |
| 1164 } | 1080 } |
| 1165 | 1081 |
| 1166 | 1082 |
| 1167 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | 1083 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
| 1168 LOperand* receiver = UseRegister(instr->receiver()); | 1084 LOperand* receiver = UseRegister(instr->receiver()); |
| 1169 LOperand* function = UseRegisterAtStart(instr->function()); | 1085 LOperand* function = UseRegister(instr->function()); |
| 1170 LOperand* temp = TempRegister(); | 1086 LOperand* temp = TempRegister(); |
| 1171 LWrapReceiver* result = | 1087 LWrapReceiver* result = |
| 1172 new(zone()) LWrapReceiver(receiver, function, temp); | 1088 new(zone()) LWrapReceiver(receiver, function, temp); |
| 1173 return AssignEnvironment(DefineSameAsFirst(result)); | 1089 return AssignEnvironment(DefineSameAsFirst(result)); |
| 1174 } | 1090 } |
| 1175 | 1091 |
| 1176 | 1092 |
| 1177 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { | 1093 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { |
| 1178 LOperand* function = UseFixed(instr->function(), edi); | 1094 LOperand* function = UseFixed(instr->function(), edi); |
| 1179 LOperand* receiver = UseFixed(instr->receiver(), eax); | 1095 LOperand* receiver = UseFixed(instr->receiver(), eax); |
| (...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 } | 2617 } |
| 2702 | 2618 |
| 2703 | 2619 |
| 2704 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | 2620 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
| 2705 HEnvironment* outer = current_block_->last_environment(); | 2621 HEnvironment* outer = current_block_->last_environment(); |
| 2706 HConstant* undefined = graph()->GetConstantUndefined(); | 2622 HConstant* undefined = graph()->GetConstantUndefined(); |
| 2707 HEnvironment* inner = outer->CopyForInlining(instr->closure(), | 2623 HEnvironment* inner = outer->CopyForInlining(instr->closure(), |
| 2708 instr->arguments_count(), | 2624 instr->arguments_count(), |
| 2709 instr->function(), | 2625 instr->function(), |
| 2710 undefined, | 2626 undefined, |
| 2711 instr->inlining_kind(), | 2627 instr->inlining_kind()); |
| 2712 instr->undefined_receiver()); | |
| 2713 // Only replay binding of arguments object if it wasn't removed from graph. | 2628 // Only replay binding of arguments object if it wasn't removed from graph. |
| 2714 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { | 2629 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { |
| 2715 inner->Bind(instr->arguments_var(), instr->arguments_object()); | 2630 inner->Bind(instr->arguments_var(), instr->arguments_object()); |
| 2716 } | 2631 } |
| 2717 inner->set_entry(instr); | 2632 inner->set_entry(instr); |
| 2718 current_block_->UpdateEnvironment(inner); | 2633 current_block_->UpdateEnvironment(inner); |
| 2719 chunk_->AddInlinedClosure(instr->closure()); | 2634 chunk_->AddInlinedClosure(instr->closure()); |
| 2720 return NULL; | 2635 return NULL; |
| 2721 } | 2636 } |
| 2722 | 2637 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2764 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2679 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2765 LOperand* object = UseRegister(instr->object()); | 2680 LOperand* object = UseRegister(instr->object()); |
| 2766 LOperand* index = UseTempRegister(instr->index()); | 2681 LOperand* index = UseTempRegister(instr->index()); |
| 2767 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2682 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2768 } | 2683 } |
| 2769 | 2684 |
| 2770 | 2685 |
| 2771 } } // namespace v8::internal | 2686 } } // namespace v8::internal |
| 2772 | 2687 |
| 2773 #endif // V8_TARGET_ARCH_IA32 | 2688 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |