| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 691 |
| 692 LEnvironment* LChunkBuilder::CreateEnvironment( | 692 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 693 HEnvironment* hydrogen_env, | 693 HEnvironment* hydrogen_env, |
| 694 int* argument_index_accumulator) { | 694 int* argument_index_accumulator) { |
| 695 if (hydrogen_env == NULL) return NULL; | 695 if (hydrogen_env == NULL) return NULL; |
| 696 | 696 |
| 697 LEnvironment* outer = | 697 LEnvironment* outer = |
| 698 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 698 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
| 699 BailoutId ast_id = hydrogen_env->ast_id(); | 699 BailoutId ast_id = hydrogen_env->ast_id(); |
| 700 ASSERT(!ast_id.IsNone() || (hydrogen_env->frame_type() != JS_FUNCTION)); | 700 ASSERT(!ast_id.IsNone() || (hydrogen_env->frame_type() != JS_FUNCTION)); |
| 701 int value_count = hydrogen_env->length(); | 701 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
| 702 | 702 |
| 703 LEnvironment* result = new(zone()) LEnvironment( | 703 LEnvironment* result = new(zone()) LEnvironment( |
| 704 hydrogen_env->closure(), | 704 hydrogen_env->closure(), |
| 705 hydrogen_env->frame_type(), | 705 hydrogen_env->frame_type(), |
| 706 ast_id, | 706 ast_id, |
| 707 hydrogen_env->parameter_count(), | 707 hydrogen_env->parameter_count(), |
| 708 argument_count(), | 708 argument_count(), |
| 709 value_count, | 709 value_count, |
| 710 outer, | 710 outer, |
| 711 hydrogen_env->entry(), | 711 hydrogen_env->entry(), |
| 712 zone()); | 712 zone()); |
| 713 | 713 |
| 714 bool needs_arguments_object_materialization = false; |
| 714 int argument_index = *argument_index_accumulator; | 715 int argument_index = *argument_index_accumulator; |
| 715 for (int i = 0; i < value_count; ++i) { | 716 for (int i = 0; i < hydrogen_env->length(); ++i) { |
| 716 if (hydrogen_env->is_special_index(i)) continue; | 717 if (hydrogen_env->is_special_index(i)) continue; |
| 717 | 718 |
| 718 HValue* value = hydrogen_env->values()->at(i); | 719 HValue* value = hydrogen_env->values()->at(i); |
| 719 LOperand* op = NULL; | 720 LOperand* op = NULL; |
| 720 if (value->IsArgumentsObject()) { | 721 if (value->IsArgumentsObject()) { |
| 722 needs_arguments_object_materialization = true; |
| 721 op = NULL; | 723 op = NULL; |
| 722 } else if (value->IsPushArgument()) { | 724 } else if (value->IsPushArgument()) { |
| 723 op = new(zone()) LArgument(argument_index++); | 725 op = new(zone()) LArgument(argument_index++); |
| 724 } else { | 726 } else { |
| 725 op = UseAny(value); | 727 op = UseAny(value); |
| 726 } | 728 } |
| 727 result->AddValue(op, | 729 result->AddValue(op, |
| 728 value->representation(), | 730 value->representation(), |
| 729 value->CheckFlag(HInstruction::kUint32)); | 731 value->CheckFlag(HInstruction::kUint32)); |
| 730 } | 732 } |
| 731 | 733 |
| 734 if (needs_arguments_object_materialization) { |
| 735 HArgumentsObject* arguments = hydrogen_env->entry() == NULL |
| 736 ? graph()->GetArgumentsObject() |
| 737 : hydrogen_env->entry()->arguments_object(); |
| 738 ASSERT(arguments->IsLinked()); |
| 739 for (int i = 1; i < arguments->arguments_count(); ++i) { |
| 740 HValue* value = arguments->arguments_values()->at(i); |
| 741 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); |
| 742 LOperand* op = UseAny(value); |
| 743 result->AddValue(op, |
| 744 value->representation(), |
| 745 value->CheckFlag(HInstruction::kUint32)); |
| 746 } |
| 747 } |
| 748 |
| 732 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 749 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
| 733 *argument_index_accumulator = argument_index; | 750 *argument_index_accumulator = argument_index; |
| 734 } | 751 } |
| 735 | 752 |
| 736 return result; | 753 return result; |
| 737 } | 754 } |
| 738 | 755 |
| 739 | 756 |
| 740 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 757 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| 741 HArithmeticBinaryOperation* instr) { | 758 HArithmeticBinaryOperation* instr) { |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 | 1391 |
| 1375 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | 1392 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
| 1376 HEnvironment* outer = current_block_->last_environment(); | 1393 HEnvironment* outer = current_block_->last_environment(); |
| 1377 HConstant* undefined = graph()->GetConstantUndefined(); | 1394 HConstant* undefined = graph()->GetConstantUndefined(); |
| 1378 HEnvironment* inner = outer->CopyForInlining(instr->closure(), | 1395 HEnvironment* inner = outer->CopyForInlining(instr->closure(), |
| 1379 instr->arguments_count(), | 1396 instr->arguments_count(), |
| 1380 instr->function(), | 1397 instr->function(), |
| 1381 undefined, | 1398 undefined, |
| 1382 instr->inlining_kind(), | 1399 instr->inlining_kind(), |
| 1383 instr->undefined_receiver()); | 1400 instr->undefined_receiver()); |
| 1384 if (instr->arguments_var() != NULL) { | 1401 // Only replay binding of arguments object if it wasn't removed from graph. |
| 1385 inner->Bind(instr->arguments_var(), graph()->GetArgumentsObject()); | 1402 if ((instr->arguments_var() != NULL) && |
| 1403 instr->arguments_object()->IsLinked()) { |
| 1404 inner->Bind(instr->arguments_var(), instr->arguments_object()); |
| 1386 } | 1405 } |
| 1387 inner->set_entry(instr); | 1406 inner->set_entry(instr); |
| 1388 current_block_->UpdateEnvironment(inner); | 1407 current_block_->UpdateEnvironment(inner); |
| 1389 chunk_->AddInlinedClosure(instr->closure()); | 1408 chunk_->AddInlinedClosure(instr->closure()); |
| 1390 return NULL; | 1409 return NULL; |
| 1391 } | 1410 } |
| 1392 | 1411 |
| 1393 | 1412 |
| 1394 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) { | 1413 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) { |
| 1395 UNREACHABLE(); | 1414 UNREACHABLE(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 return MarkAsCall(result, instr); | 1704 return MarkAsCall(result, instr); |
| 1686 } | 1705 } |
| 1687 | 1706 |
| 1688 | 1707 |
| 1689 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { | 1708 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { |
| 1690 LOperand* map = UseRegisterAtStart(instr->value()); | 1709 LOperand* map = UseRegisterAtStart(instr->value()); |
| 1691 return DefineAsRegister(new(zone()) LMapEnumLength(map)); | 1710 return DefineAsRegister(new(zone()) LMapEnumLength(map)); |
| 1692 } | 1711 } |
| 1693 | 1712 |
| 1694 | 1713 |
| 1695 HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue* dividend) { | |
| 1696 // A value with an integer representation does not need to be transformed. | |
| 1697 if (dividend->representation().IsInteger32()) { | |
| 1698 return dividend; | |
| 1699 // A change from an integer32 can be replaced by the integer32 value. | |
| 1700 } else if (dividend->IsChange() && | |
| 1701 HChange::cast(dividend)->from().IsInteger32()) { | |
| 1702 return HChange::cast(dividend)->value(); | |
| 1703 } | |
| 1704 return NULL; | |
| 1705 } | |
| 1706 | |
| 1707 | |
| 1708 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1714 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
| 1709 // A value with an integer representation does not need to be transformed. | 1715 // A value with an integer representation does not need to be transformed. |
| 1710 if (divisor->representation().IsInteger32()) { | 1716 if (divisor->representation().IsInteger32()) { |
| 1711 return divisor; | 1717 return divisor; |
| 1712 // A change from an integer32 can be replaced by the integer32 value. | 1718 // A change from an integer32 can be replaced by the integer32 value. |
| 1713 } else if (divisor->IsChange() && | 1719 } else if (divisor->IsChange() && |
| 1714 HChange::cast(divisor)->from().IsInteger32()) { | 1720 HChange::cast(divisor)->from().IsInteger32()) { |
| 1715 return HChange::cast(divisor)->value(); | 1721 return HChange::cast(divisor)->value(); |
| 1716 } | 1722 } |
| 1717 | 1723 |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2451 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | 2457 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
| 2452 LOperand* receiver = UseRegister(instr->receiver()); | 2458 LOperand* receiver = UseRegister(instr->receiver()); |
| 2453 LOperand* function = UseRegisterAtStart(instr->function()); | 2459 LOperand* function = UseRegisterAtStart(instr->function()); |
| 2454 LOperand* temp = TempRegister(); | 2460 LOperand* temp = TempRegister(); |
| 2455 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function, temp); | 2461 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function, temp); |
| 2456 return AssignEnvironment(DefineAsRegister(result)); | 2462 return AssignEnvironment(DefineAsRegister(result)); |
| 2457 } | 2463 } |
| 2458 | 2464 |
| 2459 | 2465 |
| 2460 } } // namespace v8::internal | 2466 } } // namespace v8::internal |
| OLD | NEW |