OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 | 1425 |
1426 // static | 1426 // static |
1427 compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler, | 1427 compiler::Node* ModulusStub::Generate(CodeStubAssembler* assembler, |
1428 compiler::Node* left, | 1428 compiler::Node* left, |
1429 compiler::Node* right, | 1429 compiler::Node* right, |
1430 compiler::Node* context) { | 1430 compiler::Node* context) { |
1431 using compiler::Node; | 1431 using compiler::Node; |
1432 typedef CodeStubAssembler::Label Label; | 1432 typedef CodeStubAssembler::Label Label; |
1433 typedef CodeStubAssembler::Variable Variable; | 1433 typedef CodeStubAssembler::Variable Variable; |
1434 | 1434 |
| 1435 Variable var_result(assembler, MachineRepresentation::kTagged); |
| 1436 Label return_result(assembler, &var_result); |
| 1437 |
1435 // Shared entry point for floating point modulus. | 1438 // Shared entry point for floating point modulus. |
1436 Label do_fmod(assembler); | 1439 Label do_fmod(assembler); |
1437 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), | 1440 Variable var_dividend_float64(assembler, MachineRepresentation::kFloat64), |
1438 var_divisor_float64(assembler, MachineRepresentation::kFloat64); | 1441 var_divisor_float64(assembler, MachineRepresentation::kFloat64); |
1439 | 1442 |
1440 Node* number_map = assembler->HeapNumberMapConstant(); | 1443 Node* number_map = assembler->HeapNumberMapConstant(); |
1441 | 1444 |
1442 // We might need to loop one or two times due to ToNumber conversions. | 1445 // We might need to loop one or two times due to ToNumber conversions. |
1443 Variable var_dividend(assembler, MachineRepresentation::kTagged), | 1446 Variable var_dividend(assembler, MachineRepresentation::kTagged), |
1444 var_divisor(assembler, MachineRepresentation::kTagged); | 1447 var_divisor(assembler, MachineRepresentation::kTagged); |
(...skipping 13 matching lines...) Expand all Loading... |
1458 | 1461 |
1459 assembler->Bind(÷nd_is_smi); | 1462 assembler->Bind(÷nd_is_smi); |
1460 { | 1463 { |
1461 Label dividend_is_not_zero(assembler); | 1464 Label dividend_is_not_zero(assembler); |
1462 Label divisor_is_smi(assembler), divisor_is_not_smi(assembler); | 1465 Label divisor_is_smi(assembler), divisor_is_not_smi(assembler); |
1463 assembler->Branch(assembler->WordIsSmi(divisor), &divisor_is_smi, | 1466 assembler->Branch(assembler->WordIsSmi(divisor), &divisor_is_smi, |
1464 &divisor_is_not_smi); | 1467 &divisor_is_not_smi); |
1465 | 1468 |
1466 assembler->Bind(&divisor_is_smi); | 1469 assembler->Bind(&divisor_is_smi); |
1467 { | 1470 { |
1468 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); | 1471 // Compute the modulus of two Smis. |
1469 var_divisor_float64.Bind(assembler->SmiToFloat64(divisor)); | 1472 var_result.Bind(assembler->SmiMod(dividend, divisor)); |
1470 assembler->Goto(&do_fmod); | 1473 assembler->Goto(&return_result); |
1471 } | 1474 } |
1472 | 1475 |
1473 assembler->Bind(&divisor_is_not_smi); | 1476 assembler->Bind(&divisor_is_not_smi); |
1474 { | 1477 { |
1475 Node* divisor_map = assembler->LoadMap(divisor); | 1478 Node* divisor_map = assembler->LoadMap(divisor); |
1476 | 1479 |
1477 // Check if {divisor} is a HeapNumber. | 1480 // Check if {divisor} is a HeapNumber. |
1478 Label divisor_is_number(assembler), | 1481 Label divisor_is_number(assembler), |
1479 divisor_is_not_number(assembler, Label::kDeferred); | 1482 divisor_is_not_number(assembler, Label::kDeferred); |
1480 assembler->Branch(assembler->WordEqual(divisor_map, number_map), | 1483 assembler->Branch(assembler->WordEqual(divisor_map, number_map), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 var_dividend.Bind(assembler->CallStub(callable, context, dividend)); | 1567 var_dividend.Bind(assembler->CallStub(callable, context, dividend)); |
1565 assembler->Goto(&loop); | 1568 assembler->Goto(&loop); |
1566 } | 1569 } |
1567 } | 1570 } |
1568 } | 1571 } |
1569 | 1572 |
1570 assembler->Bind(&do_fmod); | 1573 assembler->Bind(&do_fmod); |
1571 { | 1574 { |
1572 Node* value = assembler->Float64Mod(var_dividend_float64.value(), | 1575 Node* value = assembler->Float64Mod(var_dividend_float64.value(), |
1573 var_divisor_float64.value()); | 1576 var_divisor_float64.value()); |
1574 Node* result = assembler->ChangeFloat64ToTagged(value); | 1577 var_result.Bind(assembler->ChangeFloat64ToTagged(value)); |
1575 return result; | 1578 assembler->Goto(&return_result); |
1576 } | 1579 } |
| 1580 |
| 1581 assembler->Bind(&return_result); |
| 1582 return var_result.value(); |
1577 } | 1583 } |
1578 | 1584 |
1579 // static | 1585 // static |
1580 compiler::Node* ShiftLeftStub::Generate(CodeStubAssembler* assembler, | 1586 compiler::Node* ShiftLeftStub::Generate(CodeStubAssembler* assembler, |
1581 compiler::Node* left, | 1587 compiler::Node* left, |
1582 compiler::Node* right, | 1588 compiler::Node* right, |
1583 compiler::Node* context) { | 1589 compiler::Node* context) { |
1584 using compiler::Node; | 1590 using compiler::Node; |
1585 | 1591 |
1586 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); | 1592 Node* lhs_value = assembler->TruncateTaggedToWord32(context, left); |
(...skipping 3337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4924 if (type->Is(Type::UntaggedPointer())) { | 4930 if (type->Is(Type::UntaggedPointer())) { |
4925 return Representation::External(); | 4931 return Representation::External(); |
4926 } | 4932 } |
4927 | 4933 |
4928 DCHECK(!type->Is(Type::Untagged())); | 4934 DCHECK(!type->Is(Type::Untagged())); |
4929 return Representation::Tagged(); | 4935 return Representation::Tagged(); |
4930 } | 4936 } |
4931 | 4937 |
4932 } // namespace internal | 4938 } // namespace internal |
4933 } // namespace v8 | 4939 } // namespace v8 |
OLD | NEW |