| 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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 LInstruction* LChunkBuilder::DefineFixedDouble( | 612 LInstruction* LChunkBuilder::DefineFixedDouble( |
| 613 LTemplateInstruction<1, I, T>* instr, | 613 LTemplateInstruction<1, I, T>* instr, |
| 614 XMMRegister reg) { | 614 XMMRegister reg) { |
| 615 return Define(instr, ToUnallocated(reg)); | 615 return Define(instr, ToUnallocated(reg)); |
| 616 } | 616 } |
| 617 | 617 |
| 618 | 618 |
| 619 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | 619 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { |
| 620 HEnvironment* hydrogen_env = current_block_->last_environment(); | 620 HEnvironment* hydrogen_env = current_block_->last_environment(); |
| 621 int argument_index_accumulator = 0; | 621 int argument_index_accumulator = 0; |
| 622 ZoneList<HValue*> objects_to_materialize(0, zone()); |
| 622 instr->set_environment(CreateEnvironment(hydrogen_env, | 623 instr->set_environment(CreateEnvironment(hydrogen_env, |
| 623 &argument_index_accumulator)); | 624 &argument_index_accumulator, |
| 625 &objects_to_materialize)); |
| 624 return instr; | 626 return instr; |
| 625 } | 627 } |
| 626 | 628 |
| 627 | 629 |
| 628 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | 630 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, |
| 629 HInstruction* hinstr, | 631 HInstruction* hinstr, |
| 630 CanDeoptimize can_deoptimize) { | 632 CanDeoptimize can_deoptimize) { |
| 631 info()->MarkAsNonDeferredCalling(); | 633 info()->MarkAsNonDeferredCalling(); |
| 632 | 634 |
| 633 #ifdef DEBUG | 635 #ifdef DEBUG |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 } | 910 } |
| 909 instr->set_hydrogen_value(current); | 911 instr->set_hydrogen_value(current); |
| 910 chunk_->AddInstruction(instr, current_block_); | 912 chunk_->AddInstruction(instr, current_block_); |
| 911 } | 913 } |
| 912 current_instruction_ = old_current; | 914 current_instruction_ = old_current; |
| 913 } | 915 } |
| 914 | 916 |
| 915 | 917 |
| 916 LEnvironment* LChunkBuilder::CreateEnvironment( | 918 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 917 HEnvironment* hydrogen_env, | 919 HEnvironment* hydrogen_env, |
| 918 int* argument_index_accumulator) { | 920 int* argument_index_accumulator, |
| 921 ZoneList<HValue*>* objects_to_materialize) { |
| 919 if (hydrogen_env == NULL) return NULL; | 922 if (hydrogen_env == NULL) return NULL; |
| 920 | 923 |
| 921 LEnvironment* outer = | 924 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), |
| 922 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 925 argument_index_accumulator, |
| 926 objects_to_materialize); |
| 923 BailoutId ast_id = hydrogen_env->ast_id(); | 927 BailoutId ast_id = hydrogen_env->ast_id(); |
| 924 ASSERT(!ast_id.IsNone() || | 928 ASSERT(!ast_id.IsNone() || |
| 925 hydrogen_env->frame_type() != JS_FUNCTION); | 929 hydrogen_env->frame_type() != JS_FUNCTION); |
| 926 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 930 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
| 927 LEnvironment* result = new(zone()) LEnvironment( | 931 LEnvironment* result = new(zone()) LEnvironment( |
| 928 hydrogen_env->closure(), | 932 hydrogen_env->closure(), |
| 929 hydrogen_env->frame_type(), | 933 hydrogen_env->frame_type(), |
| 930 ast_id, | 934 ast_id, |
| 931 hydrogen_env->parameter_count(), | 935 hydrogen_env->parameter_count(), |
| 932 argument_count_, | 936 argument_count_, |
| 933 value_count, | 937 value_count, |
| 934 outer, | 938 outer, |
| 935 hydrogen_env->entry(), | 939 hydrogen_env->entry(), |
| 936 zone()); | 940 zone()); |
| 937 bool needs_arguments_object_materialization = false; | |
| 938 int argument_index = *argument_index_accumulator; | 941 int argument_index = *argument_index_accumulator; |
| 942 int object_index = objects_to_materialize->length(); |
| 939 for (int i = 0; i < hydrogen_env->length(); ++i) { | 943 for (int i = 0; i < hydrogen_env->length(); ++i) { |
| 940 if (hydrogen_env->is_special_index(i)) continue; | 944 if (hydrogen_env->is_special_index(i)) continue; |
| 941 | 945 |
| 946 LOperand* op; |
| 942 HValue* value = hydrogen_env->values()->at(i); | 947 HValue* value = hydrogen_env->values()->at(i); |
| 943 LOperand* op = NULL; | 948 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 944 if (value->IsArgumentsObject()) { | 949 objects_to_materialize->Add(value, zone()); |
| 945 needs_arguments_object_materialization = true; | 950 op = LEnvironment::materialization_marker(); |
| 946 op = NULL; | |
| 947 } else if (value->IsPushArgument()) { | 951 } else if (value->IsPushArgument()) { |
| 948 op = new(zone()) LArgument(argument_index++); | 952 op = new(zone()) LArgument(argument_index++); |
| 949 } else { | 953 } else { |
| 950 op = UseAny(value); | 954 op = UseAny(value); |
| 951 } | 955 } |
| 952 result->AddValue(op, | 956 result->AddValue(op, |
| 953 value->representation(), | 957 value->representation(), |
| 954 value->CheckFlag(HInstruction::kUint32)); | 958 value->CheckFlag(HInstruction::kUint32)); |
| 955 } | 959 } |
| 956 | 960 |
| 957 if (needs_arguments_object_materialization) { | 961 for (int i = object_index; i < objects_to_materialize->length(); ++i) { |
| 958 HArgumentsObject* arguments = hydrogen_env->entry() == NULL | 962 HValue* object_to_materialize = objects_to_materialize->at(i); |
| 959 ? graph()->GetArgumentsObject() | 963 int previously_materialized_object = -1; |
| 960 : hydrogen_env->entry()->arguments_object(); | 964 for (int prev = 0; prev < i; ++prev) { |
| 961 ASSERT(arguments->IsLinked()); | 965 if (objects_to_materialize->at(prev) == objects_to_materialize->at(i)) { |
| 962 for (int i = 1; i < arguments->arguments_count(); ++i) { | 966 previously_materialized_object = prev; |
| 963 HValue* value = arguments->arguments_values()->at(i); | 967 break; |
| 964 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); | 968 } |
| 965 LOperand* op = UseAny(value); | 969 } |
| 970 int length = object_to_materialize->OperandCount(); |
| 971 bool is_arguments = object_to_materialize->IsArgumentsObject(); |
| 972 if (previously_materialized_object >= 0) { |
| 973 result->AddDuplicateObject(previously_materialized_object); |
| 974 continue; |
| 975 } else { |
| 976 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); |
| 977 } |
| 978 for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
| 979 LOperand* op; |
| 980 HValue* value = object_to_materialize->OperandAt(i); |
| 981 if (value->IsArgumentsObject() || value->IsCapturedObject()) { |
| 982 objects_to_materialize->Add(value, zone()); |
| 983 op = LEnvironment::materialization_marker(); |
| 984 } else { |
| 985 ASSERT(!value->IsPushArgument()); |
| 986 op = UseAny(value); |
| 987 } |
| 966 result->AddValue(op, | 988 result->AddValue(op, |
| 967 value->representation(), | 989 value->representation(), |
| 968 value->CheckFlag(HInstruction::kUint32)); | 990 value->CheckFlag(HInstruction::kUint32)); |
| 969 } | 991 } |
| 970 } | 992 } |
| 971 | 993 |
| 972 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 994 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
| 973 *argument_index_accumulator = argument_index; | 995 *argument_index_accumulator = argument_index; |
| 974 } | 996 } |
| 975 | 997 |
| (...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2414 | 2436 |
| 2415 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | 2437 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
| 2416 // There are no real uses of the arguments object. | 2438 // There are no real uses of the arguments object. |
| 2417 // arguments.length and element access are supported directly on | 2439 // arguments.length and element access are supported directly on |
| 2418 // stack arguments, and any real arguments object use causes a bailout. | 2440 // stack arguments, and any real arguments object use causes a bailout. |
| 2419 // So this value is never used. | 2441 // So this value is never used. |
| 2420 return NULL; | 2442 return NULL; |
| 2421 } | 2443 } |
| 2422 | 2444 |
| 2423 | 2445 |
| 2446 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { |
| 2447 // There are no real uses of a captured object. |
| 2448 return NULL; |
| 2449 } |
| 2450 |
| 2451 |
| 2424 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { | 2452 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { |
| 2425 info()->MarkAsRequiresFrame(); | 2453 info()->MarkAsRequiresFrame(); |
| 2426 LOperand* args = UseRegister(instr->arguments()); | 2454 LOperand* args = UseRegister(instr->arguments()); |
| 2427 LOperand* length; | 2455 LOperand* length; |
| 2428 LOperand* index; | 2456 LOperand* index; |
| 2429 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { | 2457 if (instr->length()->IsConstant() && instr->index()->IsConstant()) { |
| 2430 length = UseRegisterOrConstant(instr->length()); | 2458 length = UseRegisterOrConstant(instr->length()); |
| 2431 index = UseOrConstant(instr->index()); | 2459 index = UseOrConstant(instr->index()); |
| 2432 } else { | 2460 } else { |
| 2433 length = UseTempRegister(instr->length()); | 2461 length = UseTempRegister(instr->length()); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2569 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2597 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2570 LOperand* object = UseRegister(instr->object()); | 2598 LOperand* object = UseRegister(instr->object()); |
| 2571 LOperand* index = UseTempRegister(instr->index()); | 2599 LOperand* index = UseTempRegister(instr->index()); |
| 2572 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2600 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2573 } | 2601 } |
| 2574 | 2602 |
| 2575 | 2603 |
| 2576 } } // namespace v8::internal | 2604 } } // namespace v8::internal |
| 2577 | 2605 |
| 2578 #endif // V8_TARGET_ARCH_X64 | 2606 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |