| 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 template<int I, int T> | 586 template<int I, int T> |
| 587 LInstruction* LChunkBuilder::DefineFixedDouble( | 587 LInstruction* LChunkBuilder::DefineFixedDouble( |
| 588 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) { | 588 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) { |
| 589 return Define(instr, ToUnallocated(reg)); | 589 return Define(instr, ToUnallocated(reg)); |
| 590 } | 590 } |
| 591 | 591 |
| 592 | 592 |
| 593 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 593 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
| 594 HEnvironment* hydrogen_env = current_block_->last_environment(); | 594 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 595 int argument_index_accumulator = 0; | 595 int argument_index_accumulator = 0; |
| 596 ZoneList<HValue*> objects_to_materialize(0, zone()); |
| 596 instr->set_environment(CreateEnvironment(hydrogen_env, | 597 instr->set_environment(CreateEnvironment(hydrogen_env, |
| 597 &argument_index_accumulator)); | 598 &argument_index_accumulator, |
| 599 &objects_to_materialize)); |
| 598 return instr; | 600 return instr; |
| 599 } | 601 } |
| 600 | 602 |
| 601 | 603 |
| 602 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 604 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
| 603 HInstruction* hinstr, | 605 HInstruction* hinstr, |
| 604 CanDeoptimize can_deoptimize) { | 606 CanDeoptimize can_deoptimize) { |
| 605 info()->MarkAsNonDeferredCalling(); | 607 info()->MarkAsNonDeferredCalling(); |
| 606 #ifdef DEBUG | 608 #ifdef DEBUG |
| 607 instr->VerifyCall(); | 609 instr->VerifyCall(); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 } | 893 } |
| 892 instr->set_hydrogen_value(current); | 894 instr->set_hydrogen_value(current); |
| 893 chunk_->AddInstruction(instr, current_block_); | 895 chunk_->AddInstruction(instr, current_block_); |
| 894 } | 896 } |
| 895 current_instruction_ = old_current; | 897 current_instruction_ = old_current; |
| 896 } | 898 } |
| 897 | 899 |
| 898 | 900 |
| 899 LEnvironment* LChunkBuilder::CreateEnvironment( | 901 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 900 HEnvironment* hydrogen_env, | 902 HEnvironment* hydrogen_env, |
| 901 int* argument_index_accumulator) { | 903 int* argument_index_accumulator, |
| 904 ZoneList<HValue*>* objects_to_materialize) { |
| 902 if (hydrogen_env == NULL) return NULL; | 905 if (hydrogen_env == NULL) return NULL; |
| 903 | 906 |
| 904 LEnvironment* outer = | 907 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), |
| 905 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 908 argument_index_accumulator, |
| 909 objects_to_materialize); |
| 906 BailoutId ast_id = hydrogen_env->ast_id(); | 910 BailoutId ast_id = hydrogen_env->ast_id(); |
| 907 ASSERT(!ast_id.IsNone() || | 911 ASSERT(!ast_id.IsNone() || |
| 908 hydrogen_env->frame_type() != JS_FUNCTION); | 912 hydrogen_env->frame_type() != JS_FUNCTION); |
| 909 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 913 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
| 910 LEnvironment* result = new(zone()) LEnvironment( | 914 LEnvironment* result = new(zone()) LEnvironment( |
| 911 hydrogen_env->closure(), | 915 hydrogen_env->closure(), |
| 912 hydrogen_env->frame_type(), | 916 hydrogen_env->frame_type(), |
| 913 ast_id, | 917 ast_id, |
| 914 hydrogen_env->parameter_count(), | 918 hydrogen_env->parameter_count(), |
| 915 argument_count_, | 919 argument_count_, |
| 916 value_count, | 920 value_count, |
| 917 outer, | 921 outer, |
| 918 hydrogen_env->entry(), | 922 hydrogen_env->entry(), |
| 919 zone()); | 923 zone()); |
| 920 bool needs_arguments_object_materialization = false; | |
| 921 int argument_index = *argument_index_accumulator; | 924 int argument_index = *argument_index_accumulator; |
| 925 int object_index = objects_to_materialize->length(); |
| 922 for (int i = 0; i < hydrogen_env->length(); ++i) { | 926 for (int i = 0; i < hydrogen_env->length(); ++i) { |
| 923 if (hydrogen_env->is_special_index(i)) continue; | 927 if (hydrogen_env->is_special_index(i)) continue; |
| 924 | 928 |
| 929 LOperand* op; |
| 925 HValue* value = hydrogen_env->values()->at(i); | 930 HValue* value = hydrogen_env->values()->at(i); |
| 926 LOperand* op = NULL; | 931 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 927 if (value->IsArgumentsObject()) { | 932 objects_to_materialize->Add(value, zone()); |
| 928 needs_arguments_object_materialization = true; | 933 op = LEnvironment::materialization_marker(); |
| 929 op = NULL; | |
| 930 } else if (value->IsPushArgument()) { | 934 } else if (value->IsPushArgument()) { |
| 931 op = new(zone()) LArgument(argument_index++); | 935 op = new(zone()) LArgument(argument_index++); |
| 932 } else { | 936 } else { |
| 933 op = UseAny(value); | 937 op = UseAny(value); |
| 934 } | 938 } |
| 935 result->AddValue(op, | 939 result->AddValue(op, |
| 936 value->representation(), | 940 value->representation(), |
| 937 value->CheckFlag(HInstruction::kUint32)); | 941 value->CheckFlag(HInstruction::kUint32)); |
| 938 } | 942 } |
| 939 | 943 |
| 940 if (needs_arguments_object_materialization) { | 944 for (int i = object_index; i < objects_to_materialize->length(); ++i) { |
| 941 HArgumentsObject* arguments = hydrogen_env->entry() == NULL | 945 HValue* object_to_materialize = objects_to_materialize->at(i); |
| 942 ? graph()->GetArgumentsObject() | 946 int previously_materialized_object = -1; |
| 943 : hydrogen_env->entry()->arguments_object(); | 947 for (int prev = 0; prev < i; ++prev) { |
| 944 ASSERT(arguments->IsLinked()); | 948 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { |
| 945 for (int i = 1; i < arguments->arguments_count(); ++i) { | 949 previously_materialized_object = prev; |
| 946 HValue* value = arguments->arguments_values()->at(i); | 950 break; |
| 947 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); | 951 } |
| 948 LOperand* op = UseAny(value); | 952 } |
| 953 int length = object_to_materialize->OperandCount(); |
| 954 bool is_arguments = object_to_materialize->IsArgumentsObject(); |
| 955 if (previously_materialized_object >= 0) { |
| 956 result->AddDuplicateObject(previously_materialized_object); |
| 957 continue; |
| 958 } else { |
| 959 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); |
| 960 } |
| 961 for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
| 962 LOperand* op; |
| 963 HValue* value = object_to_materialize->OperandAt(i); |
| 964 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 965 objects_to_materialize->Add(value, zone()); |
| 966 op = LEnvironment::materialization_marker(); |
| 967 } else { |
| 968 ASSERT(!value->IsPushArgument()); |
| 969 op = UseAny(value); |
| 970 } |
| 949 result->AddValue(op, | 971 result->AddValue(op, |
| 950 value->representation(), | 972 value->representation(), |
| 951 value->CheckFlag(HInstruction::kUint32)); | 973 value->CheckFlag(HInstruction::kUint32)); |
| 952 } | 974 } |
| 953 } | 975 } |
| 954 | 976 |
| 955 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 977 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
| 956 *argument_index_accumulator = argument_index; | 978 *argument_index_accumulator = argument_index; |
| 957 } | 979 } |
| 958 | 980 |
| (...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2430 | 2452 |
| 2431 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | 2453 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
| 2432 // There are no real uses of the arguments object. | 2454 // There are no real uses of the arguments object. |
| 2433 // arguments.length and element access are supported directly on | 2455 // arguments.length and element access are supported directly on |
| 2434 // stack arguments, and any real arguments object use causes a bailout. | 2456 // stack arguments, and any real arguments object use causes a bailout. |
| 2435 // So this value is never used. | 2457 // So this value is never used. |
| 2436 return NULL; | 2458 return NULL; |
| 2437 } | 2459 } |
| 2438 | 2460 |
| 2439 | 2461 |
| 2462 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { |
| 2463 // There are no real uses of a captured object. |
| 2464 return NULL; |
| 2465 } |
| 2466 |
| 2467 |
| 2440 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { | 2468 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { |
| 2441 info()->MarkAsRequiresFrame(); | 2469 info()->MarkAsRequiresFrame(); |
| 2442 LOperand* args = UseRegister(instr->arguments()); | 2470 LOperand* args = UseRegister(instr->arguments()); |
| 2443 LOperand* length; | 2471 LOperand* length; |
| 2444 LOperand* index; | 2472 LOperand* index; |
| 2445 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { | 2473 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { |
| 2446 length = UseRegisterOrConstant(instr->length()); | 2474 length = UseRegisterOrConstant(instr->length()); |
| 2447 index = UseOrConstant(instr->index()); | 2475 index = UseOrConstant(instr->index()); |
| 2448 } else { | 2476 } else { |
| 2449 length = UseTempRegister(instr->length()); | 2477 length = UseTempRegister(instr->length()); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2581 | 2609 |
| 2582 | 2610 |
| 2583 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2611 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2584 LOperand* object = UseRegister(instr->object()); | 2612 LOperand* object = UseRegister(instr->object()); |
| 2585 LOperand* index = UseRegister(instr->index()); | 2613 LOperand* index = UseRegister(instr->index()); |
| 2586 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2614 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2587 } | 2615 } |
| 2588 | 2616 |
| 2589 | 2617 |
| 2590 } } // namespace v8::internal | 2618 } } // namespace v8::internal |
| OLD | NEW |