OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
6 #include "src/compiler.h" | 6 #include "src/compiler.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace interpreter { | 10 namespace interpreter { |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 } | 1052 } |
1053 | 1053 |
1054 void BytecodeArrayBuilder::EnsureReturn(FunctionLiteral* literal) { | 1054 void BytecodeArrayBuilder::EnsureReturn(FunctionLiteral* literal) { |
1055 if (!exit_seen_in_block_) { | 1055 if (!exit_seen_in_block_) { |
1056 LoadUndefined(); | 1056 LoadUndefined(); |
1057 SetReturnPosition(literal); | 1057 SetReturnPosition(literal); |
1058 Return(); | 1058 Return(); |
1059 } | 1059 } |
1060 } | 1060 } |
1061 | 1061 |
1062 BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable, | 1062 BytecodeArrayBuilder& BytecodeArrayBuilder::CallIC( |
1063 Register receiver_args, | 1063 Register callable, Register receiver_args, size_t receiver_args_count, |
1064 size_t receiver_args_count, | 1064 int feedback_slot, TailCallMode tail_call_mode) { |
1065 int feedback_slot, | 1065 Bytecode bytecode = BytecodeForCallIC(tail_call_mode); |
1066 TailCallMode tail_call_mode) { | |
1067 Bytecode bytecode = BytecodeForCall(tail_call_mode); | |
1068 if (FitsInReg8Operand(callable) && FitsInReg8Operand(receiver_args) && | 1066 if (FitsInReg8Operand(callable) && FitsInReg8Operand(receiver_args) && |
1069 FitsInIdx8Operand(receiver_args_count) && | 1067 FitsInIdx8Operand(receiver_args_count) && |
1070 FitsInIdx8Operand(feedback_slot)) { | 1068 FitsInIdx8Operand(feedback_slot)) { |
1071 Output(bytecode, callable.ToRawOperand(), receiver_args.ToRawOperand(), | 1069 Output(bytecode, callable.ToRawOperand(), receiver_args.ToRawOperand(), |
1072 static_cast<uint8_t>(receiver_args_count), | 1070 static_cast<uint8_t>(receiver_args_count), |
1073 static_cast<uint8_t>(feedback_slot)); | 1071 static_cast<uint8_t>(feedback_slot)); |
1074 } else if (FitsInReg16Operand(callable) && | 1072 } else if (FitsInReg16Operand(callable) && |
1075 FitsInReg16Operand(receiver_args) && | 1073 FitsInReg16Operand(receiver_args) && |
1076 FitsInIdx16Operand(receiver_args_count) && | 1074 FitsInIdx16Operand(receiver_args_count) && |
1077 FitsInIdx16Operand(feedback_slot)) { | 1075 FitsInIdx16Operand(feedback_slot)) { |
1078 bytecode = BytecodeForWideOperands(bytecode); | 1076 bytecode = BytecodeForWideOperands(bytecode); |
1079 Output(bytecode, callable.ToRawOperand(), receiver_args.ToRawOperand(), | 1077 Output(bytecode, callable.ToRawOperand(), receiver_args.ToRawOperand(), |
1080 static_cast<uint16_t>(receiver_args_count), | 1078 static_cast<uint16_t>(receiver_args_count), |
1081 static_cast<uint16_t>(feedback_slot)); | 1079 static_cast<uint16_t>(feedback_slot)); |
1082 } else { | 1080 } else { |
1083 UNIMPLEMENTED(); | 1081 UNIMPLEMENTED(); |
1084 } | 1082 } |
1085 return *this; | 1083 return *this; |
1086 } | 1084 } |
1087 | 1085 |
| 1086 BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable, |
| 1087 Register receiver_args, |
| 1088 size_t receiver_args_count, |
| 1089 TailCallMode tail_call_mode) { |
| 1090 Bytecode bytecode = BytecodeForCall(tail_call_mode); |
| 1091 if (FitsInReg8Operand(callable) && FitsInReg8Operand(receiver_args) && |
| 1092 FitsInIdx8Operand(receiver_args_count)) { |
| 1093 Output(bytecode, callable.ToRawOperand(), receiver_args.ToRawOperand(), |
| 1094 static_cast<uint8_t>(receiver_args_count)); |
| 1095 } else if (FitsInReg16Operand(callable) && |
| 1096 FitsInReg16Operand(receiver_args) && |
| 1097 FitsInIdx16Operand(receiver_args_count)) { |
| 1098 bytecode = BytecodeForWideOperands(bytecode); |
| 1099 Output(bytecode, callable.ToRawOperand(), receiver_args.ToRawOperand(), |
| 1100 static_cast<uint16_t>(receiver_args_count)); |
| 1101 } else { |
| 1102 UNIMPLEMENTED(); |
| 1103 } |
| 1104 return *this; |
| 1105 } |
1088 BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor, | 1106 BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor, |
1089 Register first_arg, | 1107 Register first_arg, |
1090 size_t arg_count) { | 1108 size_t arg_count) { |
1091 if (!first_arg.is_valid()) { | 1109 if (!first_arg.is_valid()) { |
1092 DCHECK_EQ(0u, arg_count); | 1110 DCHECK_EQ(0u, arg_count); |
1093 first_arg = Register(0); | 1111 first_arg = Register(0); |
1094 } | 1112 } |
1095 if (FitsInReg8Operand(constructor) && FitsInReg8Operand(first_arg) && | 1113 if (FitsInReg8Operand(constructor) && FitsInReg8Operand(first_arg) && |
1096 FitsInIdx8Operand(arg_count)) { | 1114 FitsInIdx8Operand(arg_count)) { |
1097 Output(Bytecode::kNew, constructor.ToRawOperand(), first_arg.ToRawOperand(), | 1115 Output(Bytecode::kNew, constructor.ToRawOperand(), first_arg.ToRawOperand(), |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 default: | 1437 default: |
1420 UNREACHABLE(); | 1438 UNREACHABLE(); |
1421 return static_cast<Bytecode>(-1); | 1439 return static_cast<Bytecode>(-1); |
1422 } | 1440 } |
1423 } | 1441 } |
1424 | 1442 |
1425 | 1443 |
1426 // static | 1444 // static |
1427 Bytecode BytecodeArrayBuilder::BytecodeForWideOperands(Bytecode bytecode) { | 1445 Bytecode BytecodeArrayBuilder::BytecodeForWideOperands(Bytecode bytecode) { |
1428 switch (bytecode) { | 1446 switch (bytecode) { |
| 1447 case Bytecode::kCallIC: |
| 1448 return Bytecode::kCallICWide; |
| 1449 case Bytecode::kTailCallIC: |
| 1450 return Bytecode::kTailCallICWide; |
1429 case Bytecode::kCall: | 1451 case Bytecode::kCall: |
1430 return Bytecode::kCallWide; | 1452 return Bytecode::kCallWide; |
1431 case Bytecode::kTailCall: | 1453 case Bytecode::kTailCall: |
1432 return Bytecode::kTailCallWide; | 1454 return Bytecode::kTailCallWide; |
1433 case Bytecode::kLoadIC: | 1455 case Bytecode::kLoadIC: |
1434 return Bytecode::kLoadICWide; | 1456 return Bytecode::kLoadICWide; |
1435 case Bytecode::kKeyedLoadIC: | 1457 case Bytecode::kKeyedLoadIC: |
1436 return Bytecode::kKeyedLoadICWide; | 1458 return Bytecode::kKeyedLoadICWide; |
1437 case Bytecode::kStoreICSloppy: | 1459 case Bytecode::kStoreICSloppy: |
1438 return Bytecode::kStoreICSloppyWide; | 1460 return Bytecode::kStoreICSloppyWide; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 return Bytecode::kDeletePropertyStrict; | 1585 return Bytecode::kDeletePropertyStrict; |
1564 case STRONG: | 1586 case STRONG: |
1565 UNIMPLEMENTED(); | 1587 UNIMPLEMENTED(); |
1566 default: | 1588 default: |
1567 UNREACHABLE(); | 1589 UNREACHABLE(); |
1568 } | 1590 } |
1569 return static_cast<Bytecode>(-1); | 1591 return static_cast<Bytecode>(-1); |
1570 } | 1592 } |
1571 | 1593 |
1572 // static | 1594 // static |
| 1595 Bytecode BytecodeArrayBuilder::BytecodeForCallIC(TailCallMode tail_call_mode) { |
| 1596 switch (tail_call_mode) { |
| 1597 case TailCallMode::kDisallow: |
| 1598 return Bytecode::kCallIC; |
| 1599 case TailCallMode::kAllow: |
| 1600 return Bytecode::kTailCallIC; |
| 1601 default: |
| 1602 UNREACHABLE(); |
| 1603 } |
| 1604 return static_cast<Bytecode>(-1); |
| 1605 } |
| 1606 |
| 1607 // static |
1573 Bytecode BytecodeArrayBuilder::BytecodeForCall(TailCallMode tail_call_mode) { | 1608 Bytecode BytecodeArrayBuilder::BytecodeForCall(TailCallMode tail_call_mode) { |
1574 switch (tail_call_mode) { | 1609 switch (tail_call_mode) { |
1575 case TailCallMode::kDisallow: | 1610 case TailCallMode::kDisallow: |
1576 return Bytecode::kCall; | 1611 return Bytecode::kCall; |
1577 case TailCallMode::kAllow: | 1612 case TailCallMode::kAllow: |
1578 return Bytecode::kTailCall; | 1613 return Bytecode::kTailCall; |
1579 default: | 1614 default: |
1580 UNREACHABLE(); | 1615 UNREACHABLE(); |
1581 } | 1616 } |
1582 return static_cast<Bytecode>(-1); | 1617 return static_cast<Bytecode>(-1); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 } | 1664 } |
1630 | 1665 |
1631 // static | 1666 // static |
1632 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { | 1667 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { |
1633 return value.is_short_operand(); | 1668 return value.is_short_operand(); |
1634 } | 1669 } |
1635 | 1670 |
1636 } // namespace interpreter | 1671 } // namespace interpreter |
1637 } // namespace internal | 1672 } // namespace internal |
1638 } // namespace v8 | 1673 } // namespace v8 |
OLD | NEW |