mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 1351107 - Make the DeprecatedLanguageExtensions enum an enum class in a new header, to address a thorny cyclic dependency issue in subsequent patches. r=arai
This commit is contained in:
parent
0e9d30f091
commit
4e5271b990
45
js/src/frontend/LanguageExtensions.h
Normal file
45
js/src/frontend/LanguageExtensions.h
Normal file
@ -0,0 +1,45 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* 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/. */
|
||||
|
||||
/* Code related to various SpiderMonkey-specific language syntax extensions. */
|
||||
|
||||
#ifndef frontend_LanguageExtensions_h
|
||||
#define frontend_LanguageExtensions_h
|
||||
|
||||
namespace js {
|
||||
|
||||
/**
|
||||
* Numeric identifiers for various deprecated language extensions.
|
||||
*
|
||||
* The initializer numbers are directly used in telemetry, so while it's okay
|
||||
* to *remove* values as language extensions are removed from SpiderMonkey,
|
||||
* it's *not* okay to compact or reorder them. When an initializer falls into
|
||||
* disuse, remove it without reassigning its value to a new or existing
|
||||
* initializer. The *only* initializer whose value should ever change is
|
||||
* DeprecatedLanguageExtension::Count.
|
||||
*/
|
||||
enum class DeprecatedLanguageExtension
|
||||
{
|
||||
ForEach = 0, // JS 1.6+
|
||||
// NO LONGER USING 1
|
||||
LegacyGenerator = 2, // JS 1.7+
|
||||
ExpressionClosure = 3, // Added in JS 1.8
|
||||
// NO LONGER USING 4
|
||||
// NO LONGER USING 5
|
||||
// NO LONGER USING 6
|
||||
// NO LONGER USING 7
|
||||
// NO LONGER USING 8
|
||||
// NO LONGER USING 9
|
||||
BlockScopeFunRedecl = 10,
|
||||
|
||||
// Sentinel value. MAY change as extension initializers are added (only to
|
||||
// the end) above.
|
||||
Count
|
||||
};
|
||||
|
||||
} // namespace js
|
||||
|
||||
#endif /* frontend_LanguageExtensions_h */
|
@ -3695,7 +3695,7 @@ Parser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling inHandli
|
||||
}
|
||||
|
||||
#if JS_HAS_EXPR_CLOSURES
|
||||
addTelemetry(JSCompartment::DeprecatedExpressionClosure);
|
||||
addTelemetry(DeprecatedLanguageExtension::ExpressionClosure);
|
||||
if (!warnOnceAboutExprClosure())
|
||||
return false;
|
||||
#else
|
||||
@ -6191,7 +6191,7 @@ Parser<ParseHandler, CharT>::forStatement(YieldHandling yieldHandling)
|
||||
if (matched) {
|
||||
iflags = JSITER_FOREACH;
|
||||
isForEach = true;
|
||||
addTelemetry(JSCompartment::DeprecatedForEach);
|
||||
addTelemetry(DeprecatedLanguageExtension::ForEach);
|
||||
if (!warnOnceAboutForEach())
|
||||
return null();
|
||||
}
|
||||
@ -6702,7 +6702,7 @@ Parser<ParseHandler, CharT>::yieldExpression(InHandling inHandling)
|
||||
}
|
||||
|
||||
pc->functionBox()->setGeneratorKind(LegacyGenerator);
|
||||
addTelemetry(JSCompartment::DeprecatedLegacyGenerator);
|
||||
addTelemetry(DeprecatedLanguageExtension::LegacyGenerator);
|
||||
|
||||
MOZ_FALLTHROUGH;
|
||||
|
||||
@ -10245,7 +10245,7 @@ Parser<ParseHandler, CharT>::exprInParens(InHandling inHandling, YieldHandling y
|
||||
}
|
||||
|
||||
void
|
||||
ParserBase::addTelemetry(JSCompartment::DeprecatedLanguageExtension e)
|
||||
ParserBase::addTelemetry(DeprecatedLanguageExtension e)
|
||||
{
|
||||
if (context->helperThread())
|
||||
return;
|
||||
|
@ -13,13 +13,13 @@
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include "jscompartment.h"
|
||||
#include "jsiter.h"
|
||||
#include "jspubtd.h"
|
||||
|
||||
#include "ds/Nestable.h"
|
||||
#include "frontend/BytecodeCompiler.h"
|
||||
#include "frontend/FullParseHandler.h"
|
||||
#include "frontend/LanguageExtensions.h"
|
||||
#include "frontend/NameAnalysisTypes.h"
|
||||
#include "frontend/NameCollections.h"
|
||||
#include "frontend/SharedContext.h"
|
||||
@ -900,7 +900,7 @@ class ParserBase : public StrictModeGetter
|
||||
|
||||
bool isValidStrictBinding(PropertyName* name);
|
||||
|
||||
void addTelemetry(JSCompartment::DeprecatedLanguageExtension e);
|
||||
void addTelemetry(DeprecatedLanguageExtension e);
|
||||
|
||||
bool warnOnceAboutExprClosure();
|
||||
bool warnOnceAboutForEach();
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsgc.h"
|
||||
@ -1380,7 +1382,7 @@ JSCompartment::reportTelemetry()
|
||||
: JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT;
|
||||
|
||||
// Call back into Firefox's Telemetry reporter.
|
||||
for (size_t i = 0; i < DeprecatedLanguageExtensionCount; i++) {
|
||||
for (size_t i = 0; i < size_t(DeprecatedLanguageExtension::Count); i++) {
|
||||
if (sawDeprecatedLanguageExtension[i])
|
||||
runtime_->addTelemetry(id, i);
|
||||
}
|
||||
@ -1395,7 +1397,7 @@ JSCompartment::addTelemetry(const char* filename, DeprecatedLanguageExtension e)
|
||||
if (!creationOptions_.addonIdOrNull() && (!filename || strncmp(filename, "http", 4) != 0))
|
||||
return;
|
||||
|
||||
sawDeprecatedLanguageExtension[e] = true;
|
||||
sawDeprecatedLanguageExtension[size_t(e)] = true;
|
||||
}
|
||||
|
||||
HashNumber
|
||||
|
@ -14,7 +14,10 @@
|
||||
#include "mozilla/Variant.h"
|
||||
#include "mozilla/XorShift128PlusRNG.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "builtin/RegExp.h"
|
||||
#include "frontend/LanguageExtensions.h"
|
||||
#include "gc/Barrier.h"
|
||||
#include "gc/NurseryAwareHashMap.h"
|
||||
#include "gc/Zone.h"
|
||||
@ -957,33 +960,18 @@ struct JSCompartment
|
||||
return jitCompartment_;
|
||||
}
|
||||
|
||||
enum DeprecatedLanguageExtension {
|
||||
DeprecatedForEach = 0, // JS 1.6+
|
||||
// NO LONGER USING 1
|
||||
DeprecatedLegacyGenerator = 2, // JS 1.7+
|
||||
DeprecatedExpressionClosure = 3, // Added in JS 1.8
|
||||
// NO LONGER USING 4
|
||||
// NO LONGER USING 5
|
||||
// NO LONGER USING 6
|
||||
// NO LONGER USING 7
|
||||
// NO LONGER USING 8
|
||||
// NO LONGER USING 9
|
||||
DeprecatedBlockScopeFunRedecl = 10,
|
||||
DeprecatedLanguageExtensionCount
|
||||
};
|
||||
|
||||
js::ArgumentsObject* getOrCreateArgumentsTemplateObject(JSContext* cx, bool mapped);
|
||||
|
||||
js::ArgumentsObject* maybeArgumentsTemplateObject(bool mapped) const;
|
||||
|
||||
private:
|
||||
// Used for collecting telemetry on SpiderMonkey's deprecated language extensions.
|
||||
bool sawDeprecatedLanguageExtension[DeprecatedLanguageExtensionCount];
|
||||
bool sawDeprecatedLanguageExtension[size_t(js::DeprecatedLanguageExtension::Count)];
|
||||
|
||||
void reportTelemetry();
|
||||
|
||||
public:
|
||||
void addTelemetry(const char* filename, DeprecatedLanguageExtension e);
|
||||
void addTelemetry(const char* filename, js::DeprecatedLanguageExtension e);
|
||||
|
||||
public:
|
||||
// Aggregated output used to collect JSScript hit counts when code coverage
|
||||
|
Loading…
Reference in New Issue
Block a user