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

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

Issue 68793008: MIPS: Fixed crashes exposed though fuzzing. (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: 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
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | no next file » | 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 5033 matching lines...) Expand 10 before | Expand all | Expand 10 after
5044 5044
5045 // Up to four simple arguments are passed in registers a0..a3. 5045 // Up to four simple arguments are passed in registers a0..a3.
5046 if (num_reg_arguments > kRegisterPassedArguments) { 5046 if (num_reg_arguments > kRegisterPassedArguments) {
5047 stack_passed_words += num_reg_arguments - kRegisterPassedArguments; 5047 stack_passed_words += num_reg_arguments - kRegisterPassedArguments;
5048 } 5048 }
5049 stack_passed_words += kCArgSlotCount; 5049 stack_passed_words += kCArgSlotCount;
5050 return stack_passed_words; 5050 return stack_passed_words;
5051 } 5051 }
5052 5052
5053 5053
5054 void MacroAssembler::EmitSeqStringSetCharCheck(Register string,
5055 Register index,
5056 Register value,
5057 Register scratch,
5058 uint32_t encoding_mask) {
5059 Label is_object;
5060 And(at, string, Operand(kSmiTagMask));
5061 ThrowIf(eq, kNonObject, at, Operand(zero_reg));
5062
5063 lw(at, FieldMemOperand(string, HeapObject::kMapOffset));
5064 lbu(at, FieldMemOperand(at, Map::kInstanceTypeOffset));
5065
5066 andi(at, at, kStringRepresentationMask | kStringEncodingMask);
5067 li(scratch, Operand(encoding_mask));
5068 ThrowIf(ne, kUnexpectedStringType, at, Operand(scratch));
5069
5070 // The index is assumed to be untagged coming in, tag it to compare with the
5071 // string length without using a temp register, it is restored at the end of
5072 // this function.
5073 Label index_tag_ok, index_tag_bad;
5074 // On ARM TrySmiTag is used here.
5075 AdduAndCheckForOverflow(index, index, index, scratch);
5076 BranchOnOverflow(&index_tag_bad, scratch);
5077 Branch(&index_tag_ok);
5078 bind(&index_tag_bad);
5079 Throw(kIndexIsTooLarge);
5080 bind(&index_tag_ok);
5081
5082 lw(at, FieldMemOperand(string, String::kLengthOffset));
5083 ThrowIf(ge, kIndexIsTooLarge, index, Operand(at));
5084
5085 li(at, Operand(Smi::FromInt(0)));
5086 ThrowIf(lt, kIndexIsNegative, index, Operand(at));
5087
5088 SmiUntag(index, index);
5089 }
5090
5091
5054 void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, 5092 void MacroAssembler::PrepareCallCFunction(int num_reg_arguments,
5055 int num_double_arguments, 5093 int num_double_arguments,
5056 Register scratch) { 5094 Register scratch) {
5057 int frame_alignment = ActivationFrameAlignment(); 5095 int frame_alignment = ActivationFrameAlignment();
5058 5096
5059 // Up to four simple arguments are passed in registers a0..a3. 5097 // Up to four simple arguments are passed in registers a0..a3.
5060 // Those four arguments must have reserved argument slots on the stack for 5098 // Those four arguments must have reserved argument slots on the stack for
5061 // mips, even though those argument slots are not normally used. 5099 // mips, even though those argument slots are not normally used.
5062 // Remaining arguments are pushed on the stack, above (higher address than) 5100 // Remaining arguments are pushed on the stack, above (higher address than)
5063 // the argument slots. 5101 // the argument slots.
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
5424 5462
5425 And(bitmap_scratch, bitmap_scratch, Operand(~Page::kPageAlignmentMask)); 5463 And(bitmap_scratch, bitmap_scratch, Operand(~Page::kPageAlignmentMask));
5426 lw(t8, MemOperand(bitmap_scratch, MemoryChunk::kLiveBytesOffset)); 5464 lw(t8, MemOperand(bitmap_scratch, MemoryChunk::kLiveBytesOffset));
5427 Addu(t8, t8, Operand(length)); 5465 Addu(t8, t8, Operand(length));
5428 sw(t8, MemOperand(bitmap_scratch, MemoryChunk::kLiveBytesOffset)); 5466 sw(t8, MemOperand(bitmap_scratch, MemoryChunk::kLiveBytesOffset));
5429 5467
5430 bind(&done); 5468 bind(&done);
5431 } 5469 }
5432 5470
5433 5471
5472 void MacroAssembler::Throw(BailoutReason reason) {
5473 Label throw_start;
5474 bind(&throw_start);
5475 #ifdef DEBUG
5476 const char* msg = GetBailoutReason(reason);
5477 if (msg != NULL) {
5478 RecordComment("Throw message: ");
5479 RecordComment(msg);
5480 }
5481 #endif
5482
5483 li(a0, Operand(Smi::FromInt(reason)));
5484 push(a0);
5485 // Disable stub call restrictions to always allow calls to throw.
5486 if (!has_frame_) {
5487 // We don't actually want to generate a pile of code for this, so just
5488 // claim there is a stack frame, without generating one.
5489 FrameScope scope(this, StackFrame::NONE);
5490 CallRuntime(Runtime::kThrowMessage, 1);
5491 } else {
5492 CallRuntime(Runtime::kThrowMessage, 1);
5493 }
5494 // will not return here
5495 if (is_trampoline_pool_blocked()) {
5496 // If the calling code cares throw the exact number of
5497 // instructions generated, we insert padding here to keep the size
5498 // of the ThrowMessage macro constant.
5499 // Currently in debug mode with debug_code enabled the number of
5500 // generated instructions is 14, so we use this as a maximum value.
5501 static const int kExpectedThrowMessageInstructions = 14;
5502 int throw_instructions = InstructionsGeneratedSince(&throw_start);
5503 ASSERT(throw_instructions <= kExpectedThrowMessageInstructions);
5504 while (throw_instructions++ < kExpectedThrowMessageInstructions) {
5505 nop();
5506 }
5507 }
5508 }
5509
5510
5511 void MacroAssembler::ThrowIf(Condition cc,
5512 BailoutReason reason,
5513 Register rs,
5514 Operand rt) {
5515 Label L;
5516 Branch(&L, NegateCondition(cc), rs, rt);
5517 Throw(reason);
5518 // will not return here
5519 bind(&L);
5520 }
5521
5522
5434 void MacroAssembler::LoadInstanceDescriptors(Register map, 5523 void MacroAssembler::LoadInstanceDescriptors(Register map,
5435 Register descriptors) { 5524 Register descriptors) {
5436 lw(descriptors, FieldMemOperand(map, Map::kDescriptorsOffset)); 5525 lw(descriptors, FieldMemOperand(map, Map::kDescriptorsOffset));
5437 } 5526 }
5438 5527
5439 5528
5440 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) { 5529 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) {
5441 lw(dst, FieldMemOperand(map, Map::kBitField3Offset)); 5530 lw(dst, FieldMemOperand(map, Map::kBitField3Offset));
5442 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst); 5531 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst);
5443 } 5532 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
5660 opcode == BGTZL); 5749 opcode == BGTZL);
5661 opcode = (cond == eq) ? BEQ : BNE; 5750 opcode = (cond == eq) ? BEQ : BNE;
5662 instr = (instr & ~kOpcodeMask) | opcode; 5751 instr = (instr & ~kOpcodeMask) | opcode;
5663 masm_.emit(instr); 5752 masm_.emit(instr);
5664 } 5753 }
5665 5754
5666 5755
5667 } } // namespace v8::internal 5756 } } // namespace v8::internal
5668 5757
5669 #endif // V8_TARGET_ARCH_MIPS 5758 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698