Index: src/ia32/macro-assembler-ia32.cc |
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc |
index 914a4c2533494c3f0cefb588292332c5bda25e5a..fb94247c5b141ac500288d623bdb69e94b501ae5 100644 |
--- a/src/ia32/macro-assembler-ia32.cc |
+++ b/src/ia32/macro-assembler-ia32.cc |
@@ -3065,6 +3065,44 @@ void MacroAssembler::Abort(BailoutReason reason) { |
} |
+void MacroAssembler::Throw(BailoutReason reason) { |
+ const char* msg = GetBailoutReason(reason); |
+ intptr_t p1 = reinterpret_cast<intptr_t>(msg); |
+ intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; |
+ ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); |
+#ifdef DEBUG |
+ if (msg != NULL) { |
+ RecordComment("Throw message: "); |
+ RecordComment(msg); |
+ } |
+#endif |
+ |
+ push(eax); |
+ push(Immediate(p0)); |
+ push(Immediate(reinterpret_cast<intptr_t>(Smi::FromInt(p1 - p0)))); |
+ // Disable stub call restrictions to always allow calls to throw. |
+ 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); |
+ } |
+ // 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) { |
mov(descriptors, FieldOperand(map, Map::kDescriptorsOffset)); |
@@ -3230,6 +3268,37 @@ void MacroAssembler::JumpIfNotUniqueName(Operand operand, |
} |
+void MacroAssembler::EmitSeqStringSetCharCheck(Register string, |
+ Register index, |
+ Register value, |
+ uint32_t encoding_mask) { |
+ test(index, Immediate(kSmiTagMask)); |
+ ThrowIfNot(zero, kNonSmiIndex); |
+ test(value, Immediate(kSmiTagMask)); |
+ ThrowIfNot(zero, kNonSmiValue); |
+ |
+ Label is_object; |
+ JumpIfNotSmi(string, &is_object, Label::kNear); |
+ Throw(kNonObject); |
+ bind(&is_object); |
+ |
+ push(value); |
+ mov(value, FieldOperand(string, HeapObject::kMapOffset)); |
+ movzx_b(value, FieldOperand(value, Map::kInstanceTypeOffset)); |
+ |
+ and_(value, Immediate(kStringRepresentationMask | kStringEncodingMask)); |
+ cmp(value, Immediate(encoding_mask)); |
+ pop(value); |
+ ThrowIfNot(equal, kUnexpectedStringType); |
+ |
+ cmp(index, FieldOperand(string, String::kLengthOffset)); |
+ ThrowIfNot(less, kIndexIsTooLarge); |
+ |
+ cmp(index, Immediate(Smi::FromInt(0))); |
+ ThrowIfNot(greater_equal, kIndexIsNegative); |
+} |
+ |
+ |
void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) { |
int frame_alignment = OS::ActivationFrameAlignment(); |
if (frame_alignment != 0) { |