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 3188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // We want to pass the msg string like a smi to avoid GC |
| 3211 // problems, however msg is not guaranteed to be aligned |
| 3212 // properly. Instead, we pass an aligned pointer that is |
| 3213 // a proper v8 smi, but also pass the alignment difference |
| 3214 // from the real pointer as a smi. |
| 3215 const char* msg = GetBailoutReason(reason); |
| 3216 intptr_t p1 = reinterpret_cast<intptr_t>(msg); |
| 3217 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; |
| 3218 // Note: p0 might not be a valid Smi _value_, but it has a valid Smi tag. |
| 3219 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); |
| 3220 #ifdef DEBUG |
| 3221 if (msg != NULL) { |
| 3222 RecordComment("Throw message: "); |
| 3223 RecordComment(msg); |
| 3224 } |
| 3225 #endif |
| 3226 |
| 3227 push(rax); |
| 3228 movq(kScratchRegister, reinterpret_cast<Smi*>(p0), RelocInfo::NONE64); |
| 3229 push(kScratchRegister); |
| 3230 movq(kScratchRegister, Smi::FromInt(static_cast<int>(p1 - p0)), |
| 3231 RelocInfo::NONE64); |
| 3232 push(kScratchRegister); |
| 3233 |
| 3234 if (!has_frame_) { |
| 3235 // We don't actually want to generate a pile of code for this, so just |
| 3236 // claim there is a stack frame, without generating one. |
| 3237 FrameScope scope(this, StackFrame::NONE); |
| 3238 CallRuntime(Runtime::kThrowMessage, 2); |
| 3239 } else { |
| 3240 CallRuntime(Runtime::kThrowMessage, 2); |
| 3241 } |
| 3242 // Control will not return here. |
| 3243 int3(); |
| 3244 } |
| 3245 |
| 3246 |
| 3247 void MacroAssembler::ThrowIfNot(Condition cc, BailoutReason reason) { |
| 3248 Label L; |
| 3249 j(cc, &L); |
| 3250 Throw(reason); |
| 3251 // will not return here |
| 3252 bind(&L); |
| 3253 } |
| 3254 |
| 3255 |
3209 void MacroAssembler::LoadInstanceDescriptors(Register map, | 3256 void MacroAssembler::LoadInstanceDescriptors(Register map, |
3210 Register descriptors) { | 3257 Register descriptors) { |
3211 movq(descriptors, FieldOperand(map, Map::kDescriptorsOffset)); | 3258 movq(descriptors, FieldOperand(map, Map::kDescriptorsOffset)); |
3212 } | 3259 } |
3213 | 3260 |
3214 | 3261 |
3215 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) { | 3262 void MacroAssembler::NumberOfOwnDescriptors(Register dst, Register map) { |
3216 movq(dst, FieldOperand(map, Map::kBitField3Offset)); | 3263 movq(dst, FieldOperand(map, Map::kBitField3Offset)); |
3217 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst); | 3264 DecodeField<Map::NumberOfOwnDescriptorsBits>(dst); |
3218 } | 3265 } |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4624 const int kMinimumStackSlots = kRegisterPassedArguments; | 4671 const int kMinimumStackSlots = kRegisterPassedArguments; |
4625 if (num_arguments < kMinimumStackSlots) return kMinimumStackSlots; | 4672 if (num_arguments < kMinimumStackSlots) return kMinimumStackSlots; |
4626 return num_arguments; | 4673 return num_arguments; |
4627 #else | 4674 #else |
4628 if (num_arguments < kRegisterPassedArguments) return 0; | 4675 if (num_arguments < kRegisterPassedArguments) return 0; |
4629 return num_arguments - kRegisterPassedArguments; | 4676 return num_arguments - kRegisterPassedArguments; |
4630 #endif | 4677 #endif |
4631 } | 4678 } |
4632 | 4679 |
4633 | 4680 |
| 4681 void MacroAssembler::EmitSeqStringSetCharCheck(Register string, |
| 4682 Register index, |
| 4683 Register value, |
| 4684 uint32_t encoding_mask) { |
| 4685 ThrowIfNot(CheckSmi(index), kNonSmiIndex); |
| 4686 ThrowIfNot(CheckSmi(value), kNonSmiValue); |
| 4687 |
| 4688 Label is_object; |
| 4689 JumpIfNotSmi(string, &is_object); |
| 4690 Throw(kNonObject); |
| 4691 bind(&is_object); |
| 4692 |
| 4693 SmiCompare(index, FieldOperand(string, String::kLengthOffset)); |
| 4694 ThrowIfNot(less, kIndexIsTooLarge); |
| 4695 |
| 4696 SmiCompare(index, Smi::FromInt(0)); |
| 4697 ThrowIfNot(greater_equal, kIndexIsNegative); |
| 4698 |
| 4699 push(value); |
| 4700 movq(value, FieldOperand(string, HeapObject::kMapOffset)); |
| 4701 movzxbq(value, FieldOperand(value, Map::kInstanceTypeOffset)); |
| 4702 |
| 4703 andb(value, Immediate(kStringRepresentationMask | kStringEncodingMask)); |
| 4704 cmpq(value, Immediate(encoding_mask)); |
| 4705 pop(value); |
| 4706 ThrowIfNot(equal, kUnexpectedStringType); |
| 4707 } |
| 4708 |
| 4709 |
4634 void MacroAssembler::PrepareCallCFunction(int num_arguments) { | 4710 void MacroAssembler::PrepareCallCFunction(int num_arguments) { |
4635 int frame_alignment = OS::ActivationFrameAlignment(); | 4711 int frame_alignment = OS::ActivationFrameAlignment(); |
4636 ASSERT(frame_alignment != 0); | 4712 ASSERT(frame_alignment != 0); |
4637 ASSERT(num_arguments >= 0); | 4713 ASSERT(num_arguments >= 0); |
4638 | 4714 |
4639 // Make stack end at alignment and allocate space for arguments and old rsp. | 4715 // Make stack end at alignment and allocate space for arguments and old rsp. |
4640 movq(kScratchRegister, rsp); | 4716 movq(kScratchRegister, rsp); |
4641 ASSERT(IsPowerOf2(frame_alignment)); | 4717 ASSERT(IsPowerOf2(frame_alignment)); |
4642 int argument_slots_on_stack = | 4718 int argument_slots_on_stack = |
4643 ArgumentStackSlotsForCFunctionCall(num_arguments); | 4719 ArgumentStackSlotsForCFunctionCall(num_arguments); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4985 j(equal, found); | 5061 j(equal, found); |
4986 movq(current, FieldOperand(current, Map::kPrototypeOffset)); | 5062 movq(current, FieldOperand(current, Map::kPrototypeOffset)); |
4987 CompareRoot(current, Heap::kNullValueRootIndex); | 5063 CompareRoot(current, Heap::kNullValueRootIndex); |
4988 j(not_equal, &loop_again); | 5064 j(not_equal, &loop_again); |
4989 } | 5065 } |
4990 | 5066 |
4991 | 5067 |
4992 } } // namespace v8::internal | 5068 } } // namespace v8::internal |
4993 | 5069 |
4994 #endif // V8_TARGET_ARCH_X64 | 5070 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |