Bug 1453884 - Rename LazyScript.{begin,end} to LazyScript.{sourceStart,sourceEnd}. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Tue, 17 Apr 2018 12:37:10 +0200
changeset 414090 038b4d1d073af308be6aa92c2fa2c2e594ea2222
parent 414089 71b23fab4c0b8a450cf906a725f55171c0e81638
child 414091 a074dcfa9edbbe9d00ad0e5d9df3c48bfb7be84a
push id33858
push userncsoregi@mozilla.com
push dateTue, 17 Apr 2018 21:55:44 +0000
treeherdermozilla-central@d6eb5597d744 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1453884
milestone61.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 1453884 - Rename LazyScript.{begin,end} to LazyScript.{sourceStart,sourceEnd}. r=Yoric
js/src/frontend/BytecodeCompiler.cpp
js/src/frontend/Parser.cpp
js/src/vm/JSFunction.cpp
js/src/vm/JSScript.cpp
js/src/vm/JSScript.h
js/src/vm/ObjectGroup.cpp
js/src/vm/Xdr.cpp
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -631,17 +631,17 @@ bool
 frontend::CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const char16_t* chars, size_t length)
 {
     MOZ_ASSERT(cx->compartment() == lazy->functionNonDelazifying()->compartment());
 
     CompileOptions options(cx);
     options.setMutedErrors(lazy->mutedErrors())
            .setFileAndLine(lazy->filename(), lazy->lineno())
            .setColumn(lazy->column())
-           .setScriptSourceOffset(lazy->begin())
+           .setScriptSourceOffset(lazy->sourceStart())
            .setNoScriptRval(false)
            .setSelfHostingMode(false);
 
     // Update statistics to find out if we are delazifying just after having
     // lazified. Note that we are interested in the delta between end of
     // syntax parsing and start of full parsing, so we do this now rather than
     // after parsing below.
     if (!lazy->scriptSource()->parseEnded().IsNull()) {
@@ -673,17 +673,17 @@ frontend::CompileLazyFunction(JSContext*
                                                   lazy->asyncKind());
     if (!pn)
         return false;
 
     RootedScriptSource sourceObject(cx, lazy->sourceObject());
     MOZ_ASSERT(sourceObject);
 
     Rooted<JSScript*> script(cx, JSScript::Create(cx, options, sourceObject,
-                                                  lazy->begin(), lazy->end(),
+                                                  lazy->sourceStart(), lazy->sourceEnd(),
                                                   lazy->toStringStart(), lazy->toStringEnd()));
     if (!script)
         return false;
 
     if (lazy->isLikelyConstructorWrapper())
         script->setLikelyConstructorWrapper();
     if (lazy->hasBeenCloned())
         script->setHasBeenCloned();
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -3251,17 +3251,17 @@ Parser<FullParseHandler, CharT>::skipLaz
         return false;
 
     LazyScript* lazy = fun->lazyScript();
     if (lazy->needsHomeObject())
         funbox->setNeedsHomeObject();
 
     PropagateTransitiveParseFlags(lazy, pc->sc());
 
-    if (!tokenStream.advance(fun->lazyScript()->end()))
+    if (!tokenStream.advance(fun->lazyScript()->sourceEnd()))
         return false;
 
     // Append possible Annex B function box only upon successfully parsing.
     if (tryAnnexB && !pc->innermostScope()->addPossibleAnnexBFunctionBox(pc, funbox))
         return false;
 
     return true;
 }
--- a/js/src/vm/JSFunction.cpp
+++ b/js/src/vm/JSFunction.cpp
@@ -1611,20 +1611,20 @@ JSFunction::createScriptForLazilyInterpr
 
             fun->setUnlazifiedScript(script);
             return true;
         }
 
         MOZ_ASSERT(lazy->scriptSource()->hasSourceData());
 
         // Parse and compile the script from source.
-        size_t lazyLength = lazy->end() - lazy->begin();
+        size_t lazyLength = lazy->sourceEnd() - lazy->sourceStart();
         UncompressedSourceCache::AutoHoldEntry holder;
         ScriptSource::PinnedChars chars(cx, lazy->scriptSource(), holder,
-                                        lazy->begin(), lazyLength);
+                                        lazy->sourceStart(), lazyLength);
         if (!chars.get())
             return false;
 
         if (!frontend::CompileLazyFunction(cx, lazy, chars.get(), lazyLength)) {
             // The frontend may have linked the function and the non-lazy
             // script together during bytecode compilation. Reset it now on
             // error.
             fun->initLazyScript(lazy);
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -239,43 +239,44 @@ XDRRelazificationInfo(XDRState<mode>* xd
 {
     MOZ_ASSERT_IF(mode == XDR_ENCODE, script->isRelazifiable() && script->maybeLazyScript());
     MOZ_ASSERT_IF(mode == XDR_ENCODE, !lazy->numInnerFunctions());
 
     JSContext* cx = xdr->cx();
 
     uint64_t packedFields;
     {
-        uint32_t begin = script->sourceStart();
-        uint32_t end = script->sourceEnd();
+        uint32_t sourceStart = script->sourceStart();
+        uint32_t sourceEnd = script->sourceEnd();
         uint32_t toStringStart = script->toStringStart();
         uint32_t toStringEnd = script->toStringEnd();
         uint32_t lineno = script->lineno();
         uint32_t column = script->column();
 
         if (mode == XDR_ENCODE) {
             packedFields = lazy->packedFields();
-            MOZ_ASSERT(begin == lazy->begin());
-            MOZ_ASSERT(end == lazy->end());
+            MOZ_ASSERT(sourceStart == lazy->sourceStart());
+            MOZ_ASSERT(sourceEnd == lazy->sourceEnd());
             MOZ_ASSERT(toStringStart == lazy->toStringStart());
             MOZ_ASSERT(toStringEnd == lazy->toStringEnd());
             MOZ_ASSERT(lineno == lazy->lineno());
             MOZ_ASSERT(column == lazy->column());
             // We can assert we have no inner functions because we don't
             // relazify scripts with inner functions.  See
             // JSFunction::createScriptForLazilyInterpretedFunction.
             MOZ_ASSERT(lazy->numInnerFunctions() == 0);
         }
 
         MOZ_TRY(xdr->codeUint64(&packedFields));
 
         if (mode == XDR_DECODE) {
             RootedScriptSource sourceObject(cx, &script->scriptSourceUnwrap());
             lazy.set(LazyScript::Create(cx, fun, script, enclosingScope, sourceObject,
-                                        packedFields, begin, end, toStringStart, lineno, column));
+                                        packedFields, sourceStart, sourceEnd, toStringStart,
+                                        lineno, column));
             if (!lazy)
                 return xdr->fail(JS::TranscodeResult_Throw);
 
             lazy->setToStringEnd(toStringEnd);
 
             // As opposed to XDRLazyScript, we need to restore the runtime bits
             // of the script, as we are trying to match the fact this function
             // has already been parsed and that it would need to be re-lazified.
@@ -906,51 +907,52 @@ template<XDRMode mode>
 XDRResult
 js::XDRLazyScript(XDRState<mode>* xdr, HandleScope enclosingScope,
                   HandleScriptSource sourceObject, HandleFunction fun,
                   MutableHandle<LazyScript*> lazy)
 {
     JSContext* cx = xdr->cx();
 
     {
-        uint32_t begin;
-        uint32_t end;
+        uint32_t sourceStart;
+        uint32_t sourceEnd;
         uint32_t toStringStart;
         uint32_t toStringEnd;
         uint32_t lineno;
         uint32_t column;
         uint64_t packedFields;
 
         if (mode == XDR_ENCODE) {
             // Note: it's possible the LazyScript has a non-null script_ pointer
             // to a JSScript. We don't encode it: we can just delazify the
             // lazy script.
 
             MOZ_ASSERT(fun == lazy->functionNonDelazifying());
 
-            begin = lazy->begin();
-            end = lazy->end();
+            sourceStart = lazy->sourceStart();
+            sourceEnd = lazy->sourceEnd();
             toStringStart = lazy->toStringStart();
             toStringEnd = lazy->toStringEnd();
             lineno = lazy->lineno();
             column = lazy->column();
             packedFields = lazy->packedFields();
         }
 
-        MOZ_TRY(xdr->codeUint32(&begin));
-        MOZ_TRY(xdr->codeUint32(&end));
+        MOZ_TRY(xdr->codeUint32(&sourceStart));
+        MOZ_TRY(xdr->codeUint32(&sourceEnd));
         MOZ_TRY(xdr->codeUint32(&toStringStart));
         MOZ_TRY(xdr->codeUint32(&toStringEnd));
         MOZ_TRY(xdr->codeUint32(&lineno));
         MOZ_TRY(xdr->codeUint32(&column));
         MOZ_TRY(xdr->codeUint64(&packedFields));
 
         if (mode == XDR_DECODE) {
             lazy.set(LazyScript::Create(cx, fun, nullptr, enclosingScope, sourceObject,
-                                        packedFields, begin, end, toStringStart, lineno, column));
+                                        packedFields, sourceStart, sourceEnd, toStringStart,
+                                        lineno, column));
             if (!lazy)
                 return xdr->fail(JS::TranscodeResult_Throw);
             lazy->setToStringEnd(toStringEnd);
             fun->initLazyScript(lazy);
         }
     }
 
     // Code closed-over bindings.
@@ -4168,33 +4170,33 @@ JSScript::formalIsAliased(unsigned argSl
 
 bool
 JSScript::formalLivesInArgumentsObject(unsigned argSlot)
 {
     return argsObjAliasesFormals() && !formalIsAliased(argSlot);
 }
 
 LazyScript::LazyScript(JSFunction* fun, void* table, uint64_t packedFields,
-                       uint32_t begin, uint32_t end,
+                       uint32_t sourceStart, uint32_t sourceEnd,
                        uint32_t toStringStart, uint32_t lineno, uint32_t column)
   : script_(nullptr),
     function_(fun),
     enclosingScope_(nullptr),
     sourceObject_(nullptr),
     table_(table),
     packedFields_(packedFields),
-    begin_(begin),
-    end_(end),
+    sourceStart_(sourceStart),
+    sourceEnd_(sourceEnd),
     toStringStart_(toStringStart),
-    toStringEnd_(end),
+    toStringEnd_(sourceEnd),
     lineno_(lineno),
     column_(column)
 {
-    MOZ_ASSERT(begin <= end);
-    MOZ_ASSERT(toStringStart <= begin);
+    MOZ_ASSERT(sourceStart <= sourceEnd);
+    MOZ_ASSERT(toStringStart <= sourceStart);
 }
 
 void
 LazyScript::initScript(JSScript* script)
 {
     MOZ_ASSERT(script);
     MOZ_ASSERT(!script_.unbarrieredGet());
     script_.set(script);
@@ -4230,17 +4232,17 @@ ScriptSource*
 LazyScript::maybeForwardedScriptSource() const
 {
     JSObject* source = MaybeForwarded(sourceObject());
     return UncheckedUnwrapWithoutExpose(source)->as<ScriptSourceObject>().source();
 }
 
 /* static */ LazyScript*
 LazyScript::CreateRaw(JSContext* cx, HandleFunction fun,
-                      uint64_t packedFields, uint32_t begin, uint32_t end,
+                      uint64_t packedFields, uint32_t sourceStart, uint32_t sourceEnd,
                       uint32_t toStringStart, uint32_t lineno, uint32_t column)
 {
     union {
         PackedView p;
         uint64_t packed;
     };
 
     packed = packedFields;
@@ -4259,25 +4261,25 @@ LazyScript::CreateRaw(JSContext* cx, Han
     }
 
     LazyScript* res = Allocate<LazyScript>(cx);
     if (!res)
         return nullptr;
 
     cx->compartment()->scheduleDelazificationForDebugger();
 
-    return new (res) LazyScript(fun, table.forget(), packed, begin, end,
+    return new (res) LazyScript(fun, table.forget(), packed, sourceStart, sourceEnd,
                                 toStringStart, lineno, column);
 }
 
 /* static */ LazyScript*
 LazyScript::Create(JSContext* cx, HandleFunction fun,
                    const frontend::AtomVector& closedOverBindings,
                    Handle<GCVector<JSFunction*, 8>> innerFunctions,
-                   uint32_t begin, uint32_t end,
+                   uint32_t sourceStart, uint32_t sourceEnd,
                    uint32_t toStringStart, uint32_t lineno, uint32_t column)
 {
     union {
         PackedView p;
         uint64_t packedFields;
     };
 
     p.shouldDeclareArguments = false;
@@ -4290,18 +4292,18 @@ LazyScript::Create(JSContext* cx, Handle
     p.strict = false;
     p.bindingsAccessedDynamically = false;
     p.hasDebuggerStatement = false;
     p.hasDirectEval = false;
     p.isLikelyConstructorWrapper = false;
     p.isDerivedClassConstructor = false;
     p.needsHomeObject = false;
 
-    LazyScript* res = LazyScript::CreateRaw(cx, fun, packedFields, begin, end, toStringStart,
-                                            lineno, column);
+    LazyScript* res = LazyScript::CreateRaw(cx, fun, packedFields, sourceStart, sourceEnd,
+                                            toStringStart, lineno, column);
     if (!res)
         return nullptr;
 
     JSAtom** resClosedOverBindings = res->closedOverBindings();
     for (size_t i = 0; i < res->numClosedOverBindings(); i++)
         resClosedOverBindings[i] = closedOverBindings[i];
 
     GCPtrFunction* resInnerFunctions = res->innerFunctions();
@@ -4310,28 +4312,28 @@ LazyScript::Create(JSContext* cx, Handle
 
     return res;
 }
 
 /* static */ LazyScript*
 LazyScript::Create(JSContext* cx, HandleFunction fun,
                    HandleScript script, HandleScope enclosingScope,
                    HandleScriptSource sourceObject,
-                   uint64_t packedFields, uint32_t begin, uint32_t end,
+                   uint64_t packedFields, uint32_t sourceStart, uint32_t sourceEnd,
                    uint32_t toStringStart, uint32_t lineno, uint32_t column)
 {
     // Dummy atom which is not a valid property name.
     RootedAtom dummyAtom(cx, cx->names().comma);
 
     // Dummy function which is not a valid function as this is the one which is
     // holding this lazy script.
     HandleFunction dummyFun = fun;
 
-    LazyScript* res = LazyScript::CreateRaw(cx, fun, packedFields, begin, end, toStringStart,
-                                            lineno, column);
+    LazyScript* res = LazyScript::CreateRaw(cx, fun, packedFields, sourceStart, sourceEnd,
+                                            toStringStart, lineno, column);
     if (!res)
         return nullptr;
 
     // Fill with dummies, to be GC-safe after the initialization of the free
     // variables and inner functions.
     size_t i, num;
     JSAtom** closedOverBindings = res->closedOverBindings();
     for (i = 0, num = res->numClosedOverBindings(); i < num; i++)
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -2140,18 +2140,18 @@ class LazyScript : public gc::TenuredCel
 
     union {
         PackedView p_;
         uint64_t packedFields_;
     };
 
     // Source location for the script.
     // See the comment in JSScript for the details
-    uint32_t begin_;
-    uint32_t end_;
+    uint32_t sourceStart_;
+    uint32_t sourceEnd_;
     uint32_t toStringStart_;
     uint32_t toStringEnd_;
     // Line and column of |begin_| position, that is the position where we
     // start parsing.
     uint32_t lineno_;
     uint32_t column_;
 
     LazyScript(JSFunction* fun, void* table, uint64_t packedFields,
@@ -2347,38 +2347,38 @@ class LazyScript : public gc::TenuredCel
     }
     void setHasThisBinding() {
         p_.hasThisBinding = true;
     }
 
     const char* filename() const {
         return scriptSource()->filename();
     }
-    uint32_t begin() const {
-        return begin_;
+    uint32_t sourceStart() const {
+        return sourceStart_;
     }
-    uint32_t end() const {
-        return end_;
+    uint32_t sourceEnd() const {
+        return sourceEnd_;
     }
     uint32_t toStringStart() const {
         return toStringStart_;
     }
     uint32_t toStringEnd() const {
         return toStringEnd_;
     }
     uint32_t lineno() const {
         return lineno_;
     }
     uint32_t column() const {
         return column_;
     }
 
     void setToStringEnd(uint32_t toStringEnd) {
         MOZ_ASSERT(toStringStart_ <= toStringEnd);
-        MOZ_ASSERT(toStringEnd_ >= end_);
+        MOZ_ASSERT(toStringEnd_ >= sourceEnd_);
         toStringEnd_ = toStringEnd;
     }
 
     bool hasUncompiledEnclosingScript() const;
 
     friend class GCMarker;
     void traceChildren(JSTracer* trc);
     void finalize(js::FreeOp* fop);
--- a/js/src/vm/ObjectGroup.cpp
+++ b/js/src/vm/ObjectGroup.cpp
@@ -155,18 +155,18 @@ ObjectGroup::useSingletonForClone(JSFunc
     if (fun->hasScript()) {
         if (!fun->nonLazyScript()->isLikelyConstructorWrapper())
             return false;
         begin = fun->nonLazyScript()->sourceStart();
         end = fun->nonLazyScript()->sourceEnd();
     } else {
         if (!fun->lazyScript()->isLikelyConstructorWrapper())
             return false;
-        begin = fun->lazyScript()->begin();
-        end = fun->lazyScript()->end();
+        begin = fun->lazyScript()->sourceStart();
+        end = fun->lazyScript()->sourceEnd();
     }
 
     return end - begin <= 100;
 }
 
 /* static */ bool
 ObjectGroup::useSingletonForNewObject(JSContext* cx, JSScript* script, jsbytecode* pc)
 {
--- a/js/src/vm/Xdr.cpp
+++ b/js/src/vm/Xdr.cpp
@@ -225,20 +225,20 @@ XDRIncrementalEncoder::getTopLevelTreeKe
 {
     return AutoXDRTree::topLevel;
 }
 
 AutoXDRTree::Key
 XDRIncrementalEncoder::getTreeKey(JSFunction* fun) const
 {
     if (fun->isInterpretedLazy()) {
-        static_assert(sizeof(fun->lazyScript()->begin()) == 4 ||
-                      sizeof(fun->lazyScript()->end()) == 4,
+        static_assert(sizeof(fun->lazyScript()->sourceStart()) == 4 ||
+                      sizeof(fun->lazyScript()->sourceEnd()) == 4,
                       "AutoXDRTree key requires LazyScripts positions to be uint32");
-        return uint64_t(fun->lazyScript()->begin()) << 32 | fun->lazyScript()->end();
+        return uint64_t(fun->lazyScript()->sourceStart()) << 32 | fun->lazyScript()->sourceEnd();
     }
 
     if (fun->isInterpreted()) {
         static_assert(sizeof(fun->nonLazyScript()->sourceStart()) == 4 ||
                       sizeof(fun->nonLazyScript()->sourceEnd()) == 4,
                       "AutoXDRTree key requires JSScripts positions to be uint32");
         return uint64_t(fun->nonLazyScript()->sourceStart()) << 32 | fun->nonLazyScript()->sourceEnd();
     }