зеркало из https://github.com/mozilla/gecko-dev.git
Bug 779400: Split ScriptSource::setSource into setSource and setSourceCopy. r=jorendorff
--HG-- extra : rebase_source : 21b507a980aceb792a75e2711a934d4f9d51f37a
This commit is contained in:
Родитель
86fac7d3c7
Коммит
61c5acf48f
|
@ -85,7 +85,7 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, StackFrame *call
|
|||
AutoAttachToRuntime attacher(cx->runtime, ss);
|
||||
SourceCompressionToken sct(cx);
|
||||
if (!cx->hasRunOption(JSOPTION_ONLY_CNG_SOURCE) || options.compileAndGo) {
|
||||
if (!ss->setSource(cx, chars, length, false, &sct))
|
||||
if (!ss->setSourceCopy(cx, chars, length, false, &sct))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ frontend::CompileFunctionBody(JSContext *cx, HandleFunction fun, CompileOptions
|
|||
return NULL;
|
||||
AutoAttachToRuntime attacher(cx->runtime, ss);
|
||||
SourceCompressionToken sct(cx);
|
||||
if (!ss->setSource(cx, chars, length, true, &sct))
|
||||
if (!ss->setSourceCopy(cx, chars, length, true, &sct))
|
||||
return NULL;
|
||||
|
||||
options.setCompileAndGo(false);
|
||||
|
|
|
@ -1151,7 +1151,7 @@ JSScript::loadSource(JSContext *cx, bool *worked)
|
|||
if (!src)
|
||||
return true;
|
||||
ScriptSource *ss = scriptSource();
|
||||
JS_ALWAYS_TRUE(ss->setSource(cx, src, length, false, NULL, true));
|
||||
ss->setSource(src, length);
|
||||
*worked = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -1236,24 +1236,19 @@ ScriptSource::substring(JSContext *cx, uint32_t start, uint32_t stop)
|
|||
}
|
||||
|
||||
bool
|
||||
ScriptSource::setSource(JSContext *cx, const jschar *src, uint32_t length,
|
||||
bool argumentsNotIncluded, SourceCompressionToken *tok,
|
||||
bool ownSource)
|
||||
ScriptSource::setSourceCopy(JSContext *cx, const jschar *src, uint32_t length,
|
||||
bool argumentsNotIncluded, SourceCompressionToken *tok)
|
||||
{
|
||||
JS_ASSERT(!hasSourceData());
|
||||
if (!ownSource) {
|
||||
const size_t nbytes = length * sizeof(jschar);
|
||||
data.compressed = static_cast<unsigned char *>(cx->malloc_(nbytes));
|
||||
if (!data.compressed)
|
||||
return false;
|
||||
}
|
||||
const size_t nbytes = length * sizeof(jschar);
|
||||
data.compressed = static_cast<unsigned char *>(cx->malloc_(nbytes));
|
||||
if (!data.compressed)
|
||||
return false;
|
||||
length_ = length;
|
||||
argumentsNotIncluded_ = argumentsNotIncluded;
|
||||
|
||||
JS_ASSERT_IF(ownSource, !tok);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
if (tok && !ownSource) {
|
||||
if (tok) {
|
||||
#ifdef DEBUG
|
||||
ready_ = false;
|
||||
#endif
|
||||
|
@ -1263,18 +1258,21 @@ ScriptSource::setSource(JSContext *cx, const jschar *src, uint32_t length,
|
|||
} else
|
||||
#endif
|
||||
{
|
||||
if (ownSource)
|
||||
data.source = const_cast<jschar *>(src);
|
||||
else
|
||||
PodCopy(data.source, src, length_);
|
||||
#ifdef DEBUG
|
||||
ready_ = true;
|
||||
#endif
|
||||
PodCopy(data.source, src, length_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ScriptSource::setSource(const jschar *src, uint32_t length)
|
||||
{
|
||||
JS_ASSERT(!hasSourceData());
|
||||
length_ = length;
|
||||
JS_ASSERT(!argumentsNotIncluded_);
|
||||
data.source = const_cast<jschar *>(src);
|
||||
}
|
||||
|
||||
void
|
||||
SourceCompressionToken::ensureReady()
|
||||
{
|
||||
|
|
|
@ -1010,12 +1010,12 @@ struct ScriptSource
|
|||
{
|
||||
data.source = NULL;
|
||||
}
|
||||
bool setSource(JSContext *cx,
|
||||
const jschar *src,
|
||||
uint32_t length,
|
||||
bool argumentsNotIncluded = false,
|
||||
SourceCompressionToken *tok = NULL,
|
||||
bool ownSource = false);
|
||||
bool setSourceCopy(JSContext *cx,
|
||||
const jschar *src,
|
||||
uint32_t length,
|
||||
bool argumentsNotIncluded,
|
||||
SourceCompressionToken *tok);
|
||||
void setSource(const jschar *src, uint32_t length);
|
||||
void attachToRuntime(JSRuntime *rt);
|
||||
void mark() { marked = true; }
|
||||
bool onRuntime() const { return onRuntime_; }
|
||||
|
|
|
@ -243,7 +243,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
|
|||
cx->free_(source);
|
||||
return NULL;
|
||||
}
|
||||
JS_ALWAYS_TRUE(ss->setSource(cx, source, sourceLen, false, NULL, true));
|
||||
ss->setSource(source, sourceLen);
|
||||
|
||||
CompileOptions options(cx);
|
||||
options.setNoScriptRval(true)
|
||||
|
|
Загрузка…
Ссылка в новой задаче