зеркало из https://github.com/mozilla/gecko-dev.git
Bug 949747 - Use accessor methods for JSFunction fields, r=jandem.
This commit is contained in:
Родитель
3f5d9fdd14
Коммит
ecb06a8b95
|
@ -847,7 +847,7 @@ Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun, const AutoN
|
|||
generatorKind);
|
||||
if (!funbox)
|
||||
return null();
|
||||
funbox->length = fun->nargs - fun->hasRest();
|
||||
funbox->length = fun->nargs() - fun->hasRest();
|
||||
handler.setFunctionBox(fn, funbox);
|
||||
|
||||
ParseContext<FullParseHandler> funpc(this, pc, fn, funbox, newDirectives,
|
||||
|
@ -2212,7 +2212,7 @@ Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, unsigned st
|
|||
generatorKind);
|
||||
if (!funbox)
|
||||
return null();
|
||||
funbox->length = fun->nargs - fun->hasRest();
|
||||
funbox->length = fun->nargs() - fun->hasRest();
|
||||
|
||||
Directives newDirectives = directives;
|
||||
ParseContext<FullParseHandler> funpc(this, /* parent = */ nullptr, pn, funbox,
|
||||
|
@ -2265,11 +2265,11 @@ Parser<ParseHandler>::functionArgsAndBodyGeneric(Node pn, HandleFunction fun, Fu
|
|||
if (hasRest)
|
||||
fun->setHasRest();
|
||||
|
||||
if (type == Getter && fun->nargs > 0) {
|
||||
if (type == Getter && fun->nargs() > 0) {
|
||||
report(ParseError, false, null(), JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s");
|
||||
return false;
|
||||
}
|
||||
if (type == Setter && fun->nargs != 1) {
|
||||
if (type == Setter && fun->nargs() != 1) {
|
||||
report(ParseError, false, null(), JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -289,7 +289,7 @@ class FunctionBox : public ObjectBox, public SharedContext
|
|||
funCxFlags.definitelyNeedsArgsObj = true; }
|
||||
|
||||
bool hasDefaults() const {
|
||||
return length != function()->nargs - function()->hasRest();
|
||||
return length != function()->nargs() - function()->hasRest();
|
||||
}
|
||||
|
||||
// Return whether this function has either specified "use asm" or is
|
||||
|
|
|
@ -5967,14 +5967,14 @@ TryEnablingIon(JSContext *cx, AsmJSModule &module, HandleFunction fun, uint32_t
|
|||
return true;
|
||||
|
||||
// Currently we can't rectify arguments. Therefore disabling if argc is too low.
|
||||
if (fun->nargs > argc)
|
||||
if (fun->nargs() > size_t(argc))
|
||||
return true;
|
||||
|
||||
// Normally the types should corresond, since we just ran with those types,
|
||||
// but there are reports this is asserting. Therefore doing it as a check, instead of DEBUG only.
|
||||
if (!types::TypeScript::ThisTypes(script)->hasType(types::Type::UndefinedType()))
|
||||
return true;
|
||||
for(uint32_t i = 0; i < fun->nargs; i++) {
|
||||
for(uint32_t i = 0; i < fun->nargs(); i++) {
|
||||
types::StackTypeSet *typeset = types::TypeScript::ArgTypes(script, i);
|
||||
types::Type type = types::Type::DoubleType();
|
||||
if (!argv[i].isDouble())
|
||||
|
|
|
@ -682,7 +682,7 @@ JSFunction *
|
|||
js::NewAsmJSModuleFunction(ExclusiveContext *cx, JSFunction *origFun, HandleObject moduleObj)
|
||||
{
|
||||
RootedPropertyName name(cx, origFun->name());
|
||||
JSFunction *moduleFun = NewFunction(cx, NullPtr(), LinkAsmJS, origFun->nargs,
|
||||
JSFunction *moduleFun = NewFunction(cx, NullPtr(), LinkAsmJS, origFun->nargs(),
|
||||
JSFunction::NATIVE_FUN, NullPtr(), name,
|
||||
JSFunction::ExtendedFinalizeKind, TenuredObject);
|
||||
if (!moduleFun)
|
||||
|
|
|
@ -624,7 +624,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
|
|||
|
||||
JS_ASSERT(iter.slots() >= CountArgSlots(script, fun));
|
||||
IonSpew(IonSpew_BaselineBailouts, " frame slots %u, nargs %u, nfixed %u",
|
||||
iter.slots(), fun->nargs, script->nfixed());
|
||||
iter.slots(), fun->nargs(), script->nfixed());
|
||||
|
||||
if (!callerPC) {
|
||||
// This is the first frame. Store the formals in a Vector until we
|
||||
|
@ -633,11 +633,11 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
|
|||
// locals may still reference the original argument slot
|
||||
// (MParameter/LArgument) and expect the original Value.
|
||||
JS_ASSERT(startFrameFormals.empty());
|
||||
if (!startFrameFormals.resize(fun->nargs))
|
||||
if (!startFrameFormals.resize(fun->nargs()))
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < fun->nargs; i++) {
|
||||
for (uint32_t i = 0; i < fun->nargs(); i++) {
|
||||
Value arg = iter.read();
|
||||
IonSpew(IonSpew_BaselineBailouts, " arg %d = %016llx",
|
||||
(int) i, *((uint64_t *) &arg));
|
||||
|
@ -1108,7 +1108,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
|
|||
|
||||
// If actualArgc >= fun->nargs, then we are done. Otherwise, we need to push on
|
||||
// a reconstructed rectifier frame.
|
||||
if (actualArgc >= calleeFun->nargs)
|
||||
if (actualArgc >= calleeFun->nargs())
|
||||
return true;
|
||||
|
||||
// Push a reconstructed rectifier frame.
|
||||
|
@ -1147,7 +1147,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
|
|||
#endif
|
||||
|
||||
// Push undefined for missing arguments.
|
||||
for (unsigned i = 0; i < (calleeFun->nargs - actualArgc); i++) {
|
||||
for (unsigned i = 0; i < (calleeFun->nargs() - actualArgc); i++) {
|
||||
if (!builder.writeValue(UndefinedValue(), "FillerVal"))
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -668,7 +668,7 @@ BaselineCompiler::emitArgumentTypeChecks()
|
|||
if (!emitNonOpIC(compiler.getStub(&stubSpace_)))
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < function()->nargs; i++) {
|
||||
for (size_t i = 0; i < function()->nargs(); i++) {
|
||||
frame.pushArg(i);
|
||||
frame.popRegsAndSync(1);
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ class BaselineFrame
|
|||
offsetOfNumActualArgs());
|
||||
}
|
||||
unsigned numFormalArgs() const {
|
||||
return script()->function()->nargs;
|
||||
return script()->function()->nargs();
|
||||
}
|
||||
Value &thisValue() const {
|
||||
return *(Value *)(reinterpret_cast<const uint8_t *>(this) +
|
||||
|
|
|
@ -182,7 +182,7 @@ class FrameInfo
|
|||
return script->nfixed();
|
||||
}
|
||||
uint32_t nargs() const {
|
||||
return script->function()->nargs;
|
||||
return script->function()->nargs();
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -4125,7 +4125,7 @@ ICGetElemNativeCompiler::emitCallScripted(MacroAssembler &masm, Register objReg)
|
|||
|
||||
// Handle arguments underflow.
|
||||
Label noUnderflow;
|
||||
masm.load16ZeroExtend(Address(callee, offsetof(JSFunction, nargs)), scratch);
|
||||
masm.load16ZeroExtend(Address(callee, JSFunction::offsetOfNargs()), scratch);
|
||||
masm.branch32(Assembler::Equal, scratch, Imm32(0), &noUnderflow);
|
||||
{
|
||||
// Call the arguments rectifier.
|
||||
|
@ -6682,7 +6682,7 @@ ICGetProp_CallScripted::Compiler::generateStubCode(MacroAssembler &masm)
|
|||
|
||||
// Handle arguments underflow.
|
||||
Label noUnderflow;
|
||||
masm.load16ZeroExtend(Address(callee, offsetof(JSFunction, nargs)), scratch);
|
||||
masm.load16ZeroExtend(Address(callee, JSFunction::offsetOfNargs()), scratch);
|
||||
masm.branch32(Assembler::Equal, scratch, Imm32(0), &noUnderflow);
|
||||
{
|
||||
// Call the arguments rectifier.
|
||||
|
@ -7591,7 +7591,7 @@ ICSetProp_CallScripted::Compiler::generateStubCode(MacroAssembler &masm)
|
|||
|
||||
// Handle arguments underflow.
|
||||
Label noUnderflow;
|
||||
masm.load16ZeroExtend(Address(callee, offsetof(JSFunction, nargs)), scratch);
|
||||
masm.load16ZeroExtend(Address(callee, JSFunction::offsetOfNargs()), scratch);
|
||||
masm.branch32(Assembler::BelowOrEqual, scratch, Imm32(1), &noUnderflow);
|
||||
{
|
||||
// Call the arguments rectifier.
|
||||
|
@ -8538,7 +8538,7 @@ ICCallScriptedCompiler::generateStubCode(MacroAssembler &masm)
|
|||
|
||||
// Handle arguments underflow.
|
||||
Label noUnderflow;
|
||||
masm.load16ZeroExtend(Address(callee, offsetof(JSFunction, nargs)), callee);
|
||||
masm.load16ZeroExtend(Address(callee, JSFunction::offsetOfNargs()), callee);
|
||||
masm.branch32(Assembler::AboveOrEqual, argcReg, callee, &noUnderflow);
|
||||
{
|
||||
// Call the arguments rectifier.
|
||||
|
@ -8794,7 +8794,7 @@ ICCall_ScriptedApplyArray::Compiler::generateStubCode(MacroAssembler &masm)
|
|||
masm.Push(scratch);
|
||||
|
||||
// Load nargs into scratch for underflow check, and then load jitcode pointer into target.
|
||||
masm.load16ZeroExtend(Address(target, offsetof(JSFunction, nargs)), scratch);
|
||||
masm.load16ZeroExtend(Address(target, JSFunction::offsetOfNargs()), scratch);
|
||||
masm.loadPtr(Address(target, JSFunction::offsetOfNativeOrScript()), target);
|
||||
masm.loadBaselineOrIonRaw(target, target, SequentialExecution, nullptr);
|
||||
|
||||
|
@ -8905,7 +8905,7 @@ ICCall_ScriptedApplyArguments::Compiler::generateStubCode(MacroAssembler &masm)
|
|||
masm.Push(scratch);
|
||||
|
||||
// Load nargs into scratch for underflow check, and then load jitcode pointer into target.
|
||||
masm.load16ZeroExtend(Address(target, offsetof(JSFunction, nargs)), scratch);
|
||||
masm.load16ZeroExtend(Address(target, JSFunction::offsetOfNargs()), scratch);
|
||||
masm.loadPtr(Address(target, JSFunction::offsetOfNativeOrScript()), target);
|
||||
masm.loadBaselineOrIonRaw(target, target, SequentialExecution, nullptr);
|
||||
|
||||
|
|
|
@ -826,11 +826,11 @@ CodeGenerator::emitLambdaInit(const Register &output, const Register &scopeChain
|
|||
} s;
|
||||
uint32_t word;
|
||||
} u;
|
||||
u.s.nargs = info.fun->nargs;
|
||||
u.s.nargs = info.fun->nargs();
|
||||
u.s.flags = info.flags & ~JSFunction::EXTENDED;
|
||||
|
||||
JS_STATIC_ASSERT(offsetof(JSFunction, flags) == offsetof(JSFunction, nargs) + 2);
|
||||
masm.store32(Imm32(u.word), Address(output, offsetof(JSFunction, nargs)));
|
||||
JS_ASSERT(JSFunction::offsetOfFlags() == JSFunction::offsetOfNargs() + 2);
|
||||
masm.store32(Imm32(u.word), Address(output, JSFunction::offsetOfNargs()));
|
||||
masm.storePtr(ImmGCPtr(info.scriptOrLazyScript),
|
||||
Address(output, JSFunction::offsetOfNativeOrScript()));
|
||||
masm.storePtr(scopeChain, Address(output, JSFunction::offsetOfEnvironment()));
|
||||
|
@ -1953,7 +1953,7 @@ CodeGenerator::visitCallGeneric(LCallGeneric *call)
|
|||
masm.Push(Imm32(descriptor));
|
||||
|
||||
// Check whether the provided arguments satisfy target argc.
|
||||
masm.load16ZeroExtend(Address(calleereg, offsetof(JSFunction, nargs)), nargsreg);
|
||||
masm.load16ZeroExtend(Address(calleereg, JSFunction::offsetOfNargs()), nargsreg);
|
||||
masm.cmp32(nargsreg, Imm32(call->numStackArgs()));
|
||||
masm.j(Assembler::Above, &thunk);
|
||||
|
||||
|
@ -2045,7 +2045,7 @@ CodeGenerator::visitCallKnown(LCallKnown *call)
|
|||
// Native single targets are handled by LCallNative.
|
||||
JS_ASSERT(!target->isNative());
|
||||
// Missing arguments must have been explicitly appended by the IonBuilder.
|
||||
JS_ASSERT(target->nargs <= call->numStackArgs());
|
||||
JS_ASSERT(target->nargs() <= call->numStackArgs());
|
||||
|
||||
JS_ASSERT_IF(call->mir()->isConstructing(), target->isInterpretedConstructor());
|
||||
|
||||
|
@ -2285,11 +2285,11 @@ CodeGenerator::visitApplyArgsGeneric(LApplyArgsGeneric *apply)
|
|||
|
||||
// Check whether the provided arguments satisfy target argc.
|
||||
if (!apply->hasSingleTarget()) {
|
||||
masm.load16ZeroExtend(Address(calleereg, offsetof(JSFunction, nargs)), copyreg);
|
||||
masm.load16ZeroExtend(Address(calleereg, JSFunction::offsetOfNargs()), copyreg);
|
||||
masm.cmp32(argcreg, copyreg);
|
||||
masm.j(Assembler::Below, &underflow);
|
||||
} else {
|
||||
masm.cmp32(argcreg, Imm32(apply->getSingleTarget()->nargs));
|
||||
masm.cmp32(argcreg, Imm32(apply->getSingleTarget()->nargs()));
|
||||
masm.j(Assembler::Below, &underflow);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ CountArgSlots(JSScript *script, JSFunction *fun)
|
|||
// Slot x + n: Argument n.
|
||||
|
||||
// Note: when updating this, please also update the assert in SnapshotWriter::startFrame
|
||||
return StartArgSlot(script) + (fun ? fun->nargs + 1 : 0);
|
||||
return StartArgSlot(script) + (fun ? fun->nargs() + 1 : 0);
|
||||
}
|
||||
|
||||
// Contains information about the compilation source for IR being generated.
|
||||
|
@ -60,7 +60,7 @@ class CompileInfo
|
|||
|
||||
nimplicit_ = StartArgSlot(script) /* scope chain and argument obj */
|
||||
+ (fun ? 1 : 0); /* this */
|
||||
nargs_ = fun ? fun->nargs : 0;
|
||||
nargs_ = fun ? fun->nargs() : 0;
|
||||
nlocals_ = script->nfixed();
|
||||
nstack_ = script->nslots() - script->nfixed();
|
||||
nslots_ = nimplicit_ + nargs_ + nlocals_ + nstack_;
|
||||
|
|
|
@ -2018,7 +2018,7 @@ jit::CanEnter(JSContext *cx, RunState &state)
|
|||
return Method_CantCompile;
|
||||
}
|
||||
|
||||
if (TooManyArguments(invoke.args().callee().as<JSFunction>().nargs)) {
|
||||
if (TooManyArguments(invoke.args().callee().as<JSFunction>().nargs())) {
|
||||
IonSpew(IonSpew_Abort, "too many args");
|
||||
ForbidCompilation(cx, script);
|
||||
return Method_CantCompile;
|
||||
|
@ -2165,7 +2165,7 @@ jit::CanEnterUsingFastInvoke(JSContext *cx, HandleScript script, uint32_t numAct
|
|||
|
||||
// Don't handle arguments underflow, to make this work we would have to pad
|
||||
// missing arguments with |undefined|.
|
||||
if (numActualArgs < script->function()->nargs)
|
||||
if (numActualArgs < script->function()->nargs())
|
||||
return Method_Skipped;
|
||||
|
||||
if (!cx->compartment()->ensureJitCompartmentExists(cx))
|
||||
|
@ -2226,7 +2226,7 @@ jit::SetEnterJitData(JSContext *cx, EnterJitData &data, RunState &state, AutoVal
|
|||
|
||||
if (state.isInvoke()) {
|
||||
CallArgs &args = state.asInvoke()->args();
|
||||
unsigned numFormals = state.script()->function()->nargs;
|
||||
unsigned numFormals = state.script()->function()->nargs();
|
||||
data.constructing = state.asInvoke()->constructing();
|
||||
data.numActualArgs = args.length();
|
||||
data.maxArgc = Max(args.length(), numFormals) + 1;
|
||||
|
@ -2309,7 +2309,7 @@ jit::FastInvoke(JSContext *cx, HandleFunction fun, CallArgs &args)
|
|||
void *calleeToken = CalleeToToken(fun);
|
||||
|
||||
RootedValue result(cx, Int32Value(args.length()));
|
||||
JS_ASSERT(args.length() >= fun->nargs);
|
||||
JS_ASSERT(args.length() >= fun->nargs());
|
||||
|
||||
JSAutoResolveFlags rf(cx, RESOLVE_INFER);
|
||||
enter(jitcode, args.length() + 1, args.array() - 1, nullptr, calleeToken,
|
||||
|
|
|
@ -361,7 +361,7 @@ IonBuilder::canInlineTarget(JSFunction *target, CallInfo &callInfo)
|
|||
if (!inlineScript->hasBaselineScript())
|
||||
return DontInline(inlineScript, "No baseline jitcode");
|
||||
|
||||
if (TooManyArguments(target->nargs))
|
||||
if (TooManyArguments(target->nargs()))
|
||||
return DontInline(inlineScript, "Too many args");
|
||||
|
||||
if (TooManyArguments(callInfo.argc()))
|
||||
|
@ -5136,12 +5136,12 @@ IonBuilder::testNeedsArgumentCheck(JSFunction *target, CallInfo &callInfo)
|
|||
|
||||
if (!ArgumentTypesMatch(callInfo.thisArg(), types::TypeScript::ThisTypes(targetScript)))
|
||||
return true;
|
||||
uint32_t expected_args = Min<uint32_t>(callInfo.argc(), target->nargs);
|
||||
uint32_t expected_args = Min<uint32_t>(callInfo.argc(), target->nargs());
|
||||
for (size_t i = 0; i < expected_args; i++) {
|
||||
if (!ArgumentTypesMatch(callInfo.getArg(i), types::TypeScript::ArgTypes(targetScript, i)))
|
||||
return true;
|
||||
}
|
||||
for (size_t i = callInfo.argc(); i < target->nargs; i++) {
|
||||
for (size_t i = callInfo.argc(); i < target->nargs(); i++) {
|
||||
if (!types::TypeScript::ArgTypes(targetScript, i)->mightBeType(JSVAL_TYPE_UNDEFINED))
|
||||
return true;
|
||||
}
|
||||
|
@ -5162,7 +5162,7 @@ IonBuilder::makeCallHelper(JSFunction *target, CallInfo &callInfo, bool cloneAtC
|
|||
// Collect number of missing arguments provided that the target is
|
||||
// scripted. Native functions are passed an explicit 'argc' parameter.
|
||||
if (target && !target->isNative())
|
||||
targetArgs = Max<uint32_t>(target->nargs, callInfo.argc());
|
||||
targetArgs = Max<uint32_t>(target->nargs(), callInfo.argc());
|
||||
|
||||
MCall *call =
|
||||
MCall::New(alloc(), target, targetArgs + 1, callInfo.argc(), callInfo.constructing());
|
||||
|
|
|
@ -398,7 +398,7 @@ class InlineFrameIteratorMaybeGC
|
|||
count = nactual - start;
|
||||
|
||||
unsigned end = start + count;
|
||||
unsigned nformal = callee()->nargs;
|
||||
unsigned nformal = callee()->nargs();
|
||||
|
||||
JS_ASSERT(start <= end && end <= nactual);
|
||||
|
||||
|
|
|
@ -1659,15 +1659,15 @@ InlineFrameIteratorMaybeGC<allowGC>::dump() const
|
|||
fprintf(stderr, " scope chain: ");
|
||||
else if (i == 1)
|
||||
fprintf(stderr, " this: ");
|
||||
else if (i - 2 < callee()->nargs)
|
||||
else if (i - 2 < callee()->nargs())
|
||||
fprintf(stderr, " formal (arg %d): ", i - 2);
|
||||
else {
|
||||
if (i - 2 == callee()->nargs && numActualArgs() > callee()->nargs) {
|
||||
DumpOp d(callee()->nargs);
|
||||
if (i - 2 == callee()->nargs() && numActualArgs() > callee()->nargs()) {
|
||||
DumpOp d(callee()->nargs());
|
||||
forEachCanonicalActualArg(GetIonContext()->cx, d, d.i_, numActualArgs() - d.i_);
|
||||
}
|
||||
|
||||
fprintf(stderr, " slot %d: ", i - 2 - callee()->nargs);
|
||||
fprintf(stderr, " slot %d: ", int(i - 2 - callee()->nargs()));
|
||||
}
|
||||
} else
|
||||
fprintf(stderr, " slot %u: ", i);
|
||||
|
|
|
@ -1780,8 +1780,8 @@ MacroAssembler::branchIfNotInterpretedConstructor(Register fun, Register scratch
|
|||
{
|
||||
// 16-bit loads are slow and unaligned 32-bit loads may be too so
|
||||
// perform an aligned 32-bit load and adjust the bitmask accordingly.
|
||||
JS_STATIC_ASSERT(offsetof(JSFunction, nargs) % sizeof(uint32_t) == 0);
|
||||
JS_STATIC_ASSERT(offsetof(JSFunction, flags) == offsetof(JSFunction, nargs) + 2);
|
||||
JS_ASSERT(JSFunction::offsetOfNargs() % sizeof(uint32_t) == 0);
|
||||
JS_ASSERT(JSFunction::offsetOfFlags() == JSFunction::offsetOfNargs() + 2);
|
||||
JS_STATIC_ASSERT(IS_LITTLE_ENDIAN);
|
||||
|
||||
// Emit code for the following test:
|
||||
|
@ -1792,7 +1792,7 @@ MacroAssembler::branchIfNotInterpretedConstructor(Register fun, Register scratch
|
|||
// }
|
||||
|
||||
// First, ensure it's a scripted function.
|
||||
load32(Address(fun, offsetof(JSFunction, nargs)), scratch);
|
||||
load32(Address(fun, JSFunction::offsetOfNargs()), scratch);
|
||||
branchTest32(Assembler::Zero, scratch, Imm32(JSFunction::INTERPRETED << 16), label);
|
||||
|
||||
// Common case: if both IS_FUN_PROTO and SELF_HOSTED are not set,
|
||||
|
|
|
@ -490,20 +490,20 @@ class MacroAssembler : public MacroAssemblerSpecific
|
|||
void branchIfFunctionHasNoScript(Register fun, Label *label) {
|
||||
// 16-bit loads are slow and unaligned 32-bit loads may be too so
|
||||
// perform an aligned 32-bit load and adjust the bitmask accordingly.
|
||||
JS_STATIC_ASSERT(offsetof(JSFunction, nargs) % sizeof(uint32_t) == 0);
|
||||
JS_STATIC_ASSERT(offsetof(JSFunction, flags) == offsetof(JSFunction, nargs) + 2);
|
||||
JS_ASSERT(JSFunction::offsetOfNargs() % sizeof(uint32_t) == 0);
|
||||
JS_ASSERT(JSFunction::offsetOfFlags() == JSFunction::offsetOfNargs() + 2);
|
||||
JS_STATIC_ASSERT(IS_LITTLE_ENDIAN);
|
||||
Address address(fun, offsetof(JSFunction, nargs));
|
||||
Address address(fun, JSFunction::offsetOfNargs());
|
||||
uint32_t bit = JSFunction::INTERPRETED << 16;
|
||||
branchTest32(Assembler::Zero, address, Imm32(bit), label);
|
||||
}
|
||||
void branchIfInterpreted(Register fun, Label *label) {
|
||||
// 16-bit loads are slow and unaligned 32-bit loads may be too so
|
||||
// perform an aligned 32-bit load and adjust the bitmask accordingly.
|
||||
JS_STATIC_ASSERT(offsetof(JSFunction, nargs) % sizeof(uint32_t) == 0);
|
||||
JS_STATIC_ASSERT(offsetof(JSFunction, flags) == offsetof(JSFunction, nargs) + 2);
|
||||
JS_ASSERT(JSFunction::offsetOfNargs() % sizeof(uint32_t) == 0);
|
||||
JS_ASSERT(JSFunction::offsetOfFlags() == JSFunction::offsetOfNargs() + 2);
|
||||
JS_STATIC_ASSERT(IS_LITTLE_ENDIAN);
|
||||
Address address(fun, offsetof(JSFunction, nargs));
|
||||
Address address(fun, JSFunction::offsetOfNargs());
|
||||
uint32_t bit = JSFunction::INTERPRETED << 16;
|
||||
branchTest32(Assembler::NonZero, address, Imm32(bit), label);
|
||||
}
|
||||
|
|
|
@ -4939,7 +4939,7 @@ struct LambdaFunctionInfo
|
|||
bool useNewTypeForClone;
|
||||
|
||||
LambdaFunctionInfo(JSFunction *fun)
|
||||
: fun(fun), flags(fun->flags),
|
||||
: fun(fun), flags(fun->flags()),
|
||||
scriptOrLazyScript(fun->hasScript()
|
||||
? (gc::Cell *) fun->nonLazyScript()
|
||||
: (gc::Cell *) fun->lazyScript()),
|
||||
|
|
|
@ -423,7 +423,7 @@ JitRuntime::generateArgumentsRectifier(JSContext *cx, ExecutionMode mode, void *
|
|||
|
||||
// Load the number of |undefined|s to push into r6.
|
||||
masm.ma_ldr(DTRAddr(sp, DtrOffImm(IonRectifierFrameLayout::offsetOfCalleeToken())), r1);
|
||||
masm.ma_ldrh(EDtrAddr(r1, EDtrOffImm(offsetof(JSFunction, nargs))), r6);
|
||||
masm.ma_ldrh(EDtrAddr(r1, EDtrOffImm(JSFunction::offsetOfNargs())), r6);
|
||||
|
||||
masm.ma_sub(r6, r8, r2);
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ JitRuntime::generateArgumentsRectifier(JSContext *cx, ExecutionMode mode, void *
|
|||
|
||||
// Load the number of |undefined|s to push into %rcx.
|
||||
masm.loadPtr(Address(rsp, IonRectifierFrameLayout::offsetOfCalleeToken()), rax);
|
||||
masm.movzwl(Operand(rax, offsetof(JSFunction, nargs)), rcx);
|
||||
masm.movzwl(Operand(rax, JSFunction::offsetOfNargs()), rcx);
|
||||
masm.subq(r8, rcx);
|
||||
|
||||
// Copy the number of actual arguments
|
||||
|
|
|
@ -353,7 +353,7 @@ JitRuntime::generateArgumentsRectifier(JSContext *cx, ExecutionMode mode, void *
|
|||
|
||||
// Load the number of |undefined|s to push into %ecx.
|
||||
masm.loadPtr(Address(esp, IonRectifierFrameLayout::offsetOfCalleeToken()), eax);
|
||||
masm.movzwl(Operand(eax, offsetof(JSFunction, nargs)), ecx);
|
||||
masm.movzwl(Operand(eax, JSFunction::offsetOfNargs()), ecx);
|
||||
masm.subl(esi, ecx);
|
||||
|
||||
// Copy the number of actual arguments.
|
||||
|
|
|
@ -225,7 +225,7 @@ static inline uint32_t ArgSlot(uint32_t arg) {
|
|||
return 1 + arg;
|
||||
}
|
||||
static inline uint32_t LocalSlot(JSScript *script, uint32_t local) {
|
||||
return 1 + (script->function() ? script->function()->nargs : 0) + local;
|
||||
return 1 + (script->function() ? script->function()->nargs() : 0) + local;
|
||||
}
|
||||
static inline uint32_t TotalSlots(JSScript *script) {
|
||||
return LocalSlot(script, 0) + script->nfixed();
|
||||
|
|
|
@ -4014,7 +4014,7 @@ JS_GetFunctionDisplayId(JSFunction *fun)
|
|||
JS_PUBLIC_API(uint16_t)
|
||||
JS_GetFunctionArity(JSFunction *fun)
|
||||
{
|
||||
return fun->nargs;
|
||||
return fun->nargs();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
|
|
|
@ -302,7 +302,7 @@ js::fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
|||
if (fun->isInterpretedLazy() && !fun->getOrCreateScript(cx))
|
||||
return false;
|
||||
uint16_t length = fun->hasScript() ? fun->nonLazyScript()->funLength() :
|
||||
fun->nargs - fun->hasRest();
|
||||
fun->nargs() - fun->hasRest();
|
||||
v.setInt32(length);
|
||||
} else {
|
||||
v.setString(fun->atom() == nullptr ? cx->runtime()->emptyString : fun->atom());
|
||||
|
@ -387,7 +387,7 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
|||
if (!script)
|
||||
return false;
|
||||
atom = fun->atom();
|
||||
flagsword = (fun->nargs << 16) | fun->flags;
|
||||
flagsword = (fun->nargs() << 16) | fun->flags();
|
||||
|
||||
if (!xdr->codeUint32(&firstword))
|
||||
return false;
|
||||
|
@ -419,14 +419,14 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
|||
return false;
|
||||
|
||||
if (mode == XDR_DECODE) {
|
||||
fun->nargs = flagsword >> 16;
|
||||
fun->flags = uint16_t(flagsword);
|
||||
fun->setArgCount(flagsword >> 16);
|
||||
fun->setFlags(uint16_t(flagsword));
|
||||
fun->initAtom(atom);
|
||||
fun->initScript(script);
|
||||
script->setFunction(fun);
|
||||
if (!JSFunction::setTypeForScriptedFunction(cx, fun))
|
||||
return false;
|
||||
JS_ASSERT(fun->nargs == fun->nonLazyScript()->bindings.numArgs());
|
||||
JS_ASSERT(fun->nargs() == fun->nonLazyScript()->bindings.numArgs());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
CallNewScriptHook(cx, script, fun);
|
||||
objp.set(fun);
|
||||
|
@ -463,8 +463,8 @@ js::CloneFunctionAndScript(JSContext *cx, HandleObject enclosingScope, HandleFun
|
|||
if (!clonedScript)
|
||||
return nullptr;
|
||||
|
||||
clone->nargs = srcFun->nargs;
|
||||
clone->flags = srcFun->flags;
|
||||
clone->setArgCount(srcFun->nargs());
|
||||
clone->setFlags(srcFun->flags());
|
||||
clone->initAtom(srcFun->displayAtom());
|
||||
clone->initScript(clonedScript);
|
||||
clonedScript->setFunction(clone);
|
||||
|
@ -717,9 +717,9 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
|||
ScopedJSDeletePtr<BindingVector> freeNames(localNames);
|
||||
if (!FillBindingVector(script, localNames))
|
||||
return nullptr;
|
||||
for (unsigned i = 0; i < fun->nargs; i++) {
|
||||
for (unsigned i = 0; i < fun->nargs(); i++) {
|
||||
if ((i && !out.append(", ")) ||
|
||||
(i == unsigned(fun->nargs - 1) && fun->hasRest() && !out.append("...")) ||
|
||||
(i == unsigned(fun->nargs() - 1) && fun->hasRest() && !out.append("...")) ||
|
||||
!out.append((*localNames)[i].name())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1124,8 +1124,8 @@ JSFunction::createScriptForLazilyInterpretedFunction(JSContext *cx, HandleFuncti
|
|||
// THING_ROOT_LAZY_SCRIPT).
|
||||
AutoSuppressGC suppressGC(cx);
|
||||
|
||||
fun->flags &= ~INTERPRETED_LAZY;
|
||||
fun->flags |= INTERPRETED;
|
||||
fun->flags_ &= ~INTERPRETED_LAZY;
|
||||
fun->flags_ |= INTERPRETED;
|
||||
|
||||
RootedScript script(cx, lazy->maybeScript());
|
||||
|
||||
|
@ -1333,7 +1333,7 @@ js_fun_bind(JSContext *cx, HandleObject target, HandleValue thisArg,
|
|||
/* Steps 15-16. */
|
||||
unsigned length = 0;
|
||||
if (target->is<JSFunction>()) {
|
||||
unsigned nargs = target->as<JSFunction>().nargs;
|
||||
unsigned nargs = target->as<JSFunction>().nargs();
|
||||
if (nargs > argslen)
|
||||
length = nargs - argslen;
|
||||
}
|
||||
|
@ -1662,9 +1662,12 @@ js::NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobjArg, Native na
|
|||
}
|
||||
RootedFunction fun(cx, &funobj->as<JSFunction>());
|
||||
|
||||
if (allocKind == JSFunction::ExtendedFinalizeKind)
|
||||
flags = JSFunction::Flags(flags | JSFunction::EXTENDED);
|
||||
|
||||
/* Initialize all function members. */
|
||||
fun->nargs = uint16_t(nargs);
|
||||
fun->flags = flags;
|
||||
fun->setArgCount(uint16_t(nargs));
|
||||
fun->setFlags(flags);
|
||||
if (fun->isInterpreted()) {
|
||||
JS_ASSERT(!native);
|
||||
fun->mutableScript().init(nullptr);
|
||||
|
@ -1674,10 +1677,8 @@ js::NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobjArg, Native na
|
|||
JS_ASSERT(native);
|
||||
fun->initNative(native, nullptr);
|
||||
}
|
||||
if (allocKind == JSFunction::ExtendedFinalizeKind) {
|
||||
fun->flags |= JSFunction::EXTENDED;
|
||||
if (allocKind == JSFunction::ExtendedFinalizeKind)
|
||||
fun->initializeExtended();
|
||||
}
|
||||
fun->initAtom(atom);
|
||||
|
||||
return fun;
|
||||
|
@ -1710,8 +1711,12 @@ js::CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
|
|||
return nullptr;
|
||||
RootedFunction clone(cx, &cloneobj->as<JSFunction>());
|
||||
|
||||
clone->nargs = fun->nargs;
|
||||
clone->flags = fun->flags & ~JSFunction::EXTENDED;
|
||||
uint16_t flags = fun->flags() & ~JSFunction::EXTENDED;
|
||||
if (allocKind == JSFunction::ExtendedFinalizeKind)
|
||||
flags |= JSFunction::EXTENDED;
|
||||
|
||||
clone->setArgCount(fun->nargs());
|
||||
clone->setFlags(flags);
|
||||
if (fun->hasScript()) {
|
||||
clone->initScript(fun->nonLazyScript());
|
||||
clone->initEnvironment(parent);
|
||||
|
@ -1725,7 +1730,6 @@ js::CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
|
|||
clone->initAtom(fun->displayAtom());
|
||||
|
||||
if (allocKind == JSFunction::ExtendedFinalizeKind) {
|
||||
clone->flags |= JSFunction::EXTENDED;
|
||||
if (fun->isExtended() && fun->compartment() == cx->compartment()) {
|
||||
for (unsigned i = 0; i < FunctionExtended::NUM_EXTENDED_SLOTS; i++)
|
||||
clone->initExtendedSlot(i, fun->getExtendedSlot(i));
|
||||
|
|
|
@ -63,9 +63,10 @@ class JSFunction : public JSObject
|
|||
"shadow interface must match actual interface");
|
||||
}
|
||||
|
||||
uint16_t nargs; /* number of formal arguments
|
||||
private:
|
||||
uint16_t nargs_; /* number of formal arguments
|
||||
(including defaults and the rest parameter unlike f.length) */
|
||||
uint16_t flags; /* bitfield composed of the above Flags enum */
|
||||
uint16_t flags_; /* bitfield composed of the above Flags enum */
|
||||
union U {
|
||||
class Native {
|
||||
friend class JSFunction;
|
||||
|
@ -85,7 +86,6 @@ class JSFunction : public JSObject
|
|||
} i;
|
||||
void *nativeOrScript;
|
||||
} u;
|
||||
private:
|
||||
js::HeapPtrAtom atom_; /* name for diagnostics and decompiling */
|
||||
|
||||
public:
|
||||
|
@ -104,26 +104,36 @@ class JSFunction : public JSObject
|
|||
isGenerator();
|
||||
}
|
||||
|
||||
size_t nargs() const {
|
||||
js::AutoThreadSafeAccess ts(this);
|
||||
return nargs_;
|
||||
}
|
||||
|
||||
uint16_t flags() const {
|
||||
js::AutoThreadSafeAccess ts(this);
|
||||
return flags_;
|
||||
}
|
||||
|
||||
/* A function can be classified as either native (C++) or interpreted (JS): */
|
||||
bool isInterpreted() const { return flags & (INTERPRETED | INTERPRETED_LAZY); }
|
||||
bool isInterpreted() const { return flags() & (INTERPRETED | INTERPRETED_LAZY); }
|
||||
bool isNative() const { return !isInterpreted(); }
|
||||
|
||||
/* Possible attributes of a native function: */
|
||||
bool isNativeConstructor() const { return flags & NATIVE_CTOR; }
|
||||
bool isNativeConstructor() const { return flags() & NATIVE_CTOR; }
|
||||
|
||||
/* Possible attributes of an interpreted function: */
|
||||
bool isFunctionPrototype() const { return flags & IS_FUN_PROTO; }
|
||||
bool isInterpretedLazy() const { return flags & INTERPRETED_LAZY; }
|
||||
bool hasScript() const { return flags & INTERPRETED; }
|
||||
bool isExprClosure() const { return flags & EXPR_CLOSURE; }
|
||||
bool hasGuessedAtom() const { return flags & HAS_GUESSED_ATOM; }
|
||||
bool isLambda() const { return flags & LAMBDA; }
|
||||
bool isSelfHostedBuiltin() const { return flags & SELF_HOSTED; }
|
||||
bool isSelfHostedConstructor() const { return flags & SELF_HOSTED_CTOR; }
|
||||
bool hasRest() const { return flags & HAS_REST; }
|
||||
bool isFunctionPrototype() const { return flags() & IS_FUN_PROTO; }
|
||||
bool isInterpretedLazy() const { return flags() & INTERPRETED_LAZY; }
|
||||
bool hasScript() const { return flags() & INTERPRETED; }
|
||||
bool isExprClosure() const { return flags() & EXPR_CLOSURE; }
|
||||
bool hasGuessedAtom() const { return flags() & HAS_GUESSED_ATOM; }
|
||||
bool isLambda() const { return flags() & LAMBDA; }
|
||||
bool isSelfHostedBuiltin() const { return flags() & SELF_HOSTED; }
|
||||
bool isSelfHostedConstructor() const { return flags() & SELF_HOSTED_CTOR; }
|
||||
bool hasRest() const { return flags() & HAS_REST; }
|
||||
bool isWrappable() const {
|
||||
JS_ASSERT_IF(flags & SH_WRAPPABLE, isSelfHostedBuiltin());
|
||||
return flags & SH_WRAPPABLE;
|
||||
JS_ASSERT_IF(flags() & SH_WRAPPABLE, isSelfHostedBuiltin());
|
||||
return flags() & SH_WRAPPABLE;
|
||||
}
|
||||
|
||||
bool hasJITCode() const {
|
||||
|
@ -144,7 +154,7 @@ class JSFunction : public JSObject
|
|||
//
|
||||
// isArrow() is true for all three of these Function objects.
|
||||
// isBoundFunction() is true only for the last one.
|
||||
bool isArrow() const { return flags & ARROW; }
|
||||
bool isArrow() const { return flags() & ARROW; }
|
||||
|
||||
/* Compound attributes: */
|
||||
bool isBuiltin() const {
|
||||
|
@ -170,40 +180,48 @@ class JSFunction : public JSObject
|
|||
return nonLazyScript()->strict();
|
||||
}
|
||||
|
||||
void setFlags(uint16_t flags) {
|
||||
this->flags_ = flags;
|
||||
}
|
||||
|
||||
// Can be called multiple times by the parser.
|
||||
void setArgCount(uint16_t nargs) {
|
||||
this->nargs = nargs;
|
||||
this->nargs_ = nargs;
|
||||
}
|
||||
|
||||
// Can be called multiple times by the parser.
|
||||
void setHasRest() {
|
||||
flags |= HAS_REST;
|
||||
flags_ |= HAS_REST;
|
||||
}
|
||||
|
||||
void setIsSelfHostedBuiltin() {
|
||||
JS_ASSERT(!isSelfHostedBuiltin());
|
||||
flags |= SELF_HOSTED;
|
||||
flags_ |= SELF_HOSTED;
|
||||
}
|
||||
|
||||
void setIsSelfHostedConstructor() {
|
||||
JS_ASSERT(!isSelfHostedConstructor());
|
||||
flags |= SELF_HOSTED_CTOR;
|
||||
flags_ |= SELF_HOSTED_CTOR;
|
||||
}
|
||||
|
||||
void makeWrappable() {
|
||||
JS_ASSERT(isSelfHostedBuiltin());
|
||||
JS_ASSERT(!isWrappable());
|
||||
flags |= SH_WRAPPABLE;
|
||||
flags_ |= SH_WRAPPABLE;
|
||||
}
|
||||
|
||||
void setIsFunctionPrototype() {
|
||||
JS_ASSERT(!isFunctionPrototype());
|
||||
flags |= IS_FUN_PROTO;
|
||||
flags_ |= IS_FUN_PROTO;
|
||||
}
|
||||
|
||||
// Can be called multiple times by the parser.
|
||||
void setIsExprClosure() {
|
||||
flags |= EXPR_CLOSURE;
|
||||
flags_ |= EXPR_CLOSURE;
|
||||
}
|
||||
|
||||
void setArrow() {
|
||||
flags_ |= ARROW;
|
||||
}
|
||||
|
||||
JSAtom *atom() const { return hasGuessedAtom() ? nullptr : atom_.get(); }
|
||||
|
@ -216,7 +234,7 @@ class JSFunction : public JSObject
|
|||
JS_ASSERT(atom != nullptr);
|
||||
JS_ASSERT(!hasGuessedAtom());
|
||||
atom_ = atom;
|
||||
flags |= HAS_GUESSED_ATOM;
|
||||
flags_ |= HAS_GUESSED_ATOM;
|
||||
}
|
||||
|
||||
/* uint16_t representation bounds number of call object dynamic slots. */
|
||||
|
@ -241,6 +259,8 @@ class JSFunction : public JSObject
|
|||
((js::HeapPtrObject *)&u.i.env_)->init(obj);
|
||||
}
|
||||
|
||||
static inline size_t offsetOfNargs() { return offsetof(JSFunction, nargs_); }
|
||||
static inline size_t offsetOfFlags() { return offsetof(JSFunction, flags_); }
|
||||
static inline size_t offsetOfEnvironment() { return offsetof(JSFunction, u.i.env_); }
|
||||
static inline size_t offsetOfAtom() { return offsetof(JSFunction, atom_); }
|
||||
|
||||
|
@ -291,8 +311,8 @@ class JSFunction : public JSObject
|
|||
if (shadowZone()->needsBarrier())
|
||||
js::LazyScript::writeBarrierPre(lazy);
|
||||
|
||||
flags &= ~INTERPRETED_LAZY;
|
||||
flags |= INTERPRETED;
|
||||
flags_ &= ~INTERPRETED_LAZY;
|
||||
flags_ |= INTERPRETED;
|
||||
initScript(script);
|
||||
}
|
||||
JS_ASSERT(hasScript());
|
||||
|
@ -348,8 +368,8 @@ class JSFunction : public JSObject
|
|||
|
||||
void initLazyScript(js::LazyScript *lazy) {
|
||||
JS_ASSERT(isInterpreted());
|
||||
flags &= ~INTERPRETED;
|
||||
flags |= INTERPRETED_LAZY;
|
||||
flags_ &= ~INTERPRETED;
|
||||
flags_ |= INTERPRETED_LAZY;
|
||||
u.i.s.lazy_ = lazy;
|
||||
}
|
||||
|
||||
|
@ -426,8 +446,8 @@ class JSFunction : public JSObject
|
|||
public:
|
||||
inline bool isExtended() const {
|
||||
JS_STATIC_ASSERT(FinalizeKind != ExtendedFinalizeKind);
|
||||
JS_ASSERT_IF(isTenured(), !!(flags & EXTENDED) == (tenuredGetAllocKind() == ExtendedFinalizeKind));
|
||||
return !!(flags & EXTENDED);
|
||||
JS_ASSERT_IF(isTenured(), !!(flags() & EXTENDED) == (tenuredGetAllocKind() == ExtendedFinalizeKind));
|
||||
return !!(flags() & EXTENDED);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -692,7 +692,7 @@ TypeScript::FreezeTypeSets(CompilerConstraintList *constraints, JSScript *script
|
|||
}
|
||||
|
||||
*pThisTypes = types + (ThisTypes(script) - existing);
|
||||
*pArgTypes = (script->function() && script->function()->nargs)
|
||||
*pArgTypes = (script->function() && script->function()->nargs())
|
||||
? (types + (ArgTypes(script, 0) - existing))
|
||||
: nullptr;
|
||||
*pBytecodeTypes = types;
|
||||
|
@ -972,7 +972,7 @@ types::FinishCompilation(JSContext *cx, HandleScript script, ExecutionMode execu
|
|||
|
||||
if (!CheckFrozenTypeSet(cx, entry.thisTypes, types::TypeScript::ThisTypes(entry.script)))
|
||||
succeeded = false;
|
||||
unsigned nargs = entry.script->function() ? entry.script->function()->nargs : 0;
|
||||
unsigned nargs = entry.script->function() ? entry.script->function()->nargs() : 0;
|
||||
for (size_t i = 0; i < nargs; i++) {
|
||||
if (!CheckFrozenTypeSet(cx, &entry.argTypes[i], types::TypeScript::ArgTypes(entry.script, i)))
|
||||
succeeded = false;
|
||||
|
@ -3354,7 +3354,7 @@ void
|
|||
types::TypeMonitorCallSlow(JSContext *cx, JSObject *callee, const CallArgs &args,
|
||||
bool constructing)
|
||||
{
|
||||
unsigned nargs = callee->as<JSFunction>().nargs;
|
||||
unsigned nargs = callee->as<JSFunction>().nargs();
|
||||
JSScript *script = callee->as<JSFunction>().nonLazyScript();
|
||||
|
||||
if (!constructing)
|
||||
|
@ -3505,7 +3505,7 @@ JSScript::makeTypes(JSContext *cx)
|
|||
InferSpew(ISpewOps, "typeSet: %sT%p%s this #%u",
|
||||
InferSpewColor(thisTypes), thisTypes, InferSpewColorReset(),
|
||||
id());
|
||||
unsigned nargs = function() ? function()->nargs : 0;
|
||||
unsigned nargs = function() ? function()->nargs() : 0;
|
||||
for (unsigned i = 0; i < nargs; i++) {
|
||||
TypeSet *types = TypeScript::ArgTypes(this, i);
|
||||
InferSpew(ISpewOps, "typeSet: %sT%p%s arg%u #%u",
|
||||
|
@ -4385,7 +4385,7 @@ TypeScript::printTypes(JSContext *cx, HandleScript script) const
|
|||
fprintf(stderr, "\n this:");
|
||||
TypeScript::ThisTypes(script)->print();
|
||||
|
||||
for (unsigned i = 0; script->function() && i < script->function()->nargs; i++) {
|
||||
for (unsigned i = 0; script->function() && i < script->function()->nargs(); i++) {
|
||||
fprintf(stderr, "\n arg%u:", i);
|
||||
TypeScript::ArgTypes(script, i)->print();
|
||||
}
|
||||
|
|
|
@ -617,7 +617,7 @@ TypeScript::ThisTypes(JSScript *script)
|
|||
/* static */ inline StackTypeSet *
|
||||
TypeScript::ArgTypes(JSScript *script, unsigned i)
|
||||
{
|
||||
JS_ASSERT(i < script->function()->nargs);
|
||||
JS_ASSERT(i < script->function()->nargs());
|
||||
return script->types->typeArray() + script->nTypeSets() + js::analyze::ArgSlot(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -410,7 +410,7 @@ class BytecodeParser
|
|||
}
|
||||
|
||||
uint32_t numSlots() {
|
||||
return 1 + (script_->function() ? script_->function()->nargs : 0) + script_->nfixed();
|
||||
return 1 + (script_->function() ? script_->function()->nargs() : 0) + script_->nfixed();
|
||||
}
|
||||
|
||||
uint32_t maximumStackDepth() {
|
||||
|
@ -1688,7 +1688,7 @@ JSAtom *
|
|||
ExpressionDecompiler::getVar(unsigned slot)
|
||||
{
|
||||
JS_ASSERT(fun);
|
||||
slot += fun->nargs;
|
||||
slot += fun->nargs();
|
||||
JS_ASSERT(slot < script->bindings.count());
|
||||
return (*localNames)[slot].name();
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ struct CopyIonJSFrameArgs
|
|||
|
||||
void copyArgs(JSContext *, HeapValue *dstBase, unsigned totalArgs) const {
|
||||
unsigned numActuals = frame_->numActualArgs();
|
||||
unsigned numFormals = jit::CalleeTokenToFunction(frame_->calleeToken())->nargs;
|
||||
unsigned numFormals = jit::CalleeTokenToFunction(frame_->calleeToken())->nargs();
|
||||
JS_ASSERT(numActuals <= totalArgs);
|
||||
JS_ASSERT(numFormals <= totalArgs);
|
||||
JS_ASSERT(Max(numActuals, numFormals) == totalArgs);
|
||||
|
@ -144,7 +144,7 @@ struct CopyScriptFrameIterArgs
|
|||
|
||||
/* Define formals which are not part of the actuals. */
|
||||
unsigned numActuals = iter_.numActualArgs();
|
||||
unsigned numFormals = iter_.callee()->nargs;
|
||||
unsigned numFormals = iter_.callee()->nargs();
|
||||
JS_ASSERT(numActuals <= totalArgs);
|
||||
JS_ASSERT(numFormals <= totalArgs);
|
||||
JS_ASSERT(Max(numActuals, numFormals) == totalArgs);
|
||||
|
@ -192,7 +192,7 @@ ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction calle
|
|||
if (!shape)
|
||||
return nullptr;
|
||||
|
||||
unsigned numFormals = callee->nargs;
|
||||
unsigned numFormals = callee->nargs();
|
||||
unsigned numDeletedWords = NumWordsForBitArrayOfLength(numActuals);
|
||||
unsigned numArgs = Max(numActuals, numFormals);
|
||||
unsigned numBytes = offsetof(ArgumentsData, args) +
|
||||
|
@ -341,7 +341,7 @@ ArgSetter(JSContext *cx, HandleObject obj, HandleId id, bool strict, MutableHand
|
|||
unsigned arg = unsigned(JSID_TO_INT(id));
|
||||
if (arg < argsobj.initialLength() && !argsobj.isElementDeleted(arg)) {
|
||||
argsobj.setElement(cx, arg, vp);
|
||||
if (arg < script->function()->nargs)
|
||||
if (arg < script->function()->nargs())
|
||||
types::TypeScript::SetArgument(cx, script, arg, vp);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4720,23 +4720,23 @@ DebuggerObject_getParameterNames(JSContext *cx, unsigned argc, Value *vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
RootedObject result(cx, NewDenseAllocatedArray(cx, fun->nargs));
|
||||
RootedObject result(cx, NewDenseAllocatedArray(cx, fun->nargs()));
|
||||
if (!result)
|
||||
return false;
|
||||
result->ensureDenseInitializedLength(cx, 0, fun->nargs);
|
||||
result->ensureDenseInitializedLength(cx, 0, fun->nargs());
|
||||
|
||||
if (fun->isInterpreted()) {
|
||||
RootedScript script(cx, GetOrCreateFunctionScript(cx, fun));
|
||||
if (!script)
|
||||
return false;
|
||||
|
||||
JS_ASSERT(fun->nargs == script->bindings.numArgs());
|
||||
JS_ASSERT(fun->nargs() == script->bindings.numArgs());
|
||||
|
||||
if (fun->nargs > 0) {
|
||||
if (fun->nargs() > 0) {
|
||||
BindingVector bindings(cx);
|
||||
if (!FillBindingVector(script, &bindings))
|
||||
return false;
|
||||
for (size_t i = 0; i < fun->nargs; i++) {
|
||||
for (size_t i = 0; i < fun->nargs(); i++) {
|
||||
Value v;
|
||||
if (bindings[i].name()->length() == 0)
|
||||
v = UndefinedValue();
|
||||
|
@ -4746,7 +4746,7 @@ DebuggerObject_getParameterNames(JSContext *cx, unsigned argc, Value *vp)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < fun->nargs; i++)
|
||||
for (size_t i = 0; i < fun->nargs(); i++)
|
||||
result->setDenseElement(i, UndefinedValue());
|
||||
}
|
||||
|
||||
|
|
|
@ -3609,7 +3609,7 @@ js::Lambda(JSContext *cx, HandleFunction fun, HandleObject parent)
|
|||
clone = js_fun_bind(cx, clone, thisval, nullptr, 0);
|
||||
if (!clone)
|
||||
return nullptr;
|
||||
clone->as<JSFunction>().flags |= JSFunction::ARROW;
|
||||
clone->as<JSFunction>().setArrow();
|
||||
}
|
||||
|
||||
JS_ASSERT(clone->global() == clone->global());
|
||||
|
|
|
@ -450,7 +450,7 @@ JS_GetLinePCs(JSContext *cx, JSScript *script,
|
|||
JS_PUBLIC_API(unsigned)
|
||||
JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun)
|
||||
{
|
||||
return fun->nargs;
|
||||
return fun->nargs();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
|
|
|
@ -960,8 +960,8 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext *cx, Handle<PropertyName*> na
|
|||
return false;
|
||||
targetFun->setScript(cscript);
|
||||
cscript->setFunction(targetFun);
|
||||
JS_ASSERT(sourceFun->nargs == targetFun->nargs);
|
||||
targetFun->flags = sourceFun->flags | JSFunction::EXTENDED;
|
||||
JS_ASSERT(sourceFun->nargs() == targetFun->nargs());
|
||||
targetFun->setFlags(sourceFun->flags() | JSFunction::EXTENDED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ InterpreterStack::getCallFrame(JSContext *cx, const CallArgs &args, HandleScript
|
|||
JSFunction *fun = &args.callee().as<JSFunction>();
|
||||
|
||||
JS_ASSERT(fun->nonLazyScript() == script);
|
||||
unsigned nformal = fun->nargs;
|
||||
unsigned nformal = fun->nargs();
|
||||
unsigned nvals = script->nslots();
|
||||
|
||||
if (args.length() >= nformal) {
|
||||
|
|
|
@ -165,7 +165,7 @@ JSObject *
|
|||
StackFrame::createRestParameter(JSContext *cx)
|
||||
{
|
||||
JS_ASSERT(fun()->hasRest());
|
||||
unsigned nformal = fun()->nargs - 1, nactual = numActualArgs();
|
||||
unsigned nformal = fun()->nargs() - 1, nactual = numActualArgs();
|
||||
unsigned nrest = (nactual > nformal) ? nactual - nformal : 0;
|
||||
Value *restvp = argv() + nformal;
|
||||
JSObject *obj = NewDenseCopiedArray(cx, nrest, restvp, nullptr);
|
||||
|
|
|
@ -534,7 +534,7 @@ class StackFrame
|
|||
|
||||
bool copyRawFrameSlots(AutoValueVector *v);
|
||||
|
||||
unsigned numFormalArgs() const { JS_ASSERT(hasArgs()); return fun()->nargs; }
|
||||
unsigned numFormalArgs() const { JS_ASSERT(hasArgs()); return fun()->nargs(); }
|
||||
unsigned numActualArgs() const { JS_ASSERT(hasArgs()); return u.nactual; }
|
||||
|
||||
inline Value &canonicalActualArg(unsigned i) const;
|
||||
|
@ -1563,7 +1563,7 @@ class ScriptFrameIter
|
|||
JSFunction *callee() const;
|
||||
Value calleev() const;
|
||||
unsigned numActualArgs() const;
|
||||
unsigned numFormalArgs() const { return script()->function()->nargs; }
|
||||
unsigned numFormalArgs() const { return script()->function()->nargs(); }
|
||||
Value unaliasedActual(unsigned i, MaybeCheckAliasing = CHECK_ALIASING) const;
|
||||
|
||||
JSObject *scopeChain() const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче