Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index 7ceff76e148f70efd55d40c898b00e50a628ced0..e3e37d57e2c7244bf816869dbceae05f395eacee 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -440,14 +440,16 @@ void LCodeGen::AddToTranslation(Translation* translation, |
} |
-void LCodeGen::CallCode(Handle<Code> code, |
- RelocInfo::Mode mode, |
- LInstruction* instr) { |
+void LCodeGen::CallCodeGeneric(Handle<Code> code, |
+ RelocInfo::Mode mode, |
+ LInstruction* instr, |
+ SafepointMode safepoint_mode, |
+ int argc) { |
ASSERT(instr != NULL); |
LPointerMap* pointers = instr->pointer_map(); |
RecordPosition(pointers->position()); |
__ call(code, mode); |
- RegisterLazyDeoptimization(instr); |
+ RegisterLazyDeoptimization(instr, safepoint_mode, argc); |
// Signal that we don't inline smi code before these stubs in the |
// optimizing code generator. |
@@ -458,6 +460,13 @@ void LCodeGen::CallCode(Handle<Code> code, |
} |
+void LCodeGen::CallCode(Handle<Code> code, |
+ RelocInfo::Mode mode, |
+ LInstruction* instr) { |
+ CallCodeGeneric(code, mode, instr, RECORD_SIMPLE_SAFEPOINT, 0); |
+} |
+ |
+ |
void LCodeGen::CallRuntime(const Runtime::Function* function, |
int num_arguments, |
LInstruction* instr) { |
@@ -467,11 +476,23 @@ void LCodeGen::CallRuntime(const Runtime::Function* function, |
RecordPosition(pointers->position()); |
__ CallRuntime(function, num_arguments); |
- RegisterLazyDeoptimization(instr); |
+ RegisterLazyDeoptimization(instr, RECORD_SIMPLE_SAFEPOINT, 0); |
+} |
+ |
+ |
+void LCodeGen::CallRuntimeFromDeferred(Runtime::FunctionId id, |
+ int argc, |
+ LInstruction* instr) { |
+ __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
+ __ CallRuntimeSaveDoubles(id); |
+ RecordSafepointWithRegisters( |
+ instr->pointer_map(), argc, Safepoint::kNoDeoptimizationIndex); |
} |
-void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) { |
+void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr, |
+ SafepointMode safepoint_mode, |
+ int argc) { |
// Create the environment to bailout to. If the call has side effects |
// execution has to continue after the call otherwise execution can continue |
// from a previous bailout point repeating the call. |
@@ -483,8 +504,17 @@ void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) { |
} |
RegisterEnvironmentForDeoptimization(deoptimization_environment); |
- RecordSafepoint(instr->pointer_map(), |
- deoptimization_environment->deoptimization_index()); |
+ if (safepoint_mode == RECORD_SIMPLE_SAFEPOINT) { |
+ ASSERT(argc == 0); |
+ RecordSafepoint(instr->pointer_map(), |
+ deoptimization_environment->deoptimization_index()); |
+ } else { |
+ ASSERT(safepoint_mode == RECORD_SAFEPOINT_WITH_REGISTERS); |
+ RecordSafepointWithRegisters( |
+ instr->pointer_map(), |
+ argc, |
+ deoptimization_environment->deoptimization_index()); |
+ } |
} |
@@ -605,6 +635,8 @@ void LCodeGen::RecordSafepoint( |
Safepoint::Kind kind, |
int arguments, |
int deoptimization_index) { |
+ ASSERT(kind == expected_safepoint_kind_); |
+ |
const ZoneList<LOperand*>* operands = pointers->operands(); |
Safepoint safepoint = safepoints_.DefineSafepoint(masm(), |
@@ -1328,11 +1360,8 @@ void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) { |
void LCodeGen::DoDeferredStackCheck(LGoto* instr) { |
- __ Pushad(); |
- __ CallRuntimeSaveDoubles(Runtime::kStackGuard); |
- RecordSafepointWithRegisters( |
- instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); |
- __ Popad(); |
+ PushSafepointRegistersScope scope(this); |
+ CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr); |
} |
@@ -1937,23 +1966,31 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { |
void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
Label* map_check) { |
- __ PushSafepointRegisters(); |
- InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( |
- InstanceofStub::kNoFlags | InstanceofStub::kCallSiteInlineCheck); |
- InstanceofStub stub(flags); |
+ { |
+ PushSafepointRegistersScope scope(this); |
+ InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( |
+ InstanceofStub::kNoFlags | InstanceofStub::kCallSiteInlineCheck); |
+ InstanceofStub stub(flags); |
- __ push(ToRegister(instr->InputAt(0))); |
- __ Push(instr->function()); |
- Register temp = ToRegister(instr->TempAt(0)); |
- ASSERT(temp.is(rdi)); |
- static const int kAdditionalDelta = 16; |
- int delta = |
- masm_->SizeOfCodeGeneratedSince(map_check) + kAdditionalDelta; |
- __ movq(temp, Immediate(delta)); |
- __ push(temp); |
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
- __ movq(kScratchRegister, rax); |
- __ PopSafepointRegisters(); |
+ __ push(ToRegister(instr->InputAt(0))); |
+ __ Push(instr->function()); |
+ |
+ Register temp = ToRegister(instr->TempAt(0)); |
+ static const int kAdditionalDelta = 13; |
+ int delta = |
+ masm_->SizeOfCodeGeneratedSince(map_check) + kAdditionalDelta; |
+ __ movq(temp, Immediate(delta)); |
+ __ push(temp); |
+ |
+ // |
fschneider
2011/04/07 11:28:30
Remove extra line.
|
+ CallCodeGeneric(stub.GetCode(), |
+ RelocInfo::CODE_TARGET, |
+ instr, |
+ RECORD_SAFEPOINT_WITH_REGISTERS, |
+ 2); |
+ ASSERT(delta == masm_->SizeOfCodeGeneratedSince(map_check)); |
+ __ movq(kScratchRegister, rax); |
+ } |
__ testq(kScratchRegister, kScratchRegister); |
Label load_false; |
Label done; |
@@ -2535,7 +2572,7 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
} |
// Setup deoptimization. |
- RegisterLazyDeoptimization(instr); |
+ RegisterLazyDeoptimization(instr, RECORD_SIMPLE_SAFEPOINT, 0); |
// Restore context. |
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
@@ -2560,7 +2597,7 @@ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { |
Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; |
// Preserve the value of all registers. |
- __ PushSafepointRegisters(); |
+ PushSafepointRegistersScope scope(this); |
Label negative; |
__ movl(tmp, FieldOperand(input_reg, HeapNumber::kExponentOffset)); |
@@ -2581,9 +2618,7 @@ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { |
// Slow case: Call the runtime system to do the number allocation. |
__ bind(&slow); |
- __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); |
- RecordSafepointWithRegisters( |
- instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); |
+ CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0, instr); |
// Set the pointer to the new heap number in tmp. |
if (!tmp.is(rax)) { |
__ movq(tmp, rax); |
@@ -2600,7 +2635,6 @@ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { |
__ StoreToSafepointRegisterSlot(input_reg, tmp); |
__ bind(&done); |
- __ PopSafepointRegisters(); |
} |
@@ -3159,7 +3193,7 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { |
// contained in the register pointer map. |
__ Set(result, 0); |
- __ PushSafepointRegisters(); |
+ PushSafepointRegistersScope scope(this); |
__ push(string); |
// Push the index as a smi. This is safe because of the checks in |
// DoStringCharCodeAt above. |
@@ -3172,16 +3206,12 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { |
__ Integer32ToSmi(index, index); |
__ push(index); |
} |
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
- __ CallRuntimeSaveDoubles(Runtime::kStringCharCodeAt); |
- RecordSafepointWithRegisters( |
- instr->pointer_map(), 2, Safepoint::kNoDeoptimizationIndex); |
+ CallRuntimeFromDeferred(Runtime::kStringCharCodeAt, 2, instr); |
if (FLAG_debug_code) { |
__ AbortIfNotSmi(rax); |
} |
__ SmiToInteger32(rax, rax); |
__ StoreToSafepointRegisterSlot(result, rax); |
- __ PopSafepointRegisters(); |
} |
@@ -3224,14 +3254,11 @@ void LCodeGen::DoDeferredStringCharFromCode(LStringCharFromCode* instr) { |
// contained in the register pointer map. |
__ Set(result, 0); |
- __ PushSafepointRegisters(); |
+ PushSafepointRegistersScope scope(this); |
__ Integer32ToSmi(char_code, char_code); |
__ push(char_code); |
- __ CallRuntimeSaveDoubles(Runtime::kCharFromCode); |
- RecordSafepointWithRegisters( |
- instr->pointer_map(), 1, Safepoint::kNoDeoptimizationIndex); |
+ CallRuntimeFromDeferred(Runtime::kCharFromCode, 1, instr); |
__ StoreToSafepointRegisterSlot(result, rax); |
- __ PopSafepointRegisters(); |
} |
@@ -3296,13 +3323,12 @@ void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) { |
Register reg = ToRegister(instr->result()); |
__ Move(reg, Smi::FromInt(0)); |
- __ PushSafepointRegisters(); |
- __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); |
- RecordSafepointWithRegisters( |
- instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); |
- // Ensure that value in rax survives popping registers. |
- __ movq(kScratchRegister, rax); |
- __ PopSafepointRegisters(); |
+ { |
+ PushSafepointRegistersScope scope(this); |
+ CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0, instr); |
+ // Ensure that value in rax survives popping registers. |
+ __ movq(kScratchRegister, rax); |
+ } |
__ movq(reg, kScratchRegister); |
} |