OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 RecordWriteStub(Register object, Register addr, Register scratch) | 92 RecordWriteStub(Register object, Register addr, Register scratch) |
93 : object_(object), addr_(addr), scratch_(scratch) { } | 93 : object_(object), addr_(addr), scratch_(scratch) { } |
94 | 94 |
95 void Generate(MacroAssembler* masm); | 95 void Generate(MacroAssembler* masm); |
96 | 96 |
97 private: | 97 private: |
98 Register object_; | 98 Register object_; |
99 Register addr_; | 99 Register addr_; |
100 Register scratch_; | 100 Register scratch_; |
101 | 101 |
102 const char* GetName() { return "RecordWriteStub"; } | |
103 | |
104 #ifdef DEBUG | 102 #ifdef DEBUG |
105 void Print() { | 103 void Print() { |
106 PrintF("RecordWriteStub (object reg %d), (addr reg %d), (scratch reg %d)\n", | 104 PrintF("RecordWriteStub (object reg %d), (addr reg %d), (scratch reg %d)\n", |
107 object_.code(), addr_.code(), scratch_.code()); | 105 object_.code(), addr_.code(), scratch_.code()); |
108 } | 106 } |
109 #endif | 107 #endif |
110 | 108 |
111 // Minor key encoding in 12 bits of three registers (object, address and | 109 // Minor key encoding in 12 bits of three registers (object, address and |
112 // scratch) OOOOAAAASSSS. | 110 // scratch) OOOOAAAASSSS. |
113 class ScratchBits: public BitField<uint32_t, 0, 4> {}; | 111 class ScratchBits: public BitField<uint32_t, 0, 4> {}; |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 Label ok; | 580 Label ok; |
583 test(result, Operand(result)); | 581 test(result, Operand(result)); |
584 j(not_zero, &ok, taken); | 582 j(not_zero, &ok, taken); |
585 mov(scratch, Operand(op1)); | 583 mov(scratch, Operand(op1)); |
586 or_(scratch, Operand(op2)); | 584 or_(scratch, Operand(op2)); |
587 j(sign, then_label, not_taken); | 585 j(sign, then_label, not_taken); |
588 bind(&ok); | 586 bind(&ok); |
589 } | 587 } |
590 | 588 |
591 | 589 |
590 void MacroAssembler::TryGetFunctionPrototype(Register function, | |
591 Register result, | |
592 Register scratch, | |
593 Label* miss) { | |
594 // Check that the receiver isn't a smi. | |
595 test(function, Immediate(kSmiTagMask)); | |
Erik Corry
2008/10/08 13:29:08
We normally have an assert here in case we ever de
| |
596 j(zero, miss, not_taken); | |
597 | |
598 // Check that the function really is a function. | |
599 mov(result, FieldOperand(function, HeapObject::kMapOffset)); | |
600 movzx_b(scratch, FieldOperand(result, Map::kInstanceTypeOffset)); | |
601 cmp(scratch, JS_FUNCTION_TYPE); | |
602 j(not_equal, miss, not_taken); | |
603 | |
604 // Make sure that the function has an instance prototype. | |
605 Label non_instance; | |
606 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset)); | |
607 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype)); | |
608 j(not_zero, &non_instance, not_taken); | |
609 | |
610 // Get the prototype or initial map from the function. | |
611 mov(result, | |
612 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | |
613 | |
614 // If the prototype or initial map is the hole, don't return it and | |
615 // simply miss the cache instead. This will allow us to allocate a | |
616 // prototype object on-demand in the runtime system. | |
617 cmp(Operand(result), Immediate(Factory::the_hole_value())); | |
618 j(equal, miss, not_taken); | |
619 | |
620 // If the function does not have an initial map, we're done. | |
621 Label done; | |
622 mov(scratch, FieldOperand(result, HeapObject::kMapOffset)); | |
623 movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); | |
624 cmp(scratch, MAP_TYPE); | |
625 j(not_equal, &done); | |
626 | |
627 // Get the prototype from the initial map. | |
628 mov(result, FieldOperand(result, Map::kPrototypeOffset)); | |
629 jmp(&done); | |
630 | |
631 // Non-instance prototype: Fetch prototype from constructor field | |
632 // in initial map. | |
633 bind(&non_instance); | |
634 mov(result, FieldOperand(result, Map::kConstructorOffset)); | |
635 | |
636 // All done. | |
637 bind(&done); | |
638 } | |
639 | |
640 | |
592 void MacroAssembler::CallStub(CodeStub* stub) { | 641 void MacroAssembler::CallStub(CodeStub* stub) { |
593 ASSERT(allow_stub_calls()); // calls are not allowed in some stubs | 642 ASSERT(allow_stub_calls()); // calls are not allowed in some stubs |
594 call(stub->GetCode(), RelocInfo::CODE_TARGET); | 643 call(stub->GetCode(), RelocInfo::CODE_TARGET); |
595 } | 644 } |
596 | 645 |
597 | 646 |
598 void MacroAssembler::StubReturn(int argc) { | 647 void MacroAssembler::StubReturn(int argc) { |
599 ASSERT(argc >= 1 && generating_stub()); | 648 ASSERT(argc >= 1 && generating_stub()); |
600 ret((argc - 1) * kPointerSize); | 649 ret((argc - 1) * kPointerSize); |
601 } | 650 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
915 // Indicate that code has changed. | 964 // Indicate that code has changed. |
916 CPU::FlushICache(address_, size_); | 965 CPU::FlushICache(address_, size_); |
917 | 966 |
918 // Check that the code was patched as expected. | 967 // Check that the code was patched as expected. |
919 ASSERT(masm_.pc_ == address_ + size_); | 968 ASSERT(masm_.pc_ == address_ + size_); |
920 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 969 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
921 } | 970 } |
922 | 971 |
923 | 972 |
924 } } // namespace v8::internal | 973 } } // namespace v8::internal |
OLD | NEW |