зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1569315) on request from mgaudet on a CLOSED TREE
Backed out changeset eb0b2f561461 (bug 1569315) Backed out changeset 5d553fb84ecb (bug 1569315)
This commit is contained in:
Родитель
6d094c687d
Коммит
d5489769c1
|
@ -261,15 +261,10 @@ JS::Result<FunctionBox*> BinASTParserPerTokenizer<Tok>::buildFunctionBox(
|
|||
|
||||
// Allocate the function before walking down the tree.
|
||||
RootedFunction fun(cx_);
|
||||
if (pc_) {
|
||||
Rooted<FunctionCreationData> fcd(
|
||||
cx_, GenerateFunctionCreationData(atom, syntax, generatorKind,
|
||||
BINJS_TRY_VAR(fun, !pc_ ? lazyScript_->functionNonDelazifying()
|
||||
: AllocNewFunction(cx_, atom, syntax, generatorKind,
|
||||
functionAsyncKind));
|
||||
BINJS_TRY_VAR(fun, AllocNewFunction(cx_, fcd));
|
||||
MOZ_ASSERT(fun->explicitName() == atom);
|
||||
} else {
|
||||
BINJS_TRY_VAR(fun, lazyScript_->functionNonDelazifying());
|
||||
}
|
||||
MOZ_ASSERT_IF(pc_, fun->explicitName() == atom);
|
||||
|
||||
mozilla::Maybe<Directives> directives;
|
||||
if (pc_) {
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef frontend_FunctionCreationData_h
|
||||
#define frontend_FunctionCreationData_h
|
||||
|
||||
#include "frontend/ParseNode.h"
|
||||
#include "gc/AllocKind.h"
|
||||
#include "gc/Rooting.h"
|
||||
#include "vm/JSFunction.h"
|
||||
#include "vm/JSScript.h"
|
||||
|
||||
namespace js {
|
||||
namespace frontend {
|
||||
|
||||
// Metadata that can be used to allocate a JSFunction object.
|
||||
//
|
||||
// Keeping metadata separate allows the parser to generate
|
||||
// metadata without requiring immediate access to the garbage
|
||||
// collector.
|
||||
struct FunctionCreationData {
|
||||
// The Parser uses KeepAtoms to prevent GC from collecting atoms
|
||||
JSAtom* atom = nullptr;
|
||||
FunctionSyntaxKind kind = FunctionSyntaxKind::Expression;
|
||||
GeneratorKind generatorKind = GeneratorKind::NotGenerator;
|
||||
FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction;
|
||||
|
||||
gc::AllocKind allocKind = gc::AllocKind::FUNCTION;
|
||||
FunctionFlags flags = {};
|
||||
|
||||
bool isSelfHosting = false;
|
||||
|
||||
HandleAtom getAtom(JSContext* cx) const;
|
||||
|
||||
void trace(JSTracer* trc) {
|
||||
TraceRoot(trc, &atom, "FunctionCreationData atom");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace frontend */
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* frontend_FunctionCreationData_h */
|
|
@ -1966,10 +1966,21 @@ GeneralParser<ParseHandler, Unit>::functionBody(InHandling inHandling,
|
|||
return finishLexicalScope(pc_->varScope(), body, ScopeKind::FunctionLexical);
|
||||
}
|
||||
|
||||
FunctionCreationData GenerateFunctionCreationData(
|
||||
HandleAtom atom, FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind, bool isSelfHosting /* = false */,
|
||||
JSFunction* AllocNewFunction(JSContext* cx, HandleAtom atom,
|
||||
FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind,
|
||||
bool isSelfHosting /* = false */,
|
||||
bool inFunctionBox /* = false */) {
|
||||
MOZ_ASSERT_IF(kind == FunctionSyntaxKind::Statement, atom != nullptr);
|
||||
|
||||
RootedObject proto(cx);
|
||||
if (!GetFunctionPrototype(cx, generatorKind, asyncKind, &proto)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RootedFunction fun(cx);
|
||||
|
||||
gc::AllocKind allocKind = gc::AllocKind::FUNCTION;
|
||||
FunctionFlags flags;
|
||||
bool isExtendedUnclonedSelfHostedFunctionName =
|
||||
|
@ -2015,35 +2026,12 @@ FunctionCreationData GenerateFunctionCreationData(
|
|||
: FunctionFlags::INTERPRETED_GENERATOR_OR_ASYNC);
|
||||
}
|
||||
|
||||
return FunctionCreationData{atom, kind, generatorKind, asyncKind,
|
||||
allocKind, flags, isSelfHosting};
|
||||
}
|
||||
|
||||
HandleAtom FunctionCreationData::getAtom(JSContext* cx) const {
|
||||
// We can create a handle here because atoms are traced
|
||||
// by FunctionCreationData.
|
||||
return HandleAtom::fromMarkedLocation(&atom);
|
||||
}
|
||||
|
||||
JSFunction* AllocNewFunction(JSContext* cx,
|
||||
Handle<FunctionCreationData> dataHandle) {
|
||||
// FunctionCreationData don't move, so it is safe to grab a reference
|
||||
// out of the handle.
|
||||
const FunctionCreationData& data = dataHandle.get();
|
||||
|
||||
RootedObject proto(cx);
|
||||
if (!GetFunctionPrototype(cx, data.generatorKind, data.asyncKind, &proto)) {
|
||||
return nullptr;
|
||||
}
|
||||
RootedFunction fun(cx);
|
||||
|
||||
|
||||
fun = NewFunctionWithProto(cx, nullptr, 0, data.flags, nullptr, data.getAtom(cx), proto,
|
||||
data.allocKind, TenuredObject);
|
||||
fun = NewFunctionWithProto(cx, nullptr, 0, flags, nullptr, atom, proto,
|
||||
allocKind, TenuredObject);
|
||||
if (!fun) {
|
||||
return nullptr;
|
||||
}
|
||||
if (data.isSelfHosting) {
|
||||
if (isSelfHosting) {
|
||||
fun->setIsSelfHostedBuiltin();
|
||||
MOZ_ASSERT(!fun->isInterpretedLazy());
|
||||
}
|
||||
|
@ -2053,11 +2041,8 @@ JSFunction* AllocNewFunction(JSContext* cx,
|
|||
JSFunction* ParserBase::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind) {
|
||||
Rooted<FunctionCreationData> fcd(
|
||||
cx_, GenerateFunctionCreationData(atom, kind, generatorKind, asyncKind,
|
||||
options().selfHostingMode,
|
||||
pc_->isFunctionBox()));
|
||||
return AllocNewFunction(cx_, fcd);
|
||||
return AllocNewFunction(cx_, atom, kind, generatorKind, asyncKind,
|
||||
options().selfHostingMode, pc_->isFunctionBox());
|
||||
}
|
||||
|
||||
template <class ParseHandler, typename Unit>
|
||||
|
|
|
@ -1895,14 +1895,13 @@ mozilla::Maybe<LexicalScope::Data*> NewLexicalScopeData(
|
|||
JSContext* context, ParseContext::Scope& scope, LifoAlloc& alloc,
|
||||
ParseContext* pc);
|
||||
|
||||
FunctionCreationData GenerateFunctionCreationData(
|
||||
HandleAtom atom, FunctionSyntaxKind kind, GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind, bool isSelfHosting = false,
|
||||
JSFunction* AllocNewFunction(JSContext* cx, HandleAtom atom,
|
||||
FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind,
|
||||
bool isSelfHosting = false,
|
||||
bool inFunctionBox = false);
|
||||
|
||||
JSFunction* AllocNewFunction(JSContext* cx,
|
||||
Handle<FunctionCreationData> dataHandle);
|
||||
|
||||
} /* namespace frontend */
|
||||
} /* namespace js */
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "jstypes.h"
|
||||
|
||||
#include "ds/InlineTable.h"
|
||||
#include "frontend/FunctionCreationData.h"
|
||||
#include "frontend/ParseNode.h"
|
||||
#include "vm/BytecodeUtil.h"
|
||||
#include "vm/JSFunction.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче