| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 | 599 |
| 600 // Load address of new object into result. | 600 // Load address of new object into result. |
| 601 LoadAllocationTopHelper(result, scratch, flags); | 601 LoadAllocationTopHelper(result, scratch, flags); |
| 602 | 602 |
| 603 Register top_reg = result_end.is_valid() ? result_end : result; | 603 Register top_reg = result_end.is_valid() ? result_end : result; |
| 604 | 604 |
| 605 // Calculate new top and bail out if new space is exhausted. | 605 // Calculate new top and bail out if new space is exhausted. |
| 606 ExternalReference new_space_allocation_limit = | 606 ExternalReference new_space_allocation_limit = |
| 607 ExternalReference::new_space_allocation_limit_address(); | 607 ExternalReference::new_space_allocation_limit_address(); |
| 608 | 608 |
| 609 if (top_reg.is(result)) { | 609 if (!top_reg.is(result)) { |
| 610 add(Operand(top_reg), Immediate(object_size)); | 610 mov(top_reg, result); |
| 611 } else { | |
| 612 lea(top_reg, Operand(result, object_size)); | |
| 613 } | 611 } |
| 612 add(Operand(top_reg), Immediate(object_size)); |
| 613 j(carry, gc_required, not_taken); |
| 614 cmp(top_reg, Operand::StaticVariable(new_space_allocation_limit)); | 614 cmp(top_reg, Operand::StaticVariable(new_space_allocation_limit)); |
| 615 j(above, gc_required, not_taken); | 615 j(above, gc_required, not_taken); |
| 616 | 616 |
| 617 // Update allocation top. | 617 // Update allocation top. |
| 618 UpdateAllocationTopHelper(top_reg, scratch); | 618 UpdateAllocationTopHelper(top_reg, scratch); |
| 619 | 619 |
| 620 // Tag result if requested. | 620 // Tag result if requested. |
| 621 if (top_reg.is(result)) { | 621 if (top_reg.is(result)) { |
| 622 if ((flags & TAG_OBJECT) != 0) { | 622 if ((flags & TAG_OBJECT) != 0) { |
| 623 sub(Operand(result), Immediate(object_size - kHeapObjectTag)); | 623 sub(Operand(result), Immediate(object_size - kHeapObjectTag)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 652 return; | 652 return; |
| 653 } | 653 } |
| 654 ASSERT(!result.is(result_end)); | 654 ASSERT(!result.is(result_end)); |
| 655 | 655 |
| 656 // Load address of new object into result. | 656 // Load address of new object into result. |
| 657 LoadAllocationTopHelper(result, scratch, flags); | 657 LoadAllocationTopHelper(result, scratch, flags); |
| 658 | 658 |
| 659 // Calculate new top and bail out if new space is exhausted. | 659 // Calculate new top and bail out if new space is exhausted. |
| 660 ExternalReference new_space_allocation_limit = | 660 ExternalReference new_space_allocation_limit = |
| 661 ExternalReference::new_space_allocation_limit_address(); | 661 ExternalReference::new_space_allocation_limit_address(); |
| 662 lea(result_end, Operand(result, element_count, element_size, header_size)); | 662 |
| 663 // We assume that element_count*element_size + header_size does not |
| 664 // overflow. |
| 665 lea(result_end, Operand(element_count, element_size, header_size)); |
| 666 add(result_end, Operand(result)); |
| 667 j(carry, gc_required); |
| 663 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); | 668 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); |
| 664 j(above, gc_required); | 669 j(above, gc_required); |
| 665 | 670 |
| 666 // Tag result if requested. | 671 // Tag result if requested. |
| 667 if ((flags & TAG_OBJECT) != 0) { | 672 if ((flags & TAG_OBJECT) != 0) { |
| 668 lea(result, Operand(result, kHeapObjectTag)); | 673 lea(result, Operand(result, kHeapObjectTag)); |
| 669 } | 674 } |
| 670 | 675 |
| 671 // Update allocation top. | 676 // Update allocation top. |
| 672 UpdateAllocationTopHelper(result_end, scratch); | 677 UpdateAllocationTopHelper(result_end, scratch); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 697 // Load address of new object into result. | 702 // Load address of new object into result. |
| 698 LoadAllocationTopHelper(result, scratch, flags); | 703 LoadAllocationTopHelper(result, scratch, flags); |
| 699 | 704 |
| 700 // Calculate new top and bail out if new space is exhausted. | 705 // Calculate new top and bail out if new space is exhausted. |
| 701 ExternalReference new_space_allocation_limit = | 706 ExternalReference new_space_allocation_limit = |
| 702 ExternalReference::new_space_allocation_limit_address(); | 707 ExternalReference::new_space_allocation_limit_address(); |
| 703 if (!object_size.is(result_end)) { | 708 if (!object_size.is(result_end)) { |
| 704 mov(result_end, object_size); | 709 mov(result_end, object_size); |
| 705 } | 710 } |
| 706 add(result_end, Operand(result)); | 711 add(result_end, Operand(result)); |
| 712 j(carry, gc_required, not_taken); |
| 707 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); | 713 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); |
| 708 j(above, gc_required, not_taken); | 714 j(above, gc_required, not_taken); |
| 709 | 715 |
| 710 // Tag result if requested. | 716 // Tag result if requested. |
| 711 if ((flags & TAG_OBJECT) != 0) { | 717 if ((flags & TAG_OBJECT) != 0) { |
| 712 lea(result, Operand(result, kHeapObjectTag)); | 718 lea(result, Operand(result, kHeapObjectTag)); |
| 713 } | 719 } |
| 714 | 720 |
| 715 // Update allocation top. | 721 // Update allocation top. |
| 716 UpdateAllocationTopHelper(result_end, scratch); | 722 UpdateAllocationTopHelper(result_end, scratch); |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { | 1527 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { |
| 1522 if (context_chain_length > 0) { | 1528 if (context_chain_length > 0) { |
| 1523 // Move up the chain of contexts to the context containing the slot. | 1529 // Move up the chain of contexts to the context containing the slot. |
| 1524 mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX))); | 1530 mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX))); |
| 1525 // Load the function context (which is the incoming, outer context). | 1531 // Load the function context (which is the incoming, outer context). |
| 1526 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); | 1532 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
| 1527 for (int i = 1; i < context_chain_length; i++) { | 1533 for (int i = 1; i < context_chain_length; i++) { |
| 1528 mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); | 1534 mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); |
| 1529 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); | 1535 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
| 1530 } | 1536 } |
| 1531 // The context may be an intermediate context, not a function context. | 1537 } else { |
| 1532 mov(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); | 1538 // Slot is in the current function context. Move it into the |
| 1533 } else { // Slot is in the current function context. | 1539 // destination register in case we store into it (the write barrier |
| 1534 // The context may be an intermediate context, not a function context. | 1540 // cannot be allowed to destroy the context in esi). |
| 1535 mov(dst, Operand(esi, Context::SlotOffset(Context::FCONTEXT_INDEX))); | 1541 mov(dst, esi); |
| 1542 } |
| 1543 |
| 1544 // We should not have found a 'with' context by walking the context chain |
| 1545 // (i.e., the static scope chain and runtime context chain do not agree). |
| 1546 // A variable occurring in such a scope should have slot type LOOKUP and |
| 1547 // not CONTEXT. |
| 1548 if (FLAG_debug_code) { |
| 1549 cmp(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
| 1550 Check(equal, "Yo dawg, I heard you liked function contexts " |
| 1551 "so I put function contexts in all your contexts"); |
| 1536 } | 1552 } |
| 1537 } | 1553 } |
| 1538 | 1554 |
| 1539 | 1555 |
| 1540 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 1556 void MacroAssembler::LoadGlobalFunction(int index, Register function) { |
| 1541 // Load the global or builtins object from the current context. | 1557 // Load the global or builtins object from the current context. |
| 1542 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 1558 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 1543 // Load the global context from the global or builtins object. | 1559 // Load the global context from the global or builtins object. |
| 1544 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); | 1560 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); |
| 1545 // Load the function from the global context. | 1561 // Load the function from the global context. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1569 ASSERT(reg_code >= 0 && reg_code < kNumSafepointRegisters); | 1585 ASSERT(reg_code >= 0 && reg_code < kNumSafepointRegisters); |
| 1570 return kNumSafepointRegisters - reg_code - 1; | 1586 return kNumSafepointRegisters - reg_code - 1; |
| 1571 } | 1587 } |
| 1572 | 1588 |
| 1573 | 1589 |
| 1574 void MacroAssembler::Ret() { | 1590 void MacroAssembler::Ret() { |
| 1575 ret(0); | 1591 ret(0); |
| 1576 } | 1592 } |
| 1577 | 1593 |
| 1578 | 1594 |
| 1595 void MacroAssembler::Ret(int bytes_dropped, Register scratch) { |
| 1596 if (is_uint16(bytes_dropped)) { |
| 1597 ret(bytes_dropped); |
| 1598 } else { |
| 1599 pop(scratch); |
| 1600 add(Operand(esp), Immediate(bytes_dropped)); |
| 1601 push(scratch); |
| 1602 ret(0); |
| 1603 } |
| 1604 } |
| 1605 |
| 1606 |
| 1607 |
| 1608 |
| 1579 void MacroAssembler::Drop(int stack_elements) { | 1609 void MacroAssembler::Drop(int stack_elements) { |
| 1580 if (stack_elements > 0) { | 1610 if (stack_elements > 0) { |
| 1581 add(Operand(esp), Immediate(stack_elements * kPointerSize)); | 1611 add(Operand(esp), Immediate(stack_elements * kPointerSize)); |
| 1582 } | 1612 } |
| 1583 } | 1613 } |
| 1584 | 1614 |
| 1585 | 1615 |
| 1586 void MacroAssembler::Move(Register dst, Register src) { | 1616 void MacroAssembler::Move(Register dst, Register src) { |
| 1587 if (!dst.is(src)) { | 1617 if (!dst.is(src)) { |
| 1588 mov(dst, src); | 1618 mov(dst, src); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 | 1932 |
| 1903 // Check that the code was patched as expected. | 1933 // Check that the code was patched as expected. |
| 1904 ASSERT(masm_.pc_ == address_ + size_); | 1934 ASSERT(masm_.pc_ == address_ + size_); |
| 1905 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1935 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 1906 } | 1936 } |
| 1907 | 1937 |
| 1908 | 1938 |
| 1909 } } // namespace v8::internal | 1939 } } // namespace v8::internal |
| 1910 | 1940 |
| 1911 #endif // V8_TARGET_ARCH_IA32 | 1941 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |