Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: src/arm/macro-assembler-arm.cc

Issue 72813004: Fixed crashes exposed though fuzzing. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nits Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/full-codegen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 Label is_object;
3399 SmiTst(string);
3400 ThrowIf(eq, kNonObject);
3401
3402 ldr(ip, FieldMemOperand(string, HeapObject::kMapOffset));
3403 ldrb(ip, FieldMemOperand(ip, Map::kInstanceTypeOffset));
3404
3405 and_(ip, ip, Operand(kStringRepresentationMask | kStringEncodingMask));
3406 cmp(ip, Operand(encoding_mask));
3407 ThrowIf(ne, kUnexpectedStringType);
3408
3409 // The index is assumed to be untagged coming in, tag it to compare with the
3410 // string length without using a temp register, it is restored at the end of
3411 // this function.
3412 Label index_tag_ok, index_tag_bad;
3413 TrySmiTag(index, index, &index_tag_bad);
3414 b(&index_tag_ok);
3415 bind(&index_tag_bad);
3416 Throw(kIndexIsTooLarge);
3417 bind(&index_tag_ok);
3418
3419 ldr(ip, FieldMemOperand(string, String::kLengthOffset));
3420 cmp(index, ip);
3421 ThrowIf(ge, kIndexIsTooLarge);
3422
3423 cmp(index, Operand(Smi::FromInt(0)));
3424 ThrowIf(lt, kIndexIsNegative);
3425
3426 SmiUntag(index, index);
3427 }
3428
3429
3394 void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, 3430 void MacroAssembler::PrepareCallCFunction(int num_reg_arguments,
3395 int num_double_arguments, 3431 int num_double_arguments,
3396 Register scratch) { 3432 Register scratch) {
3397 int frame_alignment = ActivationFrameAlignment(); 3433 int frame_alignment = ActivationFrameAlignment();
3398 int stack_passed_arguments = CalculateStackPassedWords( 3434 int stack_passed_arguments = CalculateStackPassedWords(
3399 num_reg_arguments, num_double_arguments); 3435 num_reg_arguments, num_double_arguments);
3400 if (frame_alignment > kPointerSize) { 3436 if (frame_alignment > kPointerSize) {
3401 // Make stack end at alignment and make room for num_arguments - 4 words 3437 // Make stack end at alignment and make room for num_arguments - 4 words
3402 // and the original value of sp. 3438 // and the original value of sp.
3403 mov(scratch, sp); 3439 mov(scratch, sp);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3767 bic(result_reg, ip, Operand(kVFPRoundingModeMask)); 3803 bic(result_reg, ip, Operand(kVFPRoundingModeMask));
3768 vmsr(result_reg); 3804 vmsr(result_reg);
3769 vcvt_s32_f64(double_scratch.low(), input_reg, kFPSCRRounding); 3805 vcvt_s32_f64(double_scratch.low(), input_reg, kFPSCRRounding);
3770 vmov(result_reg, double_scratch.low()); 3806 vmov(result_reg, double_scratch.low());
3771 // Restore FPSCR. 3807 // Restore FPSCR.
3772 vmsr(ip); 3808 vmsr(ip);
3773 bind(&done); 3809 bind(&done);
3774 } 3810 }
3775 3811
3776 3812
3813 void MacroAssembler::Throw(BailoutReason reason) {
3814 Label throw_start;
3815 bind(&throw_start);
3816 #ifdef DEBUG
3817 const char* msg = GetBailoutReason(reason);
3818 if (msg != NULL) {
3819 RecordComment("Throw message: ");
3820 RecordComment(msg);
3821 }
3822 #endif
3823
3824 mov(r0, Operand(Smi::FromInt(reason)));
3825 push(r0);
3826 // Disable stub call restrictions to always allow calls to throw.
3827 if (!has_frame_) {
3828 // We don't actually want to generate a pile of code for this, so just
3829 // claim there is a stack frame, without generating one.
3830 FrameScope scope(this, StackFrame::NONE);
3831 CallRuntime(Runtime::kThrowMessage, 1);
3832 } else {
3833 CallRuntime(Runtime::kThrowMessage, 1);
3834 }
3835 // will not return here
3836 if (is_const_pool_blocked()) {
3837 // If the calling code cares throw the exact number of
3838 // instructions generated, we insert padding here to keep the size
3839 // of the ThrowMessage macro constant.
3840 static const int kExpectedThrowMessageInstructions = 10;
3841 int throw_instructions = InstructionsGeneratedSince(&throw_start);
3842 ASSERT(throw_instructions <= kExpectedThrowMessageInstructions);
3843 while (throw_instructions++ < kExpectedThrowMessageInstructions) {
3844 nop();
3845 }
3846 }
3847 }
3848
3849
3850 void MacroAssembler::ThrowIf(Condition cc, BailoutReason reason) {
3851 Label L;
3852 b(NegateCondition(cc), &L);
3853 Throw(reason);
3854 // will not return here
3855 bind(&L);
3856 }
3857
3858
3777 void MacroAssembler::LoadInstanceDescriptors(Register map, 3859 void MacroAssembler::LoadInstanceDescriptors(Register map,
3778 Register descriptors) { 3860 Register descriptors) {
3779 ldr(descriptors, FieldMemOperand(map, Map::kDescriptorsOffset)); 3861 ldr(descriptors, FieldMemOperand(map, Map::kDescriptorsOffset));
3780 } 3862 }
3781 3863
3782 3864
3783 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) { 3865 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) {
3784 ldr(dst, FieldMemOperand(map, Map::kBitField3Offset)); 3866 ldr(dst, FieldMemOperand(map, Map::kBitField3Offset));
3785 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst); 3867 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst);
3786 } 3868 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3966 void CodePatcher::EmitCondition(Condition cond) { 4048 void CodePatcher::EmitCondition(Condition cond) {
3967 Instr instr = Assembler::instr_at(masm_.pc_); 4049 Instr instr = Assembler::instr_at(masm_.pc_);
3968 instr = (instr & ~kCondMask) | cond; 4050 instr = (instr & ~kCondMask) | cond;
3969 masm_.emit(instr); 4051 masm_.emit(instr);
3970 } 4052 }
3971 4053
3972 4054
3973 } } // namespace v8::internal 4055 } } // namespace v8::internal
3974 4056
3975 #endif // V8_TARGET_ARCH_ARM 4057 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698