summaryrefslogtreecommitdiffstats
path: root/js/src/jsscript.h
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-02-02 12:47:28 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-02-02 12:47:28 +0100
commite547de64c80b98d661999c0788c09210d9d4a37e (patch)
tree19b0f1b8dd67c3cff002ecad5d10de6c5e806801 /js/src/jsscript.h
parent278eda6a09e9177678d57a2da2b6a8ddcb503b1c (diff)
downloadUXP-e547de64c80b98d661999c0788c09210d9d4a37e.tar
UXP-e547de64c80b98d661999c0788c09210d9d4a37e.tar.gz
UXP-e547de64c80b98d661999c0788c09210d9d4a37e.tar.lz
UXP-e547de64c80b98d661999c0788c09210d9d4a37e.tar.xz
UXP-e547de64c80b98d661999c0788c09210d9d4a37e.zip
Stage 1-1: Implement Function.prototype.toString revision proposal.
Tag #960
Diffstat (limited to 'js/src/jsscript.h')
-rw-r--r--js/src/jsscript.h49
1 files changed, 35 insertions, 14 deletions
diff --git a/js/src/jsscript.h b/js/src/jsscript.h
index 87da79901..bb8635581 100644
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -575,10 +575,6 @@ class ScriptSource
introductionOffset_ = offset;
hasIntroductionOffset_ = true;
}
-
- uint32_t parameterListEnd() const {
- return parameterListEnd_;
- }
};
class ScriptSourceHolder
@@ -857,9 +853,19 @@ class JSScript : public js::gc::TenuredCell
uint32_t bodyScopeIndex_; /* index into the scopes array of the body scope */
- /* Range of characters in scriptSource which contains this script's source. */
+ // Range of characters in scriptSource which contains this script's source.
+ // each field points the following location.
+ //
+ // function * f(a, b) { return a + b; }
+ // ^ ^ ^
+ // | | |
+ // | sourceStart_ sourceEnd_
+ // |
+ // preludeStart_
+ //
uint32_t sourceStart_;
uint32_t sourceEnd_;
+ uint32_t preludeStart_;
// Number of times the script has been called or has had backedges taken.
// When running in ion, also increased for any inlined scripts. Reset if
@@ -1020,7 +1026,7 @@ class JSScript : public js::gc::TenuredCell
// instead of private to suppress -Wunused-private-field compiler warnings.
protected:
#if JS_BITS_PER_WORD == 32
- // Currently no padding is needed.
+ uint32_t padding;
#endif
//
@@ -1031,7 +1037,7 @@ class JSScript : public js::gc::TenuredCell
static JSScript* Create(js::ExclusiveContext* cx,
const JS::ReadOnlyCompileOptions& options,
js::HandleObject sourceObject, uint32_t sourceStart,
- uint32_t sourceEnd);
+ uint32_t sourceEnd, uint32_t preludeStart);
void initCompartment(js::ExclusiveContext* cx);
@@ -1178,6 +1184,10 @@ class JSScript : public js::gc::TenuredCell
return sourceEnd_;
}
+ size_t preludeStart() const {
+ return preludeStart_;
+ }
+
bool noScriptRval() const {
return noScriptRval_;
}
@@ -1501,7 +1511,8 @@ class JSScript : public js::gc::TenuredCell
bool mayReadFrameArgsDirectly();
JSFlatString* sourceData(JSContext* cx);
-
+ JSFlatString* sourceDataWithPrelude(JSContext* cx);
+
static bool loadSource(JSContext* cx, js::ScriptSource* ss, bool* worked);
void setSourceObject(JSObject* object);
@@ -1920,7 +1931,8 @@ class LazyScript : public gc::TenuredCell
// instead of private to suppress -Wunused-private-field compiler warnings.
protected:
#if JS_BITS_PER_WORD == 32
- uint32_t padding;
+ // uint32_t padding;
+ // Currently no padding is needed.
#endif
private:
@@ -1960,20 +1972,25 @@ class LazyScript : public gc::TenuredCell
};
// Source location for the script.
+ // See the comment in JSScript for the details.
uint32_t begin_;
uint32_t end_;
+ uint32_t preludeStart_;
+ // 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,
- uint32_t begin, uint32_t end, uint32_t lineno, uint32_t column);
+ uint32_t begin, uint32_t end, uint32_t preludeStart,
+ uint32_t lineno, uint32_t column);
// Create a LazyScript without initializing the closedOverBindings and the
// innerFunctions. To be GC-safe, the caller must initialize both vectors
// with valid atoms and functions.
static LazyScript* CreateRaw(ExclusiveContext* cx, HandleFunction fun,
uint64_t packedData, uint32_t begin, uint32_t end,
- uint32_t lineno, uint32_t column);
+ uint32_t preludeStart, uint32_t lineno, uint32_t column);
public:
static const uint32_t NumClosedOverBindingsLimit = 1 << NumClosedOverBindingsBits;
@@ -1985,7 +2002,7 @@ class LazyScript : public gc::TenuredCell
const frontend::AtomVector& closedOverBindings,
Handle<GCVector<JSFunction*, 8>> innerFunctions,
JSVersion version, uint32_t begin, uint32_t end,
- uint32_t lineno, uint32_t column);
+ uint32_t preludeStart, uint32_t lineno, uint32_t column);
// Create a LazyScript and initialize the closedOverBindings and the
// innerFunctions with dummy values to be replaced in a later initialization
@@ -2000,7 +2017,7 @@ class LazyScript : public gc::TenuredCell
HandleScript script, HandleScope enclosingScope,
HandleScript enclosingScript,
uint64_t packedData, uint32_t begin, uint32_t end,
- uint32_t lineno, uint32_t column);
+ uint32_t preludeStart, uint32_t lineno, uint32_t column);
void initRuntimeFields(uint64_t packedFields);
@@ -2173,6 +2190,9 @@ class LazyScript : public gc::TenuredCell
uint32_t end() const {
return end_;
}
+ uint32_t preludeStart() const {
+ return preludeStart_;
+ }
uint32_t lineno() const {
return lineno_;
}
@@ -2199,7 +2219,8 @@ class LazyScript : public gc::TenuredCell
};
/* If this fails, add/remove padding within LazyScript. */
-JS_STATIC_ASSERT(sizeof(LazyScript) % js::gc::CellSize == 0);
+static_assert(sizeof(LazyScript) % js::gc::CellSize == 0,
+ "Size of LazyScript must be an integral multiple of js::gc::CellSize");
struct ScriptAndCounts
{