| Index: src/x64/lithium-codegen-x64.cc
|
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
|
| index af4431fc0eda60b9e41879b41040e6a051271280..6eb00fbfc94dacead001536d6a6dc166a5eb8e60 100644
|
| --- a/src/x64/lithium-codegen-x64.cc
|
| +++ b/src/x64/lithium-codegen-x64.cc
|
| @@ -50,9 +50,7 @@ class SafepointGenerator V8_FINAL : public CallWrapper {
|
| deopt_mode_(mode) { }
|
| virtual ~SafepointGenerator() {}
|
|
|
| - virtual void BeforeCall(int call_size) const V8_OVERRIDE {
|
| - codegen_->EnsureSpaceForLazyDeopt(Deoptimizer::patch_size() - call_size);
|
| - }
|
| + virtual void BeforeCall(int call_size) const V8_OVERRIDE {}
|
|
|
| virtual void AfterCall() const V8_OVERRIDE {
|
| codegen_->RecordSafepoint(pointers_, deopt_mode_);
|
| @@ -162,9 +160,6 @@ bool LCodeGen::GeneratePrologue() {
|
| info_->is_classic_mode() &&
|
| !info_->is_native()) {
|
| Label ok;
|
| - __ testq(rcx, rcx);
|
| - __ j(zero, &ok, Label::kNear);
|
| -
|
| StackArgumentsAccessor args(rsp, scope()->num_parameters());
|
| __ movq(rcx, args.GetReceiverOperand());
|
|
|
| @@ -605,7 +600,6 @@ void LCodeGen::CallCodeGeneric(Handle<Code> code,
|
| LInstruction* instr,
|
| SafepointMode safepoint_mode,
|
| int argc) {
|
| - EnsureSpaceForLazyDeopt(Deoptimizer::patch_size() - masm()->CallSize(code));
|
| ASSERT(instr != NULL);
|
| __ call(code, mode);
|
| RecordSafepointWithLazyDeopt(instr, safepoint_mode, argc);
|
| @@ -3302,8 +3296,7 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
|
| SafepointGenerator safepoint_generator(
|
| this, pointers, Safepoint::kLazyDeopt);
|
| ParameterCount actual(rax);
|
| - __ InvokeFunction(function, actual, CALL_FUNCTION,
|
| - safepoint_generator, CALL_AS_FUNCTION);
|
| + __ InvokeFunction(function, actual, CALL_FUNCTION, safepoint_generator);
|
| }
|
|
|
|
|
| @@ -3371,7 +3364,6 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
|
| int formal_parameter_count,
|
| int arity,
|
| LInstruction* instr,
|
| - CallKind call_kind,
|
| RDIState rdi_state) {
|
| bool dont_adapt_arguments =
|
| formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel;
|
| @@ -3395,7 +3387,6 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
|
| }
|
|
|
| // Invoke function.
|
| - __ SetCallKind(rcx, call_kind);
|
| if (function.is_identical_to(info()->closure())) {
|
| __ CallSelf();
|
| } else {
|
| @@ -3410,20 +3401,63 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
|
| this, pointers, Safepoint::kLazyDeopt);
|
| ParameterCount count(arity);
|
| ParameterCount expected(formal_parameter_count);
|
| - __ InvokeFunction(
|
| - function, expected, count, CALL_FUNCTION, generator, call_kind);
|
| + __ InvokeFunction(function, expected, count, CALL_FUNCTION, generator);
|
| }
|
| }
|
|
|
|
|
| -void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) {
|
| +void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) {
|
| ASSERT(ToRegister(instr->result()).is(rax));
|
| - CallKnownFunction(instr->hydrogen()->function(),
|
| - instr->hydrogen()->formal_parameter_count(),
|
| - instr->arity(),
|
| - instr,
|
| - CALL_AS_FUNCTION,
|
| - RDI_UNINITIALIZED);
|
| +
|
| + LPointerMap* pointers = instr->pointer_map();
|
| + SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);
|
| +
|
| + if (instr->target()->IsConstantOperand()) {
|
| + LConstantOperand* target = LConstantOperand::cast(instr->target());
|
| + Handle<Code> code = Handle<Code>::cast(ToHandle(target));
|
| + generator.BeforeCall(__ CallSize(code));
|
| + __ call(code, RelocInfo::CODE_TARGET);
|
| + } else {
|
| + ASSERT(instr->target()->IsRegister());
|
| + Register target = ToRegister(instr->target());
|
| + generator.BeforeCall(__ CallSize(target));
|
| + __ addq(target, Immediate(Code::kHeaderSize - kHeapObjectTag));
|
| + __ call(target);
|
| + }
|
| + generator.AfterCall();
|
| +}
|
| +
|
| +
|
| +void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
|
| + ASSERT(ToRegister(instr->function()).is(rdi));
|
| + ASSERT(ToRegister(instr->result()).is(rax));
|
| +
|
| + if (instr->hydrogen()->pass_argument_count()) {
|
| + __ Set(rax, instr->arity());
|
| + }
|
| +
|
| + // Change context.
|
| + __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
|
| +
|
| + LPointerMap* pointers = instr->pointer_map();
|
| + SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);
|
| +
|
| + bool is_self_call = false;
|
| + if (instr->hydrogen()->function()->IsConstant()) {
|
| + Handle<JSFunction> jsfun = Handle<JSFunction>::null();
|
| + HConstant* fun_const = HConstant::cast(instr->hydrogen()->function());
|
| + jsfun = Handle<JSFunction>::cast(fun_const->handle(isolate()));
|
| + is_self_call = jsfun.is_identical_to(info()->closure());
|
| + }
|
| +
|
| + if (is_self_call) {
|
| + __ CallSelf();
|
| + } else {
|
| + Operand target = FieldOperand(rdi, JSFunction::kCodeEntryOffset);
|
| + generator.BeforeCall(__ CallSize(target));
|
| + __ call(target);
|
| + }
|
| + generator.AfterCall();
|
| }
|
|
|
|
|
| @@ -3781,42 +3815,17 @@ void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) {
|
| LPointerMap* pointers = instr->pointer_map();
|
| SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);
|
| ParameterCount count(instr->arity());
|
| - __ InvokeFunction(rdi, count, CALL_FUNCTION, generator, CALL_AS_FUNCTION);
|
| + __ InvokeFunction(rdi, count, CALL_FUNCTION, generator);
|
| } else {
|
| CallKnownFunction(known_function,
|
| instr->hydrogen()->formal_parameter_count(),
|
| instr->arity(),
|
| instr,
|
| - CALL_AS_FUNCTION,
|
| RDI_CONTAINS_TARGET);
|
| }
|
| }
|
|
|
|
|
| -void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
|
| - ASSERT(ToRegister(instr->context()).is(rsi));
|
| - ASSERT(ToRegister(instr->key()).is(rcx));
|
| - ASSERT(ToRegister(instr->result()).is(rax));
|
| -
|
| - int arity = instr->arity();
|
| - Handle<Code> ic =
|
| - isolate()->stub_cache()->ComputeKeyedCallInitialize(arity);
|
| - CallCode(ic, RelocInfo::CODE_TARGET, instr);
|
| -}
|
| -
|
| -
|
| -void LCodeGen::DoCallNamed(LCallNamed* instr) {
|
| - ASSERT(ToRegister(instr->context()).is(rsi));
|
| - ASSERT(ToRegister(instr->result()).is(rax));
|
| -
|
| - int arity = instr->arity();
|
| - Handle<Code> ic =
|
| - isolate()->stub_cache()->ComputeCallInitialize(arity, NOT_CONTEXTUAL);
|
| - __ Move(rcx, instr->name());
|
| - CallCode(ic, RelocInfo::CODE_TARGET, instr);
|
| -}
|
| -
|
| -
|
| void LCodeGen::DoCallFunction(LCallFunction* instr) {
|
| ASSERT(ToRegister(instr->context()).is(rsi));
|
| ASSERT(ToRegister(instr->function()).is(rdi));
|
| @@ -3833,28 +3842,6 @@ void LCodeGen::DoCallFunction(LCallFunction* instr) {
|
| }
|
|
|
|
|
| -void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
|
| - ASSERT(ToRegister(instr->context()).is(rsi));
|
| - ASSERT(ToRegister(instr->result()).is(rax));
|
| - int arity = instr->arity();
|
| - Handle<Code> ic =
|
| - isolate()->stub_cache()->ComputeCallInitialize(arity, CONTEXTUAL);
|
| - __ Move(rcx, instr->name());
|
| - CallCode(ic, RelocInfo::CODE_TARGET, instr);
|
| -}
|
| -
|
| -
|
| -void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) {
|
| - ASSERT(ToRegister(instr->result()).is(rax));
|
| - CallKnownFunction(instr->hydrogen()->target(),
|
| - instr->hydrogen()->formal_parameter_count(),
|
| - instr->arity(),
|
| - instr,
|
| - CALL_AS_FUNCTION,
|
| - RDI_UNINITIALIZED);
|
| -}
|
| -
|
| -
|
| void LCodeGen::DoCallNew(LCallNew* instr) {
|
| ASSERT(ToRegister(instr->context()).is(rsi));
|
| ASSERT(ToRegister(instr->constructor()).is(rdi));
|
| @@ -4995,7 +4982,7 @@ void LCodeGen::DoDeferredInstanceMigration(LCheckMaps* instr, Register object) {
|
| PushSafepointRegistersScope scope(this);
|
| __ push(object);
|
| __ Set(rsi, 0);
|
| - __ CallRuntimeSaveDoubles(Runtime::kMigrateInstance);
|
| + __ CallRuntimeSaveDoubles(Runtime::kTryMigrateInstance);
|
| RecordSafepointWithRegisters(
|
| instr->pointer_map(), 1, Safepoint::kNoLazyDeopt);
|
|
|
| @@ -5424,20 +5411,21 @@ void LCodeGen::EmitIsConstructCall(Register temp) {
|
|
|
|
|
| void LCodeGen::EnsureSpaceForLazyDeopt(int space_needed) {
|
| - if (info()->IsStub()) return;
|
| - // Ensure that we have enough space after the previous lazy-bailout
|
| - // instruction for patching the code here.
|
| - int current_pc = masm()->pc_offset();
|
| - if (current_pc < last_lazy_deopt_pc_ + space_needed) {
|
| - int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
|
| - __ Nop(padding_size);
|
| + if (!info()->IsStub()) {
|
| + // Ensure that we have enough space after the previous lazy-bailout
|
| + // instruction for patching the code here.
|
| + int current_pc = masm()->pc_offset();
|
| + if (current_pc < last_lazy_deopt_pc_ + space_needed) {
|
| + int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
|
| + __ Nop(padding_size);
|
| + }
|
| }
|
| + last_lazy_deopt_pc_ = masm()->pc_offset();
|
| }
|
|
|
|
|
| void LCodeGen::DoLazyBailout(LLazyBailout* instr) {
|
| EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
|
| - last_lazy_deopt_pc_ = masm()->pc_offset();
|
| ASSERT(instr->HasEnvironment());
|
| LEnvironment* env = instr->environment();
|
| RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt);
|
| @@ -5510,7 +5498,6 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) {
|
| RelocInfo::CODE_TARGET,
|
| instr);
|
| EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
|
| - last_lazy_deopt_pc_ = masm()->pc_offset();
|
| __ bind(&done);
|
| RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt);
|
| safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index());
|
| @@ -5522,7 +5509,6 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) {
|
| __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
|
| __ j(below, deferred_stack_check->entry());
|
| EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
|
| - last_lazy_deopt_pc_ = masm()->pc_offset();
|
| __ bind(instr->done_label());
|
| deferred_stack_check->SetExit(instr->done_label());
|
| RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt);
|
|
|