| 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 LInstruction* LChunkBuilder::DefineFixedDouble( | 638 LInstruction* LChunkBuilder::DefineFixedDouble( |
| 639 LTemplateInstruction<1, I, T>* instr, | 639 LTemplateInstruction<1, I, T>* instr, |
| 640 XMMRegister reg) { | 640 XMMRegister reg) { |
| 641 return Define(instr, ToUnallocated(reg)); | 641 return Define(instr, ToUnallocated(reg)); |
| 642 } | 642 } |
| 643 | 643 |
| 644 | 644 |
| 645 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 645 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
| 646 HEnvironment* hydrogen_env = current_block_->last_environment(); | 646 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 647 int argument_index_accumulator = 0; | 647 int argument_index_accumulator = 0; |
| 648 ZoneList<HValue*> objects_to_materialize(0, zone()); |
| 648 instr->set_environment(CreateEnvironment(hydrogen_env, | 649 instr->set_environment(CreateEnvironment(hydrogen_env, |
| 649 &argument_index_accumulator)); | 650 &argument_index_accumulator, |
| 651 &objects_to_materialize)); |
| 650 return instr; | 652 return instr; |
| 651 } | 653 } |
| 652 | 654 |
| 653 | 655 |
| 654 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 656 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
| 655 HInstruction* hinstr, | 657 HInstruction* hinstr, |
| 656 CanDeoptimize can_deoptimize) { | 658 CanDeoptimize can_deoptimize) { |
| 657 info()->MarkAsNonDeferredCalling(); | 659 info()->MarkAsNonDeferredCalling(); |
| 658 | 660 |
| 659 #ifdef DEBUG | 661 #ifdef DEBUG |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 } | 948 } |
| 947 instr->set_hydrogen_value(current); | 949 instr->set_hydrogen_value(current); |
| 948 chunk_->AddInstruction(instr, current_block_); | 950 chunk_->AddInstruction(instr, current_block_); |
| 949 } | 951 } |
| 950 current_instruction_ = old_current; | 952 current_instruction_ = old_current; |
| 951 } | 953 } |
| 952 | 954 |
| 953 | 955 |
| 954 LEnvironment* LChunkBuilder::CreateEnvironment( | 956 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 955 HEnvironment* hydrogen_env, | 957 HEnvironment* hydrogen_env, |
| 956 int* argument_index_accumulator) { | 958 int* argument_index_accumulator, |
| 959 ZoneList<HValue*>* objects_to_materialize) { |
| 957 if (hydrogen_env == NULL) return NULL; | 960 if (hydrogen_env == NULL) return NULL; |
| 958 | 961 |
| 959 LEnvironment* outer = | 962 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), |
| 960 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 963 argument_index_accumulator, |
| 964 objects_to_materialize); |
| 961 BailoutId ast_id = hydrogen_env->ast_id(); | 965 BailoutId ast_id = hydrogen_env->ast_id(); |
| 962 ASSERT(!ast_id.IsNone() || | 966 ASSERT(!ast_id.IsNone() || |
| 963 hydrogen_env->frame_type() != JS_FUNCTION); | 967 hydrogen_env->frame_type() != JS_FUNCTION); |
| 964 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 968 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
| 965 LEnvironment* result = | 969 LEnvironment* result = |
| 966 new(zone()) LEnvironment(hydrogen_env->closure(), | 970 new(zone()) LEnvironment(hydrogen_env->closure(), |
| 967 hydrogen_env->frame_type(), | 971 hydrogen_env->frame_type(), |
| 968 ast_id, | 972 ast_id, |
| 969 hydrogen_env->parameter_count(), | 973 hydrogen_env->parameter_count(), |
| 970 argument_count_, | 974 argument_count_, |
| 971 value_count, | 975 value_count, |
| 972 outer, | 976 outer, |
| 973 hydrogen_env->entry(), | 977 hydrogen_env->entry(), |
| 974 zone()); | 978 zone()); |
| 975 bool needs_arguments_object_materialization = false; | |
| 976 int argument_index = *argument_index_accumulator; | 979 int argument_index = *argument_index_accumulator; |
| 980 int object_index = objects_to_materialize->length(); |
| 977 for (int i = 0; i < hydrogen_env->length(); ++i) { | 981 for (int i = 0; i < hydrogen_env->length(); ++i) { |
| 978 if (hydrogen_env->is_special_index(i)) continue; | 982 if (hydrogen_env->is_special_index(i)) continue; |
| 979 | 983 |
| 984 LOperand* op; |
| 980 HValue* value = hydrogen_env->values()->at(i); | 985 HValue* value = hydrogen_env->values()->at(i); |
| 981 LOperand* op = NULL; | 986 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 982 if (value->IsArgumentsObject()) { | 987 objects_to_materialize->Add(value, zone()); |
| 983 needs_arguments_object_materialization = true; | 988 op = LEnvironment::materialization_marker(); |
| 984 op = NULL; | |
| 985 } else if (value->IsPushArgument()) { | 989 } else if (value->IsPushArgument()) { |
| 986 op = new(zone()) LArgument(argument_index++); | 990 op = new(zone()) LArgument(argument_index++); |
| 987 } else { | 991 } else { |
| 988 op = UseAny(value); | 992 op = UseAny(value); |
| 989 } | 993 } |
| 990 result->AddValue(op, | 994 result->AddValue(op, |
| 991 value->representation(), | 995 value->representation(), |
| 992 value->CheckFlag(HInstruction::kUint32)); | 996 value->CheckFlag(HInstruction::kUint32)); |
| 993 } | 997 } |
| 994 | 998 |
| 995 if (needs_arguments_object_materialization) { | 999 for (int i = object_index; i < objects_to_materialize->length(); ++i) { |
| 996 HArgumentsObject* arguments = hydrogen_env->entry() == NULL | 1000 HValue* object_to_materialize = objects_to_materialize->at(i); |
| 997 ? graph()->GetArgumentsObject() | 1001 int previously_materialized_object = -1; |
| 998 : hydrogen_env->entry()->arguments_object(); | 1002 for (int prev = 0; prev < i; ++prev) { |
| 999 ASSERT(arguments->IsLinked()); | 1003 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { |
| 1000 for (int i = 1; i < arguments->arguments_count(); ++i) { | 1004 previously_materialized_object = prev; |
| 1001 HValue* value = arguments->arguments_values()->at(i); | 1005 break; |
| 1002 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); | 1006 } |
| 1003 LOperand* op = UseAny(value); | 1007 } |
| 1008 int length = object_to_materialize->OperandCount(); |
| 1009 bool is_arguments = object_to_materialize->IsArgumentsObject(); |
| 1010 if (previously_materialized_object >= 0) { |
| 1011 result->AddDuplicateObject(previously_materialized_object); |
| 1012 continue; |
| 1013 } else { |
| 1014 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); |
| 1015 } |
| 1016 for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
| 1017 LOperand* op; |
| 1018 HValue* value = object_to_materialize->OperandAt(i); |
| 1019 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 1020 objects_to_materialize->Add(value, zone()); |
| 1021 op = LEnvironment::materialization_marker(); |
| 1022 } else { |
| 1023 ASSERT(!value->IsPushArgument()); |
| 1024 op = UseAny(value); |
| 1025 } |
| 1004 result->AddValue(op, | 1026 result->AddValue(op, |
| 1005 value->representation(), | 1027 value->representation(), |
| 1006 value->CheckFlag(HInstruction::kUint32)); | 1028 value->CheckFlag(HInstruction::kUint32)); |
| 1007 } | 1029 } |
| 1008 } | 1030 } |
| 1009 | 1031 |
| 1010 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 1032 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
| 1011 *argument_index_accumulator = argument_index; | 1033 *argument_index_accumulator = argument_index; |
| 1012 } | 1034 } |
| 1013 | 1035 |
| (...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 | 2582 |
| 2561 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | 2583 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
| 2562 // There are no real uses of the arguments object. | 2584 // There are no real uses of the arguments object. |
| 2563 // arguments.length and element access are supported directly on | 2585 // arguments.length and element access are supported directly on |
| 2564 // stack arguments, and any real arguments object use causes a bailout. | 2586 // stack arguments, and any real arguments object use causes a bailout. |
| 2565 // So this value is never used. | 2587 // So this value is never used. |
| 2566 return NULL; | 2588 return NULL; |
| 2567 } | 2589 } |
| 2568 | 2590 |
| 2569 | 2591 |
| 2592 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { |
| 2593 // There are no real uses of a captured object. |
| 2594 return NULL; |
| 2595 } |
| 2596 |
| 2597 |
| 2570 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { | 2598 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { |
| 2571 info()->MarkAsRequiresFrame(); | 2599 info()->MarkAsRequiresFrame(); |
| 2572 LOperand* args = UseRegister(instr->arguments()); | 2600 LOperand* args = UseRegister(instr->arguments()); |
| 2573 LOperand* length; | 2601 LOperand* length; |
| 2574 LOperand* index; | 2602 LOperand* index; |
| 2575 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { | 2603 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { |
| 2576 length = UseRegisterOrConstant(instr->length()); | 2604 length = UseRegisterOrConstant(instr->length()); |
| 2577 index = UseOrConstant(instr->index()); | 2605 index = UseOrConstant(instr->index()); |
| 2578 } else { | 2606 } else { |
| 2579 length = UseTempRegister(instr->length()); | 2607 length = UseTempRegister(instr->length()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2721 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2749 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2722 LOperand* object = UseRegister(instr->object()); | 2750 LOperand* object = UseRegister(instr->object()); |
| 2723 LOperand* index = UseTempRegister(instr->index()); | 2751 LOperand* index = UseTempRegister(instr->index()); |
| 2724 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2752 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2725 } | 2753 } |
| 2726 | 2754 |
| 2727 | 2755 |
| 2728 } } // namespace v8::internal | 2756 } } // namespace v8::internal |
| 2729 | 2757 |
| 2730 #endif // V8_TARGET_ARCH_IA32 | 2758 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |