| Index: src/x64/lithium-codegen-x64.cc
|
| ===================================================================
|
| --- src/x64/lithium-codegen-x64.cc (revision 7542)
|
| +++ src/x64/lithium-codegen-x64.cc (working copy)
|
| @@ -429,14 +429,16 @@
|
| }
|
|
|
|
|
| -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.
|
| @@ -447,6 +449,13 @@
|
| }
|
|
|
|
|
| +void LCodeGen::CallCode(Handle<Code> code,
|
| + RelocInfo::Mode mode,
|
| + LInstruction* instr) {
|
| + CallCodeGeneric(code, mode, instr, RECORD_SIMPLE_SAFEPOINT, 0);
|
| +}
|
| +
|
| +
|
| void LCodeGen::CallRuntime(Runtime::Function* function,
|
| int num_arguments,
|
| LInstruction* instr) {
|
| @@ -456,11 +465,23 @@
|
| RecordPosition(pointers->position());
|
|
|
| __ CallRuntime(function, num_arguments);
|
| - RegisterLazyDeoptimization(instr);
|
| + RegisterLazyDeoptimization(instr, RECORD_SIMPLE_SAFEPOINT, 0);
|
| }
|
|
|
|
|
| -void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) {
|
| +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,
|
| + 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.
|
| @@ -472,8 +493,17 @@
|
| }
|
|
|
| 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());
|
| + }
|
| }
|
|
|
|
|
| @@ -598,6 +628,8 @@
|
| Safepoint::Kind kind,
|
| int arguments,
|
| int deoptimization_index) {
|
| + ASSERT(kind == expected_safepoint_kind_);
|
| +
|
| const ZoneList<LOperand*>* operands = pointers->operands();
|
|
|
| Safepoint safepoint = safepoints_.DefineSafepoint(masm(),
|
| @@ -1260,11 +1292,8 @@
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| @@ -1827,16 +1856,21 @@
|
|
|
|
|
| void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
|
| - __ PushSafepointRegisters();
|
| + {
|
| + PushSafepointRegistersScope scope(this);
|
|
|
| - InstanceofStub stub(InstanceofStub::kNoFlags);
|
| + InstanceofStub stub(InstanceofStub::kNoFlags);
|
|
|
| - __ push(ToRegister(instr->InputAt(0)));
|
| - __ Push(instr->function());
|
| - __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| - CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
|
| - __ movq(kScratchRegister, rax);
|
| - __ PopSafepointRegisters();
|
| + __ push(ToRegister(instr->InputAt(0)));
|
| + __ Push(instr->function());
|
| + __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| + CallCodeGeneric(stub.GetCode(),
|
| + RelocInfo::CODE_TARGET,
|
| + instr,
|
| + RECORD_SAFEPOINT_WITH_REGISTERS,
|
| + 2);
|
| + __ movq(kScratchRegister, rax);
|
| + }
|
| __ testq(kScratchRegister, kScratchRegister);
|
| Label load_false;
|
| Label done;
|
| @@ -2292,7 +2326,7 @@
|
| }
|
|
|
| // Setup deoptimization.
|
| - RegisterLazyDeoptimization(instr);
|
| + RegisterLazyDeoptimization(instr, RECORD_SIMPLE_SAFEPOINT, 0);
|
|
|
| // Restore context.
|
| __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| @@ -2317,7 +2351,7 @@
|
| 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));
|
| @@ -2338,9 +2372,7 @@
|
| // 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);
|
| @@ -2357,7 +2389,6 @@
|
| __ StoreToSafepointRegisterSlot(input_reg, tmp);
|
|
|
| __ bind(&done);
|
| - __ PopSafepointRegisters();
|
| }
|
|
|
|
|
| @@ -2884,7 +2915,7 @@
|
| // 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.
|
| @@ -2897,16 +2928,12 @@
|
| __ 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();
|
| }
|
|
|
|
|
| @@ -2971,13 +2998,12 @@
|
| 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);
|
| }
|
|
|
|
|