Chromium Code Reviews| 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 3373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3384 num_reg_arguments += 2 * num_double_arguments; | 3384 num_reg_arguments += 2 * num_double_arguments; |
| 3385 } | 3385 } |
| 3386 // Up to four simple arguments are passed in registers r0..r3. | 3386 // Up to four simple arguments are passed in registers r0..r3. |
| 3387 if (num_reg_arguments > kRegisterPassedArguments) { | 3387 if (num_reg_arguments > kRegisterPassedArguments) { |
| 3388 stack_passed_words += num_reg_arguments - kRegisterPassedArguments; | 3388 stack_passed_words += num_reg_arguments - kRegisterPassedArguments; |
| 3389 } | 3389 } |
| 3390 return stack_passed_words; | 3390 return stack_passed_words; |
| 3391 } | 3391 } |
| 3392 | 3392 |
| 3393 | 3393 |
| 3394 void MacroAssembler::EmitSeqStringSetCharCheck(Register string, | |
| 3395 Register index, | |
| 3396 Register value, | |
| 3397 uint32_t encoding_mask) { | |
| 3398 SmiTst(index); | |
| 3399 ThrowIfNot(eq, kNonSmiIndex); | |
| 3400 SmiTst(value); | |
| 3401 ThrowIfNot(eq, kNonSmiValue); | |
| 3402 | |
| 3403 Label is_object; | |
| 3404 tst(string, Operand(kSmiTagMask)); | |
| 3405 b(ne, &is_object); | |
|
Yang
2013/11/19 14:35:29
Use ThrowIfNot(ne, kNonObject) instead?
Personall
danno
2013/11/19 16:19:14
Done.
| |
| 3406 Throw(kNonObject); | |
| 3407 bind(&is_object); | |
| 3408 | |
| 3409 | |
| 3410 ldr(ip, FieldMemOperand(string, String::kLengthOffset)); | |
| 3411 cmp(index, ip); | |
| 3412 ThrowIfNot(lt, kIndexIsTooLarge); | |
| 3413 | |
| 3414 cmp(index, Operand(Smi::FromInt(0))); | |
| 3415 ThrowIfNot(ge, kIndexIsNegative); | |
| 3416 | |
| 3417 ldr(ip, FieldMemOperand(string, HeapObject::kMapOffset)); | |
| 3418 ldrb(ip, FieldMemOperand(ip, Map::kInstanceTypeOffset)); | |
| 3419 | |
| 3420 and_(ip, ip, Operand(kStringRepresentationMask | kStringEncodingMask)); | |
| 3421 cmp(ip, Operand(encoding_mask)); | |
| 3422 ThrowIfNot(eq, kUnexpectedStringType); | |
| 3423 } | |
| 3424 | |
| 3425 | |
| 3394 void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, | 3426 void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, |
| 3395 int num_double_arguments, | 3427 int num_double_arguments, |
| 3396 Register scratch) { | 3428 Register scratch) { |
| 3397 int frame_alignment = ActivationFrameAlignment(); | 3429 int frame_alignment = ActivationFrameAlignment(); |
| 3398 int stack_passed_arguments = CalculateStackPassedWords( | 3430 int stack_passed_arguments = CalculateStackPassedWords( |
| 3399 num_reg_arguments, num_double_arguments); | 3431 num_reg_arguments, num_double_arguments); |
| 3400 if (frame_alignment > kPointerSize) { | 3432 if (frame_alignment > kPointerSize) { |
| 3401 // Make stack end at alignment and make room for num_arguments - 4 words | 3433 // Make stack end at alignment and make room for num_arguments - 4 words |
| 3402 // and the original value of sp. | 3434 // and the original value of sp. |
| 3403 mov(scratch, sp); | 3435 mov(scratch, sp); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3767 bic(result_reg, ip, Operand(kVFPRoundingModeMask)); | 3799 bic(result_reg, ip, Operand(kVFPRoundingModeMask)); |
| 3768 vmsr(result_reg); | 3800 vmsr(result_reg); |
| 3769 vcvt_s32_f64(double_scratch.low(), input_reg, kFPSCRRounding); | 3801 vcvt_s32_f64(double_scratch.low(), input_reg, kFPSCRRounding); |
| 3770 vmov(result_reg, double_scratch.low()); | 3802 vmov(result_reg, double_scratch.low()); |
| 3771 // Restore FPSCR. | 3803 // Restore FPSCR. |
| 3772 vmsr(ip); | 3804 vmsr(ip); |
| 3773 bind(&done); | 3805 bind(&done); |
| 3774 } | 3806 } |
| 3775 | 3807 |
| 3776 | 3808 |
| 3809 void MacroAssembler::Throw(BailoutReason reason) { | |
| 3810 Label abort_start; | |
| 3811 bind(&abort_start); | |
| 3812 // We want to pass the msg string like a smi to avoid GC | |
| 3813 // problems, however msg is not guaranteed to be aligned | |
| 3814 // properly. Instead, we pass an aligned pointer that is | |
| 3815 // a proper v8 smi, but also pass the alignment difference | |
| 3816 // from the real pointer as a smi. | |
| 3817 const char* msg = GetBailoutReason(reason); | |
| 3818 intptr_t p1 = reinterpret_cast<intptr_t>(msg); | |
| 3819 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; | |
|
Yang
2013/11/19 14:35:29
How about just encoding the reason enum as smi and
danno
2013/11/19 16:19:14
Done.
| |
| 3820 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); | |
| 3821 #ifdef DEBUG | |
| 3822 if (msg != NULL) { | |
| 3823 RecordComment("Throw message: "); | |
| 3824 RecordComment(msg); | |
| 3825 } | |
| 3826 #endif | |
| 3827 | |
| 3828 mov(r0, Operand(p0)); | |
| 3829 push(r0); | |
| 3830 mov(r0, Operand(Smi::FromInt(p1 - p0))); | |
| 3831 push(r0); | |
| 3832 // Disable stub call restrictions to always allow calls to throw. | |
| 3833 if (!has_frame_) { | |
| 3834 // We don't actually want to generate a pile of code for this, so just | |
| 3835 // claim there is a stack frame, without generating one. | |
| 3836 FrameScope scope(this, StackFrame::NONE); | |
| 3837 CallRuntime(Runtime::kThrowMessage, 2); | |
| 3838 } else { | |
| 3839 CallRuntime(Runtime::kThrowMessage, 2); | |
| 3840 } | |
| 3841 // will not return here | |
| 3842 if (is_const_pool_blocked()) { | |
| 3843 // If the calling code cares about the exact number of | |
| 3844 // instructions generated, we insert padding here to keep the size | |
| 3845 // of the Abort macro constant. | |
| 3846 static const int kExpectedAbortInstructions = 10; | |
| 3847 int abort_instructions = InstructionsGeneratedSince(&abort_start); | |
| 3848 ASSERT(abort_instructions <= kExpectedAbortInstructions); | |
| 3849 while (abort_instructions++ < kExpectedAbortInstructions) { | |
| 3850 nop(); | |
| 3851 } | |
| 3852 } | |
| 3853 } | |
| 3854 | |
| 3855 | |
| 3856 void MacroAssembler::ThrowIfNot(Condition cc, BailoutReason reason) { | |
| 3857 Label L; | |
| 3858 b(cc, &L); | |
| 3859 Throw(reason); | |
| 3860 // will not return here | |
| 3861 bind(&L); | |
| 3862 } | |
| 3863 | |
| 3864 | |
| 3777 void MacroAssembler::LoadInstanceDescriptors(Register map, | 3865 void MacroAssembler::LoadInstanceDescriptors(Register map, |
| 3778 Register descriptors) { | 3866 Register descriptors) { |
| 3779 ldr(descriptors, FieldMemOperand(map, Map::kDescriptorsOffset)); | 3867 ldr(descriptors, FieldMemOperand(map, Map::kDescriptorsOffset)); |
| 3780 } | 3868 } |
| 3781 | 3869 |
| 3782 | 3870 |
| 3783 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) { | 3871 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) { |
| 3784 ldr(dst, FieldMemOperand(map, Map::kBitField3Offset)); | 3872 ldr(dst, FieldMemOperand(map, Map::kBitField3Offset)); |
| 3785 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst); | 3873 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst); |
| 3786 } | 3874 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3966 void CodePatcher::EmitCondition(Condition cond) { | 4054 void CodePatcher::EmitCondition(Condition cond) { |
| 3967 Instr instr = Assembler::instr_at(masm_.pc_); | 4055 Instr instr = Assembler::instr_at(masm_.pc_); |
| 3968 instr = (instr & ~kCondMask) | cond; | 4056 instr = (instr & ~kCondMask) | cond; |
| 3969 masm_.emit(instr); | 4057 masm_.emit(instr); |
| 3970 } | 4058 } |
| 3971 | 4059 |
| 3972 | 4060 |
| 3973 } } // namespace v8::internal | 4061 } } // namespace v8::internal |
| 3974 | 4062 |
| 3975 #endif // V8_TARGET_ARCH_ARM | 4063 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |