| 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 LEnvironment* LChunkBuilder::CreateEnvironment( | 922 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 923 HEnvironment* hydrogen_env, | 923 HEnvironment* hydrogen_env, |
| 924 int* argument_index_accumulator) { | 924 int* argument_index_accumulator) { |
| 925 if (hydrogen_env == NULL) return NULL; | 925 if (hydrogen_env == NULL) return NULL; |
| 926 | 926 |
| 927 LEnvironment* outer = | 927 LEnvironment* outer = |
| 928 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 928 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
| 929 BailoutId ast_id = hydrogen_env->ast_id(); | 929 BailoutId ast_id = hydrogen_env->ast_id(); |
| 930 ASSERT(!ast_id.IsNone() || | 930 ASSERT(!ast_id.IsNone() || |
| 931 hydrogen_env->frame_type() != JS_FUNCTION); | 931 hydrogen_env->frame_type() != JS_FUNCTION); |
| 932 int value_count = hydrogen_env->length(); | 932 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
| 933 LEnvironment* result = new(zone()) LEnvironment( | 933 LEnvironment* result = new(zone()) LEnvironment( |
| 934 hydrogen_env->closure(), | 934 hydrogen_env->closure(), |
| 935 hydrogen_env->frame_type(), | 935 hydrogen_env->frame_type(), |
| 936 ast_id, | 936 ast_id, |
| 937 hydrogen_env->parameter_count(), | 937 hydrogen_env->parameter_count(), |
| 938 argument_count_, | 938 argument_count_, |
| 939 value_count, | 939 value_count, |
| 940 outer, | 940 outer, |
| 941 hydrogen_env->entry(), | 941 hydrogen_env->entry(), |
| 942 zone()); | 942 zone()); |
| 943 bool needs_arguments_object_materialization = false; |
| 943 int argument_index = *argument_index_accumulator; | 944 int argument_index = *argument_index_accumulator; |
| 944 for (int i = 0; i < value_count; ++i) { | 945 for (int i = 0; i < hydrogen_env->length(); ++i) { |
| 945 if (hydrogen_env->is_special_index(i)) continue; | 946 if (hydrogen_env->is_special_index(i)) continue; |
| 946 | 947 |
| 947 HValue* value = hydrogen_env->values()->at(i); | 948 HValue* value = hydrogen_env->values()->at(i); |
| 948 LOperand* op = NULL; | 949 LOperand* op = NULL; |
| 949 if (value->IsArgumentsObject()) { | 950 if (value->IsArgumentsObject()) { |
| 951 needs_arguments_object_materialization = true; |
| 950 op = NULL; | 952 op = NULL; |
| 951 } else if (value->IsPushArgument()) { | 953 } else if (value->IsPushArgument()) { |
| 952 op = new(zone()) LArgument(argument_index++); | 954 op = new(zone()) LArgument(argument_index++); |
| 953 } else { | 955 } else { |
| 954 op = UseAny(value); | 956 op = UseAny(value); |
| 955 } | 957 } |
| 956 result->AddValue(op, | 958 result->AddValue(op, |
| 957 value->representation(), | 959 value->representation(), |
| 958 value->CheckFlag(HInstruction::kUint32)); | 960 value->CheckFlag(HInstruction::kUint32)); |
| 959 } | 961 } |
| 960 | 962 |
| 963 if (needs_arguments_object_materialization) { |
| 964 HArgumentsObject* arguments = hydrogen_env->entry() == NULL |
| 965 ? graph()->GetArgumentsObject() |
| 966 : hydrogen_env->entry()->arguments_object(); |
| 967 ASSERT(arguments->IsLinked()); |
| 968 for (int i = 1; i < arguments->arguments_count(); ++i) { |
| 969 HValue* value = arguments->arguments_values()->at(i); |
| 970 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); |
| 971 LOperand* op = UseAny(value); |
| 972 result->AddValue(op, |
| 973 value->representation(), |
| 974 value->CheckFlag(HInstruction::kUint32)); |
| 975 } |
| 976 } |
| 977 |
| 961 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 978 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
| 962 *argument_index_accumulator = argument_index; | 979 *argument_index_accumulator = argument_index; |
| 963 } | 980 } |
| 964 | 981 |
| 965 return result; | 982 return result; |
| 966 } | 983 } |
| 967 | 984 |
| 968 | 985 |
| 969 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 986 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 970 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 987 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 int32_t power_of_2_factor = | 1396 int32_t power_of_2_factor = |
| 1380 CompilerIntrinsics::CountTrailingZeros(divisor_abs); | 1397 CompilerIntrinsics::CountTrailingZeros(divisor_abs); |
| 1381 DivMagicNumbers magic_numbers = | 1398 DivMagicNumbers magic_numbers = |
| 1382 DivMagicNumberFor(divisor_abs >> power_of_2_factor); | 1399 DivMagicNumberFor(divisor_abs >> power_of_2_factor); |
| 1383 if (magic_numbers.M != InvalidDivMagicNumber.M) return true; | 1400 if (magic_numbers.M != InvalidDivMagicNumber.M) return true; |
| 1384 | 1401 |
| 1385 return false; | 1402 return false; |
| 1386 } | 1403 } |
| 1387 | 1404 |
| 1388 | 1405 |
| 1389 HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue* dividend) { | |
| 1390 // A value with an integer representation does not need to be transformed. | |
| 1391 if (dividend->representation().IsInteger32()) { | |
| 1392 return dividend; | |
| 1393 // A change from an integer32 can be replaced by the integer32 value. | |
| 1394 } else if (dividend->IsChange() && | |
| 1395 HChange::cast(dividend)->from().IsInteger32()) { | |
| 1396 return HChange::cast(dividend)->value(); | |
| 1397 } | |
| 1398 return NULL; | |
| 1399 } | |
| 1400 | |
| 1401 | |
| 1402 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1406 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
| 1403 if (CpuFeatures::IsSupported(SUDIV)) { | 1407 if (CpuFeatures::IsSupported(SUDIV)) { |
| 1404 // A value with an integer representation does not need to be transformed. | 1408 // A value with an integer representation does not need to be transformed. |
| 1405 if (divisor->representation().IsInteger32()) { | 1409 if (divisor->representation().IsInteger32()) { |
| 1406 return divisor; | 1410 return divisor; |
| 1407 // A change from an integer32 can be replaced by the integer32 value. | 1411 // A change from an integer32 can be replaced by the integer32 value. |
| 1408 } else if (divisor->IsChange() && | 1412 } else if (divisor->IsChange() && |
| 1409 HChange::cast(divisor)->from().IsInteger32()) { | 1413 HChange::cast(divisor)->from().IsInteger32()) { |
| 1410 return HChange::cast(divisor)->value(); | 1414 return HChange::cast(divisor)->value(); |
| 1411 } | 1415 } |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2581 | 2585 |
| 2582 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | 2586 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
| 2583 HEnvironment* outer = current_block_->last_environment(); | 2587 HEnvironment* outer = current_block_->last_environment(); |
| 2584 HConstant* undefined = graph()->GetConstantUndefined(); | 2588 HConstant* undefined = graph()->GetConstantUndefined(); |
| 2585 HEnvironment* inner = outer->CopyForInlining(instr->closure(), | 2589 HEnvironment* inner = outer->CopyForInlining(instr->closure(), |
| 2586 instr->arguments_count(), | 2590 instr->arguments_count(), |
| 2587 instr->function(), | 2591 instr->function(), |
| 2588 undefined, | 2592 undefined, |
| 2589 instr->inlining_kind(), | 2593 instr->inlining_kind(), |
| 2590 instr->undefined_receiver()); | 2594 instr->undefined_receiver()); |
| 2591 if (instr->arguments_var() != NULL) { | 2595 // Only replay binding of arguments object if it wasn't removed from graph. |
| 2592 inner->Bind(instr->arguments_var(), graph()->GetArgumentsObject()); | 2596 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { |
| 2597 inner->Bind(instr->arguments_var(), instr->arguments_object()); |
| 2593 } | 2598 } |
| 2594 inner->set_entry(instr); | 2599 inner->set_entry(instr); |
| 2595 current_block_->UpdateEnvironment(inner); | 2600 current_block_->UpdateEnvironment(inner); |
| 2596 chunk_->AddInlinedClosure(instr->closure()); | 2601 chunk_->AddInlinedClosure(instr->closure()); |
| 2597 return NULL; | 2602 return NULL; |
| 2598 } | 2603 } |
| 2599 | 2604 |
| 2600 | 2605 |
| 2601 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 2606 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 2602 LInstruction* pop = NULL; | 2607 LInstruction* pop = NULL; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2646 | 2651 |
| 2647 | 2652 |
| 2648 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2653 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2649 LOperand* object = UseRegister(instr->object()); | 2654 LOperand* object = UseRegister(instr->object()); |
| 2650 LOperand* index = UseRegister(instr->index()); | 2655 LOperand* index = UseRegister(instr->index()); |
| 2651 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2656 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2652 } | 2657 } |
| 2653 | 2658 |
| 2654 | 2659 |
| 2655 } } // namespace v8::internal | 2660 } } // namespace v8::internal |
| OLD | NEW |