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

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

Issue 21055011: First implementation of allocation elimination in Hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 7 years, 4 months 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
« no previous file with comments | « src/x64/lithium-x64.h ('k') | src/zone.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 LInstruction* LChunkBuilder::DefineFixedDouble( 594 LInstruction* LChunkBuilder::DefineFixedDouble(
595 LTemplateInstruction<1, I, T>* instr, 595 LTemplateInstruction<1, I, T>* instr,
596 XMMRegister reg) { 596 XMMRegister reg) {
597 return Define(instr, ToUnallocated(reg)); 597 return Define(instr, ToUnallocated(reg));
598 } 598 }
599 599
600 600
601 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { 601 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
602 HEnvironment* hydrogen_env = current_block_->last_environment(); 602 HEnvironment* hydrogen_env = current_block_->last_environment();
603 int argument_index_accumulator = 0; 603 int argument_index_accumulator = 0;
604 ZoneList<HValue*> objects_to_materialize(0, zone());
604 instr->set_environment(CreateEnvironment(hydrogen_env, 605 instr->set_environment(CreateEnvironment(hydrogen_env,
605 &argument_index_accumulator)); 606 &argument_index_accumulator,
607 &objects_to_materialize));
606 return instr; 608 return instr;
607 } 609 }
608 610
609 611
610 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, 612 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
611 HInstruction* hinstr, 613 HInstruction* hinstr,
612 CanDeoptimize can_deoptimize) { 614 CanDeoptimize can_deoptimize) {
613 info()->MarkAsNonDeferredCalling(); 615 info()->MarkAsNonDeferredCalling();
614 616
615 #ifdef DEBUG 617 #ifdef DEBUG
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 } 892 }
891 instr->set_hydrogen_value(current); 893 instr->set_hydrogen_value(current);
892 chunk_->AddInstruction(instr, current_block_); 894 chunk_->AddInstruction(instr, current_block_);
893 } 895 }
894 current_instruction_ = old_current; 896 current_instruction_ = old_current;
895 } 897 }
896 898
897 899
898 LEnvironment* LChunkBuilder::CreateEnvironment( 900 LEnvironment* LChunkBuilder::CreateEnvironment(
899 HEnvironment* hydrogen_env, 901 HEnvironment* hydrogen_env,
900 int* argument_index_accumulator) { 902 int* argument_index_accumulator,
903 ZoneList<HValue*>* objects_to_materialize) {
901 if (hydrogen_env == NULL) return NULL; 904 if (hydrogen_env == NULL) return NULL;
902 905
903 LEnvironment* outer = 906 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(),
904 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); 907 argument_index_accumulator,
908 objects_to_materialize);
905 BailoutId ast_id = hydrogen_env->ast_id(); 909 BailoutId ast_id = hydrogen_env->ast_id();
906 ASSERT(!ast_id.IsNone() || 910 ASSERT(!ast_id.IsNone() ||
907 hydrogen_env->frame_type() != JS_FUNCTION); 911 hydrogen_env->frame_type() != JS_FUNCTION);
908 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); 912 int value_count = hydrogen_env->length() - hydrogen_env->specials_count();
909 LEnvironment* result = new(zone()) LEnvironment( 913 LEnvironment* result = new(zone()) LEnvironment(
910 hydrogen_env->closure(), 914 hydrogen_env->closure(),
911 hydrogen_env->frame_type(), 915 hydrogen_env->frame_type(),
912 ast_id, 916 ast_id,
913 hydrogen_env->parameter_count(), 917 hydrogen_env->parameter_count(),
914 argument_count_, 918 argument_count_,
915 value_count, 919 value_count,
916 outer, 920 outer,
917 hydrogen_env->entry(), 921 hydrogen_env->entry(),
918 zone()); 922 zone());
919 bool needs_arguments_object_materialization = false;
920 int argument_index = *argument_index_accumulator; 923 int argument_index = *argument_index_accumulator;
924 int object_index = objects_to_materialize->length();
921 for (int i = 0; i < hydrogen_env->length(); ++i) { 925 for (int i = 0; i < hydrogen_env->length(); ++i) {
922 if (hydrogen_env->is_special_index(i)) continue; 926 if (hydrogen_env->is_special_index(i)) continue;
923 927
928 LOperand* op;
924 HValue* value = hydrogen_env->values()->at(i); 929 HValue* value = hydrogen_env->values()->at(i);
925 LOperand* op = NULL; 930 if (value->IsArgumentsObject() || value->IsCapturedObject()) {
926 if (value->IsArgumentsObject()) { 931 objects_to_materialize->Add(value, zone());
927 needs_arguments_object_materialization = true; 932 op = LEnvironment::materialization_marker();
928 op = NULL;
929 } else if (value->IsPushArgument()) { 933 } else if (value->IsPushArgument()) {
930 op = new(zone()) LArgument(argument_index++); 934 op = new(zone()) LArgument(argument_index++);
931 } else { 935 } else {
932 op = UseAny(value); 936 op = UseAny(value);
933 } 937 }
934 result->AddValue(op, 938 result->AddValue(op,
935 value->representation(), 939 value->representation(),
936 value->CheckFlag(HInstruction::kUint32)); 940 value->CheckFlag(HInstruction::kUint32));
937 } 941 }
938 942
939 if (needs_arguments_object_materialization) { 943 for (int i = object_index; i < objects_to_materialize->length(); ++i) {
940 HArgumentsObject* arguments = hydrogen_env->entry() == NULL 944 HValue* object_to_materialize = objects_to_materialize->at(i);
941 ? graph()->GetArgumentsObject() 945 int previously_materialized_object = -1;
942 : hydrogen_env->entry()->arguments_object(); 946 for (int prev = 0; prev < i; ++prev) {
943 ASSERT(arguments->IsLinked()); 947 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) {
944 for (int i = 1; i < arguments->arguments_count(); ++i) { 948 previously_materialized_object = prev;
945 HValue* value = arguments->arguments_values()->at(i); 949 break;
946 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); 950 }
947 LOperand* op = UseAny(value); 951 }
952 int length = object_to_materialize->OperandCount();
953 bool is_arguments = object_to_materialize->IsArgumentsObject();
954 if (previously_materialized_object >= 0) {
955 result->AddDuplicateObject(previously_materialized_object);
956 continue;
957 } else {
958 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments);
959 }
960 for (int i = is_arguments ? 1 : 0; i < length; ++i) {
961 LOperand* op;
962 HValue* value = object_to_materialize->OperandAt(i);
963 if (value->IsArgumentsObject() || value->IsCapturedObject()) {
964 objects_to_materialize->Add(value, zone());
965 op = LEnvironment::materialization_marker();
966 } else {
967 ASSERT(!value->IsPushArgument());
968 op = UseAny(value);
969 }
948 result->AddValue(op, 970 result->AddValue(op,
949 value->representation(), 971 value->representation(),
950 value->CheckFlag(HInstruction::kUint32)); 972 value->CheckFlag(HInstruction::kUint32));
951 } 973 }
952 } 974 }
953 975
954 if (hydrogen_env->frame_type() == JS_FUNCTION) { 976 if (hydrogen_env->frame_type() == JS_FUNCTION) {
955 *argument_index_accumulator = argument_index; 977 *argument_index_accumulator = argument_index;
956 } 978 }
957 979
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 2381
2360 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { 2382 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
2361 // There are no real uses of the arguments object. 2383 // There are no real uses of the arguments object.
2362 // arguments.length and element access are supported directly on 2384 // arguments.length and element access are supported directly on
2363 // stack arguments, and any real arguments object use causes a bailout. 2385 // stack arguments, and any real arguments object use causes a bailout.
2364 // So this value is never used. 2386 // So this value is never used.
2365 return NULL; 2387 return NULL;
2366 } 2388 }
2367 2389
2368 2390
2391 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
2392 // There are no real uses of a captured object.
2393 return NULL;
2394 }
2395
2396
2369 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { 2397 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2370 info()->MarkAsRequiresFrame(); 2398 info()->MarkAsRequiresFrame();
2371 LOperand* args = UseRegister(instr->arguments()); 2399 LOperand* args = UseRegister(instr->arguments());
2372 LOperand* length; 2400 LOperand* length;
2373 LOperand* index; 2401 LOperand* index;
2374 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { 2402 if (instr->length()->IsConstant() && instr->index()->IsConstant()) {
2375 length = UseRegisterOrConstant(instr->length()); 2403 length = UseRegisterOrConstant(instr->length());
2376 index = UseOrConstant(instr->index()); 2404 index = UseOrConstant(instr->index());
2377 } else { 2405 } else {
2378 length = UseTempRegister(instr->length()); 2406 length = UseTempRegister(instr->length());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2542 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2515 LOperand* object = UseRegister(instr->object()); 2543 LOperand* object = UseRegister(instr->object());
2516 LOperand* index = UseTempRegister(instr->index()); 2544 LOperand* index = UseTempRegister(instr->index());
2517 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2545 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2518 } 2546 }
2519 2547
2520 2548
2521 } } // namespace v8::internal 2549 } } // namespace v8::internal
2522 2550
2523 #endif // V8_TARGET_ARCH_X64 2551 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.h ('k') | src/zone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698