1344477 - Part 1: Add JSOP_CALL_IGNORES_RV for function call that ignores return value.

This commit is contained in:
Gaming4JC 2019-07-14 19:04:34 -04:00 • committed by Roy Tam
commit 417aa02122
22 changed files with 243 additions and 92 deletions

View file

@ -128,7 +128,10 @@ class MOZ_STACK_CLASS CallArgsBase : public WantUsedRval
protected:
Value* argv_;
unsigned argc_;
bool constructing_;
bool constructing_:1;
// True if the caller does not use the return value.
bool ignoresReturnValue_:1;
public:
// CALLEE ACCESS
@ -164,6 +167,10 @@ class MOZ_STACK_CLASS CallArgsBase : public WantUsedRval
return true;
}
bool ignoresReturnValue() const {
return ignoresReturnValue_;
}
MutableHandleValue newTarget() const {
MOZ_ASSERT(constructing_);
return MutableHandleValue::fromMarkedLocation(&this->argv_[argc_]);
@ -280,14 +287,17 @@ class MOZ_STACK_CLASS CallArgs : public detail::CallArgsBase<detail::IncludeUsed
{
private:
friend CallArgs CallArgsFromVp(unsigned argc, Value* vp);
friend CallArgs CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing);
friend CallArgs CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing,
bool ignoresReturnValue);
static CallArgs create(unsigned argc, Value* argv, bool constructing) {
static CallArgs create(unsigned argc, Value* argv, bool constructing,
bool ignoresReturnValue = false) {
CallArgs args;
args.clearUsedRval();
args.argv_ = argv;
args.argc_ = argc;
args.constructing_ = constructing;
args.ignoresReturnValue_ = ignoresReturnValue;
#ifdef DEBUG
for (unsigned i = 0; i < argc; ++i)
MOZ_ASSERT_IF(argv[i].isGCThing(), !GCThingIsMarkedGray(GCCellPtr(argv[i])));
@ -314,9 +324,11 @@ CallArgsFromVp(unsigned argc, Value* vp)
// eventually move it to an internal header. Embedders should use
// JS::CallArgsFromVp!
MOZ_ALWAYS_INLINE CallArgs
CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing = false)
CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing = false,
bool ignoresReturnValue = false)
{
return CallArgs::create(stackSlots - constructing, sp - stackSlots, constructing);
return CallArgs::create(stackSlots - constructing, sp - stackSlots, constructing,
ignoresReturnValue);
}
} // namespace JS