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 4494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4505 Label ok, fail; | 4505 Label ok, fail; |
4506 CheckMap(map, scratch, Heap::kMetaMapRootIndex, &fail, DO_SMI_CHECK); | 4506 CheckMap(map, scratch, Heap::kMetaMapRootIndex, &fail, DO_SMI_CHECK); |
4507 Branch(&ok); | 4507 Branch(&ok); |
4508 bind(&fail); | 4508 bind(&fail); |
4509 Abort(kGlobalFunctionsMustHaveInitialMap); | 4509 Abort(kGlobalFunctionsMustHaveInitialMap); |
4510 bind(&ok); | 4510 bind(&ok); |
4511 } | 4511 } |
4512 } | 4512 } |
4513 | 4513 |
4514 | 4514 |
4515 void MacroAssembler::LoadNumber(Register object, | |
4516 FPURegister dst, | |
4517 Register heap_number_map, | |
4518 Register scratch, | |
4519 Label* not_number) { | |
4520 Label is_smi, done; | |
4521 | |
4522 UntagAndJumpIfSmi(scratch, object, &is_smi); | |
4523 JumpIfNotHeapNumber(object, heap_number_map, scratch, not_number); | |
4524 | |
4525 ldc1(dst, FieldMemOperand(object, HeapNumber::kValueOffset)); | |
4526 Branch(&done); | |
4527 | |
4528 bind(&is_smi); | |
4529 mtc1(scratch, dst); | |
4530 cvt_d_w(dst, dst); | |
4531 | |
4532 bind(&done); | |
4533 } | |
4534 | |
4535 | |
4536 void MacroAssembler::LoadNumberAsInt32Double(Register object, | |
4537 DoubleRegister double_dst, | |
4538 Register heap_number_map, | |
4539 Register scratch1, | |
4540 Register scratch2, | |
4541 FPURegister double_scratch, | |
4542 Label* not_int32) { | |
4543 ASSERT(!scratch1.is(object) && !scratch2.is(object)); | |
4544 ASSERT(!scratch1.is(scratch2)); | |
4545 ASSERT(!heap_number_map.is(object) && | |
4546 !heap_number_map.is(scratch1) && | |
4547 !heap_number_map.is(scratch2)); | |
4548 | |
4549 Label done, obj_is_not_smi; | |
4550 | |
4551 UntagAndJumpIfNotSmi(scratch1, object, &obj_is_not_smi); | |
4552 mtc1(scratch1, double_scratch); | |
4553 cvt_d_w(double_dst, double_scratch); | |
4554 Branch(&done); | |
4555 | |
4556 bind(&obj_is_not_smi); | |
4557 JumpIfNotHeapNumber(object, heap_number_map, scratch1, not_int32); | |
4558 | |
4559 // Load the number. | |
4560 // Load the double value. | |
4561 ldc1(double_dst, FieldMemOperand(object, HeapNumber::kValueOffset)); | |
4562 | |
4563 Register except_flag = scratch2; | |
4564 EmitFPUTruncate(kRoundToZero, | |
4565 scratch1, | |
4566 double_dst, | |
4567 at, | |
4568 double_scratch, | |
4569 except_flag, | |
4570 kCheckForInexactConversion); | |
4571 | |
4572 // Jump to not_int32 if the operation did not succeed. | |
4573 Branch(not_int32, ne, except_flag, Operand(zero_reg)); | |
4574 bind(&done); | |
4575 } | |
4576 | |
4577 | |
4578 void MacroAssembler::LoadNumberAsInt32(Register object, | |
4579 Register dst, | |
4580 Register heap_number_map, | |
4581 Register scratch1, | |
4582 Register scratch2, | |
4583 FPURegister double_scratch0, | |
4584 FPURegister double_scratch1, | |
4585 Label* not_int32) { | |
4586 ASSERT(!dst.is(object)); | |
4587 ASSERT(!scratch1.is(object) && !scratch2.is(object)); | |
4588 ASSERT(!scratch1.is(scratch2)); | |
4589 | |
4590 Label done, maybe_undefined; | |
4591 | |
4592 UntagAndJumpIfSmi(dst, object, &done); | |
4593 | |
4594 JumpIfNotHeapNumber(object, heap_number_map, scratch1, &maybe_undefined); | |
4595 | |
4596 // Object is a heap number. | |
4597 // Convert the floating point value to a 32-bit integer. | |
4598 // Load the double value. | |
4599 ldc1(double_scratch0, FieldMemOperand(object, HeapNumber::kValueOffset)); | |
4600 | |
4601 Register except_flag = scratch2; | |
4602 EmitFPUTruncate(kRoundToZero, | |
4603 dst, | |
4604 double_scratch0, | |
4605 scratch1, | |
4606 double_scratch1, | |
4607 except_flag, | |
4608 kCheckForInexactConversion); | |
4609 | |
4610 // Jump to not_int32 if the operation did not succeed. | |
4611 Branch(not_int32, ne, except_flag, Operand(zero_reg)); | |
4612 Branch(&done); | |
4613 | |
4614 bind(&maybe_undefined); | |
4615 LoadRoot(at, Heap::kUndefinedValueRootIndex); | |
4616 Branch(not_int32, ne, object, Operand(at)); | |
4617 // |undefined| is truncated to 0. | |
4618 li(dst, Operand(Smi::FromInt(0))); | |
4619 // Fall through. | |
4620 | |
4621 bind(&done); | |
4622 } | |
4623 | |
4624 | |
4625 void MacroAssembler::Prologue(PrologueFrameMode frame_mode) { | 4515 void MacroAssembler::Prologue(PrologueFrameMode frame_mode) { |
4626 if (frame_mode == BUILD_STUB_FRAME) { | 4516 if (frame_mode == BUILD_STUB_FRAME) { |
4627 Push(ra, fp, cp); | 4517 Push(ra, fp, cp); |
4628 Push(Smi::FromInt(StackFrame::STUB)); | 4518 Push(Smi::FromInt(StackFrame::STUB)); |
4629 // Adjust FP to point to saved FP. | 4519 // Adjust FP to point to saved FP. |
4630 Addu(fp, sp, Operand(2 * kPointerSize)); | 4520 Addu(fp, sp, Operand(2 * kPointerSize)); |
4631 } else { | 4521 } else { |
4632 PredictableCodeSizeScope predictible_code_size_scope( | 4522 PredictableCodeSizeScope predictible_code_size_scope( |
4633 this, kNoCodeAgeSequenceLength * Assembler::kInstrSize); | 4523 this, kNoCodeAgeSequenceLength * Assembler::kInstrSize); |
4634 // The following three instructions must remain together and unmodified | 4524 // The following three instructions must remain together and unmodified |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5770 opcode == BGTZL); | 5660 opcode == BGTZL); |
5771 opcode = (cond == eq) ? BEQ : BNE; | 5661 opcode = (cond == eq) ? BEQ : BNE; |
5772 instr = (instr & ~kOpcodeMask) | opcode; | 5662 instr = (instr & ~kOpcodeMask) | opcode; |
5773 masm_.emit(instr); | 5663 masm_.emit(instr); |
5774 } | 5664 } |
5775 | 5665 |
5776 | 5666 |
5777 } } // namespace v8::internal | 5667 } } // namespace v8::internal |
5778 | 5668 |
5779 #endif // V8_TARGET_ARCH_MIPS | 5669 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |