Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 5127ddf30cd21f35839beb909c34e878af6871de..c84839c0ed426fc6c7192b8ef912c7ca06a957c7 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -3206,6 +3206,53 @@ void MacroAssembler::TaggedToI(Register result_reg, |
} |
+void MacroAssembler::Throw(BailoutReason reason) { |
+ // We want to pass the msg string like a smi to avoid GC |
+ // problems, however msg is not guaranteed to be aligned |
+ // properly. Instead, we pass an aligned pointer that is |
+ // a proper v8 smi, but also pass the alignment difference |
+ // from the real pointer as a smi. |
+ const char* msg = GetBailoutReason(reason); |
+ intptr_t p1 = reinterpret_cast<intptr_t>(msg); |
+ intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; |
+ // Note: p0 might not be a valid Smi _value_, but it has a valid Smi tag. |
+ ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); |
+#ifdef DEBUG |
+ if (msg != NULL) { |
+ RecordComment("Throw message: "); |
+ RecordComment(msg); |
+ } |
+#endif |
+ |
+ push(rax); |
+ movq(kScratchRegister, reinterpret_cast<Smi*>(p0), RelocInfo::NONE64); |
+ push(kScratchRegister); |
+ movq(kScratchRegister, Smi::FromInt(static_cast<int>(p1 - p0)), |
+ RelocInfo::NONE64); |
+ push(kScratchRegister); |
+ |
+ if (!has_frame_) { |
+ // We don't actually want to generate a pile of code for this, so just |
+ // claim there is a stack frame, without generating one. |
+ FrameScope scope(this, StackFrame::NONE); |
+ CallRuntime(Runtime::kThrowMessage, 2); |
+ } else { |
+ CallRuntime(Runtime::kThrowMessage, 2); |
+ } |
+ // Control will not return here. |
+ int3(); |
+} |
+ |
+ |
+void MacroAssembler::ThrowIfNot(Condition cc, BailoutReason reason) { |
+ Label L; |
+ j(cc, &L); |
+ Throw(reason); |
+ // will not return here |
+ bind(&L); |
+} |
+ |
+ |
void MacroAssembler::LoadInstanceDescriptors(Register map, |
Register descriptors) { |
movq(descriptors, FieldOperand(map, Map::kDescriptorsOffset)); |
@@ -4631,6 +4678,35 @@ int MacroAssembler::ArgumentStackSlotsForCFunctionCall(int num_arguments) { |
} |
+void MacroAssembler::EmitSeqStringSetCharCheck(Register string, |
+ Register index, |
+ Register value, |
+ uint32_t encoding_mask) { |
+ ThrowIfNot(CheckSmi(index), kNonSmiIndex); |
+ ThrowIfNot(CheckSmi(value), kNonSmiValue); |
+ |
+ Label is_object; |
+ JumpIfNotSmi(string, &is_object); |
+ Throw(kNonObject); |
+ bind(&is_object); |
+ |
+ SmiCompare(index, FieldOperand(string, String::kLengthOffset)); |
+ ThrowIfNot(less, kIndexIsTooLarge); |
+ |
+ SmiCompare(index, Smi::FromInt(0)); |
+ ThrowIfNot(greater_equal, kIndexIsNegative); |
+ |
+ push(value); |
+ movq(value, FieldOperand(string, HeapObject::kMapOffset)); |
+ movzxbq(value, FieldOperand(value, Map::kInstanceTypeOffset)); |
+ |
+ andb(value, Immediate(kStringRepresentationMask | kStringEncodingMask)); |
+ cmpq(value, Immediate(encoding_mask)); |
+ pop(value); |
+ ThrowIfNot(equal, kUnexpectedStringType); |
+} |
+ |
+ |
void MacroAssembler::PrepareCallCFunction(int num_arguments) { |
int frame_alignment = OS::ActivationFrameAlignment(); |
ASSERT(frame_alignment != 0); |