From d868f0540ac9f6357c4d05a540fb28bf604028cc Mon Sep 17 00:00:00 2001 From: Xuan Huang Date: Mon, 29 Mar 2021 21:17:21 -0700 Subject: [PATCH] Rename ES6Intl to Intl Summary: Intl API is standardized under ECMA-402 and it's not associated with ES6 (ECMA-262 6th). Reviewed By: mhorowitz Differential Revision: D27385605 fbshipit-source-id: 5a1d79a5783b8dc0f0220f075355ac895cbbbccb --- API/hermes/SynthTrace.cpp | 2 +- API/hermes/SynthTraceParser.cpp | 4 ++-- .../com/facebook/hermes/test/HermesRuntimeFactory.cpp | 2 +- include/hermes/ConsoleHost/RuntimeFlags.h | 8 ++++---- include/hermes/VM/Runtime.h | 8 ++++---- include/hermes/VM/SerializeHeader.h | 2 +- lib/VM/JSLib/GlobalObject.cpp | 2 +- lib/VM/Runtime.cpp | 8 ++++---- public/hermes/Public/RuntimeConfig.h | 4 ++-- tools/fuzzers/fuzzilli/fuzzilli.cpp | 1 - tools/hermes/hermes.cpp | 4 ++-- tools/hvm/hvm.cpp | 2 +- unittests/API/APITest.cpp | 2 -- unittests/API/HeapSnapshotAPITest.cpp | 1 - unittests/API/SynthTraceParserTest.cpp | 4 ++-- unittests/API/SynthTraceTest.cpp | 4 ++-- unittests/VMRuntime/StackTracesTreeTest.cpp | 4 ++-- 17 files changed, 29 insertions(+), 33 deletions(-) diff --git a/API/hermes/SynthTrace.cpp b/API/hermes/SynthTrace.cpp index 2e30ecba042..deac7f00c19 100644 --- a/API/hermes/SynthTrace.cpp +++ b/API/hermes/SynthTrace.cpp @@ -137,7 +137,7 @@ SynthTrace::SynthTrace( json_->emitKeyValue("ES6Promise", conf.getES6Promise()); json_->emitKeyValue("ES6Proxy", conf.getES6Proxy()); json_->emitKeyValue("ES6Symbol", conf.getES6Symbol()); - json_->emitKeyValue("ES6Intl", conf.getES6Intl()); + json_->emitKeyValue("Intl", conf.getIntl()); json_->emitKeyValue("enableSampledStats", conf.getEnableSampledStats()); json_->emitKeyValue("vmExperimentFlags", conf.getVMExperimentFlags()); json_->closeDict(); diff --git a/API/hermes/SynthTraceParser.cpp b/API/hermes/SynthTraceParser.cpp index 43e3a8b5219..6a9bb6cdca7 100644 --- a/API/hermes/SynthTraceParser.cpp +++ b/API/hermes/SynthTraceParser.cpp @@ -141,8 +141,8 @@ ::hermes::vm::RuntimeConfig::Builder getRuntimeConfig(JSONObject *rtConfig) { if (auto *symbol = rtConfig->get("ES6Symbol")) { conf.withES6Symbol(llvh::cast(symbol)->getValue()); } - if (auto *intl = rtConfig->get("ES6Intl")) { - conf.withES6Intl(llvh::cast(intl)->getValue()); + if (auto *intl = rtConfig->get("Intl")) { + conf.withIntl(llvh::cast(intl)->getValue()); } if (auto *enableSampledStats = rtConfig->get("enableSampledStats")) { conf.withEnableSampledStats( diff --git a/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp b/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp index 1897680c5a5..0250d8a289f 100644 --- a/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp +++ b/android/intltest/java/com/facebook/hermes/test/HermesRuntimeFactory.cpp @@ -23,7 +23,7 @@ jni::local_ref JSRuntime::makeHermesRuntime( bool shouldRecordGCStats) { return newObjectCxxArgs(hermes::makeHermesRuntime( ::hermes::vm::RuntimeConfig::Builder() - .withES6Intl(true) + .withIntl(true) .withGCConfig(::hermes::vm::GCConfig::Builder() .withShouldRecordStats(shouldRecordGCStats) .build()) diff --git a/include/hermes/ConsoleHost/RuntimeFlags.h b/include/hermes/ConsoleHost/RuntimeFlags.h index cba0b9afeea..d107d813e3e 100644 --- a/include/hermes/ConsoleHost/RuntimeFlags.h +++ b/include/hermes/ConsoleHost/RuntimeFlags.h @@ -163,10 +163,10 @@ static opt ES6Symbol( init(RuntimeConfig::getDefaultES6Symbol()), cat(RuntimeCategory)); -static opt ES6Intl( - "Xes6-intl", - desc("Enable support for ES6 Intl APIs"), - init(RuntimeConfig::getDefaultES6Intl()), +static opt Intl( + "Xintl", + desc("Enable support for ECMA-402 Intl APIs"), + init(RuntimeConfig::getDefaultIntl()), cat(RuntimeCategory)); static llvh::cl::opt StopAfterInit( diff --git a/include/hermes/VM/Runtime.h b/include/hermes/VM/Runtime.h index 01496fea496..89ed3b98036 100644 --- a/include/hermes/VM/Runtime.h +++ b/include/hermes/VM/Runtime.h @@ -829,8 +829,8 @@ class Runtime : public HandleRootOwner, return hasES6Symbol_; } - bool hasES6Intl() const { - return hasES6Intl_; + bool hasIntl() const { + return hasIntl_; } bool builtinsAreFrozen() const { @@ -1094,8 +1094,8 @@ class Runtime : public HandleRootOwner, /// Set to true if we should enable ES6 Symbol. const bool hasES6Symbol_; - /// Set to true if we should enable ES6 Intl APIs. - const bool hasES6Intl_; + /// Set to true if we should enable ECMA-402 Intl APIs. + const bool hasIntl_; /// Set to true if we should randomize stack placement etc. const bool shouldRandomizeMemoryLayout_; diff --git a/include/hermes/VM/SerializeHeader.h b/include/hermes/VM/SerializeHeader.h index 97985ca49ca..639abf2575a 100644 --- a/include/hermes/VM/SerializeHeader.h +++ b/include/hermes/VM/SerializeHeader.h @@ -45,7 +45,7 @@ struct SerializeHeader { bool hasES6Promise; bool hasES6Proxy; bool hasES6Symbol; - bool hasES6Intl; + bool hasIntl; uint8_t bytecodeWarmupPercent; bool trackIO; /// Note: The following fields are not being checked right now because they diff --git a/lib/VM/JSLib/GlobalObject.cpp b/lib/VM/JSLib/GlobalObject.cpp index b9be06ed7ae..8b63b0b4be7 100644 --- a/lib/VM/JSLib/GlobalObject.cpp +++ b/lib/VM/JSLib/GlobalObject.cpp @@ -767,7 +767,7 @@ void initGlobalObject(Runtime *runtime, const JSLibFlags &jsLibFlags) { // Define the global Intl object // TODO T65916424: Consider how we can move this somewhere more modular. - if (LLVM_UNLIKELY(runtime->hasES6Intl())) { + if (LLVM_UNLIKELY(runtime->hasIntl())) { runtime->ignoreAllocationFailure(JSObject::defineOwnProperty( runtime->getGlobal(), runtime, diff --git a/lib/VM/Runtime.cpp b/lib/VM/Runtime.cpp index 160cbe37d1e..50d0a43090f 100644 --- a/lib/VM/Runtime.cpp +++ b/lib/VM/Runtime.cpp @@ -162,7 +162,7 @@ Runtime::Runtime( hasES6Promise_(runtimeConfig.getES6Promise()), hasES6Proxy_(runtimeConfig.getES6Proxy()), hasES6Symbol_(runtimeConfig.getES6Symbol()), - hasES6Intl_(runtimeConfig.getES6Intl()), + hasIntl_(runtimeConfig.getIntl()), shouldRandomizeMemoryLayout_(runtimeConfig.getRandomizeMemoryLayout()), bytecodeWarmupPercent_(runtimeConfig.getBytecodeWarmupPercent()), trackIO_(runtimeConfig.getTrackIO()), @@ -2221,7 +2221,7 @@ void Runtime::populateHeaderRuntimeConfig(SerializeHeader &header) { header.hasES6Promise = hasES6Promise_; header.hasES6Proxy = hasES6Proxy_; header.hasES6Symbol = hasES6Symbol_; - header.hasES6Intl = hasES6Intl_; + header.hasIntl = hasIntl_; header.bytecodeWarmupPercent = bytecodeWarmupPercent_; header.trackIO = trackIO_; } @@ -2243,8 +2243,8 @@ void Runtime::checkHeaderRuntimeConfig(SerializeHeader &header) const { hermes_fatal( "serialize/deserialize Runtime Configs don't match (es6Symbol)"); } - if (header.hasES6Intl != hasES6Intl_) { - hermes_fatal("serialize/deserialize Runtime Configs don't match (es6Intl)"); + if (header.hasIntl != hasIntl_) { + hermes_fatal("serialize/deserialize Runtime Configs don't match (intl)"); } if (header.bytecodeWarmupPercent != bytecodeWarmupPercent_) { diff --git a/public/hermes/Public/RuntimeConfig.h b/public/hermes/Public/RuntimeConfig.h index 10885cc6009..558e6d760bb 100644 --- a/public/hermes/Public/RuntimeConfig.h +++ b/public/hermes/Public/RuntimeConfig.h @@ -74,8 +74,8 @@ class Deserializer; /* Support for ES6 Symbol. */ \ F(constexpr, bool, ES6Symbol, true) \ \ - /* Support for ES6 Symbol. */ \ - F(constexpr, bool, ES6Intl, false) \ + /* Support for ECMA-402 Intl APIs. */ \ + F(constexpr, bool, Intl, false) \ \ /* Enable synth trace. */ \ F(constexpr, bool, TraceEnabled, false) \ diff --git a/tools/fuzzers/fuzzilli/fuzzilli.cpp b/tools/fuzzers/fuzzilli/fuzzilli.cpp index a6e65d6b46a..6a3d019fd66 100644 --- a/tools/fuzzers/fuzzilli/fuzzilli.cpp +++ b/tools/fuzzers/fuzzilli/fuzzilli.cpp @@ -178,7 +178,6 @@ int main(int argc, char **argv) { while (true) { auto runtime = makeHermesRuntime(::hermes::vm::RuntimeConfig::Builder() .withES6Proxy(true) - .withES6Intl(true) .withES6Symbol(true) .withEnableGenerator(true) .withEnableHermesInternal(true) diff --git a/tools/hermes/hermes.cpp b/tools/hermes/hermes.cpp index a54a3769e1b..3096ed54148 100644 --- a/tools/hermes/hermes.cpp +++ b/tools/hermes/hermes.cpp @@ -107,7 +107,7 @@ static int executeHBCBytecodeFromCL( .withES6Promise(cl::ES6Promise) .withES6Proxy(cl::ES6Proxy) .withES6Symbol(cl::ES6Symbol) - .withES6Intl(cl::ES6Intl) + .withIntl(cl::Intl) .withEnableSampleProfiling(cl::SampleProfiling) .withRandomizeMemoryLayout(cl::RandomizeMemoryLayout) .withTrackIO(cl::TrackBytecodeIO) @@ -172,7 +172,7 @@ static vm::RuntimeConfig getReplRuntimeConfig() { .withES6Promise(cl::ES6Promise) .withES6Proxy(cl::ES6Proxy) .withES6Symbol(cl::ES6Symbol) - .withES6Intl(cl::ES6Intl) + .withIntl(cl::Intl) .withEnableHermesInternal(cl::EnableHermesInternal) .withEnableHermesInternalTestMethods(cl::EnableHermesInternalTestMethods) .withAllowFunctionToStringWithRuntimeSource(cl::AllowFunctionToString) diff --git a/tools/hvm/hvm.cpp b/tools/hvm/hvm.cpp index 3f025c39962..54e23e05d6a 100644 --- a/tools/hvm/hvm.cpp +++ b/tools/hvm/hvm.cpp @@ -123,7 +123,7 @@ int main(int argc, char **argv) { .withES6Promise(cl::ES6Promise) .withES6Proxy(cl::ES6Proxy) .withES6Symbol(cl::ES6Symbol) - .withES6Intl(cl::ES6Intl) + .withIntl(cl::Intl) .withTrackIO(cl::TrackBytecodeIO) .withEnableHermesInternal(cl::EnableHermesInternal) .withEnableHermesInternalTestMethods( diff --git a/unittests/API/APITest.cpp b/unittests/API/APITest.cpp index d7f03b5306a..0bd0bd74a51 100644 --- a/unittests/API/APITest.cpp +++ b/unittests/API/APITest.cpp @@ -48,7 +48,6 @@ class HermesRuntimeTest : public HermesRuntimeTestBase { : HermesRuntimeTestBase(::hermes::vm::RuntimeConfig::Builder() .withES6Proxy(true) .withES6Promise(true) - .withES6Intl(true) .build()) {} }; @@ -495,7 +494,6 @@ class HermesRuntimeTestWithAllowFunctionToString ::hermes::vm::RuntimeConfig::Builder() .withES6Proxy(true) .withES6Promise(true) - .withES6Intl(true) .withAllowFunctionToStringWithRuntimeSource(true) .build()) {} }; diff --git a/unittests/API/HeapSnapshotAPITest.cpp b/unittests/API/HeapSnapshotAPITest.cpp index f89e88429a0..ff7927cc288 100644 --- a/unittests/API/HeapSnapshotAPITest.cpp +++ b/unittests/API/HeapSnapshotAPITest.cpp @@ -25,7 +25,6 @@ class HeapSnapshotAPITest : public ::testing::TestWithParam { HeapSnapshotAPITest() : rt(makeHermesRuntime(::hermes::vm::RuntimeConfig::Builder() .withES6Proxy(true) - .withES6Intl(true) .build())) { if (trackingFromBeginning()) { rt->instrumentation().startTrackingHeapObjectStackTraces(nullptr); diff --git a/unittests/API/SynthTraceParserTest.cpp b/unittests/API/SynthTraceParserTest.cpp index cbffa07873c..abc76f2298d 100644 --- a/unittests/API/SynthTraceParserTest.cpp +++ b/unittests/API/SynthTraceParserTest.cpp @@ -39,7 +39,7 @@ TEST_F(SynthTraceParserTest, ParseHeader) { "maxNumRegisters": 100, "ES6Proxy": false, "ES6Symbol": false, - "ES6Intl": false, + "Intl": false, "enableSampledStats": true, "vmExperimentFlags": 123 }, @@ -74,7 +74,7 @@ TEST_F(SynthTraceParserTest, ParseHeader) { EXPECT_EQ(rtconf.getMaxNumRegisters(), 100); EXPECT_FALSE(rtconf.getES6Proxy()); EXPECT_FALSE(rtconf.getES6Symbol()); - EXPECT_FALSE(rtconf.getES6Intl()); + EXPECT_FALSE(rtconf.getIntl()); EXPECT_TRUE(rtconf.getEnableSampledStats()); EXPECT_EQ(rtconf.getVMExperimentFlags(), 123); diff --git a/unittests/API/SynthTraceTest.cpp b/unittests/API/SynthTraceTest.cpp index 36be831c13f..0c11b72d72b 100644 --- a/unittests/API/SynthTraceTest.cpp +++ b/unittests/API/SynthTraceTest.cpp @@ -1243,8 +1243,8 @@ TEST_F(SynthTraceSerializationTest, TraceHeader) { conf.getES6Symbol(), llvh::cast(rtConfig->at("ES6Symbol"))->getValue()); EXPECT_EQ( - conf.getES6Intl(), - llvh::cast(rtConfig->at("ES6Intl"))->getValue()); + conf.getIntl(), + llvh::cast(rtConfig->at("Intl"))->getValue()); EXPECT_EQ( conf.getEnableSampledStats(), llvh::cast(rtConfig->at("enableSampledStats"))->getValue()); diff --git a/unittests/VMRuntime/StackTracesTreeTest.cpp b/unittests/VMRuntime/StackTracesTreeTest.cpp index 153674d727c..7cc1de5d98f 100644 --- a/unittests/VMRuntime/StackTracesTreeTest.cpp +++ b/unittests/VMRuntime/StackTracesTreeTest.cpp @@ -30,7 +30,7 @@ struct StackTracesTreeTest : public RuntimeTestFixtureBase { RuntimeConfig::Builder(kTestRTConfigBuilder) .withES6Promise(true) .withES6Proxy(true) - .withES6Intl(true) + .withIntl(true) .withGCConfig(GCConfig::Builder(kTestGCConfigBuilder).build()) .build()) { runtime->enableAllocationLocationTracker(); @@ -152,7 +152,7 @@ struct StackTracesTreeParameterizedTest : StackTracesTreeTest( RuntimeConfig::Builder(kTestRTConfigBuilder) .withES6Proxy(true) - .withES6Intl(true) + .withIntl(true) .withGCConfig(GCConfig::Builder(kTestGCConfigBuilder).build()) .build()) { if (trackerOnByDefault()) {