diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 923c7aa02e5..7275795fd0b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -491,64 +491,63 @@ jobs: cmake -S hermes -B build -G 'Visual Studio 16 2019' cmake --build build --target check-hermes -- -m /p:UseMultiToolTask=true -m /p:EnforceProcessCountAcrossBuilds=true test-e2e: - runs-on: ubuntu-20.04 - container: - image: reactnativecommunity/react-native-android:latest - env: - TERM: "dumb" - GRADLE_OPTS: '-Dorg.gradle.daemon=false' - # By default we only build ARM64 to save time/resources. For release/nightlies/prealpha, we override this value to build all archs. - ORG_GRADLE_PROJECT_reactNativeArchitectures: "arm64-v8a" - REACT_NATIVE_OVERRIDE_HERMES_DIR: /__w/hermes/hermes/hermes/ + runs-on: ubuntu-22.04 + env: + ANDROID_NDK: /usr/local/lib/android/sdk/ndk/26.1.10909125 + HERMES_WS_DIR: /home/runner/work/hermes + REACT_NATIVE_OVERRIDE_HERMES_DIR: /home/runner/work/hermes/hermes steps: - - uses: actions/setup-node@v4.0.2 - - name: Setup dependencies - run: |- - (yes | sdkmanager "cmake;3.22.1" --verbose) || true - sudo apt update && sudo apt install -y openjdk-11-jdk - - uses: actions/checkout@v4.1.0 + - name: Install Node + uses: actions/setup-node@v4.0.2 + - name: Install JDK + uses: actions/setup-java@v3 with: - path: hermes - - name: Prepare RNTester + distribution: "temurin" + java-version: "17" + - name: Checkout Hermes + uses: actions/checkout@v4.1.0 + - name: Checkout React Native run: |- + cd "$HERMES_WS_DIR" git clone --depth=1 https://github.com/facebook/react-native cd react-native yarn install echo "console.log('Using Hermes: ' + (global.HermesInternal != null));" >> packages/rn-tester/js/RNTesterApp.android.js - - name: Run android tests - working-directory: react-native - run: | - ./gradlew -PreactNativeArchitectures=x86 :packages:rn-tester:android:app:installHermesRelease - && adb shell am start com.facebook.react.uiapp/.RNTesterActivity - && timeout 30s adb logcat -e "Using Hermes: true" -m 1 + - name: Run RNTester + uses: ReactiveCircus/android-emulator-runner@v2.30.1 + with: + api-level: 29 + ndk: 26.1.10909125 + cmake: 3.22.1 + script: | + cd ../react-native && ./gradlew -PreactNativeArchitectures=x86 :packages:rn-tester:android:app:installHermesRelease + adb shell am start com.facebook.react.uiapp/.RNTesterActivity + timeout 30s adb logcat -e "Using Hermes: true" -m 1 test-e2e-intl: - runs-on: ubuntu-20.04 - container: - image: reactnativecommunity/react-native-android:latest - env: - TERM: "dumb" - GRADLE_OPTS: '-Dorg.gradle.daemon=false' - # By default we only build ARM64 to save time/resources. For release/nightlies/prealpha, we override this value to build all archs. - ORG_GRADLE_PROJECT_reactNativeArchitectures: "arm64-v8a" - HERMES_WS_DIR: /__w/hermes/hermes/ + runs-on: ubuntu-22.04 + env: + HERMES_WS_DIR: /home/runner/work/hermes + ANDROID_NDK: /usr/local/lib/android/sdk/ndk/26.1.10909125 steps: - - uses: actions/checkout@v4.1.0 - with: - path: hermes - - name: Setup dependencies + - name: Checkout Hermes + uses: actions/checkout@v4.1.0 + - name: Checkout Test262 run: |- - (yes | sdkmanager "cmake;3.22.1" --verbose) || true - # Check out test262 at a pinned revision to reduce flakiness + cd "$HERMES_WS_DIR" git clone https://github.com/tc39/test262 cd test262 git checkout 19da3ca0757248f7595ee09d532bb83dd438f2b5 - name: Build Hermes Compiler run: |- + cd "$HERMES_WS_DIR" cmake -S hermes -B ./build -DCMAKE_BUILD_TYPE=Release cmake --build ./build -j 4 --target hermesc - name: Run android tests - working-directory: hermes/android - run: ./gradlew :intltest:prepareTests && ./gradlew -Pabis=x86 :intltest:connectedAndroidTest + uses: ReactiveCircus/android-emulator-runner@v2.30.1 + with: + api-level: 29 + emulator-options: -timezone Europe/Paris -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + script: cd android && ./gradlew :intltest:prepareTests && ./gradlew -Pabis=x86 :intltest:connectedAndroidTest test-macos-test262: runs-on: macos-latest steps: diff --git a/API/hermes/cdp/RemoteObjectConverters.cpp b/API/hermes/cdp/RemoteObjectConverters.cpp index 7079139fd1d..afeb206eb1c 100644 --- a/API/hermes/cdp/RemoteObjectConverters.cpp +++ b/API/hermes/cdp/RemoteObjectConverters.cpp @@ -81,7 +81,7 @@ static m::runtime::ObjectPreview generateArrayPreview( try { desc = generatePropertyPreview( runtime, indexString, obj.getValueAtIndex(runtime, i)); - } catch (const jsi::JSError &err) { + } catch (const jsi::JSError &) { desc.name = indexString; desc.type = "string"; desc.value = ""; @@ -120,7 +120,7 @@ static m::runtime::ObjectPreview generateObjectPreview( // Chrome instead detects getters and makes you click to invoke. desc = generatePropertyPreview( runtime, propName.utf8(runtime), obj.getProperty(runtime, propName)); - } catch (const jsi::JSError &err) { + } catch (const jsi::JSError &) { desc.name = propName.utf8(runtime); desc.type = "string"; desc.value = ""; diff --git a/API/hermes/cdp/RuntimeDomainAgent.cpp b/API/hermes/cdp/RuntimeDomainAgent.cpp index 0f3132dda36..af6215884de 100644 --- a/API/hermes/cdp/RuntimeDomainAgent.cpp +++ b/API/hermes/cdp/RuntimeDomainAgent.cpp @@ -675,7 +675,7 @@ void RuntimeDomainAgent::callFunctionOn( evalResult = runtime_.evaluateJavaScript( std::unique_ptr(new jsi::StringBuffer(expression)), kEvaluatedCodeUrl); - } catch (const jsi::JSIException &error) { + } catch (const jsi::JSIException &) { sendResponseToClient(m::makeErrorResponse( req.id, m::ErrorCode::InternalError, @@ -883,7 +883,7 @@ RuntimeDomainAgent::makePropsFromValue( desc.wasThrown = true; desc.value = m::runtime::makeRemoteObjectForError( runtime, err.value(), *objTable_, objectGroup); - } catch (const jsi::JSIException &err) { + } catch (const jsi::JSIException &) { desc.wasThrown = true; desc.value = m::runtime::makeRemoteObject( runtime, diff --git a/API/hermes/inspector/chrome/CDPHandler.cpp b/API/hermes/inspector/chrome/CDPHandler.cpp index d4569bafb31..1ba161b120b 100644 --- a/API/hermes/inspector/chrome/CDPHandler.cpp +++ b/API/hermes/inspector/chrome/CDPHandler.cpp @@ -1711,7 +1711,7 @@ std::vector CDPHandlerImpl::makePropsFromValue( jsi::Value propValue = obj.getProperty(runtime, propName); desc.value = m::runtime::makeRemoteObject( runtime, propValue, objTable_, objectGroup, false, generatePreview); - } catch (const jsi::JSError &err) { + } catch (const jsi::JSError &) { // We fetched a property with a getter that threw. Show a placeholder. // We could have added additional info, but the UI quickly gets messy. desc.value = m::runtime::makeRemoteObject( diff --git a/API/hermes/inspector/chrome/RemoteObjectConverters.cpp b/API/hermes/inspector/chrome/RemoteObjectConverters.cpp index d53e77493fb..e348f8571cb 100644 --- a/API/hermes/inspector/chrome/RemoteObjectConverters.cpp +++ b/API/hermes/inspector/chrome/RemoteObjectConverters.cpp @@ -82,7 +82,7 @@ static m::runtime::ObjectPreview generateArrayPreview( try { desc = generatePropertyPreview( runtime, indexString, obj.getValueAtIndex(runtime, i)); - } catch (const jsi::JSError &err) { + } catch (const jsi::JSError &) { desc.name = indexString; desc.type = "string"; desc.value = ""; @@ -121,7 +121,7 @@ static m::runtime::ObjectPreview generateObjectPreview( // Chrome instead detects getters and makes you click to invoke. desc = generatePropertyPreview( runtime, propName.utf8(runtime), obj.getProperty(runtime, propName)); - } catch (const jsi::JSError &err) { + } catch (const jsi::JSError &) { desc.name = propName.utf8(runtime); desc.type = "string"; desc.value = ""; diff --git a/API/hermes/inspector/chrome/tests/ConnectionTests.cpp b/API/hermes/inspector/chrome/tests/ConnectionTests.cpp index adcc29d3bd1..fe87ba61e2c 100644 --- a/API/hermes/inspector/chrome/tests/ConnectionTests.cpp +++ b/API/hermes/inspector/chrome/tests/ConnectionTests.cpp @@ -2793,7 +2793,7 @@ TEST_F(ConnectionTests, testConsoleBuffer) { EXPECT_EQ(note.type, "log"); EXPECT_EQ(note.args.size(), 1); received[nthLog % kExpectedMaxBufferSize] = true; - } catch (const std::exception &e) { + } catch (const std::exception &) { EXPECT_EQ(note.type, "warning"); EXPECT_EQ(note.args.size(), 1); EXPECT_NE((*note.args[0].value).find("discarded"), std::string::npos); diff --git a/include/hermes/BCGen/RegAlloc.h b/include/hermes/BCGen/RegAlloc.h index 3f759e14ba8..6476e52381b 100644 --- a/include/hermes/BCGen/RegAlloc.h +++ b/include/hermes/BCGen/RegAlloc.h @@ -384,9 +384,9 @@ class RegisterAllocator { /// predecessor blocks. void lowerPhis(ArrayRef order); - /// Allocate the registers for the instructions in the function. The order of - /// the block needs to match the order which we'll use for instruction - /// selection. + /// Allocate the registers for the instructions in the function. The blocks + /// must be in reverse-post-order, and must match the order which we'll use + /// for instruction selection. void allocate(ArrayRef order); /// Reserves consecutive registers that will be manually managed by the user. diff --git a/include/hermes/VM/GCBase.h b/include/hermes/VM/GCBase.h index 09b2f0222b5..5704edfbf40 100644 --- a/include/hermes/VM/GCBase.h +++ b/include/hermes/VM/GCBase.h @@ -971,12 +971,24 @@ class GCBase { /// \return An error code on failure, else an empty error code. std::error_code createSnapshotToFile(const std::string &fileName); + /// An edges counter array for each root section. The counter is uninitialized + /// if a root section is not visited yet. + using SavedNumRootEdges = std::array< + llvh::Optional, + static_cast(RootSectionAcceptor::Section::NumSections)>; + /// Creates a snapshot of the heap, which includes information about what /// objects exist, their sizes, and what they point to. virtual void createSnapshot(llvh::raw_ostream &os) = 0; void createSnapshot(GC &gc, llvh::raw_ostream &os); - /// Actual implementation of writing the snapshot. - void createSnapshotImpl(GC &gc, HeapSnapshot &snap); + /// Actual implementation of writing the snapshot. If \p numRootEdges is + // uninitialized, it will be populated with the edge counts for each root + // section. Otherwise, it will be used to pad the output with additional edges + // if necessary so they match the recorded count. + void createSnapshotImpl( + GC &gc, + HeapSnapshot &snap, + SavedNumRootEdges &numRootEdges); /// Subclasses can override and add more specific native memory usage. virtual void snapshotAddGCNativeNodes(HeapSnapshot &snap); diff --git a/include/hermes/VM/HeapSnapshot.h b/include/hermes/VM/HeapSnapshot.h index 4b4a81bb860..02c9ebe4d0f 100644 --- a/include/hermes/VM/HeapSnapshot.h +++ b/include/hermes/VM/HeapSnapshot.h @@ -174,6 +174,10 @@ class HeapSnapshot { EdgeIndex getEdgeCount() const { return edgeCount_; } + /// Get the number of edges for the current node. + HeapSizeType getCurEdgeCount() const { + return currEdgeCount_; + } /// Get the trace function count for stackTracesTree_. size_t getTraceFunctionCount() const { return traceFunctionCount_; diff --git a/lib/BCGen/RegAlloc.cpp b/lib/BCGen/RegAlloc.cpp index d28bd99d6a8..6f07632b069 100644 --- a/lib/BCGen/RegAlloc.cpp +++ b/lib/BCGen/RegAlloc.cpp @@ -535,19 +535,6 @@ void RegisterAllocator::coalesce( } } -namespace { -/// Determines whether the Instruction is ever used outside its BasicBlock. -bool isBlockLocal(Instruction *inst) { - BasicBlock *parent = inst->getParent(); - for (auto user : inst->getUsers()) { - if (parent != user->getParent()) { - return false; - } - } - return true; -} -} // namespace - void RegisterAllocator::allocateFastPass(ArrayRef order) { // Make sure Phis and related Movs get the same register for (auto *bb : order) { @@ -563,26 +550,70 @@ void RegisterAllocator::allocateFastPass(ArrayRef order) { } } - llvh::SmallVector blockLocals; + // Bit vector indicating whether a register with a given index is being used + // as a block local register. + llvh::BitVector blockLocals; + + // List of free block local registers. We have to maintain this outside the + // file because we cannot determine interference between local and global + // registers. So we have to ensure that the local registers are only reused + // for other block-local instructions. + llvh::SmallVector freeBlockLocals; + + // A dummy register used for all instructions that have no users. + Register deadReg = file.allocateRegister(); + + // Iterate in reverse, so we can cheaply determine whether an instruction + // is local, and assign it a register accordingly. + for (auto *bb : llvh::reverse(order)) { + for (auto &inst : llvh::reverse(*bb)) { + if (isAllocated(&inst)) { + // If this is using a local register, we know the register is free after + // we visit the definition. + auto reg = getRegister(&inst); + auto idx = reg.getIndex(); + if (idx < blockLocals.size() && blockLocals.test(idx)) + freeBlockLocals.push_back(reg); + } else { + // Unallocated instruction means the result is dead, because all users + // are visited first. Allocate a temporary register. + // Note that we cannot assert that the instruction has no users, because + // there may be users in dead blocks. + updateRegister(&inst, deadReg); + } - // Then just allocate the rest sequentially, while optimizing the case - // where an inst is only ever used in its own block. - for (auto *bb : order) { - for (auto &inst : *bb) { - if (!isAllocated(&inst)) { - Register R = file.allocateRegister(); - updateRegister(&inst, R); - if (inst.getNumUsers() == 0) { - file.killRegister(R); - } else if (isBlockLocal(&inst)) { - blockLocals.push_back(R); + // Allocate a register to unallocated operands. + for (size_t i = 0, e = inst.getNumOperands(); i < e; ++i) { + auto *op = llvh::dyn_cast(inst.getOperand(i)); + + // Skip if op is not an instruction or already has a register. + if (!op || isAllocated(op)) + continue; + + if (op->getParent() != bb) { + // Live across blocks, allocate a global regigster. + updateRegister(op, file.allocateRegister()); + continue; } + + // We know this operand is local because: + // 1. The operand is in the same block as this one. + // 2. All blocks dominated by this block have been visited. + // 3. All users must be dominated by their def, since Phis are + // allocated beforehand. + if (!freeBlockLocals.empty()) { + updateRegister(op, freeBlockLocals.pop_back_val()); + continue; + } + + // No free local register, allocate another one. + Register reg = file.allocateRegister(); + if (blockLocals.size() <= reg.getIndex()) + blockLocals.resize(reg.getIndex() + 1); + blockLocals.set(reg.getIndex()); + updateRegister(op, reg); } } - for (auto ® : blockLocals) { - file.killRegister(reg); - } - blockLocals.clear(); } } diff --git a/lib/Parser/rust-api.cpp b/lib/Parser/rust-api.cpp index 5970a2dc26a..ac232b42606 100644 --- a/lib/Parser/rust-api.cpp +++ b/lib/Parser/rust-api.cpp @@ -608,14 +608,17 @@ hermes_parser_parse(ParserFlags flags, const char *source, size_t len) { break; case ParserDialect::Flow: parserCtx->context_.setParseFlow(hermes::ParseFlowSetting::ALL); + parserCtx->context_.setParseFlowComponentSyntax(true); break; case ParserDialect::FlowUnambiguous: parserCtx->context_.setParseFlow(hermes::ParseFlowSetting::UNAMBIGUOUS); + parserCtx->context_.setParseFlowComponentSyntax(true); break; case ParserDialect::FlowDetect: parserCtx->context_.setParseFlow( parser::hasFlowPragma(comments) ? ParseFlowSetting::ALL : ParseFlowSetting::UNAMBIGUOUS); + parserCtx->context_.setParseFlowComponentSyntax(true); break; case ParserDialect::TypeScript: parserCtx->context_.setParseTS(true); diff --git a/lib/Platform/Intl/PlatformIntlApple.mm b/lib/Platform/Intl/PlatformIntlApple.mm index 7fa596f8a17..e6f3b265836 100644 --- a/lib/Platform/Intl/PlatformIntlApple.mm +++ b/lib/Platform/Intl/PlatformIntlApple.mm @@ -1230,7 +1230,7 @@ uint8_t getCurrencyDigits(std::u16string_view code) { std::u16string format(double jsTimeValue) noexcept; private: - void initializeNSDateFormatter() noexcept; + void initializeNSDateFormatter(NSLocale *nsLocale) noexcept; // https://402.ecma-international.org/8.0/#sec-properties-of-intl-datetimeformat-instances // Intl.DateTimeFormat instances have an [[InitializedDateTimeFormat]] @@ -1388,8 +1388,7 @@ uint8_t getCurrencyDigits(std::u16string_view code) { opt.emplace(u"hc", *hourCycleOpt); // 16. Let localeData be %DateTimeFormat%.[[LocaleData]]. // NOTE: We don't actually have access to the underlying locale data, so we - // will use NSLocale.currentLocale instance as a substitute - auto localeData = NSLocale.currentLocale; + // will construct an NSLocale as needed instead. // 17. Let r be ResolveLocale(%DateTimeFormat%.[[AvailableLocales]], // requestedLocales, opt, %DateTimeFormat%.[[RelevantExtensionKeys]], // localeData). @@ -1581,6 +1580,8 @@ uint8_t getCurrencyDigits(std::u16string_view code) { // ii. Set dateTimeFormat's internal slot whose name is the Internal // Slot column of the row to p. // 39. If dateTimeFormat.[[Hour]] is undefined, then + NSLocale *nsLocale = + [NSLocale localeWithLocaleIdentifier:u16StringToNSString(locale_)]; if (!hour_.has_value()) { // a. Set dateTimeFormat.[[HourCycle]] to undefined. hourCycle_ = std::nullopt; @@ -1589,7 +1590,7 @@ uint8_t getCurrencyDigits(std::u16string_view code) { // 40. Else, } else { // a. Let hcDefault be dataLocaleData.[[hourCycle]]. - auto hcDefault = getDefaultHourCycle(localeData); + auto hcDefault = getDefaultHourCycle(nsLocale); // b. Let hc be dateTimeFormat.[[HourCycle]]. auto hc = hourCycle_; // c. If hc is null, then @@ -1635,7 +1636,7 @@ uint8_t getCurrencyDigits(std::u16string_view code) { // 41. Set dateTimeFormat.[[Pattern]] to pattern. // 42. Set dateTimeFormat.[[RangePatterns]] to rangePatterns. // 43. Return dateTimeFormat. - initializeNSDateFormatter(); + initializeNSDateFormatter(nsLocale); return vm::ExecutionStatus::RETURNED; } @@ -1693,7 +1694,8 @@ uint8_t getCurrencyDigits(std::u16string_view code) { return static_cast(this)->resolvedOptions(); } -void DateTimeFormatApple::initializeNSDateFormatter() noexcept { +void DateTimeFormatApple::initializeNSDateFormatter( + NSLocale *nsLocale) noexcept { static constexpr std::u16string_view kLong = u"long", kShort = u"short", kNarrow = u"narrow", kMedium = u"medium", kFull = u"full", kNumeric = u"numeric", @@ -1730,8 +1732,7 @@ uint8_t getCurrencyDigits(std::u16string_view code) { } nsDateFormatter_.timeZone = [[NSTimeZone alloc] initWithName:u16StringToNSString(timeZone_)]; - nsDateFormatter_.locale = - [[NSLocale alloc] initWithLocaleIdentifier:u16StringToNSString(locale_)]; + nsDateFormatter_.locale = nsLocale; if (calendar_) nsDateFormatter_.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:u16StringToNSString(*calendar_)]; diff --git a/lib/VM/GCBase.cpp b/lib/VM/GCBase.cpp index e2e78b258a8..43ac5bd9f21 100644 --- a/lib/VM/GCBase.cpp +++ b/lib/VM/GCBase.cpp @@ -340,10 +340,14 @@ struct SnapshotRootAcceptor : public SnapshotAcceptor, using SnapshotAcceptor::accept; using WeakRootAcceptor::acceptWeak; - SnapshotRootAcceptor(GCBase &gc, HeapSnapshot &snap) + SnapshotRootAcceptor( + GCBase &gc, + HeapSnapshot &snap, + GCBase::SavedNumRootEdges &numRootEdges) : SnapshotAcceptor(gc.getPointerBase(), snap), WeakAcceptorDefault(gc.getPointerBase()), - gc_(gc) {} + gc_(gc), + numRootEdges_(numRootEdges) {} void accept(GCCell *&ptr, const char *name) override { pointerAccept(ptr, name, false); @@ -388,6 +392,27 @@ struct SnapshotRootAcceptor : public SnapshotAcceptor, #define ROOT_SECTION(name) "(" #name ")", #include "hermes/VM/RootSections.def" }; + + // If we haven't visited this section before, save its current edge count. + auto sectionIdx = static_cast(currentSection_); + if (!numRootEdges_[sectionIdx].hasValue()) { + numRootEdges_[sectionIdx] = snap_.getCurEdgeCount(); + } else { + // Compare the edge count of this scan with the first scan, if some roots + // are newly dropped, we will add dummy edges to make sure all following + // scans have the same edge count as the first scan in a single call of + // createSnapshot(). + auto savedEdgeCount = numRootEdges_[sectionIdx].getValue(); + assert( + savedEdgeCount >= snap_.getCurEdgeCount() && + "Unexpected new edges added"); + const auto id = GCBase::IDTracker::reserved( + GCBase::IDTracker::ReservedObjectID::Undefined); + for (auto i = snap_.getCurEdgeCount(); i < savedEdgeCount; ++i) { + snap_.addIndexedEdge(HeapSnapshot::EdgeType::Element, nextEdge_++, id); + } + } + snap_.endNode( HeapSnapshot::NodeType::Synthetic, rootNames[static_cast(currentSection_)], @@ -405,9 +430,11 @@ struct SnapshotRootAcceptor : public SnapshotAcceptor, private: GCBase &gc_; llvh::DenseSet seenIDs_; - // For unnamed edges, use indices instead. + /// For unnamed edges, use indices instead. unsigned nextEdge_{0}; Section currentSection_{Section::InvalidSection}; + /// Number of edges for each root section. + GCBase::SavedNumRootEdges &numRootEdges_; void pointerAccept(GCCell *ptr, const char *name, bool weak) { assert( @@ -441,8 +468,11 @@ struct SnapshotRootAcceptor : public SnapshotAcceptor, } // namespace -void GCBase::createSnapshotImpl(GC &gc, HeapSnapshot &snap) { - const auto rootScan = [&gc, &snap, this]() { +void GCBase::createSnapshotImpl( + GC &gc, + HeapSnapshot &snap, + SavedNumRootEdges &numRootEdges) { + const auto rootScan = [&gc, &snap, &numRootEdges, this]() { { // Make the super root node and add edges to each root section. SnapshotRootSectionAcceptor rootSectionAcceptor(getPointerBase(), snap); @@ -478,7 +508,7 @@ void GCBase::createSnapshotImpl(GC &gc, HeapSnapshot &snap) { // Within a root section, there might be duplicates. The root acceptor // filters out duplicate edges because there cannot be duplicate edges to // nodes reachable from the super root. - SnapshotRootAcceptor rootAcceptor(gc, snap); + SnapshotRootAcceptor rootAcceptor(gc, snap, numRootEdges); markRoots(rootAcceptor, true); markWeakRoots(rootAcceptor, /*markLongLived*/ true); } @@ -575,7 +605,11 @@ void GCBase::createSnapshot(GC &gc, llvh::raw_ostream &os) { // them to create a HeapSnapShot instance in the second pass. JSONEmitter dummyJSON{llvh::nulls()}; HeapSnapshot dummySnap{dummyJSON, 0, 0, 0, gcCallbacks_.getStackTracesTree()}; - createSnapshotImpl(gc, dummySnap); + // Array for saving the number of edges for each root section. We set the + // value the first time we visit a root section, and make sure the same number + // of edges are added in a single call of this function. + SavedNumRootEdges numRootEdges; + createSnapshotImpl(gc, dummySnap, numRootEdges); // Second pass, write out the real snapshot with the correct node_count and // edge_count. @@ -586,7 +620,7 @@ void GCBase::createSnapshot(GC &gc, llvh::raw_ostream &os) { dummySnap.getEdgeCount(), dummySnap.getTraceFunctionCount(), gcCallbacks_.getStackTracesTree()}; - createSnapshotImpl(gc, snap); + createSnapshotImpl(gc, snap, numRootEdges); // Check if the node/edge counts of the two passes are equal. assert( dummySnap.getNodeCount() == snap.getNodeCount() && diff --git a/lib/VM/HeapSnapshot.cpp b/lib/VM/HeapSnapshot.cpp index 5c302f669f2..a9a173b06b7 100644 --- a/lib/VM/HeapSnapshot.cpp +++ b/lib/VM/HeapSnapshot.cpp @@ -56,8 +56,7 @@ HeapSnapshot::HeapSnapshot( } HeapSnapshot::~HeapSnapshot() { - assert( - edgeCount_ == expectedEdges_ && "Fewer edges added than were expected"); + assert(edgeCount_ == expectedEdges_ && "Unexpected edges count"); emitStrings(); json_.closeDict(); // top level } @@ -96,13 +95,11 @@ void HeapSnapshot::endSection(Section section) { } void HeapSnapshot::beginNode() { - if (nextSection_ == Section::Edges) { - // If the edges are being emitted, ignore node output. - return; - } - assert(nextSection_ == Section::Nodes && sectionOpened_); // Reset the edge counter. currEdgeCount_ = 0; + assert( + nextSection_ == Section::Edges || + (nextSection_ == Section::Nodes && sectionOpened_)); } void HeapSnapshot::endNode( @@ -139,10 +136,10 @@ void HeapSnapshot::addNamedEdge( EdgeType type, llvh::StringRef name, NodeID toNode) { + // If we're emitting nodes, only count the number of edges being processed, + // but don't actually emit them. + currEdgeCount_++; if (nextSection_ == Section::Nodes) { - // If we're emitting nodes, only count the number of edges being processed, - // but don't actually emit them. - currEdgeCount_++; return; } assert(edgeCount_ < expectedEdges_ && "Added more edges than were expected"); @@ -162,10 +159,10 @@ void HeapSnapshot::addIndexedEdge( EdgeType type, EdgeIndex edgeIndex, NodeID toNode) { + // If we're emitting nodes, only count the number of edges being processed, + // but don't actually emit them. + currEdgeCount_++; if (nextSection_ == Section::Nodes) { - // If we're emitting nodes, only count the number of edges being processed, - // but don't actually emit them. - currEdgeCount_++; return; } assert(edgeCount_ < expectedEdges_ && "Added more edges than were expected"); diff --git a/lib/VM/JSError.cpp b/lib/VM/JSError.cpp index 478bfc25c8c..f012fc11b87 100644 --- a/lib/VM/JSError.cpp +++ b/lib/VM/JSError.cpp @@ -217,63 +217,6 @@ PseudoHandle JSError::create( return JSObjectInit::initToPseudoHandle(runtime, cell); } -ExecutionStatus JSError::setupStack( - Handle selfHandle, - Runtime &runtime) { - // Lazily allocate the accessor. - if (runtime.jsErrorStackAccessor.isUndefined()) { - // This code path allocates quite a few handles, so make sure we - // don't disturb the parent GCScope and free them. - GCScope gcScope{runtime}; - - auto getter = NativeFunction::create( - runtime, - Handle::vmcast(&runtime.functionPrototype), - nullptr, - errorStackGetter, - Predefined::getSymbolID(Predefined::emptyString), - 0, - Runtime::makeNullHandle()); - - auto setter = NativeFunction::create( - runtime, - Handle::vmcast(&runtime.functionPrototype), - nullptr, - errorStackSetter, - Predefined::getSymbolID(Predefined::emptyString), - 1, - Runtime::makeNullHandle()); - - runtime.jsErrorStackAccessor = - PropertyAccessor::create(runtime, getter, setter); - } - - auto accessor = - Handle::vmcast(&runtime.jsErrorStackAccessor); - - DefinePropertyFlags dpf{}; - dpf.setEnumerable = 1; - dpf.setConfigurable = 1; - dpf.setGetter = 1; - dpf.setSetter = 1; - dpf.enumerable = 0; - dpf.configurable = 1; - - auto res = JSObject::defineOwnProperty( - selfHandle, - runtime, - Predefined::getSymbolID(Predefined::stack), - dpf, - accessor); - - // Ignore failures to set the "stack" property as other engines do. - if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { - runtime.clearThrownValue(); - } - - return ExecutionStatus::RETURNED; -} - CallResult> JSError::toString( Handle O, Runtime &runtime) { diff --git a/lib/VM/JSLib/Error.cpp b/lib/VM/JSLib/Error.cpp index 693f6071b76..8f2820dde08 100644 --- a/lib/VM/JSLib/Error.cpp +++ b/lib/VM/JSLib/Error.cpp @@ -14,6 +14,7 @@ #include "hermes/VM/CallResult.h" #include "hermes/VM/Operations.h" +#include "hermes/VM/PropertyAccessor.h" #include "hermes/VM/StringBuilder.h" #include "hermes/VM/StringPrimitive.h" @@ -36,7 +37,7 @@ Handle createErrorConstructor(Runtime &runtime) { 0); // Error.prototype.xxx properties. - // Error.prototype has two own properties: name and message. + // Error.prototype has three own properties: name, message, and stack. auto defaultName = runtime.getPredefinedString(Predefined::Error); defineProperty( runtime, @@ -51,6 +52,49 @@ Handle createErrorConstructor(Runtime &runtime) { Predefined::getSymbolID(Predefined::message), runtime.makeHandle(HermesValue::encodeStringValue(defaultMessage))); + auto getter = NativeFunction::create( + runtime, + Handle::vmcast(&runtime.functionPrototype), + nullptr, + errorStackGetter, + Predefined::getSymbolID(Predefined::emptyString), + 0, + Runtime::makeNullHandle()); + + auto setter = NativeFunction::create( + runtime, + Handle::vmcast(&runtime.functionPrototype), + nullptr, + errorStackSetter, + Predefined::getSymbolID(Predefined::emptyString), + 1, + Runtime::makeNullHandle()); + + // Save the accessors on the runtime so we can use them for captureStackTrace. + runtime.jsErrorStackAccessor = + PropertyAccessor::create(runtime, getter, setter); + + auto accessor = + Handle::vmcast(&runtime.jsErrorStackAccessor); + + DefinePropertyFlags dpf{}; + dpf.setEnumerable = 1; + dpf.setConfigurable = 1; + dpf.setGetter = 1; + dpf.setSetter = 1; + dpf.enumerable = 0; + dpf.configurable = 1; + + auto stackRes = JSObject::defineOwnProperty( + errorPrototype, + runtime, + Predefined::getSymbolID(Predefined::stack), + dpf, + accessor); + (void)stackRes; + + assert(*stackRes && "Failed to define stack accessor"); + auto cons = defineSystemConstructor( runtime, Predefined::getSymbolID(Predefined::Error), @@ -123,13 +167,6 @@ static CallResult constructErrorObject( return ExecutionStatus::EXCEPTION; } - // Initialize stack accessor. - if (LLVM_UNLIKELY( - JSError::setupStack(selfHandle, runtime) == - ExecutionStatus::EXCEPTION)) { - return ExecutionStatus::EXCEPTION; - } - // new Error(message). // Only proceed when 'typeof message' isn't undefined. if (!message->isUndefined()) { @@ -320,10 +357,24 @@ errorCaptureStackTrace(void *, Runtime &runtime, NativeArgs args) { } // Initialize the `stack` accessor on the target object. - if (LLVM_UNLIKELY( - JSError::setupStack(targetHandle, runtime) == - ExecutionStatus::EXCEPTION)) { - return ExecutionStatus::EXCEPTION; + DefinePropertyFlags dpf{}; + dpf.setEnumerable = 1; + dpf.setConfigurable = 1; + dpf.setGetter = 1; + dpf.setSetter = 1; + dpf.enumerable = 0; + dpf.configurable = 1; + + auto stackRes = JSObject::defineOwnProperty( + targetHandle, + runtime, + Predefined::getSymbolID(Predefined::stack), + dpf, + Handle<>(&runtime.jsErrorStackAccessor)); + + // Ignore failures to set the "stack" property as other engines do. + if (LLVM_UNLIKELY(stackRes == ExecutionStatus::EXCEPTION)) { + runtime.clearThrownValue(); } return HermesValue::encodeUndefinedValue(); diff --git a/lib/VM/Operations.cpp b/lib/VM/Operations.cpp index 9ff432654d2..7b714aa6451 100644 --- a/lib/VM/Operations.cpp +++ b/lib/VM/Operations.cpp @@ -1910,13 +1910,6 @@ CallResult instanceOfOperator_RJS( "right operand of 'instanceof' is not an object"); } - // Fast path: Function.prototype[Symbol.hasInstance] is non-configurable - // and non-writable (ES6.0 19.2.3.6), so we directly run its behavior here. - // Simply call through to ordinaryHasInstance. - if (vmisa(*constructor)) { - return ordinaryHasInstance(runtime, constructor, object); - } - // 2. Let instOfHandler be GetMethod(C,@@hasInstance). CallResult> instOfHandlerRes = JSObject::getNamed_RJS( Handle::vmcast(constructor), diff --git a/lib/VM/Runtime.cpp b/lib/VM/Runtime.cpp index 85f9049049b..6143f86bb00 100644 --- a/lib/VM/Runtime.cpp +++ b/lib/VM/Runtime.cpp @@ -1281,7 +1281,6 @@ uint32_t Runtime::getCurrentFrameOffset() const { static ExecutionStatus raisePlaceholder(Runtime &runtime, Handle errorObj, Handle<> message) { JSError::recordStackTrace(errorObj, runtime); - JSError::setupStack(errorObj, runtime); JSError::setMessage(errorObj, runtime, message); return runtime.setThrownValue(errorObj.getHermesValue()); } diff --git a/test/BCGen/HBC/async-function.js b/test/BCGen/HBC/async-function.js index 9ace0be7e7f..d4c2e5eb072 100644 --- a/test/BCGen/HBC/async-function.js +++ b/test/BCGen/HBC/async-function.js @@ -57,169 +57,162 @@ var simpleAsyncFE = async function () { // CHECK-NEXT: Function ID 6 -> s0 // CHECK-NEXT: Function ID 9 -> s0 -// CHECK:Function(1 params, 11 registers, 0 symbols): +// CHECK:Function(1 params, 4 registers, 0 symbols): // CHECK-NEXT:Offset in debug table: source 0x0000, scope 0x0000, textified callees 0x0000 // CHECK-NEXT: DeclareGlobalVar "simpleAsyncFE" // CHECK-NEXT: DeclareGlobalVar "simpleReturn" // CHECK-NEXT: DeclareGlobalVar "simpleAwait" -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: CreateAsyncClosure r1, r0, NCFunction -// CHECK-NEXT: GetGlobalObject r2 -// CHECK-NEXT: PutById r2, r1, 1, "simpleReturn" -// CHECK-NEXT: CreateAsyncClosure r3, r0, NCFunction -// CHECK-NEXT: GetGlobalObject r4 -// CHECK-NEXT: PutById r4, r3, 2, "simpleAwait" -// CHECK-NEXT: LoadConstUndefined r6 -// CHECK-NEXT: Mov r5, r6 -// CHECK-NEXT: CreateAsyncClosure r7, r0, NCFunction -// CHECK-NEXT: GetGlobalObject r8 -// CHECK-NEXT: PutById r8, r7, 3, "simpleAsyncFE" -// CHECK-NEXT: Mov r9, r5 -// CHECK-NEXT: Ret r9 +// CHECK-NEXT: CreateEnvironment r2 +// CHECK-NEXT: CreateAsyncClosure r1, r2, NCFunction +// CHECK-NEXT: GetGlobalObject r3 +// CHECK-NEXT: PutById r3, r1, 1, "simpleReturn" +// CHECK-NEXT: CreateAsyncClosure r1, r2, NCFunction +// CHECK-NEXT: GetGlobalObject r3 +// CHECK-NEXT: PutById r3, r1, 2, "simpleAwait" +// CHECK-NEXT: LoadConstUndefined r3 +// CHECK-NEXT: Mov r1, r3 +// CHECK-NEXT: CreateAsyncClosure r2, r2, NCFunction +// CHECK-NEXT: GetGlobalObject r3 +// CHECK-NEXT: PutById r3, r2, 3, "simpleAsyncFE" +// CHECK-NEXT: Ret r1 -// CHECK:NCFunction(1 params, 20 registers, 0 symbols): +// CHECK:NCFunction(1 params, 16 registers, 0 symbols): // CHECK-NEXT:Offset in debug table: source 0x001f, scope 0x0000, textified callees 0x0000 -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: LoadThisNS r1 -// CHECK-NEXT: LoadConstUndefined r3 -// CHECK-NEXT: Mov r2, r3 -// CHECK-NEXT: CreateGeneratorClosure r4, r0, NCFunction -// CHECK-NEXT: GetBuiltinClosure r5, "HermesBuiltin.spawnAsync" -// CHECK-NEXT: ReifyArguments r2 -// CHECK-NEXT: Mov r6, r2 -// CHECK-NEXT: LoadConstUndefined r7 -// CHECK-NEXT: Mov r13, r7 -// CHECK-NEXT: Mov r12, r4 -// CHECK-NEXT: Mov r11, r1 -// CHECK-NEXT: Mov r10, r6 -// CHECK-NEXT: Call r8, r5, 4 -// CHECK-NEXT: Ret r8 +// CHECK-NEXT: CreateEnvironment r3 +// CHECK-NEXT: LoadThisNS r4 +// CHECK-NEXT: LoadConstUndefined r1 +// CHECK-NEXT: Mov r5, r1 +// CHECK-NEXT: CreateGeneratorClosure r3, r3, NCFunction +// CHECK-NEXT: GetBuiltinClosure r1, "HermesBuiltin.spawnAsync" +// CHECK-NEXT: ReifyArguments r5 +// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: Mov r9, r2 +// CHECK-NEXT: Mov r8, r3 +// CHECK-NEXT: Mov r7, r4 +// CHECK-NEXT: Mov r6, r5 +// CHECK-NEXT: Call r1, r1, 4 +// CHECK-NEXT: Ret r1 -// CHECK:NCFunction(1 params, 3 registers, 0 symbols): -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: CreateGenerator r1, r0, Function +// CHECK:NCFunction(1 params, 2 registers, 0 symbols): +// CHECK-NEXT: CreateEnvironment r1 +// CHECK-NEXT: CreateGenerator r1, r1, Function // CHECK-NEXT: Ret r1 -// CHECK:Function(1 params, 4 registers, 0 symbols): +// CHECK:Function(1 params, 3 registers, 0 symbols): // CHECK-NEXT: StartGenerator // CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: ResumeGenerator r1, r0 -// CHECK-NEXT: Mov r2, r0 +// CHECK-NEXT: ResumeGenerator r1, r2 // CHECK-NEXT: JmpTrue L1, r2 -// CHECK-NEXT: LoadConstUInt8 r0, 1 +// CHECK-NEXT: LoadConstUInt8 r2, 1 // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r0 +// CHECK-NEXT: Ret r2 // CHECK-NEXT:L1: // CHECK-NEXT: CompleteGenerator // CHECK-NEXT: Ret r1 -// CHECK:NCFunction(1 params, 21 registers, 1 symbols): +// CHECK:NCFunction(1 params, 16 registers, 1 symbols): // CHECK-NEXT:Offset in debug table: source 0x002c, scope 0x0000, textified callees 0x0000 -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: LoadThisNS r1 -// CHECK-NEXT: LoadConstUndefined r3 -// CHECK-NEXT: Mov r2, r3 -// CHECK-NEXT: LoadConstUndefined r4 -// CHECK-NEXT: StoreNPToEnvironment r0, 0, r4 -// CHECK-NEXT: CreateGeneratorClosure r5, r0, NCFunction -// CHECK-NEXT: GetBuiltinClosure r6, "HermesBuiltin.spawnAsync" -// CHECK-NEXT: ReifyArguments r2 -// CHECK-NEXT: Mov r7, r2 -// CHECK-NEXT: LoadConstUndefined r8 -// CHECK-NEXT: Mov r14, r8 -// CHECK-NEXT: Mov r13, r5 -// CHECK-NEXT: Mov r12, r1 -// CHECK-NEXT: Mov r11, r7 -// CHECK-NEXT: Call r9, r6, 4 -// CHECK-NEXT: Ret r9 - -// CHECK:NCFunction(1 params, 4 registers, 1 symbols): -// CHECK-NEXT: CreateEnvironment r0 +// CHECK-NEXT: CreateEnvironment r3 +// CHECK-NEXT: LoadThisNS r4 // CHECK-NEXT: LoadConstUndefined r1 -// CHECK-NEXT: StoreNPToEnvironment r0, 0, r1 -// CHECK-NEXT: CreateGenerator r2, r0, Function -// CHECK-NEXT: Ret r2 +// CHECK-NEXT: Mov r5, r1 +// CHECK-NEXT: LoadConstUndefined r1 +// CHECK-NEXT: StoreNPToEnvironment r3, 0, r1 +// CHECK-NEXT: CreateGeneratorClosure r3, r3, NCFunction +// CHECK-NEXT: GetBuiltinClosure r1, "HermesBuiltin.spawnAsync" +// CHECK-NEXT: ReifyArguments r5 +// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: Mov r9, r2 +// CHECK-NEXT: Mov r8, r3 +// CHECK-NEXT: Mov r7, r4 +// CHECK-NEXT: Mov r6, r5 +// CHECK-NEXT: Call r1, r1, 4 +// CHECK-NEXT: Ret r1 + +// CHECK:NCFunction(1 params, 3 registers, 1 symbols): +// CHECK-NEXT: CreateEnvironment r1 +// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: StoreNPToEnvironment r1, 0, r2 +// CHECK-NEXT: CreateGenerator r1, r1, Function +// CHECK-NEXT: Ret r1 // CHECK:Function(1 params, 6 registers, 1 symbols): // CHECK-NEXT:Offset in debug table: source 0x0039, scope 0x0000, textified callees 0x0000 // CHECK-NEXT: StartGenerator -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: ResumeGenerator r2, r1 -// CHECK-NEXT: Mov r3, r1 +// CHECK-NEXT: CreateEnvironment r4 +// CHECK-NEXT: ResumeGenerator r1, r3 // CHECK-NEXT: JmpTrue L1, r3 -// CHECK-NEXT: LoadConstUndefined r1 -// CHECK-NEXT: StoreNPToEnvironment r0, 0, r1 -// CHECK-NEXT: LoadConstUInt8 r4, 2 +// CHECK-NEXT: LoadConstUndefined r3 +// CHECK-NEXT: StoreNPToEnvironment r4, 0, r3 +// CHECK-NEXT: LoadConstUInt8 r3, 2 // CHECK-NEXT: SaveGenerator L2 -// CHECK-NEXT: Ret r4 +// CHECK-NEXT: Ret r3 // CHECK-NEXT:L2: -// CHECK-NEXT: ResumeGenerator r1, r3 -// CHECK-NEXT: Mov r4, r3 -// CHECK-NEXT: JmpTrue L3, r4 -// CHECK-NEXT: StoreToEnvironment r0, 0, r1 -// CHECK-NEXT: LoadFromEnvironment r4, r0, 0 +// CHECK-NEXT: ResumeGenerator r2, r5 +// CHECK-NEXT: Mov r3, r5 +// CHECK-NEXT: JmpTrue L3, r3 +// CHECK-NEXT: StoreToEnvironment r4, 0, r2 +// CHECK-NEXT: LoadFromEnvironment r3, r4, 0 // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r4 +// CHECK-NEXT: Ret r3 // CHECK-NEXT:L3: // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r1 +// CHECK-NEXT: Ret r2 // CHECK-NEXT:L1: // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r2 +// CHECK-NEXT: Ret r1 -// CHECK:NCFunction(1 params, 21 registers, 1 symbols): +// CHECK:NCFunction(1 params, 16 registers, 1 symbols): // CHECK-NEXT:Offset in debug table: source 0x004f, scope 0x0000, textified callees 0x0000 -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: LoadThisNS r1 -// CHECK-NEXT: LoadConstUndefined r3 -// CHECK-NEXT: Mov r2, r3 -// CHECK-NEXT: LoadConstUndefined r4 -// CHECK-NEXT: StoreNPToEnvironment r0, 0, r4 -// CHECK-NEXT: CreateGeneratorClosure r5, r0, NCFunction -// CHECK-NEXT: GetBuiltinClosure r6, "HermesBuiltin.spawnAsync" -// CHECK-NEXT: ReifyArguments r2 -// CHECK-NEXT: Mov r7, r2 -// CHECK-NEXT: LoadConstUndefined r8 -// CHECK-NEXT: Mov r14, r8 -// CHECK-NEXT: Mov r13, r5 -// CHECK-NEXT: Mov r12, r1 -// CHECK-NEXT: Mov r11, r7 -// CHECK-NEXT: Call r9, r6, 4 -// CHECK-NEXT: Ret r9 - -// CHECK:NCFunction(1 params, 4 registers, 1 symbols): -// CHECK-NEXT: CreateEnvironment r0 +// CHECK-NEXT: CreateEnvironment r3 +// CHECK-NEXT: LoadThisNS r4 // CHECK-NEXT: LoadConstUndefined r1 -// CHECK-NEXT: StoreNPToEnvironment r0, 0, r1 -// CHECK-NEXT: CreateGenerator r2, r0, Function -// CHECK-NEXT: Ret r2 +// CHECK-NEXT: Mov r5, r1 +// CHECK-NEXT: LoadConstUndefined r1 +// CHECK-NEXT: StoreNPToEnvironment r3, 0, r1 +// CHECK-NEXT: CreateGeneratorClosure r3, r3, NCFunction +// CHECK-NEXT: GetBuiltinClosure r1, "HermesBuiltin.spawnAsync" +// CHECK-NEXT: ReifyArguments r5 +// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: Mov r9, r2 +// CHECK-NEXT: Mov r8, r3 +// CHECK-NEXT: Mov r7, r4 +// CHECK-NEXT: Mov r6, r5 +// CHECK-NEXT: Call r1, r1, 4 +// CHECK-NEXT: Ret r1 + +// CHECK:NCFunction(1 params, 3 registers, 1 symbols): +// CHECK-NEXT: CreateEnvironment r1 +// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: StoreNPToEnvironment r1, 0, r2 +// CHECK-NEXT: CreateGenerator r1, r1, Function +// CHECK-NEXT: Ret r1 // CHECK:Function(1 params, 6 registers, 1 symbols): // CHECK-NEXT:Offset in debug table: source 0x005c, scope 0x0000, textified callees 0x0000 // CHECK-NEXT: StartGenerator -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: ResumeGenerator r2, r1 -// CHECK-NEXT: Mov r3, r1 +// CHECK-NEXT: CreateEnvironment r4 +// CHECK-NEXT: ResumeGenerator r1, r3 // CHECK-NEXT: JmpTrue L1, r3 -// CHECK-NEXT: LoadConstUndefined r1 -// CHECK-NEXT: StoreNPToEnvironment r0, 0, r1 -// CHECK-NEXT: LoadConstUInt8 r4, 2 +// CHECK-NEXT: LoadConstUndefined r3 +// CHECK-NEXT: StoreNPToEnvironment r4, 0, r3 +// CHECK-NEXT: LoadConstUInt8 r3, 2 // CHECK-NEXT: SaveGenerator L2 -// CHECK-NEXT: Ret r4 +// CHECK-NEXT: Ret r3 // CHECK-NEXT:L2: -// CHECK-NEXT: ResumeGenerator r1, r3 -// CHECK-NEXT: Mov r4, r3 -// CHECK-NEXT: JmpTrue L3, r4 -// CHECK-NEXT: StoreToEnvironment r0, 0, r1 -// CHECK-NEXT: LoadFromEnvironment r4, r0, 0 +// CHECK-NEXT: ResumeGenerator r2, r5 +// CHECK-NEXT: Mov r3, r5 +// CHECK-NEXT: JmpTrue L3, r3 +// CHECK-NEXT: StoreToEnvironment r4, 0, r2 +// CHECK-NEXT: LoadFromEnvironment r3, r4, 0 // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r4 +// CHECK-NEXT: Ret r3 // CHECK-NEXT:L3: // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r1 +// CHECK-NEXT: Ret r2 // CHECK-NEXT:L1: // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r2 +// CHECK-NEXT: Ret r1 // CHECK:Debug filename table: // CHECK-NEXT: 0: {{.*}}async-function.js @@ -233,17 +226,17 @@ var simpleAsyncFE = async function () { // CHECK-NEXT: bc 37: line 10 col 1 scope offset 0x0000 env none // CHECK-NEXT: bc 55: line 19 col 19 scope offset 0x0000 env none // CHECK-NEXT: 0x001f function idx 1, starts at line 10 col 1 -// CHECK-NEXT: bc 36: line 10 col 1 scope offset 0x0000 env none +// CHECK-NEXT: bc 33: line 10 col 1 scope offset 0x0000 env none // CHECK-NEXT: 0x002c function idx 4, starts at line 14 col 1 -// CHECK-NEXT: bc 42: line 14 col 1 scope offset 0x0000 env none +// CHECK-NEXT: bc 39: line 14 col 1 scope offset 0x0000 env none // CHECK-NEXT: 0x0039 function idx 6, starts at line 14 col 1 -// CHECK-NEXT: bc 21: line 15 col 11 scope offset 0x0000 env none -// CHECK-NEXT: bc 25: line 15 col 11 scope offset 0x0000 env none +// CHECK-NEXT: bc 18: line 15 col 11 scope offset 0x0000 env none +// CHECK-NEXT: bc 22: line 15 col 11 scope offset 0x0000 env none // CHECK-NEXT: 0x004f function idx 7, starts at line 19 col 21 -// CHECK-NEXT: bc 42: line 19 col 21 scope offset 0x0000 env none +// CHECK-NEXT: bc 39: line 19 col 21 scope offset 0x0000 env none // CHECK-NEXT: 0x005c function idx 9, starts at line 19 col 21 -// CHECK-NEXT: bc 21: line 20 col 11 scope offset 0x0000 env none -// CHECK-NEXT: bc 25: line 20 col 11 scope offset 0x0000 env none +// CHECK-NEXT: bc 18: line 20 col 11 scope offset 0x0000 env none +// CHECK-NEXT: bc 22: line 20 col 11 scope offset 0x0000 env none // CHECK-NEXT: 0x0072 end of debug source table // CHECK:Debug scope descriptor table: diff --git a/test/BCGen/HBC/debug_info.js b/test/BCGen/HBC/debug_info.js index f6445c36a22..d259f81f125 100644 --- a/test/BCGen/HBC/debug_info.js +++ b/test/BCGen/HBC/debug_info.js @@ -31,7 +31,7 @@ function Fc() { } // CHECK: Function{{.*}} // CHECK-NEXT: Offset in debug table: {{.*}} -// CHECK: Function(1 params, 5 registers, 1 symbols): +// CHECK: Function(1 params, 3 registers, 1 symbols): // CHECK-NEXT: Offset in debug table: {{.*}} // CHECK: Debug filename table: diff --git a/test/BCGen/HBC/es6/generator.js b/test/BCGen/HBC/es6/generator.js index 623aa7525b6..042ff5776ed 100644 --- a/test/BCGen/HBC/es6/generator.js +++ b/test/BCGen/HBC/es6/generator.js @@ -51,100 +51,97 @@ function *args() { // CHECK-NEXT: Function ID 2 -> s0 // CHECK-NEXT: Function ID 4 -> s0 -// CHECK:Function(1 params, 9 registers, 0 symbols): +// CHECK:Function(1 params, 4 registers, 0 symbols): // CHECK-NEXT:Offset in debug table: source 0x0000, scope 0x0000, textified callees 0x0000 // CHECK-NEXT: DeclareGlobalVar "loop" // CHECK-NEXT: DeclareGlobalVar "args" -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: CreateGeneratorClosure r1, r0, NCFunction +// CHECK-NEXT: CreateEnvironment r1 +// CHECK-NEXT: CreateGeneratorClosure r2, r1, NCFunction +// CHECK-NEXT: GetGlobalObject r3 +// CHECK-NEXT: PutById r3, r2, 1, "loop" +// CHECK-NEXT: CreateGeneratorClosure r1, r1, NCFunction // CHECK-NEXT: GetGlobalObject r2 -// CHECK-NEXT: PutById r2, r1, 1, "loop" -// CHECK-NEXT: CreateGeneratorClosure r3, r0, NCFunction -// CHECK-NEXT: GetGlobalObject r4 -// CHECK-NEXT: PutById r4, r3, 2, "args" -// CHECK-NEXT: LoadConstUndefined r6 -// CHECK-NEXT: Mov r5, r6 -// CHECK-NEXT: Mov r7, r5 -// CHECK-NEXT: Ret r7 - -// CHECK:NCFunction(2 params, 4 registers, 1 symbols): -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: LoadConstUndefined r1 -// CHECK-NEXT: StoreNPToEnvironment r0, 0, r1 -// CHECK-NEXT: CreateGenerator r2, r0, Function -// CHECK-NEXT: Ret r2 +// CHECK-NEXT: PutById r2, r1, 2, "args" +// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: Mov r1, r2 +// CHECK-NEXT: Ret r1 + +// CHECK:NCFunction(2 params, 3 registers, 1 symbols): +// CHECK-NEXT: CreateEnvironment r1 +// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: StoreNPToEnvironment r1, 0, r2 +// CHECK-NEXT: CreateGenerator r1, r1, Function +// CHECK-NEXT: Ret r1 -// CHECK:Function(2 params, 10 registers, 2 symbols): +// CHECK:Function(2 params, 9 registers, 2 symbols): // CHECK-NEXT:Offset in debug table: source 0x0016, scope 0x0000, textified callees 0x0000 // CHECK-NEXT: StartGenerator -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: LoadParam r1, 1 -// CHECK-NEXT: ResumeGenerator r3, r2 -// CHECK-NEXT: Mov r4, r2 -// CHECK-NEXT: JmpTrue L1, r4 -// CHECK-NEXT: StoreToEnvironment r0, 0, r1 -// CHECK-NEXT: LoadConstUndefined r2 -// CHECK-NEXT: StoreNPToEnvironment r0, 1, r2 -// CHECK-NEXT: LoadConstZero r4 -// CHECK-NEXT: StoreNPToEnvironment r0, 1, r4 -// CHECK-NEXT: GetGlobalObject r2 -// CHECK-NEXT: TryGetById r4, r2, 1, "y" -// CHECK-NEXT: JmpFalse L2, r4 +// CHECK-NEXT: CreateEnvironment r6 +// CHECK-NEXT: LoadParam r8, 1 +// CHECK-NEXT: ResumeGenerator r1, r3 +// CHECK-NEXT: JmpTrue L1, r3 +// CHECK-NEXT: StoreToEnvironment r6, 0, r8 +// CHECK-NEXT: LoadConstUndefined r3 +// CHECK-NEXT: StoreNPToEnvironment r6, 1, r3 +// CHECK-NEXT: LoadConstZero r3 +// CHECK-NEXT: StoreNPToEnvironment r6, 1, r3 +// CHECK-NEXT: GetGlobalObject r3 +// CHECK-NEXT: TryGetById r3, r3, 1, "y" +// CHECK-NEXT: JmpFalse L2, r3 // CHECK-NEXT:L5: -// CHECK-NEXT: LoadFromEnvironment r2, r0, 0 -// CHECK-NEXT: LoadFromEnvironment r4, r0, 1 -// CHECK-NEXT: ToNumeric r5, r4 -// CHECK-NEXT: Inc r6, r5 -// CHECK-NEXT: StoreToEnvironment r0, 1, r6 -// CHECK-NEXT: GetByVal r7, r2, r5 +// CHECK-NEXT: LoadFromEnvironment r3, r6, 0 +// CHECK-NEXT: LoadFromEnvironment r5, r6, 1 +// CHECK-NEXT: ToNumeric r5, r5 +// CHECK-NEXT: Inc r7, r5 +// CHECK-NEXT: StoreToEnvironment r6, 1, r7 +// CHECK-NEXT: GetByVal r3, r3, r5 // CHECK-NEXT: SaveGenerator L3 -// CHECK-NEXT: Ret r7 +// CHECK-NEXT: Ret r3 // CHECK-NEXT:L3: -// CHECK-NEXT: ResumeGenerator r2, r8 -// CHECK-NEXT: Mov r4, r8 -// CHECK-NEXT: JmpTrue L4, r4 -// CHECK-NEXT: GetGlobalObject r4 -// CHECK-NEXT: TryGetById r5, r4, 1, "y" -// CHECK-NEXT: JmpTrue L5, r5 +// CHECK-NEXT: ResumeGenerator r2, r4 +// CHECK-NEXT: Mov r3, r4 +// CHECK-NEXT: JmpTrue L4, r3 +// CHECK-NEXT: GetGlobalObject r3 +// CHECK-NEXT: TryGetById r3, r3, 1, "y" +// CHECK-NEXT: JmpTrue L5, r3 // CHECK-NEXT:L2: -// CHECK-NEXT: LoadConstString r4, "DONE LOOPING" +// CHECK-NEXT: LoadConstString r3, "DONE LOOPING" // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r4 +// CHECK-NEXT: Ret r3 // CHECK-NEXT:L4: // CHECK-NEXT: CompleteGenerator // CHECK-NEXT: Ret r2 // CHECK-NEXT:L1: // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r3 +// CHECK-NEXT: Ret r1 -// CHECK:NCFunction(1 params, 3 registers, 0 symbols): -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: CreateGenerator r1, r0, Function +// CHECK:NCFunction(1 params, 2 registers, 0 symbols): +// CHECK-NEXT: CreateEnvironment r1 +// CHECK-NEXT: CreateGenerator r1, r1, Function // CHECK-NEXT: Ret r1 -// CHECK:Function(1 params, 7 registers, 0 symbols): +// CHECK:Function(1 params, 6 registers, 0 symbols): // CHECK-NEXT:Offset in debug table: source 0x0050, scope 0x0000, textified callees 0x0000 // CHECK-NEXT: StartGenerator // CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: ResumeGenerator r1, r0 -// CHECK-NEXT: Mov r2, r0 -// CHECK-NEXT: JmpTrue L1, r2 -// CHECK-NEXT: LoadConstUndefined r2 -// CHECK-NEXT: Mov r0, r2 +// CHECK-NEXT: ResumeGenerator r1, r5 +// CHECK-NEXT: JmpTrue L1, r5 +// CHECK-NEXT: LoadConstUndefined r3 +// CHECK-NEXT: Mov r5, r3 // CHECK-NEXT: LoadConstZero r3 -// CHECK-NEXT: GetArgumentsPropByVal r4, r3, r0 +// CHECK-NEXT: GetArgumentsPropByVal r3, r3, r5 // CHECK-NEXT: SaveGenerator L2 -// CHECK-NEXT: Ret r4 +// CHECK-NEXT: Ret r3 // CHECK-NEXT:L2: -// CHECK-NEXT: ResumeGenerator r0, r5 -// CHECK-NEXT: Mov r2, r5 -// CHECK-NEXT: JmpTrue L3, r2 -// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: ResumeGenerator r2, r4 +// CHECK-NEXT: Mov r3, r4 +// CHECK-NEXT: JmpTrue L3, r3 +// CHECK-NEXT: LoadConstUndefined r3 // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r2 +// CHECK-NEXT: Ret r3 // CHECK-NEXT:L3: // CHECK-NEXT: CompleteGenerator -// CHECK-NEXT: Ret r0 +// CHECK-NEXT: Ret r2 // CHECK-NEXT:L1: // CHECK-NEXT: CompleteGenerator // CHECK-NEXT: Ret r1 @@ -160,16 +157,16 @@ function *args() { // CHECK-NEXT: bc 19: line 10 col 1 scope offset 0x0000 env none // CHECK-NEXT: bc 32: line 10 col 1 scope offset 0x0000 env none // CHECK-NEXT: 0x0016 function idx 2, starts at line 10 col 1 -// CHECK-NEXT: bc 33: line 12 col 10 scope offset 0x0000 env none -// CHECK-NEXT: bc 50: line 13 col 14 scope offset 0x0000 env none -// CHECK-NEXT: bc 60: line 13 col 12 scope offset 0x0000 env none -// CHECK-NEXT: bc 64: line 13 col 5 scope offset 0x0000 env none -// CHECK-NEXT: bc 68: line 13 col 5 scope offset 0x0000 env none -// CHECK-NEXT: bc 79: line 12 col 10 scope offset 0x0000 env none +// CHECK-NEXT: bc 30: line 12 col 10 scope offset 0x0000 env none +// CHECK-NEXT: bc 47: line 13 col 14 scope offset 0x0000 env none +// CHECK-NEXT: bc 57: line 13 col 12 scope offset 0x0000 env none +// CHECK-NEXT: bc 61: line 13 col 5 scope offset 0x0000 env none +// CHECK-NEXT: bc 65: line 13 col 5 scope offset 0x0000 env none +// CHECK-NEXT: bc 76: line 12 col 10 scope offset 0x0000 env none // CHECK-NEXT: 0x0050 function idx 4, starts at line 18 col 1 -// CHECK-NEXT: bc 19: line 19 col 18 scope offset 0x0000 env none -// CHECK-NEXT: bc 23: line 19 col 3 scope offset 0x0000 env none -// CHECK-NEXT: bc 27: line 19 col 3 scope offset 0x0000 env none +// CHECK-NEXT: bc 16: line 19 col 18 scope offset 0x0000 env none +// CHECK-NEXT: bc 20: line 19 col 3 scope offset 0x0000 env none +// CHECK-NEXT: bc 24: line 19 col 3 scope offset 0x0000 env none // CHECK-NEXT: 0x006f end of debug source table // CHECK:Debug scope descriptor table: diff --git a/test/BCGen/HBC/es6/spread-arguments.js b/test/BCGen/HBC/es6/spread-arguments.js index 5ad2f9eb602..2625719d93b 100644 --- a/test/BCGen/HBC/es6/spread-arguments.js +++ b/test/BCGen/HBC/es6/spread-arguments.js @@ -12,42 +12,42 @@ function foo(fn, x) { new fn(...x); } -// CHECK-LABEL: Function(3 params, 30 registers, 2 symbols): +// CHECK-LABEL:Function(3 params, 17 registers, 2 symbols): // CHECK-NEXT: Offset in debug table: source 0x{{.*}}, scope 0x{{.*}} -// CHECK-NEXT: CreateEnvironment r0 -// CHECK-NEXT: LoadParam r1, 1 -// CHECK-NEXT: LoadParam r2, 2 -// CHECK-NEXT: StoreToEnvironment r0, 0, r1 -// CHECK-NEXT: StoreToEnvironment r0, 1, r2 -// CHECK-NEXT: LoadFromEnvironment r3, r0, 0 -// CHECK-NEXT: LoadConstZero r5 -// CHECK-NEXT: Mov r4, r5 -// CHECK-NEXT: LoadFromEnvironment r6, r0, 1 -// CHECK-NEXT: NewArray r7, 0 +// CHECK-NEXT: CreateEnvironment r3 +// CHECK-NEXT: LoadParam r5, 1 +// CHECK-NEXT: LoadParam r1, 2 +// CHECK-NEXT: StoreToEnvironment r3, 0, r5 +// CHECK-NEXT: StoreToEnvironment r3, 1, r1 +// CHECK-NEXT: LoadFromEnvironment r1, r3, 0 +// CHECK-NEXT: LoadConstZero r2 +// CHECK-NEXT: Mov r5, r2 +// CHECK-NEXT: LoadFromEnvironment r2, r3, 1 +// CHECK-NEXT: NewArray r4, 0 +// CHECK-NEXT: Mov r6, r5 +// CHECK-NEXT: Mov r9, r4 +// CHECK-NEXT: Mov r8, r2 +// CHECK-NEXT: Mov r7, r6 +// CHECK-NEXT: CallBuiltin r2, "HermesBuiltin.arraySpread", 4 +// CHECK-NEXT: Mov r5, r2 +// CHECK-NEXT: LoadConstUndefined r2 +// CHECK-NEXT: Mov r9, r1 // CHECK-NEXT: Mov r8, r4 -// CHECK-NEXT: Mov r22, r7 -// CHECK-NEXT: Mov r21, r6 -// CHECK-NEXT: Mov r20, r8 -// CHECK-NEXT: CallBuiltin r9, "HermesBuiltin.arraySpread", 4 -// CHECK-NEXT: Mov r4, r9 -// CHECK-NEXT: LoadConstUndefined r10 -// CHECK-NEXT: Mov r22, r3 -// CHECK-NEXT: Mov r21, r7 -// CHECK-NEXT: Mov r20, r10 -// CHECK-NEXT: CallBuiltin r11, "HermesBuiltin.apply", 4 -// CHECK-NEXT: LoadFromEnvironment r11, r0, 0 -// CHECK-NEXT: LoadConstZero r13 -// CHECK-NEXT: Mov r12, r13 -// CHECK-NEXT: LoadFromEnvironment r14, r0, 1 -// CHECK-NEXT: NewArray r15, 0 -// CHECK-NEXT: Mov r16, r12 -// CHECK-NEXT: Mov r22, r15 -// CHECK-NEXT: Mov r21, r14 -// CHECK-NEXT: Mov r20, r16 -// CHECK-NEXT: CallBuiltin r17, "HermesBuiltin.arraySpread", 4 -// CHECK-NEXT: Mov r12, r17 -// CHECK-NEXT: Mov r22, r11 -// CHECK-NEXT: Mov r21, r15 -// CHECK-NEXT: CallBuiltin r18, "HermesBuiltin.apply", 3 -// CHECK-NEXT: LoadConstUndefined r18 -// CHECK-NEXT: Ret r18 +// CHECK-NEXT: Mov r7, r2 +// CHECK-NEXT: CallBuiltin r0, "HermesBuiltin.apply", 4 +// CHECK-NEXT: LoadFromEnvironment r1, r3, 0 +// CHECK-NEXT: LoadConstZero r2 +// CHECK-NEXT: Mov r4, r2 +// CHECK-NEXT: LoadFromEnvironment r3, r3, 1 +// CHECK-NEXT: NewArray r2, 0 +// CHECK-NEXT: Mov r5, r4 +// CHECK-NEXT: Mov r9, r2 +// CHECK-NEXT: Mov r8, r3 +// CHECK-NEXT: Mov r7, r5 +// CHECK-NEXT: CallBuiltin r3, "HermesBuiltin.arraySpread", 4 +// CHECK-NEXT: Mov r4, r3 +// CHECK-NEXT: Mov r9, r1 +// CHECK-NEXT: Mov r8, r2 +// CHECK-NEXT: CallBuiltin r0, "HermesBuiltin.apply", 3 +// CHECK-NEXT: LoadConstUndefined r1 +// CHECK-NEXT: Ret r1 diff --git a/test/BCGen/HBC/unique-lit.js b/test/BCGen/HBC/unique-lit.js index 1b6dcab9f92..d18925e35df 100644 --- a/test/BCGen/HBC/unique-lit.js +++ b/test/BCGen/HBC/unique-lit.js @@ -20,24 +20,24 @@ function foo(x) { b = 10; } -//CHECK-LABEL:Function(2 params, 4 registers, 1 symbols): +//CHECK-LABEL:Function(2 params, 3 registers, 1 symbols): //CHECK-NEXT:Offset in debug table: source 0x{{.*}}, scope 0x{{.*}} -//CHECK-NEXT: CreateEnvironment r0 -//CHECK-NEXT: LoadParam r1, 1 -//CHECK-NEXT: StoreToEnvironment r0, 0, r1 -//CHECK-NEXT: LoadFromEnvironment r2, r0, 0 -//CHECK-NEXT: JmpTrue L1, r2 -//CHECK-NEXT: LoadConstUInt8 r0, 10 -//CHECK-NEXT: GetGlobalObject r1 -//CHECK-NEXT: PutById r1, r0, 1, "b" +//CHECK-NEXT: CreateEnvironment r1 +//CHECK-NEXT: LoadParam r2, 1 +//CHECK-NEXT: StoreToEnvironment r1, 0, r2 +//CHECK-NEXT: LoadFromEnvironment r1, r1, 0 +//CHECK-NEXT: JmpTrue L1, r1 +//CHECK-NEXT: LoadConstUInt8 r1, 10 +//CHECK-NEXT: GetGlobalObject r2 +//CHECK-NEXT: PutById r2, r1, 1, "b" //CHECK-NEXT: Jmp L2 //CHECK-NEXT:L1: -//CHECK-NEXT: LoadConstUInt8 r0, 10 -//CHECK-NEXT: GetGlobalObject r1 -//CHECK-NEXT: PutById r1, r0, 2, "a" +//CHECK-NEXT: LoadConstUInt8 r1, 10 +//CHECK-NEXT: GetGlobalObject r2 +//CHECK-NEXT: PutById r2, r1, 2, "a" //CHECK-NEXT:L2: -//CHECK-NEXT: LoadConstUndefined r0 -//CHECK-NEXT: Ret r0 +//CHECK-NEXT: LoadConstUndefined r1 +//CHECK-NEXT: Ret r1 //CHKOPT-LABEL:Function(2 params, 3 registers, 0 symbols): //CHKOPT-NEXT:Offset in debug table: source 0x{{.*}}, scope 0x{{.*}} diff --git a/test/IRGen/es6/block-scoping-top-level-scope.js b/test/IRGen/es6/block-scoping-top-level-scope.js index b07ec763766..2855f2fcdc1 100644 --- a/test/IRGen/es6/block-scoping-top-level-scope.js +++ b/test/IRGen/es6/block-scoping-top-level-scope.js @@ -81,213 +81,212 @@ function StrictHasParamExprs() { // BS-NEXT:i9[ASCII, 166..187] #DC9E65B9: notStrictHasParamExprs // BS-NEXT:i10[ASCII, 188..208] #689EB6F3: notStrictNoParamExprs -// BS:Function(1 params, 13 registers, 0 symbols): +// BS:Function(1 params, 4 registers, 0 symbols): // BS-NEXT:Offset in debug table: source 0x0000, scope 0x0000, textified callees 0x0000 // BS-NEXT: DeclareGlobalVar "notStrictNoParamE"... // BS-NEXT: DeclareGlobalVar "notStrictHasParam"... // BS-NEXT: DeclareGlobalVar "StrictNoParamExpr"... // BS-NEXT: DeclareGlobalVar "StrictHasParamExp"... // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: CreateClosure r1, r0, Function -// BS-NEXT: GetGlobalObject r2 -// BS-NEXT: PutById r2, r1, 1, "notStrictNoParamE"... -// BS-NEXT: CreateClosure r3, r0, Function -// BS-NEXT: GetGlobalObject r4 -// BS-NEXT: PutById r4, r3, 2, "notStrictHasParam"... -// BS-NEXT: CreateClosure r5, r0, Function -// BS-NEXT: GetGlobalObject r6 -// BS-NEXT: PutById r6, r5, 3, "StrictNoParamExpr"... -// BS-NEXT: CreateClosure r7, r0, Function -// BS-NEXT: GetGlobalObject r8 -// BS-NEXT: PutById r8, r7, 4, "StrictHasParamExp"... -// BS-NEXT: LoadConstUndefined r10 -// BS-NEXT: Mov r9, r10 -// BS-NEXT: Mov r11, r9 +// BS-NEXT: CreateClosure r2, r0, Function +// BS-NEXT: GetGlobalObject r3 +// BS-NEXT: PutById r3, r2, 1, "notStrictNoParamE"... +// BS-NEXT: CreateClosure r2, r0, Function +// BS-NEXT: GetGlobalObject r3 +// BS-NEXT: PutById r3, r2, 2, "notStrictHasParam"... +// BS-NEXT: CreateClosure r2, r0, Function +// BS-NEXT: GetGlobalObject r3 +// BS-NEXT: PutById r3, r2, 3, "StrictNoParamExpr"... +// BS-NEXT: CreateClosure r2, r0, Function +// BS-NEXT: GetGlobalObject r3 +// BS-NEXT: PutById r3, r2, 4, "StrictHasParamExp"... +// BS-NEXT: LoadConstUndefined r3 +// BS-NEXT: Mov r2, r3 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: Ret r11 +// BS-NEXT: Ret r2 -// BS:Function(1 params, 5 registers, 1 symbols): +// BS:Function(1 params, 4 registers, 1 symbols): // BS-NEXT:Offset in debug table: source 0x003d, scope 0x0003, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 // BS-NEXT: CreateInnerEnvironment r1, r0, 0 -// BS-NEXT: CreateClosure r2, r1, Function -// BS-NEXT: StoreToEnvironment r0, 0, r2 +// BS-NEXT: CreateClosure r3, r1, Function +// BS-NEXT: StoreToEnvironment r0, 0, r3 // BS-NEXT: LoadConstUndefined r3 // BS-NEXT: AsyncBreakCheck // BS-NEXT: Ret r3 -// BS:Function(2 params, 8 registers, 2 symbols): +// BS:Function(2 params, 4 registers, 2 symbols): // BS-NEXT:Offset in debug table: source 0x0051, scope 0x000a, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: LoadParam r2, 1 -// BS-NEXT: StoreToEnvironment r0, 0, r2 +// BS-NEXT: LoadParam r3, 1 +// BS-NEXT: StoreToEnvironment r0, 0, r3 // BS-NEXT: LoadConstUndefined r3 // BS-NEXT: StoreNPToEnvironment r0, 1, r3 // BS-NEXT: CreateInnerEnvironment r1, r0, 1 -// BS-NEXT: LoadConstUndefined r4 -// BS-NEXT: StoreNPToEnvironment r1, 0, r4 -// BS-NEXT: LoadConstUndefined r5 -// BS-NEXT: StoreNPToEnvironment r1, 0, r5 -// BS-NEXT: LoadConstUndefined r6 +// BS-NEXT: LoadConstUndefined r3 +// BS-NEXT: StoreNPToEnvironment r1, 0, r3 +// BS-NEXT: LoadConstUndefined r3 +// BS-NEXT: StoreNPToEnvironment r1, 0, r3 +// BS-NEXT: LoadConstUndefined r3 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: Ret r6 +// BS-NEXT: Ret r3 -// BS:Function(1 params, 5 registers, 1 symbols): +// BS:Function(1 params, 4 registers, 1 symbols): // BS-NEXT:Offset in debug table: source 0x006f, scope 0x0013, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 // BS-NEXT: CreateInnerEnvironment r1, r0, 0 -// BS-NEXT: CreateClosure r2, r1, Function -// BS-NEXT: StoreToEnvironment r0, 0, r2 +// BS-NEXT: CreateClosure r3, r1, Function +// BS-NEXT: StoreToEnvironment r0, 0, r3 // BS-NEXT: LoadConstUndefined r3 // BS-NEXT: AsyncBreakCheck // BS-NEXT: Ret r3 -// BS:Function(1 params, 14 registers, 2 symbols): +// BS:Function(1 params, 10 registers, 2 symbols): // BS-NEXT:Offset in debug table: source 0x0083, scope 0x001a, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: LoadParam r7, 1 +// BS-NEXT: LoadParam r9, 1 // BS-NEXT: CreateInnerEnvironment r1, r0, 0 // BS-NEXT: LoadConstEmpty r8 // BS-NEXT: StoreToEnvironment r0, 0, r8 -// BS-NEXT: LoadConstUndefined r9 -// BS-NEXT: StrictNeq r10, r7, r9 -// BS-NEXT: Mov r6, r7 +// BS-NEXT: LoadConstUndefined r8 +// BS-NEXT: StrictNeq r8, r9, r8 +// BS-NEXT: Mov r6, r9 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: JmpTrue L1, r10 +// BS-NEXT: JmpTrue L1, r8 // BS-NEXT: CreateInnerEnvironment r2, r1, 1 -// BS-NEXT: CreateClosure r7, r2, Function -// BS-NEXT: StoreToEnvironment r2, 0, r7 +// BS-NEXT: CreateClosure r8, r2, Function +// BS-NEXT: StoreToEnvironment r2, 0, r8 // BS-NEXT: CreateInnerEnvironment r3, r1, 1 // BS-NEXT: CreateClosure r8, r3, Function // BS-NEXT: StoreToEnvironment r3, 0, r8 // BS-NEXT: Mov r6, r8 // BS-NEXT:L1: // BS-NEXT: StoreToEnvironment r0, 0, r6 -// BS-NEXT: LoadFromEnvironment r7, r0, 0 -// BS-NEXT: ThrowIfEmpty r8, r7 +// BS-NEXT: LoadFromEnvironment r8, r0, 0 +// BS-NEXT: ThrowIfEmpty r8, r8 // BS-NEXT: StoreToEnvironment r0, 1, r8 // BS-NEXT: CreateInnerEnvironment r4, r1, 1 -// BS-NEXT: LoadConstUndefined r9 -// BS-NEXT: StoreNPToEnvironment r4, 0, r9 +// BS-NEXT: LoadConstUndefined r8 +// BS-NEXT: StoreNPToEnvironment r4, 0, r8 // BS-NEXT: CreateInnerEnvironment r5, r4, 1 -// BS-NEXT: LoadConstUndefined r10 -// BS-NEXT: StoreNPToEnvironment r5, 0, r10 -// BS-NEXT: LoadConstUndefined r11 -// BS-NEXT: StoreNPToEnvironment r5, 0, r11 -// BS-NEXT: LoadConstUndefined r12 -// BS-NEXT: Ret r12 - -// BS:Function(2 params, 8 registers, 2 symbols): +// BS-NEXT: LoadConstUndefined r8 +// BS-NEXT: StoreNPToEnvironment r5, 0, r8 +// BS-NEXT: LoadConstUndefined r8 +// BS-NEXT: StoreNPToEnvironment r5, 0, r8 +// BS-NEXT: LoadConstUndefined r8 +// BS-NEXT: Ret r8 + +// BS:Function(2 params, 4 registers, 2 symbols): // BS-NEXT:Offset in debug table: source 0x00d3, scope 0x0034, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: LoadParam r2, 1 -// BS-NEXT: StoreToEnvironment r0, 0, r2 +// BS-NEXT: LoadParam r3, 1 +// BS-NEXT: StoreToEnvironment r0, 0, r3 // BS-NEXT: LoadConstUndefined r3 // BS-NEXT: StoreNPToEnvironment r0, 1, r3 // BS-NEXT: CreateInnerEnvironment r1, r0, 1 -// BS-NEXT: LoadConstUndefined r4 -// BS-NEXT: StoreNPToEnvironment r1, 0, r4 -// BS-NEXT: LoadConstUndefined r5 -// BS-NEXT: StoreNPToEnvironment r1, 0, r5 -// BS-NEXT: LoadConstUndefined r6 +// BS-NEXT: LoadConstUndefined r3 +// BS-NEXT: StoreNPToEnvironment r1, 0, r3 +// BS-NEXT: LoadConstUndefined r3 +// BS-NEXT: StoreNPToEnvironment r1, 0, r3 +// BS-NEXT: LoadConstUndefined r3 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: Ret r6 +// BS-NEXT: Ret r3 // BS:Function(1 params, 4 registers, 0 symbols): // BS-NEXT:Offset in debug table: source 0x00f1, scope 0x0040, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 // BS-NEXT: CreateInnerEnvironment r1, r0, 0 -// BS-NEXT: LoadConstUndefined r2 +// BS-NEXT: LoadConstUndefined r3 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: Ret r2 +// BS-NEXT: Ret r3 -// BS:Function(1 params, 4 registers, 1 symbols): +// BS:Function(1 params, 3 registers, 1 symbols): // BS-NEXT:Offset in debug table: source 0x00fb, scope 0x0047, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: CreateClosure r1, r0, Function -// BS-NEXT: StoreToEnvironment r0, 0, r1 +// BS-NEXT: CreateClosure r2, r0, Function +// BS-NEXT: StoreToEnvironment r0, 0, r2 // BS-NEXT: LoadConstUndefined r2 // BS-NEXT: AsyncBreakCheck // BS-NEXT: Ret r2 -// BS:Function(2 params, 7 registers, 3 symbols): +// BS:Function(2 params, 3 registers, 3 symbols): // BS-NEXT:Offset in debug table: source 0x0112, scope 0x004c, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: LoadParam r1, 1 -// BS-NEXT: StoreToEnvironment r0, 0, r1 +// BS-NEXT: LoadParam r2, 1 +// BS-NEXT: StoreToEnvironment r0, 0, r2 // BS-NEXT: LoadConstUndefined r2 // BS-NEXT: StoreNPToEnvironment r0, 1, r2 -// BS-NEXT: LoadConstUndefined r3 -// BS-NEXT: StoreNPToEnvironment r0, 2, r3 -// BS-NEXT: LoadConstUndefined r4 -// BS-NEXT: StoreNPToEnvironment r0, 2, r4 -// BS-NEXT: LoadConstUndefined r5 +// BS-NEXT: LoadConstUndefined r2 +// BS-NEXT: StoreNPToEnvironment r0, 2, r2 +// BS-NEXT: LoadConstUndefined r2 +// BS-NEXT: StoreNPToEnvironment r0, 2, r2 +// BS-NEXT: LoadConstUndefined r2 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: Ret r5 +// BS-NEXT: Ret r2 -// BS:Function(1 params, 4 registers, 1 symbols): +// BS:Function(1 params, 3 registers, 1 symbols): // BS-NEXT:Offset in debug table: source 0x0135, scope 0x0053, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: CreateClosure r1, r0, Function -// BS-NEXT: StoreToEnvironment r0, 0, r1 +// BS-NEXT: CreateClosure r2, r0, Function +// BS-NEXT: StoreToEnvironment r0, 0, r2 // BS-NEXT: LoadConstUndefined r2 // BS-NEXT: AsyncBreakCheck // BS-NEXT: Ret r2 -// BS:Function(1 params, 12 registers, 2 symbols): +// BS:Function(1 params, 8 registers, 2 symbols): // BS-NEXT:Offset in debug table: source 0x014c, scope 0x0058, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: LoadParam r5, 1 +// BS-NEXT: LoadParam r7, 1 // BS-NEXT: LoadConstEmpty r6 // BS-NEXT: StoreToEnvironment r0, 0, r6 -// BS-NEXT: LoadConstUndefined r7 -// BS-NEXT: StrictNeq r8, r5, r7 -// BS-NEXT: Mov r4, r5 +// BS-NEXT: LoadConstUndefined r6 +// BS-NEXT: StrictNeq r6, r7, r6 +// BS-NEXT: Mov r4, r7 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: JmpTrue L1, r8 +// BS-NEXT: JmpTrue L1, r6 // BS-NEXT: CreateInnerEnvironment r1, r0, 1 -// BS-NEXT: CreateClosure r5, r1, Function -// BS-NEXT: StoreToEnvironment r1, 0, r5 +// BS-NEXT: CreateClosure r6, r1, Function +// BS-NEXT: StoreToEnvironment r1, 0, r6 // BS-NEXT: CreateInnerEnvironment r2, r0, 1 // BS-NEXT: CreateClosure r6, r2, Function // BS-NEXT: StoreToEnvironment r2, 0, r6 // BS-NEXT: Mov r4, r6 // BS-NEXT:L1: // BS-NEXT: StoreToEnvironment r0, 0, r4 -// BS-NEXT: LoadFromEnvironment r5, r0, 0 -// BS-NEXT: ThrowIfEmpty r6, r5 +// BS-NEXT: LoadFromEnvironment r6, r0, 0 +// BS-NEXT: ThrowIfEmpty r6, r6 // BS-NEXT: StoreToEnvironment r0, 1, r6 // BS-NEXT: CreateInnerEnvironment r3, r0, 2 -// BS-NEXT: LoadConstUndefined r7 -// BS-NEXT: StoreNPToEnvironment r3, 0, r7 -// BS-NEXT: LoadConstUndefined r8 -// BS-NEXT: StoreNPToEnvironment r3, 1, r8 -// BS-NEXT: LoadConstUndefined r9 -// BS-NEXT: StoreNPToEnvironment r3, 1, r9 -// BS-NEXT: LoadConstUndefined r10 -// BS-NEXT: Ret r10 +// BS-NEXT: LoadConstUndefined r6 +// BS-NEXT: StoreNPToEnvironment r3, 0, r6 +// BS-NEXT: LoadConstUndefined r6 +// BS-NEXT: StoreNPToEnvironment r3, 1, r6 +// BS-NEXT: LoadConstUndefined r6 +// BS-NEXT: StoreNPToEnvironment r3, 1, r6 +// BS-NEXT: LoadConstUndefined r6 +// BS-NEXT: Ret r6 -// BS:Function(2 params, 7 registers, 3 symbols): +// BS:Function(2 params, 3 registers, 3 symbols): // BS-NEXT:Offset in debug table: source 0x01ab, scope 0x0070, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: LoadParam r1, 1 -// BS-NEXT: StoreToEnvironment r0, 0, r1 +// BS-NEXT: LoadParam r2, 1 +// BS-NEXT: StoreToEnvironment r0, 0, r2 // BS-NEXT: LoadConstUndefined r2 // BS-NEXT: StoreNPToEnvironment r0, 1, r2 -// BS-NEXT: LoadConstUndefined r3 -// BS-NEXT: StoreNPToEnvironment r0, 2, r3 -// BS-NEXT: LoadConstUndefined r4 -// BS-NEXT: StoreNPToEnvironment r0, 2, r4 -// BS-NEXT: LoadConstUndefined r5 +// BS-NEXT: LoadConstUndefined r2 +// BS-NEXT: StoreNPToEnvironment r0, 2, r2 +// BS-NEXT: LoadConstUndefined r2 +// BS-NEXT: StoreNPToEnvironment r0, 2, r2 +// BS-NEXT: LoadConstUndefined r2 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: Ret r5 +// BS-NEXT: Ret r2 // BS:Function(1 params, 3 registers, 0 symbols): // BS-NEXT:Offset in debug table: source 0x01ce, scope 0x007a, textified callees 0x0000 // BS-NEXT: CreateEnvironment r0 -// BS-NEXT: LoadConstUndefined r1 +// BS-NEXT: LoadConstUndefined r2 // BS-NEXT: AsyncBreakCheck -// BS-NEXT: Ret r1 +// BS-NEXT: Ret r2 // BS:Debug filename table: // BS-NEXT: 0: {{.*}}block-scoping-top-level-scope.js @@ -307,7 +306,7 @@ function StrictHasParamExprs() { // BS-NEXT: bc 68: line 11 col 1 scope offset 0x0000 env r0 // BS-NEXT: bc 74: line 11 col 1 scope offset 0x0000 env r0 // BS-NEXT: bc 79: line 11 col 1 scope offset 0x0000 env r0 -// BS-NEXT: bc 83: line 51 col 1 scope offset 0x0000 env r0 +// BS-NEXT: bc 80: line 51 col 1 scope offset 0x0000 env r0 // BS-NEXT: 0x003d function idx 1, starts at line 11 col 1 // BS-NEXT: bc 9: line 11 col 1 scope offset 0x0007 env r1 // BS-NEXT: bc 14: line 11 col 1 scope offset 0x0007 env r1 @@ -491,190 +490,189 @@ function StrictHasParamExprs() { // NOBS-NEXT:i9[ASCII, 166..187] #DC9E65B9: notStrictHasParamExprs // NOBS-NEXT:i10[ASCII, 188..208] #689EB6F3: notStrictNoParamExprs -// NOBS:Function(1 params, 13 registers, 0 symbols): +// NOBS:Function(1 params, 4 registers, 0 symbols): // NOBS-NEXT:Offset in debug table: source 0x0000, scope 0x0000, textified callees 0x0000 // NOBS-NEXT: DeclareGlobalVar "notStrictNoParamE"... // NOBS-NEXT: DeclareGlobalVar "notStrictHasParam"... // NOBS-NEXT: DeclareGlobalVar "StrictNoParamExpr"... // NOBS-NEXT: DeclareGlobalVar "StrictHasParamExp"... // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: CreateClosure r1, r0, Function -// NOBS-NEXT: GetGlobalObject r2 -// NOBS-NEXT: PutById r2, r1, 1, "notStrictNoParamE"... -// NOBS-NEXT: CreateClosure r3, r0, Function -// NOBS-NEXT: GetGlobalObject r4 -// NOBS-NEXT: PutById r4, r3, 2, "notStrictHasParam"... -// NOBS-NEXT: CreateClosure r5, r0, Function -// NOBS-NEXT: GetGlobalObject r6 -// NOBS-NEXT: PutById r6, r5, 3, "StrictNoParamExpr"... -// NOBS-NEXT: CreateClosure r7, r0, Function -// NOBS-NEXT: GetGlobalObject r8 -// NOBS-NEXT: PutById r8, r7, 4, "StrictHasParamExp"... -// NOBS-NEXT: LoadConstUndefined r10 -// NOBS-NEXT: Mov r9, r10 -// NOBS-NEXT: Mov r11, r9 +// NOBS-NEXT: CreateClosure r2, r0, Function +// NOBS-NEXT: GetGlobalObject r3 +// NOBS-NEXT: PutById r3, r2, 1, "notStrictNoParamE"... +// NOBS-NEXT: CreateClosure r2, r0, Function +// NOBS-NEXT: GetGlobalObject r3 +// NOBS-NEXT: PutById r3, r2, 2, "notStrictHasParam"... +// NOBS-NEXT: CreateClosure r2, r0, Function +// NOBS-NEXT: GetGlobalObject r3 +// NOBS-NEXT: PutById r3, r2, 3, "StrictNoParamExpr"... +// NOBS-NEXT: CreateClosure r2, r0, Function +// NOBS-NEXT: GetGlobalObject r3 +// NOBS-NEXT: PutById r3, r2, 4, "StrictHasParamExp"... +// NOBS-NEXT: LoadConstUndefined r3 +// NOBS-NEXT: Mov r2, r3 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: Ret r11 +// NOBS-NEXT: Ret r2 -// NOBS:Function(1 params, 4 registers, 1 symbols): +// NOBS:Function(1 params, 3 registers, 1 symbols): // NOBS-NEXT:Offset in debug table: source 0x003d, scope 0x0003, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: CreateClosure r1, r0, Function -// NOBS-NEXT: StoreToEnvironment r0, 0, r1 +// NOBS-NEXT: CreateClosure r2, r0, Function +// NOBS-NEXT: StoreToEnvironment r0, 0, r2 // NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck // NOBS-NEXT: Ret r2 -// NOBS:Function(2 params, 7 registers, 3 symbols): +// NOBS:Function(2 params, 3 registers, 3 symbols): // NOBS-NEXT:Offset in debug table: source 0x0051, scope 0x0007, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: LoadParam r1, 1 -// NOBS-NEXT: StoreToEnvironment r0, 0, r1 +// NOBS-NEXT: LoadParam r2, 1 +// NOBS-NEXT: StoreToEnvironment r0, 0, r2 // NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: StoreNPToEnvironment r0, 1, r2 -// NOBS-NEXT: LoadConstUndefined r3 -// NOBS-NEXT: StoreNPToEnvironment r0, 2, r3 -// NOBS-NEXT: LoadConstUndefined r4 -// NOBS-NEXT: StoreNPToEnvironment r0, 2, r4 -// NOBS-NEXT: LoadConstUndefined r5 +// NOBS-NEXT: LoadConstUndefined r2 +// NOBS-NEXT: StoreNPToEnvironment r0, 2, r2 +// NOBS-NEXT: LoadConstUndefined r2 +// NOBS-NEXT: StoreNPToEnvironment r0, 2, r2 +// NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: Ret r5 +// NOBS-NEXT: Ret r2 -// NOBS:Function(1 params, 4 registers, 1 symbols): +// NOBS:Function(1 params, 3 registers, 1 symbols): // NOBS-NEXT:Offset in debug table: source 0x006f, scope 0x000d, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: CreateClosure r1, r0, Function -// NOBS-NEXT: StoreToEnvironment r0, 0, r1 +// NOBS-NEXT: CreateClosure r2, r0, Function +// NOBS-NEXT: StoreToEnvironment r0, 0, r2 // NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck // NOBS-NEXT: Ret r2 -// NOBS:Function(1 params, 7 registers, 5 symbols): +// NOBS:Function(1 params, 5 registers, 5 symbols): // NOBS-NEXT:Offset in debug table: source 0x0083, scope 0x0011, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: LoadParam r2, 1 +// NOBS-NEXT: LoadParam r4, 1 // NOBS-NEXT: LoadConstUndefined r3 -// NOBS-NEXT: StrictNeq r4, r2, r3 -// NOBS-NEXT: Mov r1, r2 +// NOBS-NEXT: StrictNeq r3, r4, r3 +// NOBS-NEXT: Mov r1, r4 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: JmpTrue L1, r4 -// NOBS-NEXT: CreateClosure r2, r0, Function -// NOBS-NEXT: StoreToEnvironment r0, 1, r2 +// NOBS-NEXT: JmpTrue L1, r3 +// NOBS-NEXT: CreateClosure r3, r0, Function +// NOBS-NEXT: StoreToEnvironment r0, 1, r3 // NOBS-NEXT: CreateClosure r3, r0, Function // NOBS-NEXT: StoreToEnvironment r0, 2, r3 // NOBS-NEXT: Mov r1, r3 // NOBS-NEXT:L1: // NOBS-NEXT: StoreToEnvironment r0, 0, r1 -// NOBS-NEXT: LoadConstUndefined r2 -// NOBS-NEXT: StoreNPToEnvironment r0, 3, r2 +// NOBS-NEXT: LoadConstUndefined r3 +// NOBS-NEXT: StoreNPToEnvironment r0, 3, r3 // NOBS-NEXT: LoadConstUndefined r3 // NOBS-NEXT: StoreNPToEnvironment r0, 4, r3 -// NOBS-NEXT: LoadConstUndefined r4 -// NOBS-NEXT: StoreNPToEnvironment r0, 4, r4 -// NOBS-NEXT: LoadConstUndefined r5 -// NOBS-NEXT: Ret r5 +// NOBS-NEXT: LoadConstUndefined r3 +// NOBS-NEXT: StoreNPToEnvironment r0, 4, r3 +// NOBS-NEXT: LoadConstUndefined r3 +// NOBS-NEXT: Ret r3 -// NOBS:Function(2 params, 7 registers, 3 symbols): +// NOBS:Function(2 params, 3 registers, 3 symbols): // NOBS-NEXT:Offset in debug table: source 0x00bf, scope 0x001b, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: LoadParam r1, 1 -// NOBS-NEXT: StoreToEnvironment r0, 0, r1 +// NOBS-NEXT: LoadParam r2, 1 +// NOBS-NEXT: StoreToEnvironment r0, 0, r2 // NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: StoreNPToEnvironment r0, 1, r2 -// NOBS-NEXT: LoadConstUndefined r3 -// NOBS-NEXT: StoreNPToEnvironment r0, 2, r3 -// NOBS-NEXT: LoadConstUndefined r4 -// NOBS-NEXT: StoreNPToEnvironment r0, 2, r4 -// NOBS-NEXT: LoadConstUndefined r5 +// NOBS-NEXT: LoadConstUndefined r2 +// NOBS-NEXT: StoreNPToEnvironment r0, 2, r2 +// NOBS-NEXT: LoadConstUndefined r2 +// NOBS-NEXT: StoreNPToEnvironment r0, 2, r2 +// NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: Ret r5 +// NOBS-NEXT: Ret r2 // NOBS:Function(1 params, 3 registers, 0 symbols): // NOBS-NEXT:Offset in debug table: source 0x00dd, scope 0x0024, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: LoadConstUndefined r1 +// NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: Ret r1 +// NOBS-NEXT: Ret r2 -// NOBS:Function(1 params, 4 registers, 1 symbols): +// NOBS:Function(1 params, 3 registers, 1 symbols): // NOBS-NEXT:Offset in debug table: source 0x00e6, scope 0x0027, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: CreateClosure r1, r0, Function -// NOBS-NEXT: StoreToEnvironment r0, 0, r1 +// NOBS-NEXT: CreateClosure r2, r0, Function +// NOBS-NEXT: StoreToEnvironment r0, 0, r2 // NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck // NOBS-NEXT: Ret r2 -// NOBS:Function(2 params, 7 registers, 3 symbols): +// NOBS:Function(2 params, 3 registers, 3 symbols): // NOBS-NEXT:Offset in debug table: source 0x00fa, scope 0x002c, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: LoadParam r1, 1 -// NOBS-NEXT: StoreToEnvironment r0, 0, r1 +// NOBS-NEXT: LoadParam r2, 1 +// NOBS-NEXT: StoreToEnvironment r0, 0, r2 // NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: StoreNPToEnvironment r0, 1, r2 -// NOBS-NEXT: LoadConstUndefined r3 -// NOBS-NEXT: StoreNPToEnvironment r0, 2, r3 -// NOBS-NEXT: LoadConstUndefined r4 -// NOBS-NEXT: StoreNPToEnvironment r0, 2, r4 -// NOBS-NEXT: LoadConstUndefined r5 +// NOBS-NEXT: LoadConstUndefined r2 +// NOBS-NEXT: StoreNPToEnvironment r0, 2, r2 +// NOBS-NEXT: LoadConstUndefined r2 +// NOBS-NEXT: StoreNPToEnvironment r0, 2, r2 +// NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: Ret r5 +// NOBS-NEXT: Ret r2 -// NOBS:Function(1 params, 4 registers, 1 symbols): +// NOBS:Function(1 params, 3 registers, 1 symbols): // NOBS-NEXT:Offset in debug table: source 0x0118, scope 0x0032, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: CreateClosure r1, r0, Function -// NOBS-NEXT: StoreToEnvironment r0, 0, r1 +// NOBS-NEXT: CreateClosure r2, r0, Function +// NOBS-NEXT: StoreToEnvironment r0, 0, r2 // NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck // NOBS-NEXT: Ret r2 -// NOBS:Function(1 params, 7 registers, 5 symbols): +// NOBS:Function(1 params, 5 registers, 5 symbols): // NOBS-NEXT:Offset in debug table: source 0x012c, scope 0x0037, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: LoadParam r2, 1 +// NOBS-NEXT: LoadParam r4, 1 // NOBS-NEXT: LoadConstUndefined r3 -// NOBS-NEXT: StrictNeq r4, r2, r3 -// NOBS-NEXT: Mov r1, r2 +// NOBS-NEXT: StrictNeq r3, r4, r3 +// NOBS-NEXT: Mov r1, r4 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: JmpTrue L1, r4 -// NOBS-NEXT: CreateClosure r2, r0, Function -// NOBS-NEXT: StoreToEnvironment r0, 1, r2 +// NOBS-NEXT: JmpTrue L1, r3 +// NOBS-NEXT: CreateClosure r3, r0, Function +// NOBS-NEXT: StoreToEnvironment r0, 1, r3 // NOBS-NEXT: CreateClosure r3, r0, Function // NOBS-NEXT: StoreToEnvironment r0, 2, r3 // NOBS-NEXT: Mov r1, r3 // NOBS-NEXT:L1: // NOBS-NEXT: StoreToEnvironment r0, 0, r1 -// NOBS-NEXT: LoadConstUndefined r2 -// NOBS-NEXT: StoreNPToEnvironment r0, 3, r2 +// NOBS-NEXT: LoadConstUndefined r3 +// NOBS-NEXT: StoreNPToEnvironment r0, 3, r3 +// NOBS-NEXT: LoadConstUndefined r3 +// NOBS-NEXT: StoreNPToEnvironment r0, 4, r3 // NOBS-NEXT: LoadConstUndefined r3 // NOBS-NEXT: StoreNPToEnvironment r0, 4, r3 -// NOBS-NEXT: LoadConstUndefined r4 -// NOBS-NEXT: StoreNPToEnvironment r0, 4, r4 -// NOBS-NEXT: LoadConstUndefined r5 -// NOBS-NEXT: Ret r5 +// NOBS-NEXT: LoadConstUndefined r3 +// NOBS-NEXT: Ret r3 -// NOBS:Function(2 params, 7 registers, 3 symbols): +// NOBS:Function(2 params, 3 registers, 3 symbols): // NOBS-NEXT:Offset in debug table: source 0x0168, scope 0x0041, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: LoadParam r1, 1 -// NOBS-NEXT: StoreToEnvironment r0, 0, r1 +// NOBS-NEXT: LoadParam r2, 1 +// NOBS-NEXT: StoreToEnvironment r0, 0, r2 // NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: StoreNPToEnvironment r0, 1, r2 -// NOBS-NEXT: LoadConstUndefined r3 -// NOBS-NEXT: StoreNPToEnvironment r0, 2, r3 -// NOBS-NEXT: LoadConstUndefined r4 -// NOBS-NEXT: StoreNPToEnvironment r0, 2, r4 -// NOBS-NEXT: LoadConstUndefined r5 +// NOBS-NEXT: LoadConstUndefined r2 +// NOBS-NEXT: StoreNPToEnvironment r0, 2, r2 +// NOBS-NEXT: LoadConstUndefined r2 +// NOBS-NEXT: StoreNPToEnvironment r0, 2, r2 +// NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: Ret r5 +// NOBS-NEXT: Ret r2 // NOBS:Function(1 params, 3 registers, 0 symbols): // NOBS-NEXT:Offset in debug table: source 0x018b, scope 0x004a, textified callees 0x0000 // NOBS-NEXT: CreateEnvironment r0 -// NOBS-NEXT: LoadConstUndefined r1 +// NOBS-NEXT: LoadConstUndefined r2 // NOBS-NEXT: AsyncBreakCheck -// NOBS-NEXT: Ret r1 +// NOBS-NEXT: Ret r2 // NOBS:Debug filename table: // NOBS-NEXT: 0: {{.*}}block-scoping-top-level-scope.js @@ -694,7 +692,7 @@ function StrictHasParamExprs() { // NOBS-NEXT: bc 68: line 11 col 1 scope offset 0x0000 env r0 // NOBS-NEXT: bc 74: line 11 col 1 scope offset 0x0000 env r0 // NOBS-NEXT: bc 79: line 11 col 1 scope offset 0x0000 env r0 -// NOBS-NEXT: bc 83: line 51 col 1 scope offset 0x0000 env r0 +// NOBS-NEXT: bc 80: line 51 col 1 scope offset 0x0000 env r0 // NOBS-NEXT: 0x003d function idx 1, starts at line 11 col 1 // NOBS-NEXT: bc 2: line 11 col 1 scope offset 0x0003 env r0 // NOBS-NEXT: bc 7: line 11 col 1 scope offset 0x0003 env r0 diff --git a/test/IRGen/instance_of.js b/test/IRGen/instance_of.js index 5f22e489660..98492e7cd82 100644 --- a/test/IRGen/instance_of.js +++ b/test/IRGen/instance_of.js @@ -18,29 +18,29 @@ function simple_test0(x, y) { // CHECK-NEXT:globals = [simple_test0] // CHECK-NEXT:S{global#0()#1} = [] // CHECK-NEXT:%BB0: -// CHECK-NEXT: $Reg0 %0 = HBCCreateEnvironmentInst %S{global#0()#1} +// CHECK-NEXT: $Reg1 %0 = HBCCreateEnvironmentInst %S{global#0()#1} // CHECK-NEXT: $Reg1 %1 = HBCCreateFunctionInst %simple_test0#0#1()#2, %0 // CHECK-NEXT: $Reg2 %2 = HBCGetGlobalObjectInst -// CHECK-NEXT: $Reg3 %3 = StorePropertyInst %1 : closure, %2 : object, "simple_test0" : string -// CHECK-NEXT: $Reg3 %4 = AllocStackInst $?anon_0_ret -// CHECK-NEXT: $Reg4 %5 = HBCLoadConstInst undefined : undefined -// CHECK-NEXT: $Reg5 %6 = StoreStackInst %5 : undefined, %4 -// CHECK-NEXT: $Reg5 %7 = LoadStackInst %4 -// CHECK-NEXT: $Reg6 %8 = ReturnInst %7 +// CHECK-NEXT: $Reg0 %3 = StorePropertyInst %1 : closure, %2 : object, "simple_test0" : string +// CHECK-NEXT: $Reg1 %4 = AllocStackInst $?anon_0_ret +// CHECK-NEXT: $Reg2 %5 = HBCLoadConstInst undefined : undefined +// CHECK-NEXT: $Reg0 %6 = StoreStackInst %5 : undefined, %4 +// CHECK-NEXT: $Reg1 %7 = LoadStackInst %4 +// CHECK-NEXT: $Reg0 %8 = ReturnInst %7 // CHECK-NEXT:function_end // CHECK:function simple_test0#0#1(x, y)#2 // CHECK-NEXT:S{simple_test0#0#1()#2} = [x#2, y#2] // CHECK-NEXT:%BB0: -// CHECK-NEXT: $Reg0 %0 = HBCCreateEnvironmentInst %S{simple_test0#0#1()#2} -// CHECK-NEXT: $Reg1 %1 = HBCLoadParamInst 1 : number -// CHECK-NEXT: $Reg2 %2 = HBCLoadParamInst 2 : number -// CHECK-NEXT: $Reg3 %3 = HBCStoreToEnvironmentInst %0, %1, [x#2] -// CHECK-NEXT: $Reg3 %4 = HBCStoreToEnvironmentInst %0, %2, [y#2] -// CHECK-NEXT: $Reg3 %5 = HBCLoadFromEnvironmentInst %0, [x#2] -// CHECK-NEXT: $Reg4 %6 = HBCLoadFromEnvironmentInst %0, [y#2] -// CHECK-NEXT: $Reg5 %7 = BinaryOperatorInst 'instanceof', %5, %6 -// CHECK-NEXT: $Reg6 %8 = ReturnInst %7 +// CHECK-NEXT: $Reg2 %0 = HBCCreateEnvironmentInst %S{simple_test0#0#1()#2} +// CHECK-NEXT: $Reg3 %1 = HBCLoadParamInst 1 : number +// CHECK-NEXT: $Reg1 %2 = HBCLoadParamInst 2 : number +// CHECK-NEXT: $Reg0 %3 = HBCStoreToEnvironmentInst %0, %1, [x#2] +// CHECK-NEXT: $Reg0 %4 = HBCStoreToEnvironmentInst %0, %2, [y#2] +// CHECK-NEXT: $Reg1 %5 = HBCLoadFromEnvironmentInst %0, [x#2] +// CHECK-NEXT: $Reg2 %6 = HBCLoadFromEnvironmentInst %0, [y#2] +// CHECK-NEXT: $Reg1 %7 = BinaryOperatorInst 'instanceof', %5, %6 +// CHECK-NEXT: $Reg0 %8 = ReturnInst %7 // CHECK-NEXT:%BB1: // CHECK-NEXT: $??? %9 = HBCLoadConstInst undefined : undefined // CHECK-NEXT: $??? %10 = ReturnInst %9 : undefined diff --git a/test/Parser/flow/declare-module-import-allowed.js b/test/Parser/flow/declare-module-import-allowed.js index dba3fe40360..f94df253ba3 100644 --- a/test/Parser/flow/declare-module-import-allowed.js +++ b/test/Parser/flow/declare-module-import-allowed.js @@ -11,38 +11,40 @@ declare module Foo { import Bar from "baz"; } -// CHECK: { -// CHECK-NEXT: "type": "Program", -// CHECK-NEXT: "body": [ -// CHECK-NEXT: { -// CHECK-NEXT: "type": "DeclareModule", -// CHECK-NEXT: "id": { -// CHECK-NEXT: "type": "Identifier", -// CHECK-NEXT: "name": "Foo" -// CHECK-NEXT: }, -// CHECK-NEXT: "body": { -// CHECK-NEXT: "type": "BlockStatement", -// CHECK-NEXT: "body": [ -// CHECK-NEXT: { -// CHECK-NEXT: "type": "ImportDeclaration", -// CHECK-NEXT: "specifiers": [ -// CHECK-NEXT: { -// CHECK-NEXT: "type": "ImportDefaultSpecifier", -// CHECK-NEXT: "local": { -// CHECK-NEXT: "type": "Identifier", -// CHECK-NEXT: "name": "Bar" -// CHECK-NEXT: } -// CHECK-NEXT: } -// CHECK-NEXT: ], -// CHECK-NEXT: "source": { -// CHECK-NEXT: "type": "StringLiteral", -// CHECK-NEXT: "value": "baz" -// CHECK-NEXT: }, -// CHECK-NEXT: "assertions": [], -// CHECK-NEXT: "importKind": "value" -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: } -// CHECK-NEXT: } -// CHECK-NEXT: ] -// CHECK-NEXT: } +// Auto-generated content below. Please do not modify manually. + +// CHECK:{ +// CHECK-NEXT: "type": "Program", +// CHECK-NEXT: "body": [ +// CHECK-NEXT: { +// CHECK-NEXT: "type": "DeclareModule", +// CHECK-NEXT: "id": { +// CHECK-NEXT: "type": "Identifier", +// CHECK-NEXT: "name": "Foo" +// CHECK-NEXT: }, +// CHECK-NEXT: "body": { +// CHECK-NEXT: "type": "BlockStatement", +// CHECK-NEXT: "body": [ +// CHECK-NEXT: { +// CHECK-NEXT: "type": "ImportDeclaration", +// CHECK-NEXT: "specifiers": [ +// CHECK-NEXT: { +// CHECK-NEXT: "type": "ImportDefaultSpecifier", +// CHECK-NEXT: "local": { +// CHECK-NEXT: "type": "Identifier", +// CHECK-NEXT: "name": "Bar" +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ], +// CHECK-NEXT: "source": { +// CHECK-NEXT: "type": "StringLiteral", +// CHECK-NEXT: "value": "baz" +// CHECK-NEXT: }, +// CHECK-NEXT: "assertions": [], +// CHECK-NEXT: "importKind": "value" +// CHECK-NEXT: } +// CHECK-NEXT: ] +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: ] +// CHECK-NEXT:} diff --git a/test/RA/assign_to_argument.js b/test/RA/assign_to_argument.js index 06fac5d93df..36d5a2433e1 100644 --- a/test/RA/assign_to_argument.js +++ b/test/RA/assign_to_argument.js @@ -17,25 +17,25 @@ function foo(a) { // CHECK-NEXT:globals = [foo] // CHECK-NEXT:S{global#0()#1} = [] // CHECK-NEXT:%BB0: -// CHECK-NEXT: $Reg0 %0 = HBCCreateEnvironmentInst %S{global#0()#1} +// CHECK-NEXT: $Reg1 %0 = HBCCreateEnvironmentInst %S{global#0()#1} // CHECK-NEXT: $Reg1 %1 = HBCCreateFunctionInst %foo#0#1()#2, %0 // CHECK-NEXT: $Reg2 %2 = HBCGetGlobalObjectInst -// CHECK-NEXT: $Reg3 %3 = StorePropertyInst %1 : closure, %2 : object, "foo" : string -// CHECK-NEXT: $Reg3 %4 = AllocStackInst $?anon_0_ret -// CHECK-NEXT: $Reg4 %5 = HBCLoadConstInst undefined : undefined -// CHECK-NEXT: $Reg5 %6 = StoreStackInst %5 : undefined, %4 -// CHECK-NEXT: $Reg5 %7 = LoadStackInst %4 -// CHECK-NEXT: $Reg6 %8 = ReturnInst %7 +// CHECK-NEXT: $Reg0 %3 = StorePropertyInst %1 : closure, %2 : object, "foo" : string +// CHECK-NEXT: $Reg1 %4 = AllocStackInst $?anon_0_ret +// CHECK-NEXT: $Reg2 %5 = HBCLoadConstInst undefined : undefined +// CHECK-NEXT: $Reg0 %6 = StoreStackInst %5 : undefined, %4 +// CHECK-NEXT: $Reg1 %7 = LoadStackInst %4 +// CHECK-NEXT: $Reg0 %8 = ReturnInst %7 // CHECK-NEXT:function_end // CHECK:function foo#0#1(a)#2 // CHECK-NEXT:S{foo#0#1()#2} = [a#2] // CHECK-NEXT:%BB0: -// CHECK-NEXT: $Reg0 %0 = HBCCreateEnvironmentInst %S{foo#0#1()#2} -// CHECK-NEXT: $Reg1 %1 = HBCLoadParamInst 1 : number -// CHECK-NEXT: $Reg2 %2 = HBCStoreToEnvironmentInst %0, %1, [a#2] +// CHECK-NEXT: $Reg1 %0 = HBCCreateEnvironmentInst %S{foo#0#1()#2} +// CHECK-NEXT: $Reg2 %1 = HBCLoadParamInst 1 : number +// CHECK-NEXT: $Reg0 %2 = HBCStoreToEnvironmentInst %0, %1, [a#2] // CHECK-NEXT: $Reg2 %3 = HBCLoadFromEnvironmentInst %0, [a#2] -// CHECK-NEXT: $Reg3 %4 = HBCStoreToEnvironmentInst %0, %3, [a#2] -// CHECK-NEXT: $Reg3 %5 = HBCLoadConstInst undefined : undefined -// CHECK-NEXT: $Reg4 %6 = ReturnInst %5 : undefined +// CHECK-NEXT: $Reg0 %4 = HBCStoreToEnvironmentInst %0, %3, [a#2] +// CHECK-NEXT: $Reg1 %5 = HBCLoadConstInst undefined : undefined +// CHECK-NEXT: $Reg0 %6 = ReturnInst %5 : undefined // CHECK-NEXT:function_end diff --git a/test/RA/callee.js b/test/RA/callee.js index fce52af9f73..e20278ba2c5 100644 --- a/test/RA/callee.js +++ b/test/RA/callee.js @@ -19,46 +19,46 @@ function foo(x) { // CHECK-NEXT:globals = [sink, foo] // CHECK-NEXT:S{global#0()#1} = [] // CHECK-NEXT:%BB0: -// CHECK-NEXT: $Reg0 %0 = HBCCreateEnvironmentInst %S{global#0()#1} -// CHECK-NEXT: $Reg1 %1 = HBCCreateFunctionInst %sink#0#1()#2, %0 -// CHECK-NEXT: $Reg2 %2 = HBCGetGlobalObjectInst -// CHECK-NEXT: $Reg3 %3 = StorePropertyInst %1 : closure, %2 : object, "sink" : string -// CHECK-NEXT: $Reg3 %4 = HBCCreateFunctionInst %foo#0#1()#3, %0 -// CHECK-NEXT: $Reg4 %5 = HBCGetGlobalObjectInst -// CHECK-NEXT: $Reg5 %6 = StorePropertyInst %4 : closure, %5 : object, "foo" : string -// CHECK-NEXT: $Reg5 %7 = AllocStackInst $?anon_0_ret -// CHECK-NEXT: $Reg6 %8 = HBCLoadConstInst undefined : undefined -// CHECK-NEXT: $Reg7 %9 = StoreStackInst %8 : undefined, %7 -// CHECK-NEXT: $Reg7 %10 = LoadStackInst %7 -// CHECK-NEXT: $Reg8 %11 = ReturnInst %10 +// CHECK-NEXT: $Reg1 %0 = HBCCreateEnvironmentInst %S{global#0()#1} +// CHECK-NEXT: $Reg2 %1 = HBCCreateFunctionInst %sink#0#1()#2, %0 +// CHECK-NEXT: $Reg3 %2 = HBCGetGlobalObjectInst +// CHECK-NEXT: $Reg0 %3 = StorePropertyInst %1 : closure, %2 : object, "sink" : string +// CHECK-NEXT: $Reg1 %4 = HBCCreateFunctionInst %foo#0#1()#3, %0 +// CHECK-NEXT: $Reg2 %5 = HBCGetGlobalObjectInst +// CHECK-NEXT: $Reg0 %6 = StorePropertyInst %4 : closure, %5 : object, "foo" : string +// CHECK-NEXT: $Reg1 %7 = AllocStackInst $?anon_0_ret +// CHECK-NEXT: $Reg2 %8 = HBCLoadConstInst undefined : undefined +// CHECK-NEXT: $Reg0 %9 = StoreStackInst %8 : undefined, %7 +// CHECK-NEXT: $Reg1 %10 = LoadStackInst %7 +// CHECK-NEXT: $Reg0 %11 = ReturnInst %10 // CHECK-NEXT:function_end // CHECK:function sink#0#1(x, y, z)#2 // CHECK-NEXT:S{sink#0#1()#2} = [x#2, y#2, z#2] // CHECK-NEXT:%BB0: -// CHECK-NEXT: $Reg0 %0 = HBCCreateEnvironmentInst %S{sink#0#1()#2} -// CHECK-NEXT: $Reg1 %1 = HBCLoadParamInst 1 : number -// CHECK-NEXT: $Reg2 %2 = HBCLoadParamInst 2 : number -// CHECK-NEXT: $Reg3 %3 = HBCLoadParamInst 3 : number -// CHECK-NEXT: $Reg4 %4 = HBCStoreToEnvironmentInst %0, %1, [x#2] -// CHECK-NEXT: $Reg4 %5 = HBCStoreToEnvironmentInst %0, %2, [y#2] -// CHECK-NEXT: $Reg4 %6 = HBCStoreToEnvironmentInst %0, %3, [z#2] -// CHECK-NEXT: $Reg4 %7 = HBCLoadConstInst undefined : undefined -// CHECK-NEXT: $Reg5 %8 = ReturnInst %7 : undefined +// CHECK-NEXT: $Reg1 %0 = HBCCreateEnvironmentInst %S{sink#0#1()#2} +// CHECK-NEXT: $Reg4 %1 = HBCLoadParamInst 1 : number +// CHECK-NEXT: $Reg3 %2 = HBCLoadParamInst 2 : number +// CHECK-NEXT: $Reg2 %3 = HBCLoadParamInst 3 : number +// CHECK-NEXT: $Reg0 %4 = HBCStoreToEnvironmentInst %0, %1, [x#2] +// CHECK-NEXT: $Reg0 %5 = HBCStoreToEnvironmentInst %0, %2, [y#2] +// CHECK-NEXT: $Reg0 %6 = HBCStoreToEnvironmentInst %0, %3, [z#2] +// CHECK-NEXT: $Reg1 %7 = HBCLoadConstInst undefined : undefined +// CHECK-NEXT: $Reg0 %8 = ReturnInst %7 : undefined // CHECK-NEXT:function_end // CHECK:function foo#0#1(x)#2 // CHECK-NEXT:S{foo#0#1()#2} = [x#2] // CHECK-NEXT:%BB0: -// CHECK-NEXT: $Reg0 %0 = HBCCreateEnvironmentInst %S{foo#0#1()#2} +// CHECK-NEXT: $Reg2 %0 = HBCCreateEnvironmentInst %S{foo#0#1()#2} // CHECK-NEXT: $Reg1 %1 = HBCLoadParamInst 1 : number -// CHECK-NEXT: $Reg2 %2 = HBCStoreToEnvironmentInst %0, %1, [x#2] +// CHECK-NEXT: $Reg0 %2 = HBCStoreToEnvironmentInst %0, %1, [x#2] // CHECK-NEXT: $Reg2 %3 = HBCLoadFromEnvironmentInst %0, [x#2] -// CHECK-NEXT: $Reg3 %4 = LoadPropertyInst %3, "sink" : string -// CHECK-NEXT: $Reg4 %5 = HBCLoadConstInst 1 : number -// CHECK-NEXT: $Reg5 %6 = HBCLoadConstInst 2 : number -// CHECK-NEXT: $Reg6 %7 = HBCLoadConstInst 3 : number -// CHECK-NEXT: $Reg7 %8 = CallInst %4, undefined : undefined, %3, %5 : number, %6 : number, %7 : number -// CHECK-NEXT: $Reg7 %9 = HBCLoadConstInst undefined : undefined -// CHECK-NEXT: $Reg8 %10 = ReturnInst %9 : undefined +// CHECK-NEXT: $Reg1 %4 = LoadPropertyInst %3, "sink" : string +// CHECK-NEXT: $Reg3 %5 = HBCLoadConstInst 1 : number +// CHECK-NEXT: $Reg4 %6 = HBCLoadConstInst 2 : number +// CHECK-NEXT: $Reg5 %7 = HBCLoadConstInst 3 : number +// CHECK-NEXT: $Reg0 %8 = CallInst %4, undefined : undefined, %3, %5 : number, %6 : number, %7 : number +// CHECK-NEXT: $Reg1 %9 = HBCLoadConstInst undefined : undefined +// CHECK-NEXT: $Reg0 %10 = ReturnInst %9 : undefined // CHECK-NEXT:function_end diff --git a/test/hermes/instanceof.js b/test/hermes/instanceof.js index 751900afb50..ee1f9d53200 100644 --- a/test/hermes/instanceof.js +++ b/test/hermes/instanceof.js @@ -66,3 +66,7 @@ try { } //CHECK-NEXT: caught RangeError Maximum prototype chain length exceeded +function A(){} +Object.defineProperty(A, Symbol.hasInstance, {value: function(){return true;}}) +print(undefined instanceof A); +//CHECK-NEXT: true diff --git a/test/hermes/intl/date-time-format-apple.js b/test/hermes/intl/date-time-format-apple.js index 065c97c1209..941305c45f6 100644 --- a/test/hermes/intl/date-time-format-apple.js +++ b/test/hermes/intl/date-time-format-apple.js @@ -100,6 +100,10 @@ numericOptions.forEach(element => print(new Intl.DateTimeFormat('en-GB', {second // CHECK-NEXT: 3 // CHECK-NEXT: 3 +numericOptions.forEach(element => print(new Intl.DateTimeFormat('de-DE', {hour: element, minute: element}).format(date))); +// CHECK-NEXT: 03:45 +// CHECK-NEXT: 03:45 + lengthOptions.concat(numericOptions).forEach(element => print(new Intl.DateTimeFormat('en-GB', {month: element}).format(date))); // CHECK-NEXT: J // CHECK-NEXT: Jan @@ -108,6 +112,10 @@ lengthOptions.concat(numericOptions).forEach(element => print(new Intl.DateTimeF // CHECK-NEXT: 01 numericOptions.forEach(element => print(new Intl.DateTimeFormat('ja-JP', {hour: element, minute: element}).format(date))); +// CHECK-NEXT: 3:45 +// CHECK-NEXT: 3:45 + +numericOptions.forEach(element => print(new Intl.DateTimeFormat('ja-JP', {hour: element, minute: element, hourCycle: "h12"}).format(date))); // CHECK-NEXT: 午前3:45 // CHECK-NEXT: 午前3:45 diff --git a/tools/hermes-parser/js/.flowconfig b/tools/hermes-parser/js/.flowconfig index af41425f71d..4aba44fdf02 100644 --- a/tools/hermes-parser/js/.flowconfig +++ b/tools/hermes-parser/js/.flowconfig @@ -27,7 +27,7 @@ component_syntax=true enums=true [version] -^0.241.0 +^0.243.0 [lints] untyped-type-import=error diff --git a/tools/hermes-parser/js/CHANGELOG.md b/tools/hermes-parser/js/CHANGELOG.md index 32471629e14..e77f7e9160a 100644 --- a/tools/hermes-parser/js/CHANGELOG.md +++ b/tools/hermes-parser/js/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.23.1 + +### `hermes-transform` +* Fixed an issue that caused an error when trying to print a `Program` with an empty `body` array and a docblock comment. + +### `flow-api-translator` +* Added support for `as` expressions in parent classes like `class A extends (Foo as Bar)`. + ## 0.23.0 ### `hermes-estree` diff --git a/tools/hermes-parser/js/babel-plugin-syntax-hermes-parser/package.json b/tools/hermes-parser/js/babel-plugin-syntax-hermes-parser/package.json index 79dcf29546b..9e3362c0e8b 100644 --- a/tools/hermes-parser/js/babel-plugin-syntax-hermes-parser/package.json +++ b/tools/hermes-parser/js/babel-plugin-syntax-hermes-parser/package.json @@ -1,6 +1,6 @@ { "name": "babel-plugin-syntax-hermes-parser", - "version": "0.23.0", + "version": "0.23.1", "description": "Babel plugin which switches Babel to use the Hermes parser.", "main": "dist/index.js", "license": "MIT", @@ -9,7 +9,7 @@ "url": "git@github.com:facebook/hermes.git" }, "dependencies": { - "hermes-parser": "0.23.0" + "hermes-parser": "0.23.1" }, "files": [ "dist", diff --git a/tools/hermes-parser/js/flow-api-translator/package.json b/tools/hermes-parser/js/flow-api-translator/package.json index 447ddfa5d11..fc279ac4670 100644 --- a/tools/hermes-parser/js/flow-api-translator/package.json +++ b/tools/hermes-parser/js/flow-api-translator/package.json @@ -1,6 +1,6 @@ { "name": "flow-api-translator", - "version": "0.23.0", + "version": "0.23.1", "description": "Toolkit for creating Flow and TypeScript compatible libraries from Flow source code.", "main": "dist/index.js", "license": "MIT", @@ -13,10 +13,10 @@ "@typescript-eslint/parser": "7.2.0", "@typescript-eslint/visitor-keys": "7.2.0", "flow-enums-runtime": "^0.0.6", - "hermes-eslint": "0.23.0", - "hermes-estree": "0.23.0", - "hermes-parser": "0.23.0", - "hermes-transform": "0.23.0", + "hermes-eslint": "0.23.1", + "hermes-estree": "0.23.1", + "hermes-parser": "0.23.1", + "hermes-transform": "0.23.1", "typescript": "5.3.2" }, "peerDependencies": { diff --git a/tools/hermes-parser/js/hermes-eslint/package.json b/tools/hermes-parser/js/hermes-eslint/package.json index 6cffa542c10..881fcc934b8 100644 --- a/tools/hermes-parser/js/hermes-eslint/package.json +++ b/tools/hermes-parser/js/hermes-eslint/package.json @@ -1,6 +1,6 @@ { "name": "hermes-eslint", - "version": "0.23.0", + "version": "0.23.1", "description": "A custom parser for ESLint using the Hermes parser", "main": "dist/index.js", "license": "MIT", @@ -16,7 +16,7 @@ ], "dependencies": { "esrecurse": "^4.3.0", - "hermes-estree": "0.23.0", - "hermes-parser": "0.23.0" + "hermes-estree": "0.23.1", + "hermes-parser": "0.23.1" } } diff --git a/tools/hermes-parser/js/hermes-estree/package.json b/tools/hermes-parser/js/hermes-estree/package.json index 2715fd1792c..88a2362f2c9 100644 --- a/tools/hermes-parser/js/hermes-estree/package.json +++ b/tools/hermes-parser/js/hermes-estree/package.json @@ -1,6 +1,6 @@ { "name": "hermes-estree", - "version": "0.23.0", + "version": "0.23.1", "description": "Flow types for the Flow-ESTree spec produced by the hermes parser", "main": "dist/index.js", "license": "MIT", diff --git a/tools/hermes-parser/js/hermes-parser/package.json b/tools/hermes-parser/js/hermes-parser/package.json index 7949b340fdf..c97d2667239 100644 --- a/tools/hermes-parser/js/hermes-parser/package.json +++ b/tools/hermes-parser/js/hermes-parser/package.json @@ -1,6 +1,6 @@ { "name": "hermes-parser", - "version": "0.23.0", + "version": "0.23.1", "description": "A JavaScript parser built from the Hermes engine", "main": "dist/index.js", "license": "MIT", @@ -9,7 +9,7 @@ "url": "git@github.com:facebook/hermes.git" }, "dependencies": { - "hermes-estree": "0.23.0" + "hermes-estree": "0.23.1" }, "devDependencies": { "@babel/parser": "7.7.4", diff --git a/tools/hermes-parser/js/hermes-transform/package.json b/tools/hermes-parser/js/hermes-transform/package.json index e1fb575ce26..2e6c42b4f1f 100644 --- a/tools/hermes-parser/js/hermes-transform/package.json +++ b/tools/hermes-parser/js/hermes-transform/package.json @@ -1,6 +1,6 @@ { "name": "hermes-transform", - "version": "0.23.0", + "version": "0.23.1", "description": "Tools built on top of Hermes-ESTree to enable codebase transformation", "main": "dist/index.js", "license": "MIT", @@ -12,14 +12,14 @@ "@babel/code-frame": "^7.16.0", "esquery": "^1.4.0", "flow-enums-runtime": "^0.0.6", - "hermes-eslint": "0.23.0", - "hermes-estree": "0.23.0", - "hermes-parser": "0.23.0", + "hermes-eslint": "0.23.1", + "hermes-estree": "0.23.1", + "hermes-parser": "0.23.1", "string-width": "4.2.3" }, "peerDependencies": { "prettier": "^3.0.0 || ^2.7.1", - "prettier-plugin-hermes-parser": "0.23.0" + "prettier-plugin-hermes-parser": "0.23.1" }, "files": [ "dist", diff --git a/tools/hermes-parser/js/package.json b/tools/hermes-parser/js/package.json index 07dbe491be7..19eb55e0a1b 100644 --- a/tools/hermes-parser/js/package.json +++ b/tools/hermes-parser/js/package.json @@ -17,7 +17,7 @@ "eslint-plugin-flowtype": "^8.0.3", "eslint-plugin-jest": "^25.2.4", "eslint-plugin-prettier": "^4.2.1", - "flow-bin": "^0.241.0", + "flow-bin": "^0.243.0", "glob": "^8.0.3", "jest": "^29.2.2", "jest-specific-snapshot": "^5.0.0", diff --git a/tools/hermes-parser/js/prettier-plugin-hermes-parser/package.json b/tools/hermes-parser/js/prettier-plugin-hermes-parser/package.json index 4a71c71b764..7ea8cd0eb1d 100644 --- a/tools/hermes-parser/js/prettier-plugin-hermes-parser/package.json +++ b/tools/hermes-parser/js/prettier-plugin-hermes-parser/package.json @@ -1,6 +1,6 @@ { "name": "prettier-plugin-hermes-parser", - "version": "0.23.0", + "version": "0.23.1", "description": "Hermes parser plugin for Prettier.", "main": "dist/index.js", "license": "MIT", @@ -9,9 +9,9 @@ "url": "git@github.com:facebook/hermes.git" }, "dependencies": { - "hermes-estree": "0.23.0", - "hermes-parser": "0.23.0", - "prettier-plugin-hermes-parser": "0.23.0" + "hermes-estree": "0.23.1", + "hermes-parser": "0.23.1", + "prettier-plugin-hermes-parser": "0.23.1" }, "peerDependencies": { "prettier": "^3.0.0 || ^2.7.1" diff --git a/tools/hermes-parser/js/yarn.lock b/tools/hermes-parser/js/yarn.lock index c4cb1786ef7..729892041e5 100644 --- a/tools/hermes-parser/js/yarn.lock +++ b/tools/hermes-parser/js/yarn.lock @@ -3003,10 +3003,10 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.2.tgz#64bfed5cb68fe3ca78b3eb214ad97b63bedce561" integrity sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA== -flow-bin@^0.241.0: - version "0.241.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.241.0.tgz#5feaa98f6c892b5869ec936b46d6ad6d91b664f9" - integrity sha512-R1WROxAuWCOF5gMVqVYbb3iUvqP2OQyaYLSrkUxZrLonvjUJeedGx7nv79tdkoB7eRja3kY+/lQ/nbPtkFsqOA== +flow-bin@^0.243.0: + version "0.243.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.243.0.tgz#f7d00b84bbcb16e23261031c15f955c76992970a" + integrity sha512-4OyCAkI26Bm8wGd1eNt+EBkHYAGB5PsGnykxLB0y7wK8wPitQi6pi3HsoNlk3yM6gyJsDqkRJrlkpnBB6WDgjQ== flow-enums-runtime@^0.0.6: version "0.0.6" diff --git a/tools/node-hermes/nodelib/wrappers/internal/console/constructor.js b/tools/node-hermes/nodelib/wrappers/internal/console/constructor.js index bd1a6b17dd1..a90a6aa71c3 100644 --- a/tools/node-hermes/nodelib/wrappers/internal/console/constructor.js +++ b/tools/node-hermes/nodelib/wrappers/internal/console/constructor.js @@ -145,7 +145,7 @@ function Console(options // We have to test new.target here to see if this function is called // with new, because we need to define a custom instanceof to accommodate // the global console. - if (!(this instanceof Console ? this.constructor : void 0)) { + if (new.target === undefined) { return ReflectConstruct(Console, arguments); } diff --git a/unsupported/hermes/crates/hermes_estree/src/lib.rs b/unsupported/hermes/crates/hermes_estree/src/lib.rs index fc3789bc9ae..1173a90ccb9 100644 --- a/unsupported/hermes/crates/hermes_estree/src/lib.rs +++ b/unsupported/hermes/crates/hermes_estree/src/lib.rs @@ -10,7 +10,6 @@ mod binding; mod generated_extensions; mod js_value; mod range; -mod visit; pub use binding::Binding; pub use binding::BindingId; @@ -19,7 +18,6 @@ pub use generated_extensions::*; pub use js_value::JsValue; pub use js_value::Number; pub use range::SourceRange; -pub use visit::*; #[cfg(test)] mod tests { diff --git a/unsupported/hermes/crates/hermes_estree/src/visit.rs b/unsupported/hermes/crates/hermes_estree/src/visit.rs deleted file mode 100644 index 9e6d0ab0ca8..00000000000 --- a/unsupported/hermes/crates/hermes_estree/src/visit.rs +++ /dev/null @@ -1,574 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use crate::AssignmentPropertyOrRestElement; -use crate::AssignmentTarget; -use crate::Class; -use crate::ClassItem; -use crate::ClassPrivateProperty; -use crate::ClassProperty; -use crate::Declaration; -use crate::DeclarationOrExpression; -use crate::ExportAllDeclaration; -use crate::ExportDefaultDeclaration; -use crate::ExportNamedDeclaration; -use crate::Expression; -use crate::ExpressionOrPrivateIdentifier; -use crate::ExpressionOrSpread; -use crate::ExpressionOrSuper; -use crate::ForInInit; -use crate::ForInit; -use crate::Function; -use crate::FunctionBody; -use crate::FunctionDeclaration; -use crate::Identifier; -use crate::ImportDeclaration; -use crate::ImportDeclarationSpecifier; -use crate::ImportOrExportDeclaration; -use crate::Literal; -use crate::MethodDefinition; -use crate::ModuleItem; -use crate::Pattern; -use crate::PrivateIdentifier; -use crate::PrivateName; -use crate::Program; -use crate::Statement; -use crate::StaticBlock; -use crate::Super; -use crate::SwitchCase; -use crate::VariableDeclarator; -use crate::_Literal; - -/// Trait for visiting an estree -#[allow(non_camel_case_types)] -#[deprecated] -pub trait Visitor_DEPRECATED<'ast> { - fn visit_lvalue(&mut self, f: F) - where - F: FnOnce(&mut Self), - { - f(self); - } - - fn visit_rvalue(&mut self, f: F) - where - F: FnOnce(&mut Self), - { - f(self); - } - - fn visit_program(&mut self, program: &'ast Program) { - self.default_visit_program(program) - } - - fn default_visit_program(&mut self, program: &'ast Program) { - for item in &program.body { - self.visit_module_item(item); - } - } - - fn visit_function(&mut self, function: &'ast Function) { - self.default_visit_function(function); - } - - fn default_visit_function(&mut self, function: &'ast Function) { - self.visit_lvalue(|visitor| { - for param in &function.params { - visitor.visit_pattern(param); - } - }); - match &function.body { - Some(FunctionBody::BlockStatement(body)) => { - for stmt in &body.body { - self.visit_statement(stmt) - } - } - Some(FunctionBody::Expression(body)) => self.visit_expression(body), - None => {} - } - } - - fn visit_module_item(&mut self, item: &'ast ModuleItem) { - match item { - ModuleItem::Statement(item) => self.visit_statement(item), - ModuleItem::ImportOrExportDeclaration(item) => { - self.visit_import_or_export_declaration(item) - } - } - } - - fn visit_import_or_export_declaration(&mut self, declaration: &'ast ImportOrExportDeclaration) { - match declaration { - ImportOrExportDeclaration::ImportDeclaration(declaration) => { - self.visit_import_declaration(declaration); - } - ImportOrExportDeclaration::ExportAllDeclaration(declaration) => { - self.visit_export_all_declaration(declaration); - } - ImportOrExportDeclaration::ExportDefaultDeclaration(declaration) => { - self.visit_export_default_declaration(declaration); - } - ImportOrExportDeclaration::ExportNamedDeclaration(declaration) => { - self.visit_export_named_declaration(declaration); - } - } - } - - fn visit_import_declaration(&mut self, declaration: &'ast ImportDeclaration) { - self.visit_lvalue(|visitor| { - for specifier in &declaration.specifiers { - visitor.visit_import_declaration_specifier(specifier); - } - }); - self.visit_import_source(&declaration.source); - } - - fn visit_export_all_declaration(&mut self, declaration: &'ast ExportAllDeclaration) { - self.visit_export_source(&declaration.source); - } - - fn visit_export_default_declaration(&mut self, declaration: &'ast ExportDefaultDeclaration) { - match &declaration.declaration { - DeclarationOrExpression::Declaration(declaration) => { - self.visit_declaration(declaration) - } - DeclarationOrExpression::Expression(declaration) => self.visit_expression(declaration), - } - } - - fn visit_export_named_declaration(&mut self, declaration: &'ast ExportNamedDeclaration) { - if let Some(declaration) = &declaration.declaration { - self.visit_declaration(declaration) - } - if let Some(source) = &declaration.source { - self.visit_export_source(source); - } - } - - fn visit_import_declaration_specifier(&mut self, specifier: &'ast ImportDeclarationSpecifier) { - match specifier { - ImportDeclarationSpecifier::ImportSpecifier(specifier) => { - self.visit_identifier(&specifier.local); - } - ImportDeclarationSpecifier::ImportDefaultSpecifier(specifier) => { - self.visit_identifier(&specifier.local); - } - ImportDeclarationSpecifier::ImportNamespaceSpecifier(specifier) => { - self.visit_identifier(&specifier.local); - } - } - } - - fn visit_declaration(&mut self, declaration: &'ast Declaration) { - self.default_visit_declaration(declaration); - } - - fn default_visit_declaration(&mut self, declaration: &'ast Declaration) { - match declaration { - Declaration::ClassDeclaration(declaration) => { - self.visit_class(&declaration.class); - } - Declaration::FunctionDeclaration(declaration) => { - self.visit_function_declaration(declaration); - } - Declaration::VariableDeclaration(declaration) => { - for declarator in &declaration.declarations { - self.visit_variable_declarator(declarator) - } - } - Declaration::TSTypeAliasDeclaration(_declaration) => { - todo!("visit TSTypeAliasDeclaration") - } - Declaration::TypeAlias(_) => { - todo!("visit TypeAlias") - } - Declaration::OpaqueType(_) => { - todo!("visit OpaqueType") - } - } - } - - fn visit_function_declaration(&mut self, declaration: &'ast FunctionDeclaration) { - self.visit_function(&declaration.function); - } - - fn visit_statement(&mut self, stmt: &'ast Statement) { - self.default_visit_statement(stmt); - } - - fn default_visit_statement(&mut self, stmt: &'ast Statement) { - match stmt { - Statement::BlockStatement(stmt) => { - for stmt in &stmt.body { - self.visit_statement(stmt) - } - } - Statement::BreakStatement(_stmt) => { - // todo - } - Statement::ContinueStatement(_stmt) => { - // todo - } - Statement::DebuggerStatement(_stmt) => { - // todo - } - Statement::ClassDeclaration(stmt) => { - self.visit_class(&stmt.class); - } - Statement::DoWhileStatement(stmt) => { - self.visit_statement(&stmt.body); - self.visit_expression(&stmt.test); - } - Statement::EmptyStatement(_stmt) => { - // nothing to do - } - Statement::ExpressionStatement(stmt) => { - self.visit_expression(&stmt.expression); - } - Statement::ForInStatement(stmt) => { - self.visit_for_in_init(&stmt.left); - self.visit_expression(&stmt.right); - self.visit_statement(&stmt.body); - } - Statement::ForOfStatement(stmt) => { - self.visit_for_in_init(&stmt.left); - self.visit_expression(&stmt.right); - self.visit_statement(&stmt.body); - } - Statement::ForStatement(stmt) => { - if let Some(init) = &stmt.init { - self.visit_for_init(init); - } - if let Some(test) = &stmt.test { - self.visit_expression(test); - } - if let Some(update) = &stmt.update { - self.visit_expression(update); - } - self.visit_statement(&stmt.body); - } - Statement::FunctionDeclaration(stmt) => { - self.visit_function_declaration(stmt); - } - Statement::IfStatement(stmt) => { - self.visit_expression(&stmt.test); - self.visit_statement(&stmt.consequent); - if let Some(alternate) = &stmt.alternate { - self.visit_statement(alternate); - } - } - Statement::LabeledStatement(stmt) => { - self.visit_statement(&stmt.body); - } - Statement::ReturnStatement(stmt) => { - if let Some(argument) = &stmt.argument { - self.visit_expression(argument); - } - } - Statement::SwitchStatement(stmt) => { - self.visit_expression(&stmt.discriminant); - for case_ in &stmt.cases { - self.visit_case(case_); - } - } - Statement::ThrowStatement(stmt) => { - self.visit_expression(&stmt.argument); - } - Statement::TryStatement(stmt) => { - for item in &stmt.block.body { - self.visit_statement(item); - } - if let Some(handler) = &stmt.handler { - if let Some(param) = &handler.param { - self.visit_lvalue(|visitor| visitor.visit_pattern(param)); - } - for item in &handler.body.body { - self.visit_statement(item); - } - } - if let Some(finalizer) = &stmt.finalizer { - for item in &finalizer.body { - self.visit_statement(item); - } - } - } - Statement::VariableDeclaration(stmt) => { - for decl in &stmt.declarations { - self.visit_variable_declarator(decl); - } - } - Statement::WhileStatement(stmt) => { - self.visit_expression(&stmt.test); - self.visit_statement(&stmt.body); - } - Statement::WithStatement(stmt) => { - self.visit_expression(&stmt.object); - self.visit_statement(&stmt.body); - } - Statement::TSTypeAliasDeclaration(_stmt) => { - todo!("visit TSTypeAliasDeclaration") - } - Statement::TypeAlias(_) => { - todo!("visit TypeAlias") - } - } - } - - fn visit_class(&mut self, class: &'ast Class) { - if let Some(id) = &class.id { - self.visit_identifier(id) - } - if let Some(super_class) = &class.super_class { - self.visit_expression(super_class); - } - for item in &class.body.body { - match item { - ClassItem::MethodDefinition(item) => self.visit_method_definition(item), - ClassItem::ClassProperty(item) => { - self.visit_class_property(item); - } - ClassItem::ClassPrivateProperty(item) => { - self.visit_class_private_property(item); - } - ClassItem::StaticBlock(item) => { - self.visit_static_block(item); - } - } - } - } - - fn visit_class_property(&mut self, property: &'ast ClassProperty) { - self.visit_expression(&property.key); - if let Some(value) = &property.value { - self.visit_expression(value) - } - } - - fn visit_class_private_property(&mut self, property: &'ast ClassPrivateProperty) { - match &property.key { - ExpressionOrPrivateIdentifier::Expression(key) => self.visit_expression(key), - ExpressionOrPrivateIdentifier::PrivateIdentifier(key) => { - self.visit_private_identifier(key) - } - ExpressionOrPrivateIdentifier::PrivateName(key) => self.visit_private_name(key), - } - if let Some(value) = &property.value { - self.visit_expression(value) - } - } - - fn visit_static_block(&mut self, property: &'ast StaticBlock) { - for stmt in &property.body { - self.visit_statement(stmt) - } - } - - fn visit_method_definition(&mut self, method: &'ast MethodDefinition) { - self.default_visit_method_definition(method); - } - - fn default_visit_method_definition(&mut self, method: &'ast MethodDefinition) { - self.visit_expression(&method.key); - self.visit_function(&method.value.function); - } - - fn visit_case(&mut self, case_: &'ast SwitchCase) { - if let Some(test) = &case_.test { - self.visit_expression(test); - } - for stmt in &case_.consequent { - self.visit_statement(stmt) - } - } - - fn visit_for_init(&mut self, init: &'ast ForInit) { - match init { - ForInit::Expression(init) => { - self.visit_expression(init); - } - ForInit::VariableDeclaration(init) => { - for decl in &init.declarations { - self.visit_variable_declarator(decl); - } - } - } - } - - fn visit_for_in_init(&mut self, init: &'ast ForInInit) { - match init { - ForInInit::Pattern(init) => { - self.visit_pattern(init); - } - ForInInit::VariableDeclaration(init) => { - for decl in &init.declarations { - self.visit_variable_declarator(decl); - } - } - } - } - - fn visit_pattern(&mut self, pattern: &'ast Pattern) { - match pattern { - Pattern::Identifier(pattern) => self.visit_identifier(pattern), - Pattern::ArrayPattern(pattern) => { - for element in &pattern.elements { - if let Some(element) = element { - self.visit_pattern(element); - } - } - } - Pattern::ObjectPattern(pattern) => { - for property in &pattern.properties { - match property { - AssignmentPropertyOrRestElement::AssignmentProperty(property) => { - self.visit_pattern(&property.value); - } - AssignmentPropertyOrRestElement::RestElement(property) => { - self.visit_pattern(&property.argument); - } - } - } - } - Pattern::RestElement(pattern) => self.visit_pattern(&pattern.argument), - Pattern::AssignmentPattern(pattern) => { - self.visit_pattern(&pattern.left); - self.visit_rvalue(|visitor| { - visitor.visit_expression(&pattern.right); - }); - } - } - } - - fn visit_variable_declarator(&mut self, decl: &'ast VariableDeclarator) { - self.visit_lvalue(|visitor| { - visitor.visit_pattern(&decl.id); - }); - if let Some(init) = &decl.init { - self.visit_expression(init); - } - } - - fn visit_assignment_target(&mut self, target: &'ast AssignmentTarget) { - match target { - AssignmentTarget::Expression(target) => { - self.visit_expression(target); - } - AssignmentTarget::Pattern(target) => self.visit_pattern(target), - } - } - - fn visit_expression(&mut self, expr: &'ast Expression) { - self.default_visit_expression(expr); - } - - fn default_visit_expression(&mut self, expr: &'ast Expression) { - match expr { - Expression::ArrayExpression(expr) => { - for item in &expr.elements { - match item { - Some(ExpressionOrSpread::SpreadElement(item)) => { - self.visit_expression(&item.argument) - } - Some(ExpressionOrSpread::Expression(item)) => self.visit_expression(item), - _ => {} - } - } - } - Expression::AssignmentExpression(expr) => { - self.visit_lvalue(|visitor| visitor.visit_assignment_target(&expr.left)); - self.visit_expression(&expr.right); - } - Expression::BinaryExpression(expr) => { - self.visit_expression(&expr.left); - self.visit_expression(&expr.right); - } - Expression::Identifier(expr) => { - self.visit_identifier(expr); - } - Expression::Literal(expr) => self.visit_literal(expr), - Expression::FunctionExpression(expr) => self.visit_function(&expr.function), - Expression::ArrowFunctionExpression(expr) => self.visit_function(&expr.function), - Expression::MemberExpression(expr) => { - match &expr.object { - ExpressionOrSuper::Super(object) => self.visit_super(object), - ExpressionOrSuper::Expression(object) => self.visit_expression(object), - }; - if !expr.is_computed { - match &expr.property { - ExpressionOrPrivateIdentifier::Expression(property) => { - self.visit_expression(property) - } - ExpressionOrPrivateIdentifier::PrivateIdentifier(property) => { - self.visit_private_identifier(property); - } - ExpressionOrPrivateIdentifier::PrivateName(property) => { - self.visit_private_name(property); - } - } - } - } - Expression::CallExpression(expr) => { - match &expr.callee { - ExpressionOrSuper::Expression(callee) => self.visit_expression(callee), - ExpressionOrSuper::Super(callee) => self.visit_super(callee), - } - for arg in &expr.arguments { - match arg { - ExpressionOrSpread::Expression(arg) => self.visit_expression(arg), - ExpressionOrSpread::SpreadElement(arg) => { - self.visit_expression(&arg.argument) - } - } - } - } - Expression::UpdateExpression(expr) => { - self.visit_expression(&expr.argument); - } - Expression::BooleanLiteral(_) - | Expression::NullLiteral(_) - | Expression::StringLiteral(_) - | Expression::NumericLiteral(_) => { - // no-op - } - _ => { - todo!("{:#?}", expr) - } - } - } - - fn visit_super(&mut self, _super: &'ast Super) { - todo!("Implement visit_super") - } - - fn visit_private_identifier(&mut self, _identifier: &'ast PrivateIdentifier) { - todo!("Implement visit_private_identifier()") - } - - fn visit_private_name(&mut self, _identifier: &'ast PrivateName) { - todo!("Implement visit_private_name()") - } - - fn visit_identifier(&mut self, _identifier: &'ast Identifier) { - todo!("Implement visit_identifier()") - } - - fn visit_import_source(&mut self, literal: &'ast _Literal) { - self.visit_any_literal(literal); - } - - fn visit_export_source(&mut self, literal: &'ast _Literal) { - self.visit_any_literal(literal); - } - - fn visit_any_literal(&mut self, _literal: &'ast _Literal) { - todo!("Implement visit_any_literal()") - } - - fn visit_literal(&mut self, _literal: &'ast Literal) { - todo!("Implement visit_literal()") - } -} diff --git a/unsupported/hermes/crates/hermes_estree_codegen/src/ecmascript.json b/unsupported/hermes/crates/hermes_estree_codegen/src/ecmascript.json index ab441cd2672..c76d980f2bb 100644 --- a/unsupported/hermes/crates/hermes_estree_codegen/src/ecmascript.json +++ b/unsupported/hermes/crates/hermes_estree_codegen/src/ecmascript.json @@ -383,6 +383,21 @@ } } }, + "ComponentDeclaration": { + "fields": { + "id": { + "type": "Identifier" + }, + "body":{ + "type": "BlockStatement" + }, + "type_parameters": { + "type": "Option", + "optional": true, + "rename": "typeParameters" + } + } + }, "ClassDeclaration": { "skip_hermes_codegen": true, "fields": { @@ -1544,7 +1559,8 @@ ], "ModuleItem": [ "ImportOrExportDeclaration", - "Statement" + "Statement", + "ComponentDeclaration" ], "ImportOrExportDeclaration": [ "ImportDeclaration", diff --git a/unsupported/hermes/crates/hermes_parser/tests/fixtures/component-syntax.js b/unsupported/hermes/crates/hermes_parser/tests/fixtures/component-syntax.js new file mode 100644 index 00000000000..a4bc64371fa --- /dev/null +++ b/unsupported/hermes/crates/hermes_parser/tests/fixtures/component-syntax.js @@ -0,0 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +component Field(user: User) { + return null; +} diff --git a/utils/testsuite/testsuite_skiplist.py b/utils/testsuite/testsuite_skiplist.py index d0a520d389e..7edb49e1ca4 100644 --- a/utils/testsuite/testsuite_skiplist.py +++ b/utils/testsuite/testsuite_skiplist.py @@ -1287,6 +1287,8 @@ "mjsunit/regress/regress-prepare-break-while-recompile.js", # Fails when ASAN/UBSAN are limiting the max native stack depth. "mjsunit/compiler/regress-lazy-deopt.js", + # Error stack getter is on Error.prototype in Hermes. + "mjsunit/regress/regress-3404.js", # Uncategorized mjsunit failures "mjsunit/accessor-map-sharing.js", "mjsunit/accessors-on-global-object.js",