| 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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 SharedFunctionInfo::kFormalParameterCountOffset)); | 1087 SharedFunctionInfo::kFormalParameterCountOffset)); |
| 1088 mov(expected_reg, Operand(expected_reg, ASR, kSmiTagSize)); | 1088 mov(expected_reg, Operand(expected_reg, ASR, kSmiTagSize)); |
| 1089 ldr(code_reg, | 1089 ldr(code_reg, |
| 1090 FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 1090 FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
| 1091 | 1091 |
| 1092 ParameterCount expected(expected_reg); | 1092 ParameterCount expected(expected_reg); |
| 1093 InvokeCode(code_reg, expected, actual, flag, call_wrapper, call_kind); | 1093 InvokeCode(code_reg, expected, actual, flag, call_wrapper, call_kind); |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 | 1096 |
| 1097 void MacroAssembler::InvokeFunction(JSFunction* function, | 1097 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
| 1098 const ParameterCount& actual, | 1098 const ParameterCount& actual, |
| 1099 InvokeFlag flag, | 1099 InvokeFlag flag, |
| 1100 CallKind call_kind) { | 1100 CallKind call_kind) { |
| 1101 // You can't call a function without a valid frame. | 1101 // You can't call a function without a valid frame. |
| 1102 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 1102 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
| 1103 | 1103 |
| 1104 // Get the function and setup the context. | 1104 // Get the function and setup the context. |
| 1105 mov(r1, Operand(Handle<JSFunction>(function))); | 1105 mov(r1, Operand(function)); |
| 1106 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 1106 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
| 1107 | 1107 |
| 1108 ParameterCount expected(function->shared()->formal_parameter_count()); | 1108 ParameterCount expected(function->shared()->formal_parameter_count()); |
| 1109 // We call indirectly through the code field in the function to | 1109 // We call indirectly through the code field in the function to |
| 1110 // allow recompilation to take effect without changing any of the | 1110 // allow recompilation to take effect without changing any of the |
| 1111 // call sites. | 1111 // call sites. |
| 1112 ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 1112 ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
| 1113 InvokeCode(r3, expected, actual, flag, NullCallWrapper(), call_kind); | 1113 InvokeCode(r3, expected, actual, flag, NullCallWrapper(), call_kind); |
| 1114 } | 1114 } |
| 1115 | 1115 |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 bind(&done); | 2077 bind(&done); |
| 2078 } | 2078 } |
| 2079 | 2079 |
| 2080 | 2080 |
| 2081 void MacroAssembler::CallStub(CodeStub* stub, Condition cond) { | 2081 void MacroAssembler::CallStub(CodeStub* stub, Condition cond) { |
| 2082 ASSERT(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. | 2082 ASSERT(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. |
| 2083 Call(stub->GetCode(), RelocInfo::CODE_TARGET, kNoASTId, cond); | 2083 Call(stub->GetCode(), RelocInfo::CODE_TARGET, kNoASTId, cond); |
| 2084 } | 2084 } |
| 2085 | 2085 |
| 2086 | 2086 |
| 2087 MaybeObject* MacroAssembler::TryCallStub(CodeStub* stub, Condition cond) { | |
| 2088 ASSERT(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. | |
| 2089 Object* result; | |
| 2090 { MaybeObject* maybe_result = stub->TryGetCode(); | |
| 2091 if (!maybe_result->ToObject(&result)) return maybe_result; | |
| 2092 } | |
| 2093 Handle<Code> code(Code::cast(result)); | |
| 2094 Call(code, RelocInfo::CODE_TARGET, kNoASTId, cond); | |
| 2095 return result; | |
| 2096 } | |
| 2097 | |
| 2098 | |
| 2099 void MacroAssembler::TailCallStub(CodeStub* stub, Condition cond) { | 2087 void MacroAssembler::TailCallStub(CodeStub* stub, Condition cond) { |
| 2100 ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe()); | 2088 ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe()); |
| 2101 Jump(stub->GetCode(), RelocInfo::CODE_TARGET, cond); | 2089 Jump(stub->GetCode(), RelocInfo::CODE_TARGET, cond); |
| 2102 } | 2090 } |
| 2103 | 2091 |
| 2104 | 2092 |
| 2105 MaybeObject* MacroAssembler::TryTailCallStub(CodeStub* stub, Condition cond) { | |
| 2106 Object* result; | |
| 2107 { MaybeObject* maybe_result = stub->TryGetCode(); | |
| 2108 if (!maybe_result->ToObject(&result)) return maybe_result; | |
| 2109 } | |
| 2110 Jump(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET, cond); | |
| 2111 return result; | |
| 2112 } | |
| 2113 | |
| 2114 | |
| 2115 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 2093 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
| 2116 return ref0.address() - ref1.address(); | 2094 return ref0.address() - ref1.address(); |
| 2117 } | 2095 } |
| 2118 | 2096 |
| 2119 | 2097 |
| 2120 MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn( | 2098 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, |
| 2121 ExternalReference function, int stack_space) { | 2099 int stack_space) { |
| 2122 ExternalReference next_address = | 2100 ExternalReference next_address = |
| 2123 ExternalReference::handle_scope_next_address(); | 2101 ExternalReference::handle_scope_next_address(); |
| 2124 const int kNextOffset = 0; | 2102 const int kNextOffset = 0; |
| 2125 const int kLimitOffset = AddressOffset( | 2103 const int kLimitOffset = AddressOffset( |
| 2126 ExternalReference::handle_scope_limit_address(), | 2104 ExternalReference::handle_scope_limit_address(), |
| 2127 next_address); | 2105 next_address); |
| 2128 const int kLevelOffset = AddressOffset( | 2106 const int kLevelOffset = AddressOffset( |
| 2129 ExternalReference::handle_scope_level_address(), | 2107 ExternalReference::handle_scope_level_address(), |
| 2130 next_address); | 2108 next_address); |
| 2131 | 2109 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2174 ldr(r5, MemOperand(ip)); | 2152 ldr(r5, MemOperand(ip)); |
| 2175 cmp(r4, r5); | 2153 cmp(r4, r5); |
| 2176 b(ne, &promote_scheduled_exception); | 2154 b(ne, &promote_scheduled_exception); |
| 2177 | 2155 |
| 2178 // LeaveExitFrame expects unwind space to be in a register. | 2156 // LeaveExitFrame expects unwind space to be in a register. |
| 2179 mov(r4, Operand(stack_space)); | 2157 mov(r4, Operand(stack_space)); |
| 2180 LeaveExitFrame(false, r4); | 2158 LeaveExitFrame(false, r4); |
| 2181 mov(pc, lr); | 2159 mov(pc, lr); |
| 2182 | 2160 |
| 2183 bind(&promote_scheduled_exception); | 2161 bind(&promote_scheduled_exception); |
| 2184 MaybeObject* result | 2162 TailCallExternalReference( |
| 2185 = TryTailCallExternalReference( | 2163 ExternalReference(Runtime::kPromoteScheduledException, isolate()), |
| 2186 ExternalReference(Runtime::kPromoteScheduledException, isolate()), | 2164 0, |
| 2187 0, | 2165 1); |
| 2188 1); | |
| 2189 if (result->IsFailure()) { | |
| 2190 return result; | |
| 2191 } | |
| 2192 | 2166 |
| 2193 // HandleScope limit has changed. Delete allocated extensions. | 2167 // HandleScope limit has changed. Delete allocated extensions. |
| 2194 bind(&delete_allocated_handles); | 2168 bind(&delete_allocated_handles); |
| 2195 str(r5, MemOperand(r7, kLimitOffset)); | 2169 str(r5, MemOperand(r7, kLimitOffset)); |
| 2196 mov(r4, r0); | 2170 mov(r4, r0); |
| 2197 PrepareCallCFunction(1, r5); | 2171 PrepareCallCFunction(1, r5); |
| 2198 mov(r0, Operand(ExternalReference::isolate_address())); | 2172 mov(r0, Operand(ExternalReference::isolate_address())); |
| 2199 CallCFunction( | 2173 CallCFunction( |
| 2200 ExternalReference::delete_handle_scope_extensions(isolate()), 1); | 2174 ExternalReference::delete_handle_scope_extensions(isolate()), 1); |
| 2201 mov(r0, r4); | 2175 mov(r0, r4); |
| 2202 jmp(&leave_exit_frame); | 2176 jmp(&leave_exit_frame); |
| 2203 | |
| 2204 return result; | |
| 2205 } | 2177 } |
| 2206 | 2178 |
| 2207 | 2179 |
| 2208 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { | 2180 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { |
| 2209 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false; | 2181 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false; |
| 2210 return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(); | 2182 return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(); |
| 2211 } | 2183 } |
| 2212 | 2184 |
| 2213 | 2185 |
| 2214 void MacroAssembler::IllegalOperation(int num_arguments) { | 2186 void MacroAssembler::IllegalOperation(int num_arguments) { |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 int result_size) { | 2598 int result_size) { |
| 2627 // TODO(1236192): Most runtime routines don't need the number of | 2599 // TODO(1236192): Most runtime routines don't need the number of |
| 2628 // arguments passed in because it is constant. At some point we | 2600 // arguments passed in because it is constant. At some point we |
| 2629 // should remove this need and make the runtime routine entry code | 2601 // should remove this need and make the runtime routine entry code |
| 2630 // smarter. | 2602 // smarter. |
| 2631 mov(r0, Operand(num_arguments)); | 2603 mov(r0, Operand(num_arguments)); |
| 2632 JumpToExternalReference(ext); | 2604 JumpToExternalReference(ext); |
| 2633 } | 2605 } |
| 2634 | 2606 |
| 2635 | 2607 |
| 2636 MaybeObject* MacroAssembler::TryTailCallExternalReference( | |
| 2637 const ExternalReference& ext, int num_arguments, int result_size) { | |
| 2638 // TODO(1236192): Most runtime routines don't need the number of | |
| 2639 // arguments passed in because it is constant. At some point we | |
| 2640 // should remove this need and make the runtime routine entry code | |
| 2641 // smarter. | |
| 2642 mov(r0, Operand(num_arguments)); | |
| 2643 return TryJumpToExternalReference(ext); | |
| 2644 } | |
| 2645 | |
| 2646 | |
| 2647 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, | 2608 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, |
| 2648 int num_arguments, | 2609 int num_arguments, |
| 2649 int result_size) { | 2610 int result_size) { |
| 2650 TailCallExternalReference(ExternalReference(fid, isolate()), | 2611 TailCallExternalReference(ExternalReference(fid, isolate()), |
| 2651 num_arguments, | 2612 num_arguments, |
| 2652 result_size); | 2613 result_size); |
| 2653 } | 2614 } |
| 2654 | 2615 |
| 2655 | 2616 |
| 2656 void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin) { | 2617 void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin) { |
| 2657 #if defined(__thumb__) | 2618 #if defined(__thumb__) |
| 2658 // Thumb mode builtin. | 2619 // Thumb mode builtin. |
| 2659 ASSERT((reinterpret_cast<intptr_t>(builtin.address()) & 1) == 1); | 2620 ASSERT((reinterpret_cast<intptr_t>(builtin.address()) & 1) == 1); |
| 2660 #endif | 2621 #endif |
| 2661 mov(r1, Operand(builtin)); | 2622 mov(r1, Operand(builtin)); |
| 2662 CEntryStub stub(1); | 2623 CEntryStub stub(1); |
| 2663 Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 2624 Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 2664 } | 2625 } |
| 2665 | 2626 |
| 2666 | 2627 |
| 2667 MaybeObject* MacroAssembler::TryJumpToExternalReference( | |
| 2668 const ExternalReference& builtin) { | |
| 2669 #if defined(__thumb__) | |
| 2670 // Thumb mode builtin. | |
| 2671 ASSERT((reinterpret_cast<intptr_t>(builtin.address()) & 1) == 1); | |
| 2672 #endif | |
| 2673 mov(r1, Operand(builtin)); | |
| 2674 CEntryStub stub(1); | |
| 2675 return TryTailCallStub(&stub); | |
| 2676 } | |
| 2677 | |
| 2678 | |
| 2679 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, | 2628 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, |
| 2680 InvokeFlag flag, | 2629 InvokeFlag flag, |
| 2681 const CallWrapper& call_wrapper) { | 2630 const CallWrapper& call_wrapper) { |
| 2682 // You can't call a builtin without a valid frame. | 2631 // You can't call a builtin without a valid frame. |
| 2683 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 2632 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
| 2684 | 2633 |
| 2685 GetBuiltinEntry(r2, id); | 2634 GetBuiltinEntry(r2, id); |
| 2686 if (flag == CALL_FUNCTION) { | 2635 if (flag == CALL_FUNCTION) { |
| 2687 call_wrapper.BeforeCall(CallSize(r2)); | 2636 call_wrapper.BeforeCall(CallSize(r2)); |
| 2688 SetCallKind(r5, CALL_AS_METHOD); | 2637 SetCallKind(r5, CALL_AS_METHOD); |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3657 void CodePatcher::EmitCondition(Condition cond) { | 3606 void CodePatcher::EmitCondition(Condition cond) { |
| 3658 Instr instr = Assembler::instr_at(masm_.pc_); | 3607 Instr instr = Assembler::instr_at(masm_.pc_); |
| 3659 instr = (instr & ~kCondMask) | cond; | 3608 instr = (instr & ~kCondMask) | cond; |
| 3660 masm_.emit(instr); | 3609 masm_.emit(instr); |
| 3661 } | 3610 } |
| 3662 | 3611 |
| 3663 | 3612 |
| 3664 } } // namespace v8::internal | 3613 } } // namespace v8::internal |
| 3665 | 3614 |
| 3666 #endif // V8_TARGET_ARCH_ARM | 3615 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |