Skip to content

Commit

Permalink
Bug 1530937 part 16 - Convert tailCallVMs. r=tcampbell
Browse files Browse the repository at this point in the history
Tail calls have their own list/array/enum to improve type safety.

Differential Revision: https://phabricator.services.mozilla.com/D23112
  • Loading branch information
jandem committed Mar 12, 2019
1 parent 2ec3d14 commit f7a8fc4
Show file tree
Hide file tree
Showing 8 changed files with 366 additions and 279 deletions.
19 changes: 14 additions & 5 deletions js/src/jit/BaselineCacheIRCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@ class MOZ_RAII BaselineCacheIRCompiler : public CacheIRCompiler {
BaselineCacheIRStubKind kind_;

void callVMInternal(MacroAssembler& masm, VMFunctionId id);
void tailCallVM(MacroAssembler& masm, const VMFunction& fun);

template <typename Fn, Fn fn>
void callVM(MacroAssembler& masm) {
VMFunctionId id = VMFunctionToId<Fn, fn>::id;
callVMInternal(masm, id);
}

void tailCallVMInternal(MacroAssembler& masm, TailCallVMFunctionId id);

template <typename Fn, Fn fn>
void tailCallVM(MacroAssembler& masm) {
TailCallVMFunctionId id = TailCallVMFunctionToId<Fn, fn>::id;
tailCallVMInternal(masm, id);
}

MOZ_MUST_USE bool callTypeUpdateIC(Register obj, ValueOperand val,
Register scratch,
LiveGeneralRegisterSet saveRegs);
Expand Down Expand Up @@ -158,11 +165,12 @@ void BaselineCacheIRCompiler::callVMInternal(MacroAssembler& masm,
EmitBaselineCallVM(code, masm);
}

void BaselineCacheIRCompiler::tailCallVM(MacroAssembler& masm,
const VMFunction& fun) {
void BaselineCacheIRCompiler::tailCallVMInternal(MacroAssembler& masm,
TailCallVMFunctionId id) {
MOZ_ASSERT(!inStubFrame_);

TrampolinePtr code = cx_->runtime()->jitRuntime()->getVMWrapper(fun);
TrampolinePtr code = cx_->runtime()->jitRuntime()->getVMWrapper(id);
const VMFunctionData& fun = GetVMFunction(id);
MOZ_ASSERT(fun.expectTailCall == TailCall);
size_t argSize = fun.explicitStackSlots() * sizeof(void*);

Expand Down Expand Up @@ -2414,7 +2422,8 @@ bool BaselineCacheIRCompiler::emitCallStringObjectConcatResult() {
masm.pushValue(rhs);
masm.pushValue(lhs);

tailCallVM(masm, DoConcatStringObjectInfo);
using Fn = bool (*)(JSContext*, HandleValue, HandleValue, MutableHandleValue);
tailCallVM<Fn, DoConcatStringObject>(masm);

return true;
}
16 changes: 7 additions & 9 deletions js/src/jit/BaselineCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5302,13 +5302,6 @@ bool BaselineCodeGen<Handler>::emit_JSOP_FINALYIELDRVAL() {
return emitReturn();
}

typedef bool (*GeneratorThrowFn)(JSContext*, BaselineFrame*,
Handle<AbstractGeneratorObject*>, HandleValue,
uint32_t);
static const VMFunction GeneratorThrowOrReturnInfo =
FunctionInfo<GeneratorThrowFn>(jit::GeneratorThrowOrReturn,
"GeneratorThrowOrReturn", TailCall);

template <>
bool BaselineCompilerCodeGen::emit_JSOP_RESUME() {
auto resumeKind = AbstractGeneratorObject::getResumeKind(handler.pc());
Expand Down Expand Up @@ -5518,8 +5511,13 @@ bool BaselineCompilerCodeGen::emit_JSOP_RESUME() {
pushArg(genObj);
pushArg(scratch2);

const VMFunction& fun = GeneratorThrowOrReturnInfo;
TrampolinePtr code = cx->runtime()->jitRuntime()->getVMWrapper(fun);
using Fn =
bool (*)(JSContext*, BaselineFrame*, Handle<AbstractGeneratorObject*>,
HandleValue, uint32_t);
TailCallVMFunctionId id =
TailCallVMFunctionToId<Fn, jit::GeneratorThrowOrReturn>::id;
TrampolinePtr code = cx->runtime()->jitRuntime()->getVMWrapper(id);
const VMFunctionData& fun = GetVMFunction(id);

// Create and push the frame descriptor.
masm.subStackPtrFrom(scratch1);
Expand Down
Loading

0 comments on commit f7a8fc4

Please sign in to comment.