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

Side by Side Diff: src/x64/macro-assembler-x64.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/x64/macro-assembler-x64.h ('k') | test/mjsunit/fuzz-natives-part1.js » ('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 3188 matching lines...) Expand 10 before | Expand all | Expand 10 after
3199 testl(result_reg, result_reg); 3199 testl(result_reg, result_reg);
3200 j(not_zero, &done, Label::kNear); 3200 j(not_zero, &done, Label::kNear);
3201 movmskpd(result_reg, xmm0); 3201 movmskpd(result_reg, xmm0);
3202 andl(result_reg, Immediate(1)); 3202 andl(result_reg, Immediate(1));
3203 j(not_zero, lost_precision, dst); 3203 j(not_zero, lost_precision, dst);
3204 } 3204 }
3205 bind(&done); 3205 bind(&done);
3206 } 3206 }
3207 3207
3208 3208
3209 void MacroAssembler::Throw(BailoutReason reason) {
3210 #ifdef DEBUG
3211 const char* msg = GetBailoutReason(reason);
3212 if (msg != NULL) {
3213 RecordComment("Throw message: ");
3214 RecordComment(msg);
3215 }
3216 #endif
3217
3218 push(rax);
3219 Push(Smi::FromInt(reason));
3220 if (!has_frame_) {
3221 // We don't actually want to generate a pile of code for this, so just
3222 // claim there is a stack frame, without generating one.
3223 FrameScope scope(this, StackFrame::NONE);
3224 CallRuntime(Runtime::kThrowMessage, 1);
3225 } else {
3226 CallRuntime(Runtime::kThrowMessage, 1);
3227 }
3228 // Control will not return here.
3229 int3();
3230 }
3231
3232
3233 void MacroAssembler::ThrowIf(Condition cc, BailoutReason reason) {
3234 Label L;
3235 j(NegateCondition(cc), &L);
3236 Throw(reason);
3237 // will not return here
3238 bind(&L);
3239 }
3240
3241
3209 void MacroAssembler::LoadInstanceDescriptors(Register map, 3242 void MacroAssembler::LoadInstanceDescriptors(Register map,
3210 Register descriptors) { 3243 Register descriptors) {
3211 movq(descriptors, FieldOperand(map, Map::kDescriptorsOffset)); 3244 movq(descriptors, FieldOperand(map, Map::kDescriptorsOffset));
3212 } 3245 }
3213 3246
3214 3247
3215 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) { 3248 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) {
3216 movq(dst, FieldOperand(map, Map::kBitField3Offset)); 3249 movq(dst, FieldOperand(map, Map::kBitField3Offset));
3217 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst); 3250 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst);
3218 } 3251 }
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
4624 const int kMinimumStackSlots = kRegisterPassedArguments; 4657 const int kMinimumStackSlots = kRegisterPassedArguments;
4625 if (num_arguments < kMinimumStackSlots) return kMinimumStackSlots; 4658 if (num_arguments < kMinimumStackSlots) return kMinimumStackSlots;
4626 return num_arguments; 4659 return num_arguments;
4627 #else 4660 #else
4628 if (num_arguments < kRegisterPassedArguments) return 0; 4661 if (num_arguments < kRegisterPassedArguments) return 0;
4629 return num_arguments - kRegisterPassedArguments; 4662 return num_arguments - kRegisterPassedArguments;
4630 #endif 4663 #endif
4631 } 4664 }
4632 4665
4633 4666
4667 void MacroAssembler::EmitSeqStringSetCharCheck(Register string,
4668 Register index,
4669 Register value,
4670 uint32_t encoding_mask) {
4671 Label is_object;
4672 JumpIfNotSmi(string, &is_object);
4673 Throw(kNonObject);
4674 bind(&is_object);
4675
4676 push(value);
4677 movq(value, FieldOperand(string, HeapObject::kMapOffset));
4678 movzxbq(value, FieldOperand(value, Map::kInstanceTypeOffset));
4679
4680 andb(value, Immediate(kStringRepresentationMask | kStringEncodingMask));
4681 cmpq(value, Immediate(encoding_mask));
4682 pop(value);
4683 ThrowIf(not_equal, kUnexpectedStringType);
4684
4685 // The index is assumed to be untagged coming in, tag it to compare with the
4686 // string length without using a temp register, it is restored at the end of
4687 // this function.
4688 Integer32ToSmi(index, index);
4689 SmiCompare(index, FieldOperand(string, String::kLengthOffset));
4690 ThrowIf(greater_equal, kIndexIsTooLarge);
4691
4692 SmiCompare(index, Smi::FromInt(0));
4693 ThrowIf(less, kIndexIsNegative);
4694
4695 // Restore the index
4696 SmiToInteger32(index, index);
4697 }
4698
4699
4634 void MacroAssembler::PrepareCallCFunction(int num_arguments) { 4700 void MacroAssembler::PrepareCallCFunction(int num_arguments) {
4635 int frame_alignment = OS::ActivationFrameAlignment(); 4701 int frame_alignment = OS::ActivationFrameAlignment();
4636 ASSERT(frame_alignment != 0); 4702 ASSERT(frame_alignment != 0);
4637 ASSERT(num_arguments >= 0); 4703 ASSERT(num_arguments >= 0);
4638 4704
4639 // Make stack end at alignment and allocate space for arguments and old rsp. 4705 // Make stack end at alignment and allocate space for arguments and old rsp.
4640 movq(kScratchRegister, rsp); 4706 movq(kScratchRegister, rsp);
4641 ASSERT(IsPowerOf2(frame_alignment)); 4707 ASSERT(IsPowerOf2(frame_alignment));
4642 int argument_slots_on_stack = 4708 int argument_slots_on_stack =
4643 ArgumentStackSlotsForCFunctionCall(num_arguments); 4709 ArgumentStackSlotsForCFunctionCall(num_arguments);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
4985 j(equal, found); 5051 j(equal, found);
4986 movq(current, FieldOperand(current, Map::kPrototypeOffset)); 5052 movq(current, FieldOperand(current, Map::kPrototypeOffset));
4987 CompareRoot(current, Heap::kNullValueRootIndex); 5053 CompareRoot(current, Heap::kNullValueRootIndex);
4988 j(not_equal, &loop_again); 5054 j(not_equal, &loop_again);
4989 } 5055 }
4990 5056
4991 5057
4992 } } // namespace v8::internal 5058 } } // namespace v8::internal
4993 5059
4994 #endif // V8_TARGET_ARCH_X64 5060 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | test/mjsunit/fuzz-natives-part1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698