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

Side by Side Diff: src/arm/lithium-arm.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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 919 }
920 if (FLAG_stress_environments && !instr->HasEnvironment()) { 920 if (FLAG_stress_environments && !instr->HasEnvironment()) {
921 instr = AssignEnvironment(instr); 921 instr = AssignEnvironment(instr);
922 } 922 }
923 chunk_->AddInstruction(instr, current_block_); 923 chunk_->AddInstruction(instr, current_block_);
924 } 924 }
925 current_instruction_ = old_current; 925 current_instruction_ = old_current;
926 } 926 }
927 927
928 928
929 LEnvironment* LChunkBuilder::CreateEnvironment(
930 HEnvironment* hydrogen_env,
931 int* argument_index_accumulator,
932 ZoneList<HValue*>* objects_to_materialize) {
933 if (hydrogen_env == NULL) return NULL;
934
935 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(),
936 argument_index_accumulator,
937 objects_to_materialize);
938 BailoutId ast_id = hydrogen_env->ast_id();
939 ASSERT(!ast_id.IsNone() ||
940 hydrogen_env->frame_type() != JS_FUNCTION);
941 int value_count = hydrogen_env->length() - hydrogen_env->specials_count();
942 LEnvironment* result = new(zone()) LEnvironment(
943 hydrogen_env->closure(),
944 hydrogen_env->frame_type(),
945 ast_id,
946 hydrogen_env->parameter_count(),
947 argument_count_,
948 value_count,
949 outer,
950 hydrogen_env->entry(),
951 zone());
952 int argument_index = *argument_index_accumulator;
953 int object_index = objects_to_materialize->length();
954 for (int i = 0; i < hydrogen_env->length(); ++i) {
955 if (hydrogen_env->is_special_index(i)) continue;
956
957 LOperand* op;
958 HValue* value = hydrogen_env->values()->at(i);
959 if (value->IsArgumentsObject() || value->IsCapturedObject()) {
960 objects_to_materialize->Add(value, zone());
961 op = LEnvironment::materialization_marker();
962 } else if (value->IsPushArgument()) {
963 op = new(zone()) LArgument(argument_index++);
964 } else {
965 op = UseAny(value);
966 }
967 result->AddValue(op,
968 value->representation(),
969 value->CheckFlag(HInstruction::kUint32));
970 }
971
972 for (int i = object_index; i < objects_to_materialize->length(); ++i) {
973 HValue* object_to_materialize = objects_to_materialize->at(i);
974 int previously_materialized_object = -1;
975 for (int prev = 0; prev < i; ++prev) {
976 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) {
977 previously_materialized_object = prev;
978 break;
979 }
980 }
981 int length = object_to_materialize->OperandCount();
982 bool is_arguments = object_to_materialize->IsArgumentsObject();
983 if (previously_materialized_object >= 0) {
984 result->AddDuplicateObject(previously_materialized_object);
985 continue;
986 } else {
987 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments);
988 }
989 for (int i = is_arguments ? 1 : 0; i < length; ++i) {
990 LOperand* op;
991 HValue* value = object_to_materialize->OperandAt(i);
992 if (value->IsArgumentsObject() || value->IsCapturedObject()) {
993 objects_to_materialize->Add(value, zone());
994 op = LEnvironment::materialization_marker();
995 } else {
996 ASSERT(!value->IsPushArgument());
997 op = UseAny(value);
998 }
999 result->AddValue(op,
1000 value->representation(),
1001 value->CheckFlag(HInstruction::kUint32));
1002 }
1003 }
1004
1005 if (hydrogen_env->frame_type() == JS_FUNCTION) {
1006 *argument_index_accumulator = argument_index;
1007 }
1008
1009 return result;
1010 }
1011
1012
1013 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { 929 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
1014 return new(zone()) LGoto(instr->FirstSuccessor()); 930 return new(zone()) LGoto(instr->FirstSuccessor());
1015 } 931 }
1016 932
1017 933
1018 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { 934 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
1019 LInstruction* goto_instr = CheckElideControlInstruction(instr); 935 LInstruction* goto_instr = CheckElideControlInstruction(instr);
1020 if (goto_instr != NULL) return goto_instr; 936 if (goto_instr != NULL) return goto_instr;
1021 937
1022 HValue* value = instr->value(); 938 HValue* value = instr->value();
(...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 } 2564 }
2649 2565
2650 2566
2651 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2567 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2652 LOperand* object = UseRegister(instr->object()); 2568 LOperand* object = UseRegister(instr->object());
2653 LOperand* index = UseRegister(instr->index()); 2569 LOperand* index = UseRegister(instr->index());
2654 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2570 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2655 } 2571 }
2656 2572
2657 } } // namespace v8::internal 2573 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.h ('k') | src/ia32/lithium-ia32.h » ('j') | src/lithium.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698