OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include "src/base/division-by-constant.h" | 9 #include "src/base/division-by-constant.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 4229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4240 Branch(done); | 4240 Branch(done); |
4241 } | 4241 } |
4242 } else { | 4242 } else { |
4243 Jump(adaptor, RelocInfo::CODE_TARGET); | 4243 Jump(adaptor, RelocInfo::CODE_TARGET); |
4244 } | 4244 } |
4245 bind(®ular_invoke); | 4245 bind(®ular_invoke); |
4246 } | 4246 } |
4247 } | 4247 } |
4248 | 4248 |
4249 | 4249 |
4250 void MacroAssembler::FloodFunctionIfStepping(Register fun, Register new_target, | 4250 void MacroAssembler::InvokeCode(Register code, |
4251 const ParameterCount& expected, | 4251 Register new_target, |
4252 const ParameterCount& actual) { | 4252 const ParameterCount& expected, |
4253 Label skip_flooding; | 4253 const ParameterCount& actual, |
4254 ExternalReference debug_step_action = | 4254 InvokeFlag flag, |
4255 ExternalReference::debug_last_step_action_address(isolate()); | 4255 const CallWrapper& call_wrapper) { |
4256 li(t0, Operand(debug_step_action)); | |
4257 lb(t0, MemOperand(t0)); | |
4258 Branch(&skip_flooding, ne, t0, Operand(StepIn)); | |
4259 { | |
4260 FrameScope frame(this, | |
4261 has_frame() ? StackFrame::NONE : StackFrame::INTERNAL); | |
4262 if (expected.is_reg()) { | |
4263 SmiTag(expected.reg()); | |
4264 Push(expected.reg()); | |
4265 } | |
4266 if (actual.is_reg()) { | |
4267 SmiTag(actual.reg()); | |
4268 Push(actual.reg()); | |
4269 } | |
4270 if (new_target.is_valid()) { | |
4271 Push(new_target); | |
4272 } | |
4273 Push(fun); | |
4274 Push(fun); | |
4275 CallRuntime(Runtime::kDebugPrepareStepInIfStepping, 1); | |
4276 Pop(fun); | |
4277 if (new_target.is_valid()) { | |
4278 Pop(new_target); | |
4279 } | |
4280 if (actual.is_reg()) { | |
4281 Pop(actual.reg()); | |
4282 SmiUntag(actual.reg()); | |
4283 } | |
4284 if (expected.is_reg()) { | |
4285 Pop(expected.reg()); | |
4286 SmiUntag(expected.reg()); | |
4287 } | |
4288 } | |
4289 bind(&skip_flooding); | |
4290 } | |
4291 | |
4292 | |
4293 void MacroAssembler::InvokeFunctionCode(Register function, Register new_target, | |
4294 const ParameterCount& expected, | |
4295 const ParameterCount& actual, | |
4296 InvokeFlag flag, | |
4297 const CallWrapper& call_wrapper) { | |
4298 // You can't call a function without a valid frame. | 4256 // You can't call a function without a valid frame. |
4299 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 4257 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
4300 DCHECK(function.is(a1)); | 4258 |
| 4259 // Ensure new target is passed in the correct register. Otherwise clear the |
| 4260 // appropriate register in case new target is not given. |
4301 DCHECK_IMPLIES(new_target.is_valid(), new_target.is(a3)); | 4261 DCHECK_IMPLIES(new_target.is_valid(), new_target.is(a3)); |
4302 | |
4303 if (call_wrapper.NeedsDebugStepCheck()) { | |
4304 FloodFunctionIfStepping(function, new_target, expected, actual); | |
4305 } | |
4306 | |
4307 // Clear the new.target register if not given. | |
4308 if (!new_target.is_valid()) { | 4262 if (!new_target.is_valid()) { |
4309 LoadRoot(a3, Heap::kUndefinedValueRootIndex); | 4263 LoadRoot(a3, Heap::kUndefinedValueRootIndex); |
4310 } | 4264 } |
4311 | 4265 |
4312 Label done; | 4266 Label done; |
4313 bool definitely_mismatches = false; | 4267 bool definitely_mismatches = false; |
4314 InvokePrologue(expected, actual, &done, &definitely_mismatches, flag, | 4268 InvokePrologue(expected, actual, &done, &definitely_mismatches, flag, |
4315 call_wrapper); | 4269 call_wrapper); |
4316 if (!definitely_mismatches) { | 4270 if (!definitely_mismatches) { |
4317 // We call indirectly through the code field in the function to | |
4318 // allow recompilation to take effect without changing any of the | |
4319 // call sites. | |
4320 Register code = t0; | |
4321 ld(code, FieldMemOperand(function, JSFunction::kCodeEntryOffset)); | |
4322 if (flag == CALL_FUNCTION) { | 4271 if (flag == CALL_FUNCTION) { |
4323 call_wrapper.BeforeCall(CallSize(code)); | 4272 call_wrapper.BeforeCall(CallSize(code)); |
4324 Call(code); | 4273 Call(code); |
4325 call_wrapper.AfterCall(); | 4274 call_wrapper.AfterCall(); |
4326 } else { | 4275 } else { |
4327 DCHECK(flag == JUMP_FUNCTION); | 4276 DCHECK(flag == JUMP_FUNCTION); |
4328 Jump(code); | 4277 Jump(code); |
4329 } | 4278 } |
4330 // Continue here if InvokePrologue does handle the invocation due to | 4279 // Continue here if InvokePrologue does handle the invocation due to |
4331 // mismatched parameter counts. | 4280 // mismatched parameter counts. |
4332 bind(&done); | 4281 bind(&done); |
4333 } | 4282 } |
4334 } | 4283 } |
4335 | 4284 |
4336 | 4285 |
4337 void MacroAssembler::InvokeFunction(Register function, | 4286 void MacroAssembler::InvokeFunction(Register function, |
4338 Register new_target, | 4287 Register new_target, |
4339 const ParameterCount& actual, | 4288 const ParameterCount& actual, |
4340 InvokeFlag flag, | 4289 InvokeFlag flag, |
4341 const CallWrapper& call_wrapper) { | 4290 const CallWrapper& call_wrapper) { |
4342 // You can't call a function without a valid frame. | 4291 // You can't call a function without a valid frame. |
4343 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 4292 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
4344 | 4293 |
4345 // Contract with called JS functions requires that function is passed in a1. | 4294 // Contract with called JS functions requires that function is passed in a1. |
4346 DCHECK(function.is(a1)); | 4295 DCHECK(function.is(a1)); |
4347 Register expected_reg = a2; | 4296 Register expected_reg = a2; |
4348 Register temp_reg = t0; | 4297 Register code_reg = t0; |
4349 ld(temp_reg, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 4298 ld(code_reg, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
4350 ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 4299 ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
4351 // The argument count is stored as int32_t on 64-bit platforms. | 4300 // The argument count is stored as int32_t on 64-bit platforms. |
4352 // TODO(plind): Smi on 32-bit platforms. | 4301 // TODO(plind): Smi on 32-bit platforms. |
4353 lw(expected_reg, | 4302 lw(expected_reg, |
4354 FieldMemOperand(temp_reg, | 4303 FieldMemOperand(code_reg, |
4355 SharedFunctionInfo::kFormalParameterCountOffset)); | 4304 SharedFunctionInfo::kFormalParameterCountOffset)); |
| 4305 ld(code_reg, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
4356 ParameterCount expected(expected_reg); | 4306 ParameterCount expected(expected_reg); |
4357 InvokeFunctionCode(a1, new_target, expected, actual, flag, call_wrapper); | 4307 InvokeCode(code_reg, new_target, expected, actual, flag, call_wrapper); |
4358 } | 4308 } |
4359 | 4309 |
4360 | 4310 |
4361 void MacroAssembler::InvokeFunction(Register function, | 4311 void MacroAssembler::InvokeFunction(Register function, |
4362 const ParameterCount& expected, | 4312 const ParameterCount& expected, |
4363 const ParameterCount& actual, | 4313 const ParameterCount& actual, |
4364 InvokeFlag flag, | 4314 InvokeFlag flag, |
4365 const CallWrapper& call_wrapper) { | 4315 const CallWrapper& call_wrapper) { |
4366 // You can't call a function without a valid frame. | 4316 // You can't call a function without a valid frame. |
4367 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 4317 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
4368 | 4318 |
4369 // Contract with called JS functions requires that function is passed in a1. | 4319 // Contract with called JS functions requires that function is passed in a1. |
4370 DCHECK(function.is(a1)); | 4320 DCHECK(function.is(a1)); |
4371 | 4321 |
4372 // Get the function and setup the context. | 4322 // Get the function and setup the context. |
4373 ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 4323 ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
4374 | 4324 |
4375 InvokeFunctionCode(a1, no_reg, expected, actual, flag, call_wrapper); | 4325 // We call indirectly through the code field in the function to |
| 4326 // allow recompilation to take effect without changing any of the |
| 4327 // call sites. |
| 4328 ld(t0, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
| 4329 InvokeCode(t0, no_reg, expected, actual, flag, call_wrapper); |
4376 } | 4330 } |
4377 | 4331 |
4378 | 4332 |
4379 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, | 4333 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
4380 const ParameterCount& expected, | 4334 const ParameterCount& expected, |
4381 const ParameterCount& actual, | 4335 const ParameterCount& actual, |
4382 InvokeFlag flag, | 4336 InvokeFlag flag, |
4383 const CallWrapper& call_wrapper) { | 4337 const CallWrapper& call_wrapper) { |
4384 li(a1, function); | 4338 li(a1, function); |
4385 InvokeFunction(a1, expected, actual, flag, call_wrapper); | 4339 InvokeFunction(a1, expected, actual, flag, call_wrapper); |
(...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6310 if (mag.shift > 0) sra(result, result, mag.shift); | 6264 if (mag.shift > 0) sra(result, result, mag.shift); |
6311 srl(at, dividend, 31); | 6265 srl(at, dividend, 31); |
6312 Addu(result, result, Operand(at)); | 6266 Addu(result, result, Operand(at)); |
6313 } | 6267 } |
6314 | 6268 |
6315 | 6269 |
6316 } // namespace internal | 6270 } // namespace internal |
6317 } // namespace v8 | 6271 } // namespace v8 |
6318 | 6272 |
6319 #endif // V8_TARGET_ARCH_MIPS64 | 6273 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |