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 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1472 // Macro assembler to emit code. | 1472 // Macro assembler to emit code. |
1473 MacroAssembler* masm() { return &masm_; } | 1473 MacroAssembler* masm() { return &masm_; } |
1474 | 1474 |
1475 private: | 1475 private: |
1476 byte* address_; // The address of the code being patched. | 1476 byte* address_; // The address of the code being patched. |
1477 int size_; // Number of bytes of the expected patch size. | 1477 int size_; // Number of bytes of the expected patch size. |
1478 MacroAssembler masm_; // Macro assembler used to generate the code. | 1478 MacroAssembler masm_; // Macro assembler used to generate the code. |
1479 }; | 1479 }; |
1480 | 1480 |
1481 | 1481 |
1482 class StackArguments BASE_EMBEDDED { | |
danno
2013/08/05 15:17:56
I would call this StackArgumentsAccessor
haitao.feng
2013/08/06 11:49:55
Done.
| |
1483 public: | |
1484 // argc could be an immediate or in a register. | |
1485 // extra is 1 when the receiver is considered as argument[0]. | |
1486 // disp is the displacement between rsp and return address. | |
1487 StackArguments(int immediate, int extra = 0, int disp = 0) | |
1488 : reg_(no_reg), immediate_(immediate), extra_(extra), disp_(disp) { } | |
1489 | |
1490 StackArguments(Register reg, int extra = 0, int disp = 0) | |
danno
2013/08/05 15:17:56
I find all the math with extra and disp a bit conf
haitao.feng
2013/08/06 11:49:55
Done.
| |
1491 : reg_(reg), immediate_(0), extra_(extra), disp_(disp) { } | |
1492 | |
1493 StackArguments(const ParameterCount& parameter_count, | |
1494 int extra = 0, | |
1495 int disp = 0) | |
1496 : reg_(parameter_count.is_reg() ? parameter_count.reg() : no_reg), | |
1497 immediate_(parameter_count.is_immediate() ? | |
1498 parameter_count.immediate() : 0), | |
1499 extra_(extra), | |
1500 disp_(disp) { } | |
1501 | |
1502 Operand operator[] (int index) { | |
danno
2013/08/05 15:17:56
I think it's better to not overide the [] operator
haitao.feng
2013/08/06 11:49:55
Done.
| |
1503 if (index >= 0) { | |
1504 if (reg_.is(no_reg)) { | |
1505 // argument[0] is at rsp + disp + kPCOnSackSize + | |
1506 // (immediate_ + extra_ - 1) * kPointerSize. | |
1507 ASSERT(immediate_ + extra_ > 0); | |
1508 return Operand(rsp, disp_ + kPCOnStackSize + | |
1509 (immediate_ + extra_ - 1 - index) * kPointerSize); | |
1510 } else { | |
1511 // argument[0] is at rsp + disp + kPCOnSackSize + | |
1512 // reg_ * times_pointer_size + (extra_ - 1) * kPointerSize. | |
1513 return Operand(rsp, reg_, times_pointer_size, disp_ + kPCOnStackSize + | |
1514 (extra_ - 1 - index) * kPointerSize); | |
1515 } | |
1516 } else { | |
danno
2013/08/05 15:17:56
I think the handling of negative arguments is pret
haitao.feng
2013/08/06 11:49:55
Done.
| |
1517 // Reverse order, argument[-1] is at rsp + disp + kPCOnSackSize. | |
1518 ASSERT(reg_.is(no_reg) || (-index <= immediate_)); | |
1519 return Operand(rsp, disp_ + kPCOnStackSize + (-index - 1) * kPointerSize); | |
1520 } | |
1521 } | |
1522 | |
1523 Operand GetReceiver() { | |
danno
2013/08/05 15:17:56
... and this GetReceiverOperand()
haitao.feng
2013/08/06 11:49:55
Done.
| |
1524 ASSERT(extra_ == 1); | |
1525 return (*this)[0]; | |
1526 } | |
1527 | |
1528 private: | |
1529 const Register reg_; | |
1530 const int immediate_; | |
1531 const int extra_; | |
1532 const int disp_; | |
1533 }; | |
1534 | |
1535 | |
1482 // ----------------------------------------------------------------------------- | 1536 // ----------------------------------------------------------------------------- |
1483 // Static helper functions. | 1537 // Static helper functions. |
1484 | 1538 |
1485 // Generate an Operand for loading a field from an object. | 1539 // Generate an Operand for loading a field from an object. |
1486 inline Operand FieldOperand(Register object, int offset) { | 1540 inline Operand FieldOperand(Register object, int offset) { |
1487 return Operand(object, offset - kHeapObjectTag); | 1541 return Operand(object, offset - kHeapObjectTag); |
1488 } | 1542 } |
1489 | 1543 |
1490 | 1544 |
1491 // Generate an Operand for loading an indexed field from an object. | 1545 // Generate an Operand for loading an indexed field from an object. |
(...skipping 24 matching lines...) Expand all Loading... | |
1516 return Operand(rsp, index * kPointerSize); | 1570 return Operand(rsp, index * kPointerSize); |
1517 #endif | 1571 #endif |
1518 } | 1572 } |
1519 | 1573 |
1520 | 1574 |
1521 inline Operand StackOperandForReturnAddress(int32_t disp) { | 1575 inline Operand StackOperandForReturnAddress(int32_t disp) { |
1522 return Operand(rsp, disp); | 1576 return Operand(rsp, disp); |
1523 } | 1577 } |
1524 | 1578 |
1525 | 1579 |
1580 // Computes the argument address from the argument 0 (might be receiver) | |
danno
2013/08/05 15:17:56
Do you need any of these here and below any more?
haitao.feng
2013/08/06 11:49:55
Done. Sorry, I remembered I removed all of them. M
| |
1581 // at rsp + disp + kPCOnStackSize + (total - 1) * kPointerSize, disp is the | |
1582 // displacement between the rsp and the return address. | |
1583 inline Operand StackOperandForArgument(int index, int total, int disp = 0) { | |
1584 return Operand(rsp, disp + kPCOnStackSize + | |
1585 (total - 1 - index) * kPointerSize); | |
1586 } | |
1587 | |
1588 | |
1589 // Computes the argument address in reverse order, i.e., from the last argument | |
1590 // at rsp + disp + kPCOnStackSize, disp is the displacement between the rsp | |
1591 // and the return address. | |
1592 inline Operand StackOperandForReversedArgument(int index, int disp = 0) { | |
1593 return Operand(rsp, disp + kPCOnStackSize + index * kPointerSize); | |
1594 } | |
1595 | |
1596 | |
1597 inline Operand StackOperandForReversedArgument(Register index, | |
1598 int offset, | |
1599 int disp = 0) { | |
1600 return Operand(rsp, index, times_pointer_size, | |
1601 disp + kPCOnStackSize + offset * kPointerSize); | |
1602 } | |
1603 | |
1604 | |
1605 inline Operand StackOperandForReceiver(int index, int disp = 0) { | |
1606 return StackOperandForReversedArgument(index, disp); | |
1607 } | |
1608 | |
1609 | |
1610 inline Operand StackOperandForReceiver(Register index, int disp = 0) { | |
1611 return StackOperandForReversedArgument(index, 0, disp); | |
1612 } | |
1613 | |
1614 | |
1526 #ifdef GENERATED_CODE_COVERAGE | 1615 #ifdef GENERATED_CODE_COVERAGE |
1527 extern void LogGeneratedCodeCoverage(const char* file_line); | 1616 extern void LogGeneratedCodeCoverage(const char* file_line); |
1528 #define CODE_COVERAGE_STRINGIFY(x) #x | 1617 #define CODE_COVERAGE_STRINGIFY(x) #x |
1529 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) | 1618 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) |
1530 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 1619 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
1531 #define ACCESS_MASM(masm) { \ | 1620 #define ACCESS_MASM(masm) { \ |
1532 Address x64_coverage_function = FUNCTION_ADDR(LogGeneratedCodeCoverage); \ | 1621 Address x64_coverage_function = FUNCTION_ADDR(LogGeneratedCodeCoverage); \ |
1533 masm->pushfq(); \ | 1622 masm->pushfq(); \ |
1534 masm->Pushad(); \ | 1623 masm->Pushad(); \ |
1535 masm->push(Immediate(reinterpret_cast<int>(&__FILE_LINE__))); \ | 1624 masm->push(Immediate(reinterpret_cast<int>(&__FILE_LINE__))); \ |
1536 masm->Call(x64_coverage_function, RelocInfo::EXTERNAL_REFERENCE); \ | 1625 masm->Call(x64_coverage_function, RelocInfo::EXTERNAL_REFERENCE); \ |
1537 masm->pop(rax); \ | 1626 masm->pop(rax); \ |
1538 masm->Popad(); \ | 1627 masm->Popad(); \ |
1539 masm->popfq(); \ | 1628 masm->popfq(); \ |
1540 } \ | 1629 } \ |
1541 masm-> | 1630 masm-> |
1542 #else | 1631 #else |
1543 #define ACCESS_MASM(masm) masm-> | 1632 #define ACCESS_MASM(masm) masm-> |
1544 #endif | 1633 #endif |
1545 | 1634 |
1546 } } // namespace v8::internal | 1635 } } // namespace v8::internal |
1547 | 1636 |
1548 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ | 1637 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ |
OLD | NEW |