| 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 26 matching lines...) Expand all Loading... |
| 37 #include "debug.h" | 37 #include "debug.h" |
| 38 #include "isolate-inl.h" | 38 #include "isolate-inl.h" |
| 39 #include "runtime.h" | 39 #include "runtime.h" |
| 40 | 40 |
| 41 namespace v8 { | 41 namespace v8 { |
| 42 namespace internal { | 42 namespace internal { |
| 43 | 43 |
| 44 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) | 44 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) |
| 45 : Assembler(arg_isolate, buffer, size), | 45 : Assembler(arg_isolate, buffer, size), |
| 46 generating_stub_(false), | 46 generating_stub_(false), |
| 47 allow_stub_calls_(true), | |
| 48 has_frame_(false) { | 47 has_frame_(false) { |
| 49 if (isolate() != NULL) { | 48 if (isolate() != NULL) { |
| 50 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), | 49 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), |
| 51 isolate()); | 50 isolate()); |
| 52 } | 51 } |
| 53 } | 52 } |
| 54 | 53 |
| 55 | 54 |
| 56 void MacroAssembler::Load(Register dst, | 55 void MacroAssembler::Load(Register dst, |
| 57 const MemOperand& src, | 56 const MemOperand& src, |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 SmiCheck smi_check) { | 267 SmiCheck smi_check) { |
| 269 ASSERT(!AreAliased(object, address, value, t8)); | 268 ASSERT(!AreAliased(object, address, value, t8)); |
| 270 ASSERT(!AreAliased(object, address, value, t9)); | 269 ASSERT(!AreAliased(object, address, value, t9)); |
| 271 | 270 |
| 272 if (emit_debug_code()) { | 271 if (emit_debug_code()) { |
| 273 lw(at, MemOperand(address)); | 272 lw(at, MemOperand(address)); |
| 274 Assert( | 273 Assert( |
| 275 eq, kWrongAddressOrValuePassedToRecordWrite, at, Operand(value)); | 274 eq, kWrongAddressOrValuePassedToRecordWrite, at, Operand(value)); |
| 276 } | 275 } |
| 277 | 276 |
| 277 // Count number of write barriers in generated code. |
| 278 isolate()->counters()->write_barriers_static()->Increment(); |
| 279 // TODO(mstarzinger): Dynamic counter missing. |
| 280 |
| 281 // First, check if a write barrier is even needed. The tests below |
| 282 // catch stores of smis and stores into the young generation. |
| 278 Label done; | 283 Label done; |
| 279 | 284 |
| 280 if (smi_check == INLINE_SMI_CHECK) { | 285 if (smi_check == INLINE_SMI_CHECK) { |
| 281 ASSERT_EQ(0, kSmiTag); | 286 ASSERT_EQ(0, kSmiTag); |
| 282 JumpIfSmi(value, &done); | 287 JumpIfSmi(value, &done); |
| 283 } | 288 } |
| 284 | 289 |
| 285 CheckPageFlag(value, | 290 CheckPageFlag(value, |
| 286 value, // Used as scratch. | 291 value, // Used as scratch. |
| 287 MemoryChunk::kPointersToHereAreInterestingMask, | 292 MemoryChunk::kPointersToHereAreInterestingMask, |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 } else { | 782 } else { |
| 778 srl(at, rs, rt.imm32_); | 783 srl(at, rs, rt.imm32_); |
| 779 sll(rd, rs, (0x20 - rt.imm32_) & 0x1f); | 784 sll(rd, rs, (0x20 - rt.imm32_) & 0x1f); |
| 780 or_(rd, rd, at); | 785 or_(rd, rd, at); |
| 781 } | 786 } |
| 782 } | 787 } |
| 783 } | 788 } |
| 784 } | 789 } |
| 785 | 790 |
| 786 | 791 |
| 792 void MacroAssembler::Pref(int32_t hint, const MemOperand& rs) { |
| 793 if (kArchVariant == kLoongson) { |
| 794 lw(zero_reg, rs); |
| 795 } else { |
| 796 pref(hint, rs); |
| 797 } |
| 798 } |
| 799 |
| 800 |
| 787 //------------Pseudo-instructions------------- | 801 //------------Pseudo-instructions------------- |
| 788 | 802 |
| 803 void MacroAssembler::Ulw(Register rd, const MemOperand& rs) { |
| 804 lwr(rd, rs); |
| 805 lwl(rd, MemOperand(rs.rm(), rs.offset() + 3)); |
| 806 } |
| 807 |
| 808 |
| 809 void MacroAssembler::Usw(Register rd, const MemOperand& rs) { |
| 810 swr(rd, rs); |
| 811 swl(rd, MemOperand(rs.rm(), rs.offset() + 3)); |
| 812 } |
| 813 |
| 814 |
| 789 void MacroAssembler::li(Register dst, Handle<Object> value, LiFlags mode) { | 815 void MacroAssembler::li(Register dst, Handle<Object> value, LiFlags mode) { |
| 790 AllowDeferredHandleDereference smi_check; | 816 AllowDeferredHandleDereference smi_check; |
| 791 if (value->IsSmi()) { | 817 if (value->IsSmi()) { |
| 792 li(dst, Operand(value), mode); | 818 li(dst, Operand(value), mode); |
| 793 } else { | 819 } else { |
| 794 ASSERT(value->IsHeapObject()); | 820 ASSERT(value->IsHeapObject()); |
| 795 if (isolate()->heap()->InNewSpace(*value)) { | 821 if (isolate()->heap()->InNewSpace(*value)) { |
| 796 Handle<Cell> cell = isolate()->factory()->NewCell(value); | 822 Handle<Cell> cell = isolate()->factory()->NewCell(value); |
| 797 li(dst, Operand(cell)); | 823 li(dst, Operand(cell)); |
| 798 lw(dst, FieldMemOperand(dst, Cell::kValueOffset)); | 824 lw(dst, FieldMemOperand(dst, Cell::kValueOffset)); |
| (...skipping 2916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3715 FieldMemOperand(code_reg, | 3741 FieldMemOperand(code_reg, |
| 3716 SharedFunctionInfo::kFormalParameterCountOffset)); | 3742 SharedFunctionInfo::kFormalParameterCountOffset)); |
| 3717 sra(expected_reg, expected_reg, kSmiTagSize); | 3743 sra(expected_reg, expected_reg, kSmiTagSize); |
| 3718 lw(code_reg, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 3744 lw(code_reg, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
| 3719 | 3745 |
| 3720 ParameterCount expected(expected_reg); | 3746 ParameterCount expected(expected_reg); |
| 3721 InvokeCode(code_reg, expected, actual, flag, call_wrapper, call_kind); | 3747 InvokeCode(code_reg, expected, actual, flag, call_wrapper, call_kind); |
| 3722 } | 3748 } |
| 3723 | 3749 |
| 3724 | 3750 |
| 3725 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, | 3751 void MacroAssembler::InvokeFunction(Register function, |
| 3726 const ParameterCount& expected, | 3752 const ParameterCount& expected, |
| 3727 const ParameterCount& actual, | 3753 const ParameterCount& actual, |
| 3728 InvokeFlag flag, | 3754 InvokeFlag flag, |
| 3729 const CallWrapper& call_wrapper, | 3755 const CallWrapper& call_wrapper, |
| 3730 CallKind call_kind) { | 3756 CallKind call_kind) { |
| 3731 // You can't call a function without a valid frame. | 3757 // You can't call a function without a valid frame. |
| 3732 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 3758 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
| 3733 | 3759 |
| 3760 // Contract with called JS functions requires that function is passed in a1. |
| 3761 ASSERT(function.is(a1)); |
| 3762 |
| 3734 // Get the function and setup the context. | 3763 // Get the function and setup the context. |
| 3735 li(a1, function); | |
| 3736 lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 3764 lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 3737 | 3765 |
| 3738 // We call indirectly through the code field in the function to | 3766 // We call indirectly through the code field in the function to |
| 3739 // allow recompilation to take effect without changing any of the | 3767 // allow recompilation to take effect without changing any of the |
| 3740 // call sites. | 3768 // call sites. |
| 3741 lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 3769 lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
| 3742 InvokeCode(a3, expected, actual, flag, call_wrapper, call_kind); | 3770 InvokeCode(a3, expected, actual, flag, call_wrapper, call_kind); |
| 3743 } | 3771 } |
| 3744 | 3772 |
| 3745 | 3773 |
| 3774 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
| 3775 const ParameterCount& expected, |
| 3776 const ParameterCount& actual, |
| 3777 InvokeFlag flag, |
| 3778 const CallWrapper& call_wrapper, |
| 3779 CallKind call_kind) { |
| 3780 li(a1, function); |
| 3781 InvokeFunction(a1, expected, actual, flag, call_wrapper, call_kind); |
| 3782 } |
| 3783 |
| 3784 |
| 3746 void MacroAssembler::IsObjectJSObjectType(Register heap_object, | 3785 void MacroAssembler::IsObjectJSObjectType(Register heap_object, |
| 3747 Register map, | 3786 Register map, |
| 3748 Register scratch, | 3787 Register scratch, |
| 3749 Label* fail) { | 3788 Label* fail) { |
| 3750 lw(map, FieldMemOperand(heap_object, HeapObject::kMapOffset)); | 3789 lw(map, FieldMemOperand(heap_object, HeapObject::kMapOffset)); |
| 3751 IsInstanceJSObjectType(map, scratch, fail); | 3790 IsInstanceJSObjectType(map, scratch, fail); |
| 3752 } | 3791 } |
| 3753 | 3792 |
| 3754 | 3793 |
| 3755 void MacroAssembler::IsInstanceJSObjectType(Register map, | 3794 void MacroAssembler::IsInstanceJSObjectType(Register map, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3860 Register r1, | 3899 Register r1, |
| 3861 const Operand& r2, | 3900 const Operand& r2, |
| 3862 BranchDelaySlot bd) { | 3901 BranchDelaySlot bd) { |
| 3863 ASSERT(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. | 3902 ASSERT(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. |
| 3864 Call(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, ast_id, | 3903 Call(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, ast_id, |
| 3865 cond, r1, r2, bd); | 3904 cond, r1, r2, bd); |
| 3866 } | 3905 } |
| 3867 | 3906 |
| 3868 | 3907 |
| 3869 void MacroAssembler::TailCallStub(CodeStub* stub) { | 3908 void MacroAssembler::TailCallStub(CodeStub* stub) { |
| 3870 ASSERT(allow_stub_calls_ || | |
| 3871 stub->CompilingCallsToThisStubIsGCSafe(isolate())); | |
| 3872 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); | 3909 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); |
| 3873 } | 3910 } |
| 3874 | 3911 |
| 3875 | 3912 |
| 3876 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 3913 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
| 3877 return ref0.address() - ref1.address(); | 3914 return ref0.address() - ref1.address(); |
| 3878 } | 3915 } |
| 3879 | 3916 |
| 3880 | 3917 |
| 3881 void MacroAssembler::CallApiFunctionAndReturn( | 3918 void MacroAssembler::CallApiFunctionAndReturn( |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4001 PrepareCallCFunction(1, s1); | 4038 PrepareCallCFunction(1, s1); |
| 4002 li(a0, Operand(ExternalReference::isolate_address(isolate()))); | 4039 li(a0, Operand(ExternalReference::isolate_address(isolate()))); |
| 4003 CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate()), | 4040 CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate()), |
| 4004 1); | 4041 1); |
| 4005 mov(v0, s0); | 4042 mov(v0, s0); |
| 4006 jmp(&leave_exit_frame); | 4043 jmp(&leave_exit_frame); |
| 4007 } | 4044 } |
| 4008 | 4045 |
| 4009 | 4046 |
| 4010 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { | 4047 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { |
| 4011 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false; | 4048 return has_frame_ || !stub->SometimesSetsUpAFrame(); |
| 4012 return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(isolate()); | |
| 4013 } | 4049 } |
| 4014 | 4050 |
| 4015 | 4051 |
| 4016 void MacroAssembler::IllegalOperation(int num_arguments) { | 4052 void MacroAssembler::IllegalOperation(int num_arguments) { |
| 4017 if (num_arguments > 0) { | 4053 if (num_arguments > 0) { |
| 4018 addiu(sp, sp, num_arguments * kPointerSize); | 4054 addiu(sp, sp, num_arguments * kPointerSize); |
| 4019 } | 4055 } |
| 4020 LoadRoot(v0, Heap::kUndefinedValueRootIndex); | 4056 LoadRoot(v0, Heap::kUndefinedValueRootIndex); |
| 4021 } | 4057 } |
| 4022 | 4058 |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4519 Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); | 4555 Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); |
| 4520 } else { | 4556 } else { |
| 4521 PredictableCodeSizeScope predictible_code_size_scope( | 4557 PredictableCodeSizeScope predictible_code_size_scope( |
| 4522 this, kNoCodeAgeSequenceLength * Assembler::kInstrSize); | 4558 this, kNoCodeAgeSequenceLength * Assembler::kInstrSize); |
| 4523 // The following three instructions must remain together and unmodified | 4559 // The following three instructions must remain together and unmodified |
| 4524 // for code aging to work properly. | 4560 // for code aging to work properly. |
| 4525 if (isolate()->IsCodePreAgingActive()) { | 4561 if (isolate()->IsCodePreAgingActive()) { |
| 4526 // Pre-age the code. | 4562 // Pre-age the code. |
| 4527 Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); | 4563 Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); |
| 4528 nop(Assembler::CODE_AGE_MARKER_NOP); | 4564 nop(Assembler::CODE_AGE_MARKER_NOP); |
| 4529 // Save the function's original return address | 4565 // Load the stub address to t9 and call it, |
| 4530 // (it will be clobbered by Call(t9)). | 4566 // GetCodeAgeAndParity() extracts the stub address from this instruction. |
| 4531 mov(at, ra); | |
| 4532 // Load the stub address to t9 and call it. | |
| 4533 li(t9, | 4567 li(t9, |
| 4534 Operand(reinterpret_cast<uint32_t>(stub->instruction_start()))); | 4568 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), |
| 4535 Call(t9); | 4569 CONSTANT_SIZE); |
| 4536 // Record the stub address in the empty space for GetCodeAgeAndParity(). | 4570 nop(); // Prevent jalr to jal optimization. |
| 4537 emit_code_stub_address(stub); | 4571 jalr(t9, a0); |
| 4572 nop(); // Branch delay slot nop. |
| 4573 nop(); // Pad the empty space. |
| 4538 } else { | 4574 } else { |
| 4539 Push(ra, fp, cp, a1); | 4575 Push(ra, fp, cp, a1); |
| 4540 nop(Assembler::CODE_AGE_SEQUENCE_NOP); | 4576 nop(Assembler::CODE_AGE_SEQUENCE_NOP); |
| 4541 // Adjust fp to point to caller's fp. | 4577 // Adjust fp to point to caller's fp. |
| 4542 Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); | 4578 Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); |
| 4543 } | 4579 } |
| 4544 } | 4580 } |
| 4545 } | 4581 } |
| 4546 | 4582 |
| 4547 | 4583 |
| (...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5749 opcode == BGTZL); | 5785 opcode == BGTZL); |
| 5750 opcode = (cond == eq) ? BEQ : BNE; | 5786 opcode = (cond == eq) ? BEQ : BNE; |
| 5751 instr = (instr & ~kOpcodeMask) | opcode; | 5787 instr = (instr & ~kOpcodeMask) | opcode; |
| 5752 masm_.emit(instr); | 5788 masm_.emit(instr); |
| 5753 } | 5789 } |
| 5754 | 5790 |
| 5755 | 5791 |
| 5756 } } // namespace v8::internal | 5792 } } // namespace v8::internal |
| 5757 | 5793 |
| 5758 #endif // V8_TARGET_ARCH_MIPS | 5794 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |