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 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3198 } else { | 3198 } else { |
3199 Move(r2, reg); | 3199 Move(r2, reg); |
3200 vmov(r0, r1, dreg); | 3200 vmov(r0, r1, dreg); |
3201 } | 3201 } |
3202 } | 3202 } |
3203 | 3203 |
3204 | 3204 |
3205 void MacroAssembler::CallCFunction(ExternalReference function, | 3205 void MacroAssembler::CallCFunction(ExternalReference function, |
3206 int num_reg_arguments, | 3206 int num_reg_arguments, |
3207 int num_double_arguments) { | 3207 int num_double_arguments) { |
3208 CallCFunctionHelper(no_reg, | 3208 mov(ip, Operand(function)); |
3209 function, | 3209 CallCFunctionHelper(ip, num_reg_arguments, num_double_arguments); |
3210 ip, | |
3211 num_reg_arguments, | |
3212 num_double_arguments); | |
3213 } | 3210 } |
3214 | 3211 |
3215 | 3212 |
3216 void MacroAssembler::CallCFunction(Register function, | 3213 void MacroAssembler::CallCFunction(Register function, |
3217 Register scratch, | 3214 int num_reg_arguments, |
3218 int num_reg_arguments, | 3215 int num_double_arguments) { |
3219 int num_double_arguments) { | 3216 CallCFunctionHelper(function, num_reg_arguments, num_double_arguments); |
3220 CallCFunctionHelper(function, | |
3221 ExternalReference::the_hole_value_location(isolate()), | |
3222 scratch, | |
3223 num_reg_arguments, | |
3224 num_double_arguments); | |
3225 } | 3217 } |
3226 | 3218 |
3227 | 3219 |
3228 void MacroAssembler::CallCFunction(ExternalReference function, | 3220 void MacroAssembler::CallCFunction(ExternalReference function, |
3229 int num_arguments) { | 3221 int num_arguments) { |
3230 CallCFunction(function, num_arguments, 0); | 3222 CallCFunction(function, num_arguments, 0); |
3231 } | 3223 } |
3232 | 3224 |
3233 | 3225 |
3234 void MacroAssembler::CallCFunction(Register function, | 3226 void MacroAssembler::CallCFunction(Register function, |
3235 Register scratch, | |
3236 int num_arguments) { | 3227 int num_arguments) { |
3237 CallCFunction(function, scratch, num_arguments, 0); | 3228 CallCFunction(function, num_arguments, 0); |
3238 } | 3229 } |
3239 | 3230 |
3240 | 3231 |
3241 void MacroAssembler::CallCFunctionHelper(Register function, | 3232 void MacroAssembler::CallCFunctionHelper(Register function, |
3242 ExternalReference function_reference, | |
3243 Register scratch, | |
3244 int num_reg_arguments, | 3233 int num_reg_arguments, |
3245 int num_double_arguments) { | 3234 int num_double_arguments) { |
3246 ASSERT(has_frame()); | 3235 ASSERT(has_frame()); |
3247 // Make sure that the stack is aligned before calling a C function unless | 3236 // Make sure that the stack is aligned before calling a C function unless |
3248 // running in the simulator. The simulator has its own alignment check which | 3237 // running in the simulator. The simulator has its own alignment check which |
3249 // provides more information. | 3238 // provides more information. |
3250 #if defined(V8_HOST_ARCH_ARM) | 3239 #if defined(V8_HOST_ARCH_ARM) |
3251 if (emit_debug_code()) { | 3240 if (emit_debug_code()) { |
3252 int frame_alignment = OS::ActivationFrameAlignment(); | 3241 int frame_alignment = OS::ActivationFrameAlignment(); |
3253 int frame_alignment_mask = frame_alignment - 1; | 3242 int frame_alignment_mask = frame_alignment - 1; |
3254 if (frame_alignment > kPointerSize) { | 3243 if (frame_alignment > kPointerSize) { |
3255 ASSERT(IsPowerOf2(frame_alignment)); | 3244 ASSERT(IsPowerOf2(frame_alignment)); |
3256 Label alignment_as_expected; | 3245 Label alignment_as_expected; |
3257 tst(sp, Operand(frame_alignment_mask)); | 3246 tst(sp, Operand(frame_alignment_mask)); |
3258 b(eq, &alignment_as_expected); | 3247 b(eq, &alignment_as_expected); |
3259 // Don't use Check here, as it will call Runtime_Abort possibly | 3248 // Don't use Check here, as it will call Runtime_Abort possibly |
3260 // re-entering here. | 3249 // re-entering here. |
3261 stop("Unexpected alignment"); | 3250 stop("Unexpected alignment"); |
3262 bind(&alignment_as_expected); | 3251 bind(&alignment_as_expected); |
3263 } | 3252 } |
3264 } | 3253 } |
3265 #endif | 3254 #endif |
3266 | 3255 |
3267 // Just call directly. The function called cannot cause a GC, or | 3256 // Just call directly. The function called cannot cause a GC, or |
3268 // allow preemption, so the return address in the link register | 3257 // allow preemption, so the return address in the link register |
3269 // stays correct. | 3258 // stays correct. |
3270 if (function.is(no_reg)) { | |
3271 mov(scratch, Operand(function_reference)); | |
3272 function = scratch; | |
3273 } | |
3274 Call(function); | 3259 Call(function); |
3275 int stack_passed_arguments = CalculateStackPassedWords( | 3260 int stack_passed_arguments = CalculateStackPassedWords( |
3276 num_reg_arguments, num_double_arguments); | 3261 num_reg_arguments, num_double_arguments); |
3277 if (ActivationFrameAlignment() > kPointerSize) { | 3262 if (ActivationFrameAlignment() > kPointerSize) { |
3278 ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); | 3263 ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); |
3279 } else { | 3264 } else { |
3280 add(sp, sp, Operand(stack_passed_arguments * sizeof(kPointerSize))); | 3265 add(sp, sp, Operand(stack_passed_arguments * sizeof(kPointerSize))); |
3281 } | 3266 } |
3282 } | 3267 } |
3283 | 3268 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3576 void CodePatcher::EmitCondition(Condition cond) { | 3561 void CodePatcher::EmitCondition(Condition cond) { |
3577 Instr instr = Assembler::instr_at(masm_.pc_); | 3562 Instr instr = Assembler::instr_at(masm_.pc_); |
3578 instr = (instr & ~kCondMask) | cond; | 3563 instr = (instr & ~kCondMask) | cond; |
3579 masm_.emit(instr); | 3564 masm_.emit(instr); |
3580 } | 3565 } |
3581 | 3566 |
3582 | 3567 |
3583 } } // namespace v8::internal | 3568 } } // namespace v8::internal |
3584 | 3569 |
3585 #endif // V8_TARGET_ARCH_ARM | 3570 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |