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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 template<int I, int T> | 591 template<int I, int T> |
592 LInstruction* LChunkBuilder::DefineFixedDouble( | 592 LInstruction* LChunkBuilder::DefineFixedDouble( |
593 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) { | 593 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) { |
594 return Define(instr, ToUnallocated(reg)); | 594 return Define(instr, ToUnallocated(reg)); |
595 } | 595 } |
596 | 596 |
597 | 597 |
598 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 598 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
599 HEnvironment* hydrogen_env = current_block_->last_environment(); | 599 HEnvironment* hydrogen_env = current_block_->last_environment(); |
600 int argument_index_accumulator = 0; | 600 int argument_index_accumulator = 0; |
| 601 ZoneList<HValue*> objects_to_materialize(0, zone()); |
601 instr->set_environment(CreateEnvironment(hydrogen_env, | 602 instr->set_environment(CreateEnvironment(hydrogen_env, |
602 &argument_index_accumulator)); | 603 &argument_index_accumulator, |
| 604 &objects_to_materialize)); |
603 return instr; | 605 return instr; |
604 } | 606 } |
605 | 607 |
606 | 608 |
607 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 609 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
608 HInstruction* hinstr, | 610 HInstruction* hinstr, |
609 CanDeoptimize can_deoptimize) { | 611 CanDeoptimize can_deoptimize) { |
610 info()->MarkAsNonDeferredCalling(); | 612 info()->MarkAsNonDeferredCalling(); |
611 #ifdef DEBUG | 613 #ifdef DEBUG |
612 instr->VerifyCall(); | 614 instr->VerifyCall(); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 } | 898 } |
897 instr->set_hydrogen_value(current); | 899 instr->set_hydrogen_value(current); |
898 chunk_->AddInstruction(instr, current_block_); | 900 chunk_->AddInstruction(instr, current_block_); |
899 } | 901 } |
900 current_instruction_ = old_current; | 902 current_instruction_ = old_current; |
901 } | 903 } |
902 | 904 |
903 | 905 |
904 LEnvironment* LChunkBuilder::CreateEnvironment( | 906 LEnvironment* LChunkBuilder::CreateEnvironment( |
905 HEnvironment* hydrogen_env, | 907 HEnvironment* hydrogen_env, |
906 int* argument_index_accumulator) { | 908 int* argument_index_accumulator, |
| 909 ZoneList<HValue*>* objects_to_materialize) { |
907 if (hydrogen_env == NULL) return NULL; | 910 if (hydrogen_env == NULL) return NULL; |
908 | 911 |
909 LEnvironment* outer = | 912 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), |
910 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 913 argument_index_accumulator, |
| 914 objects_to_materialize); |
911 BailoutId ast_id = hydrogen_env->ast_id(); | 915 BailoutId ast_id = hydrogen_env->ast_id(); |
912 ASSERT(!ast_id.IsNone() || | 916 ASSERT(!ast_id.IsNone() || |
913 hydrogen_env->frame_type() != JS_FUNCTION); | 917 hydrogen_env->frame_type() != JS_FUNCTION); |
914 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 918 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
915 LEnvironment* result = new(zone()) LEnvironment( | 919 LEnvironment* result = new(zone()) LEnvironment( |
916 hydrogen_env->closure(), | 920 hydrogen_env->closure(), |
917 hydrogen_env->frame_type(), | 921 hydrogen_env->frame_type(), |
918 ast_id, | 922 ast_id, |
919 hydrogen_env->parameter_count(), | 923 hydrogen_env->parameter_count(), |
920 argument_count_, | 924 argument_count_, |
921 value_count, | 925 value_count, |
922 outer, | 926 outer, |
923 hydrogen_env->entry(), | 927 hydrogen_env->entry(), |
924 zone()); | 928 zone()); |
925 bool needs_arguments_object_materialization = false; | |
926 int argument_index = *argument_index_accumulator; | 929 int argument_index = *argument_index_accumulator; |
| 930 int object_index = objects_to_materialize->length(); |
927 for (int i = 0; i < hydrogen_env->length(); ++i) { | 931 for (int i = 0; i < hydrogen_env->length(); ++i) { |
928 if (hydrogen_env->is_special_index(i)) continue; | 932 if (hydrogen_env->is_special_index(i)) continue; |
929 | 933 |
| 934 LOperand* op; |
930 HValue* value = hydrogen_env->values()->at(i); | 935 HValue* value = hydrogen_env->values()->at(i); |
931 LOperand* op = NULL; | 936 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
932 if (value->IsArgumentsObject()) { | 937 objects_to_materialize->Add(value, zone()); |
933 needs_arguments_object_materialization = true; | 938 op = LEnvironment::materialization_marker(); |
934 op = NULL; | |
935 } else if (value->IsPushArgument()) { | 939 } else if (value->IsPushArgument()) { |
936 op = new(zone()) LArgument(argument_index++); | 940 op = new(zone()) LArgument(argument_index++); |
937 } else { | 941 } else { |
938 op = UseAny(value); | 942 op = UseAny(value); |
939 } | 943 } |
940 result->AddValue(op, | 944 result->AddValue(op, |
941 value->representation(), | 945 value->representation(), |
942 value->CheckFlag(HInstruction::kUint32)); | 946 value->CheckFlag(HInstruction::kUint32)); |
943 } | 947 } |
944 | 948 |
945 if (needs_arguments_object_materialization) { | 949 for (int i = object_index; i < objects_to_materialize->length(); ++i) { |
946 HArgumentsObject* arguments = hydrogen_env->entry() == NULL | 950 HValue* object_to_materialize = objects_to_materialize->at(i); |
947 ? graph()->GetArgumentsObject() | 951 int previously_materialized_object = -1; |
948 : hydrogen_env->entry()->arguments_object(); | 952 for (int prev = 0; prev < i; ++prev) { |
949 ASSERT(arguments->IsLinked()); | 953 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { |
950 for (int i = 1; i < arguments->arguments_count(); ++i) { | 954 previously_materialized_object = prev; |
951 HValue* value = arguments->arguments_values()->at(i); | 955 break; |
952 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); | 956 } |
953 LOperand* op = UseAny(value); | 957 } |
| 958 int length = object_to_materialize->OperandCount(); |
| 959 bool is_arguments = object_to_materialize->IsArgumentsObject(); |
| 960 if (previously_materialized_object >= 0) { |
| 961 result->AddDuplicateObject(previously_materialized_object); |
| 962 continue; |
| 963 } else { |
| 964 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); |
| 965 } |
| 966 for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
| 967 LOperand* op; |
| 968 HValue* value = object_to_materialize->OperandAt(i); |
| 969 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 970 objects_to_materialize->Add(value, zone()); |
| 971 op = LEnvironment::materialization_marker(); |
| 972 } else { |
| 973 ASSERT(!value->IsPushArgument()); |
| 974 op = UseAny(value); |
| 975 } |
954 result->AddValue(op, | 976 result->AddValue(op, |
955 value->representation(), | 977 value->representation(), |
956 value->CheckFlag(HInstruction::kUint32)); | 978 value->CheckFlag(HInstruction::kUint32)); |
957 } | 979 } |
958 } | 980 } |
959 | 981 |
960 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 982 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
961 *argument_index_accumulator = argument_index; | 983 *argument_index_accumulator = argument_index; |
962 } | 984 } |
963 | 985 |
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2351 | 2373 |
2352 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | 2374 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
2353 // There are no real uses of the arguments object. | 2375 // There are no real uses of the arguments object. |
2354 // arguments.length and element access are supported directly on | 2376 // arguments.length and element access are supported directly on |
2355 // stack arguments, and any real arguments object use causes a bailout. | 2377 // stack arguments, and any real arguments object use causes a bailout. |
2356 // So this value is never used. | 2378 // So this value is never used. |
2357 return NULL; | 2379 return NULL; |
2358 } | 2380 } |
2359 | 2381 |
2360 | 2382 |
| 2383 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { |
| 2384 // There are no real uses of a captured object. |
| 2385 return NULL; |
| 2386 } |
| 2387 |
| 2388 |
2361 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { | 2389 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { |
2362 info()->MarkAsRequiresFrame(); | 2390 info()->MarkAsRequiresFrame(); |
2363 LOperand* args = UseRegister(instr->arguments()); | 2391 LOperand* args = UseRegister(instr->arguments()); |
2364 LOperand* length; | 2392 LOperand* length; |
2365 LOperand* index; | 2393 LOperand* index; |
2366 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { | 2394 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { |
2367 length = UseRegisterOrConstant(instr->length()); | 2395 length = UseRegisterOrConstant(instr->length()); |
2368 index = UseOrConstant(instr->index()); | 2396 index = UseOrConstant(instr->index()); |
2369 } else { | 2397 } else { |
2370 length = UseTempRegister(instr->length()); | 2398 length = UseTempRegister(instr->length()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 | 2530 |
2503 | 2531 |
2504 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2532 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2505 LOperand* object = UseRegister(instr->object()); | 2533 LOperand* object = UseRegister(instr->object()); |
2506 LOperand* index = UseRegister(instr->index()); | 2534 LOperand* index = UseRegister(instr->index()); |
2507 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2535 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2508 } | 2536 } |
2509 | 2537 |
2510 | 2538 |
2511 } } // namespace v8::internal | 2539 } } // namespace v8::internal |
OLD | NEW |