| 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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 LEnvironment* LChunkBuilder::CreateEnvironment( | 930 LEnvironment* LChunkBuilder::CreateEnvironment( |
| 931 HEnvironment* hydrogen_env, | 931 HEnvironment* hydrogen_env, |
| 932 int* argument_index_accumulator) { | 932 int* argument_index_accumulator) { |
| 933 if (hydrogen_env == NULL) return NULL; | 933 if (hydrogen_env == NULL) return NULL; |
| 934 | 934 |
| 935 LEnvironment* outer = | 935 LEnvironment* outer = |
| 936 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 936 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
| 937 BailoutId ast_id = hydrogen_env->ast_id(); | 937 BailoutId ast_id = hydrogen_env->ast_id(); |
| 938 ASSERT(!ast_id.IsNone() || | 938 ASSERT(!ast_id.IsNone() || |
| 939 hydrogen_env->frame_type() != JS_FUNCTION); | 939 hydrogen_env->frame_type() != JS_FUNCTION); |
| 940 int value_count = hydrogen_env->length(); | 940 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
| 941 LEnvironment* result = new(zone()) LEnvironment( | 941 LEnvironment* result = new(zone()) LEnvironment( |
| 942 hydrogen_env->closure(), | 942 hydrogen_env->closure(), |
| 943 hydrogen_env->frame_type(), | 943 hydrogen_env->frame_type(), |
| 944 ast_id, | 944 ast_id, |
| 945 hydrogen_env->parameter_count(), | 945 hydrogen_env->parameter_count(), |
| 946 argument_count_, | 946 argument_count_, |
| 947 value_count, | 947 value_count, |
| 948 outer, | 948 outer, |
| 949 hydrogen_env->entry(), | 949 hydrogen_env->entry(), |
| 950 zone()); | 950 zone()); |
| 951 bool needs_arguments_object_materialization = false; |
| 951 int argument_index = *argument_index_accumulator; | 952 int argument_index = *argument_index_accumulator; |
| 952 for (int i = 0; i < value_count; ++i) { | 953 for (int i = 0; i < hydrogen_env->length(); ++i) { |
| 953 if (hydrogen_env->is_special_index(i)) continue; | 954 if (hydrogen_env->is_special_index(i)) continue; |
| 954 | 955 |
| 955 HValue* value = hydrogen_env->values()->at(i); | 956 HValue* value = hydrogen_env->values()->at(i); |
| 956 LOperand* op = NULL; | 957 LOperand* op = NULL; |
| 957 if (value->IsArgumentsObject()) { | 958 if (value->IsArgumentsObject()) { |
| 959 needs_arguments_object_materialization = true; |
| 958 op = NULL; | 960 op = NULL; |
| 959 } else if (value->IsPushArgument()) { | 961 } else if (value->IsPushArgument()) { |
| 960 op = new(zone()) LArgument(argument_index++); | 962 op = new(zone()) LArgument(argument_index++); |
| 961 } else { | 963 } else { |
| 962 op = UseAny(value); | 964 op = UseAny(value); |
| 963 } | 965 } |
| 964 result->AddValue(op, | 966 result->AddValue(op, |
| 965 value->representation(), | 967 value->representation(), |
| 966 value->CheckFlag(HInstruction::kUint32)); | 968 value->CheckFlag(HInstruction::kUint32)); |
| 967 } | 969 } |
| 968 | 970 |
| 971 if (needs_arguments_object_materialization) { |
| 972 HArgumentsObject* arguments = hydrogen_env->entry() == NULL |
| 973 ? graph()->GetArgumentsObject() |
| 974 : hydrogen_env->entry()->arguments_object(); |
| 975 ASSERT(arguments->IsLinked()); |
| 976 for (int i = 1; i < arguments->arguments_count(); ++i) { |
| 977 HValue* value = arguments->arguments_values()->at(i); |
| 978 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); |
| 979 LOperand* op = UseAny(value); |
| 980 result->AddValue(op, |
| 981 value->representation(), |
| 982 value->CheckFlag(HInstruction::kUint32)); |
| 983 } |
| 984 } |
| 985 |
| 969 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 986 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
| 970 *argument_index_accumulator = argument_index; | 987 *argument_index_accumulator = argument_index; |
| 971 } | 988 } |
| 972 | 989 |
| 973 return result; | 990 return result; |
| 974 } | 991 } |
| 975 | 992 |
| 976 | 993 |
| 977 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 994 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
| 978 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 995 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 LOperand* divisor = UseRegister(instr->right()); | 1378 LOperand* divisor = UseRegister(instr->right()); |
| 1362 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); | 1379 LDivI* result = new(zone()) LDivI(dividend, divisor, temp); |
| 1363 return AssignEnvironment(DefineFixed(result, rax)); | 1380 return AssignEnvironment(DefineFixed(result, rax)); |
| 1364 } else { | 1381 } else { |
| 1365 ASSERT(instr->representation().IsSmiOrTagged()); | 1382 ASSERT(instr->representation().IsSmiOrTagged()); |
| 1366 return DoArithmeticT(Token::DIV, instr); | 1383 return DoArithmeticT(Token::DIV, instr); |
| 1367 } | 1384 } |
| 1368 } | 1385 } |
| 1369 | 1386 |
| 1370 | 1387 |
| 1371 HValue* LChunkBuilder::SimplifiedDividendForMathFloorOfDiv(HValue* dividend) { | |
| 1372 // A value with an integer representation does not need to be transformed. | |
| 1373 if (dividend->representation().IsInteger32()) { | |
| 1374 return dividend; | |
| 1375 // A change from an integer32 can be replaced by the integer32 value. | |
| 1376 } else if (dividend->IsChange() && | |
| 1377 HChange::cast(dividend)->from().IsInteger32()) { | |
| 1378 return HChange::cast(dividend)->value(); | |
| 1379 } | |
| 1380 return NULL; | |
| 1381 } | |
| 1382 | |
| 1383 | |
| 1384 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1388 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
| 1385 if (divisor->IsConstant() && | 1389 if (divisor->IsConstant() && |
| 1386 HConstant::cast(divisor)->HasInteger32Value()) { | 1390 HConstant::cast(divisor)->HasInteger32Value()) { |
| 1387 HConstant* constant_val = HConstant::cast(divisor); | 1391 HConstant* constant_val = HConstant::cast(divisor); |
| 1388 return constant_val->CopyToRepresentation(Representation::Integer32(), | 1392 return constant_val->CopyToRepresentation(Representation::Integer32(), |
| 1389 divisor->block()->zone()); | 1393 divisor->block()->zone()); |
| 1390 } | 1394 } |
| 1391 // A value with an integer representation does not need to be transformed. | 1395 // A value with an integer representation does not need to be transformed. |
| 1392 if (divisor->representation().IsInteger32()) { | 1396 if (divisor->representation().IsInteger32()) { |
| 1393 return divisor; | 1397 return divisor; |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2518 | 2522 |
| 2519 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | 2523 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { |
| 2520 HEnvironment* outer = current_block_->last_environment(); | 2524 HEnvironment* outer = current_block_->last_environment(); |
| 2521 HConstant* undefined = graph()->GetConstantUndefined(); | 2525 HConstant* undefined = graph()->GetConstantUndefined(); |
| 2522 HEnvironment* inner = outer->CopyForInlining(instr->closure(), | 2526 HEnvironment* inner = outer->CopyForInlining(instr->closure(), |
| 2523 instr->arguments_count(), | 2527 instr->arguments_count(), |
| 2524 instr->function(), | 2528 instr->function(), |
| 2525 undefined, | 2529 undefined, |
| 2526 instr->inlining_kind(), | 2530 instr->inlining_kind(), |
| 2527 instr->undefined_receiver()); | 2531 instr->undefined_receiver()); |
| 2528 if (instr->arguments_var() != NULL) { | 2532 // Only replay binding of arguments object if it wasn't removed from graph. |
| 2529 inner->Bind(instr->arguments_var(), graph()->GetArgumentsObject()); | 2533 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { |
| 2534 inner->Bind(instr->arguments_var(), instr->arguments_object()); |
| 2530 } | 2535 } |
| 2531 inner->set_entry(instr); | 2536 inner->set_entry(instr); |
| 2532 current_block_->UpdateEnvironment(inner); | 2537 current_block_->UpdateEnvironment(inner); |
| 2533 chunk_->AddInlinedClosure(instr->closure()); | 2538 chunk_->AddInlinedClosure(instr->closure()); |
| 2534 return NULL; | 2539 return NULL; |
| 2535 } | 2540 } |
| 2536 | 2541 |
| 2537 | 2542 |
| 2538 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 2543 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 2539 LInstruction* pop = NULL; | 2544 LInstruction* pop = NULL; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2586 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2591 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2587 LOperand* object = UseRegister(instr->object()); | 2592 LOperand* object = UseRegister(instr->object()); |
| 2588 LOperand* index = UseTempRegister(instr->index()); | 2593 LOperand* index = UseTempRegister(instr->index()); |
| 2589 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2594 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2590 } | 2595 } |
| 2591 | 2596 |
| 2592 | 2597 |
| 2593 } } // namespace v8::internal | 2598 } } // namespace v8::internal |
| 2594 | 2599 |
| 2595 #endif // V8_TARGET_ARCH_X64 | 2600 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |