Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(878)

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 93803003: Fixed Lithium environment generation bug for captured objects (created (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Move common code from LChunkBuilder into a (new) base class Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2680 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2765 LOperand* object = UseRegister(instr->object()); 2681 LOperand* object = UseRegister(instr->object());
2766 LOperand* index = UseTempRegister(instr->index()); 2682 LOperand* index = UseTempRegister(instr->index());
2767 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2683 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2768 } 2684 }
2769 2685
2770 2686
2771 } } // namespace v8::internal 2687 } } // namespace v8::internal
2772 2688
2773 #endif // V8_TARGET_ARCH_IA32 2689 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/lithium.h » ('j') | src/lithium.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698