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 3592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3603 FieldMemOperand(code_reg, | 3603 FieldMemOperand(code_reg, |
3604 SharedFunctionInfo::kFormalParameterCountOffset)); | 3604 SharedFunctionInfo::kFormalParameterCountOffset)); |
3605 sra(expected_reg, expected_reg, kSmiTagSize); | 3605 sra(expected_reg, expected_reg, kSmiTagSize); |
3606 lw(code_reg, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 3606 lw(code_reg, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
3607 | 3607 |
3608 ParameterCount expected(expected_reg); | 3608 ParameterCount expected(expected_reg); |
3609 InvokeCode(code_reg, expected, actual, flag, call_wrapper, call_kind); | 3609 InvokeCode(code_reg, expected, actual, flag, call_wrapper, call_kind); |
3610 } | 3610 } |
3611 | 3611 |
3612 | 3612 |
3613 void MacroAssembler::InvokeFunction(JSFunction* function, | 3613 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
3614 const ParameterCount& actual, | 3614 const ParameterCount& actual, |
3615 InvokeFlag flag, | 3615 InvokeFlag flag, |
3616 CallKind call_kind) { | 3616 CallKind call_kind) { |
3617 // You can't call a function without a valid frame. | 3617 // You can't call a function without a valid frame. |
3618 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 3618 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
3619 | 3619 |
3620 // Get the function and setup the context. | 3620 // Get the function and setup the context. |
3621 li(a1, Operand(Handle<JSFunction>(function))); | 3621 li(a1, Operand(function)); |
3622 lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 3622 lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
3623 | 3623 |
3624 ParameterCount expected(function->shared()->formal_parameter_count()); | 3624 ParameterCount expected(function->shared()->formal_parameter_count()); |
3625 // We call indirectly through the code field in the function to | 3625 // We call indirectly through the code field in the function to |
3626 // allow recompilation to take effect without changing any of the | 3626 // allow recompilation to take effect without changing any of the |
3627 // call sites. | 3627 // call sites. |
3628 lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 3628 lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
3629 InvokeCode(a3, expected, actual, flag, NullCallWrapper(), call_kind); | 3629 InvokeCode(a3, expected, actual, flag, NullCallWrapper(), call_kind); |
3630 } | 3630 } |
3631 | 3631 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3732 // ----------------------------------------------------------------------------- | 3732 // ----------------------------------------------------------------------------- |
3733 // Runtime calls. | 3733 // Runtime calls. |
3734 | 3734 |
3735 void MacroAssembler::CallStub(CodeStub* stub, Condition cond, | 3735 void MacroAssembler::CallStub(CodeStub* stub, Condition cond, |
3736 Register r1, const Operand& r2) { | 3736 Register r1, const Operand& r2) { |
3737 ASSERT(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. | 3737 ASSERT(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. |
3738 Call(stub->GetCode(), RelocInfo::CODE_TARGET, kNoASTId, cond, r1, r2); | 3738 Call(stub->GetCode(), RelocInfo::CODE_TARGET, kNoASTId, cond, r1, r2); |
3739 } | 3739 } |
3740 | 3740 |
3741 | 3741 |
3742 MaybeObject* MacroAssembler::TryCallStub(CodeStub* stub, Condition cond, | |
3743 Register r1, const Operand& r2) { | |
3744 ASSERT(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. | |
3745 Object* result; | |
3746 { MaybeObject* maybe_result = stub->TryGetCode(); | |
3747 if (!maybe_result->ToObject(&result)) return maybe_result; | |
3748 } | |
3749 Call(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET, | |
3750 kNoASTId, cond, r1, r2); | |
3751 return result; | |
3752 } | |
3753 | |
3754 | |
3755 void MacroAssembler::TailCallStub(CodeStub* stub) { | 3742 void MacroAssembler::TailCallStub(CodeStub* stub) { |
3756 ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe()); | 3743 ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe()); |
3757 Jump(stub->GetCode(), RelocInfo::CODE_TARGET); | 3744 Jump(stub->GetCode(), RelocInfo::CODE_TARGET); |
3758 } | 3745 } |
3759 | 3746 |
3760 | 3747 |
3761 MaybeObject* MacroAssembler::TryTailCallStub(CodeStub* stub, | |
3762 Condition cond, | |
3763 Register r1, | |
3764 const Operand& r2) { | |
3765 Object* result; | |
3766 { MaybeObject* maybe_result = stub->TryGetCode(); | |
3767 if (!maybe_result->ToObject(&result)) return maybe_result; | |
3768 } | |
3769 Jump(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET, cond, r1, r2); | |
3770 return result; | |
3771 } | |
3772 | |
3773 | |
3774 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 3748 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
3775 return ref0.address() - ref1.address(); | 3749 return ref0.address() - ref1.address(); |
3776 } | 3750 } |
3777 | 3751 |
3778 | 3752 |
3779 MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn( | 3753 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, |
3780 ExternalReference function, int stack_space) { | 3754 int stack_space) { |
3781 ExternalReference next_address = | 3755 ExternalReference next_address = |
3782 ExternalReference::handle_scope_next_address(); | 3756 ExternalReference::handle_scope_next_address(); |
3783 const int kNextOffset = 0; | 3757 const int kNextOffset = 0; |
3784 const int kLimitOffset = AddressOffset( | 3758 const int kLimitOffset = AddressOffset( |
3785 ExternalReference::handle_scope_limit_address(), | 3759 ExternalReference::handle_scope_limit_address(), |
3786 next_address); | 3760 next_address); |
3787 const int kLevelOffset = AddressOffset( | 3761 const int kLevelOffset = AddressOffset( |
3788 ExternalReference::handle_scope_level_address(), | 3762 ExternalReference::handle_scope_level_address(), |
3789 next_address); | 3763 next_address); |
3790 | 3764 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3841 bind(&leave_exit_frame); | 3815 bind(&leave_exit_frame); |
3842 LoadRoot(t0, Heap::kTheHoleValueRootIndex); | 3816 LoadRoot(t0, Heap::kTheHoleValueRootIndex); |
3843 li(at, Operand(ExternalReference::scheduled_exception_address(isolate()))); | 3817 li(at, Operand(ExternalReference::scheduled_exception_address(isolate()))); |
3844 lw(t1, MemOperand(at)); | 3818 lw(t1, MemOperand(at)); |
3845 Branch(&promote_scheduled_exception, ne, t0, Operand(t1)); | 3819 Branch(&promote_scheduled_exception, ne, t0, Operand(t1)); |
3846 li(s0, Operand(stack_space)); | 3820 li(s0, Operand(stack_space)); |
3847 LeaveExitFrame(false, s0); | 3821 LeaveExitFrame(false, s0); |
3848 Ret(); | 3822 Ret(); |
3849 | 3823 |
3850 bind(&promote_scheduled_exception); | 3824 bind(&promote_scheduled_exception); |
3851 MaybeObject* result = TryTailCallExternalReference( | 3825 TailCallExternalReference( |
3852 ExternalReference(Runtime::kPromoteScheduledException, isolate()), 0, 1); | 3826 ExternalReference(Runtime::kPromoteScheduledException, isolate()), |
3853 if (result->IsFailure()) { | 3827 0, |
3854 return result; | 3828 1); |
3855 } | |
3856 | 3829 |
3857 // HandleScope limit has changed. Delete allocated extensions. | 3830 // HandleScope limit has changed. Delete allocated extensions. |
3858 bind(&delete_allocated_handles); | 3831 bind(&delete_allocated_handles); |
3859 sw(s1, MemOperand(s3, kLimitOffset)); | 3832 sw(s1, MemOperand(s3, kLimitOffset)); |
3860 mov(s0, v0); | 3833 mov(s0, v0); |
3861 mov(a0, v0); | 3834 mov(a0, v0); |
3862 PrepareCallCFunction(1, s1); | 3835 PrepareCallCFunction(1, s1); |
3863 li(a0, Operand(ExternalReference::isolate_address())); | 3836 li(a0, Operand(ExternalReference::isolate_address())); |
3864 CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate()), | 3837 CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate()), |
3865 1); | 3838 1); |
3866 mov(v0, s0); | 3839 mov(v0, s0); |
3867 jmp(&leave_exit_frame); | 3840 jmp(&leave_exit_frame); |
3868 | |
3869 return result; | |
3870 } | 3841 } |
3871 | 3842 |
3872 | 3843 |
3873 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { | 3844 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { |
3874 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false; | 3845 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false; |
3875 return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(); | 3846 return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(); |
3876 } | 3847 } |
3877 | 3848 |
3878 | 3849 |
3879 void MacroAssembler::IllegalOperation(int num_arguments) { | 3850 void MacroAssembler::IllegalOperation(int num_arguments) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4082 int result_size) { | 4053 int result_size) { |
4083 // TODO(1236192): Most runtime routines don't need the number of | 4054 // TODO(1236192): Most runtime routines don't need the number of |
4084 // arguments passed in because it is constant. At some point we | 4055 // arguments passed in because it is constant. At some point we |
4085 // should remove this need and make the runtime routine entry code | 4056 // should remove this need and make the runtime routine entry code |
4086 // smarter. | 4057 // smarter. |
4087 li(a0, Operand(num_arguments)); | 4058 li(a0, Operand(num_arguments)); |
4088 JumpToExternalReference(ext); | 4059 JumpToExternalReference(ext); |
4089 } | 4060 } |
4090 | 4061 |
4091 | 4062 |
4092 MaybeObject* MacroAssembler::TryTailCallExternalReference( | |
4093 const ExternalReference& ext, int num_arguments, int result_size) { | |
4094 // TODO(1236192): Most runtime routines don't need the number of | |
4095 // arguments passed in because it is constant. At some point we | |
4096 // should remove this need and make the runtime routine entry code | |
4097 // smarter. | |
4098 li(a0, num_arguments); | |
4099 return TryJumpToExternalReference(ext); | |
4100 } | |
4101 | |
4102 | |
4103 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, | 4063 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, |
4104 int num_arguments, | 4064 int num_arguments, |
4105 int result_size) { | 4065 int result_size) { |
4106 TailCallExternalReference(ExternalReference(fid, isolate()), | 4066 TailCallExternalReference(ExternalReference(fid, isolate()), |
4107 num_arguments, | 4067 num_arguments, |
4108 result_size); | 4068 result_size); |
4109 } | 4069 } |
4110 | 4070 |
4111 | 4071 |
4112 void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin) { | 4072 void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin) { |
4113 li(a1, Operand(builtin)); | 4073 li(a1, Operand(builtin)); |
4114 CEntryStub stub(1); | 4074 CEntryStub stub(1); |
4115 Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 4075 Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
4116 } | 4076 } |
4117 | 4077 |
4118 | 4078 |
4119 MaybeObject* MacroAssembler::TryJumpToExternalReference( | |
4120 const ExternalReference& builtin) { | |
4121 li(a1, Operand(builtin)); | |
4122 CEntryStub stub(1); | |
4123 return TryTailCallStub(&stub); | |
4124 } | |
4125 | |
4126 | |
4127 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, | 4079 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, |
4128 InvokeFlag flag, | 4080 InvokeFlag flag, |
4129 const CallWrapper& call_wrapper) { | 4081 const CallWrapper& call_wrapper) { |
4130 // You can't call a builtin without a valid frame. | 4082 // You can't call a builtin without a valid frame. |
4131 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 4083 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
4132 | 4084 |
4133 GetBuiltinEntry(t9, id); | 4085 GetBuiltinEntry(t9, id); |
4134 if (flag == CALL_FUNCTION) { | 4086 if (flag == CALL_FUNCTION) { |
4135 call_wrapper.BeforeCall(CallSize(t9)); | 4087 call_wrapper.BeforeCall(CallSize(t9)); |
4136 SetCallKind(t1, CALL_AS_METHOD); | 4088 SetCallKind(t1, CALL_AS_METHOD); |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5128 opcode == BGTZL); | 5080 opcode == BGTZL); |
5129 opcode = (cond == eq) ? BEQ : BNE; | 5081 opcode = (cond == eq) ? BEQ : BNE; |
5130 instr = (instr & ~kOpcodeMask) | opcode; | 5082 instr = (instr & ~kOpcodeMask) | opcode; |
5131 masm_.emit(instr); | 5083 masm_.emit(instr); |
5132 } | 5084 } |
5133 | 5085 |
5134 | 5086 |
5135 } } // namespace v8::internal | 5087 } } // namespace v8::internal |
5136 | 5088 |
5137 #endif // V8_TARGET_ARCH_MIPS | 5089 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |