Bug 1551916 - Make JS_COLUMN_DIMENSION_IS_CODE_POINTS a no-argument macro function so that calling it before its definition is an error, and move it upward in TokenStream.h so it's defined in places where subsequent changes will need it. r=arai
authorJeff Walden <jwalden@mit.edu>
Fri, 17 May 2019 03:21:02 +0000
changeset 533103 04cce27de4ac16500981c23558b355cfe4ddc186
parent 533102 c5180b76c35305e08385c338101b6f7e18ae1641
child 533104 70c4b663298ae5c4b287d020cc0842625fe6f52c
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1551916
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551916 - Make JS_COLUMN_DIMENSION_IS_CODE_POINTS a no-argument macro function so that calling it before its definition is an error, and move it upward in TokenStream.h so it's defined in places where subsequent changes will need it. r=arai Differential Revision: https://phabricator.services.mozilla.com/D31301
js/src/frontend/TokenStream.cpp
js/src/frontend/TokenStream.h
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -686,21 +686,21 @@ inline void SourceUnits<Utf8Unit>::asser
     MOZ_ASSERT(expectedUnits[i] == ptr[i].toUint8());
   }
 }
 
 #endif  // DEBUG
 
 template <typename Unit>
 static size_t ComputeColumn(const Unit* begin, const Unit* end) {
-#if JS_COLUMN_DIMENSION_IS_CODE_POINTS
+#if JS_COLUMN_DIMENSION_IS_CODE_POINTS()
   return unicode::CountCodePoints(begin, end);
 #else
   return PointerRangeSize(begin, end);
-#endif
+#endif  // JS_COLUMN_DIMENSION_IS_CODE_POINTS()
 }
 
 template <typename Unit, class AnyCharsAccess>
 uint32_t GeneralTokenStreamChars<Unit, AnyCharsAccess>::computeColumn(
     LineToken lineToken, uint32_t offset) const {
   lineToken.assertConsistentOffset(offset);
 
   const TokenStreamAnyChars& anyChars = anyCharsAccess();
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -313,16 +313,22 @@ class MOZ_STACK_CLASS TokenStreamPositio
   unsigned lineno;
   size_t linebase;
   size_t prevLinebase;
   Token currentToken;
   unsigned lookahead;
   Token lookaheadTokens[TokenStreamShared::maxLookahead];
 } JS_HAZ_ROOTED;
 
+// Column numbers *ought* be in terms of counts of code points, but in the past
+// we counted code units.  Set this to 0 to keep returning counts of code units
+// (even for UTF-8, which is clearly wrong, but we don't ship UTF-8 yet so this
+// is fine until we can fix users that depend on code-unit counting).
+#define JS_COLUMN_DIMENSION_IS_CODE_POINTS() 0
+
 class TokenStreamAnyChars : public TokenStreamShared {
  public:
   TokenStreamAnyChars(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
                       StrictModeGetter* smg);
 
   template <typename Unit, class AnyCharsAccess>
   friend class GeneralTokenStreamChars;
   template <typename Unit, class AnyCharsAccess>
@@ -1600,22 +1606,16 @@ class TokenStart {
   TokenStart(const SourceUnits& sourceUnits, ptrdiff_t adjust)
       : startOffset_(sourceUnits.offset() + adjust) {}
 
   TokenStart(const TokenStart&) = default;
 
   uint32_t offset() const { return startOffset_; }
 };
 
-// Column numbers *ought* be in terms of counts of code points, but in the past
-// we counted code units.  Set this to 0 to keep returning counts of code units
-// (even for UTF-8, which is clearly wrong, but we don't ship UTF-8 yet so this
-// is fine until we can fix users that depend on code-unit counting).
-#define JS_COLUMN_DIMENSION_IS_CODE_POINTS 0
-
 template <typename Unit, class AnyCharsAccess>
 class GeneralTokenStreamChars : public SpecializedTokenStreamCharsBase<Unit> {
   using CharsBase = TokenStreamCharsBase<Unit>;
   using SpecializedCharsBase = SpecializedTokenStreamCharsBase<Unit>;
 
   using LineToken = TokenStreamAnyChars::LineToken;
 
  private: