mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 900669 - OdinMonkey: hoist AsmJSModuleSourceDesc (r=bbouvier)
This commit is contained in:
parent
949f85802a
commit
aae05cac1b
@ -1559,7 +1559,7 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
// the link-time validation fails in LinkAsmJS and we need to re-parse
|
||||
// the entire module from scratch.
|
||||
uint32_t bodyEnd = parser_.tokenStream.currentToken().pos.end;
|
||||
module_->initPostLinkFailureInfo(parser_.ss, bodyStart_, bodyEnd);
|
||||
module_->initSourceDesc(parser_.ss, bodyStart_, bodyEnd);
|
||||
|
||||
// Finish the code section.
|
||||
masm_.finish();
|
||||
|
@ -398,10 +398,9 @@ HandleDynamicLinkFailure(JSContext *cx, CallArgs args, AsmJSModule &module, Hand
|
||||
if (cx->isExceptionPending())
|
||||
return false;
|
||||
|
||||
const AsmJSModule::PostLinkFailureInfo &info = module.postLinkFailureInfo();
|
||||
|
||||
uint32_t length = info.bufEnd - info.bufStart;
|
||||
Rooted<JSStableString*> src(cx, info.scriptSource->substring(cx, info.bufStart, info.bufEnd));
|
||||
const AsmJSModuleSourceDesc &desc= module.sourceDesc();
|
||||
uint32_t length = desc.bufEnd() - desc.bufStart();
|
||||
Rooted<JSStableString*> src(cx, desc.scriptSource()->substring(cx, desc.bufStart(), desc.bufEnd()));
|
||||
if (!src)
|
||||
return false;
|
||||
|
||||
@ -422,7 +421,7 @@ HandleDynamicLinkFailure(JSContext *cx, CallArgs args, AsmJSModule &module, Hand
|
||||
|
||||
CompileOptions options(cx);
|
||||
options.setPrincipals(cx->compartment()->principals)
|
||||
.setOriginPrincipals(info.scriptSource->originPrincipals())
|
||||
.setOriginPrincipals(desc.scriptSource()->originPrincipals())
|
||||
.setCompileAndGo(false)
|
||||
.setNoScriptRval(false);
|
||||
|
||||
@ -501,8 +500,7 @@ SendFunctionsToPerf(JSContext *cx, AsmJSModule &module)
|
||||
|
||||
unsigned long base = (unsigned long) module.functionCode();
|
||||
|
||||
const AsmJSModule::PostLinkFailureInfo &info = module.postLinkFailureInfo();
|
||||
const char *filename = const_cast<char *>(info.scriptSource->filename());
|
||||
const char *filename = module.sourceDesc().scriptSource()->filename();
|
||||
|
||||
for (unsigned i = 0; i < module.numPerfFunctions(); i++) {
|
||||
const AsmJSModule::ProfiledFunction &func = module.perfProfiledFunction(i);
|
||||
@ -536,8 +534,7 @@ SendBlocksToPerf(JSContext *cx, AsmJSModule &module)
|
||||
AsmJSPerfSpewer spewer;
|
||||
unsigned long funcBaseAddress = (unsigned long) module.functionCode();
|
||||
|
||||
const AsmJSModule::PostLinkFailureInfo &info = module.postLinkFailureInfo();
|
||||
const char *filename = const_cast<char *>(info.scriptSource->filename());
|
||||
const char *filename = module.sourceDesc().scriptSource()->filename();
|
||||
|
||||
for (unsigned i = 0; i < module.numPerfBlocksFunctions(); i++) {
|
||||
const AsmJSModule::ProfiledBlocksFunction &func = module.perfProfiledBlocksFunction(i);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsscript.h"
|
||||
|
||||
#include "gc/Marking.h"
|
||||
@ -317,32 +318,6 @@ class AsmJSModule
|
||||
};
|
||||
#endif
|
||||
|
||||
// If linking fails, we recompile the function as if it's ordinary JS.
|
||||
// This struct holds the data required to do this.
|
||||
struct PostLinkFailureInfo
|
||||
{
|
||||
ScriptSource * scriptSource;
|
||||
uint32_t bufStart; // offset of the function body's start
|
||||
uint32_t bufEnd; // offset of the function body's end
|
||||
|
||||
PostLinkFailureInfo()
|
||||
: scriptSource(), bufStart(), bufEnd()
|
||||
{}
|
||||
|
||||
void init(ScriptSource *scriptSource, uint32_t bufStart, uint32_t bufEnd) {
|
||||
JS_ASSERT(!this->scriptSource);
|
||||
this->scriptSource = scriptSource;
|
||||
this->bufStart = bufStart;
|
||||
this->bufEnd = bufEnd;
|
||||
scriptSource->incref();
|
||||
}
|
||||
|
||||
~PostLinkFailureInfo() {
|
||||
if (scriptSource)
|
||||
scriptSource->decref();
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
typedef Vector<ExportedFunction, 0, SystemAllocPolicy> ExportedFunctionVector;
|
||||
typedef Vector<Global, 0, SystemAllocPolicy> GlobalVector;
|
||||
@ -384,7 +359,7 @@ class AsmJSModule
|
||||
HeapPtrPropertyName importArgumentName_;
|
||||
HeapPtrPropertyName bufferArgumentName_;
|
||||
|
||||
PostLinkFailureInfo postLinkFailureInfo_;
|
||||
AsmJSModuleSourceDesc sourceDesc_;
|
||||
FunctionCountsVector functionCounts_;
|
||||
|
||||
public:
|
||||
@ -400,7 +375,7 @@ class AsmJSModule
|
||||
totalBytes_(0),
|
||||
linked_(false),
|
||||
maybeHeap_(),
|
||||
postLinkFailureInfo_()
|
||||
sourceDesc_()
|
||||
{}
|
||||
|
||||
~AsmJSModule();
|
||||
@ -706,13 +681,11 @@ class AsmJSModule
|
||||
PropertyName *importArgumentName() const { return importArgumentName_; }
|
||||
PropertyName *bufferArgumentName() const { return bufferArgumentName_; }
|
||||
|
||||
void initPostLinkFailureInfo(ScriptSource *scriptSource,
|
||||
uint32_t bufStart,
|
||||
uint32_t bufEnd) {
|
||||
postLinkFailureInfo_.init(scriptSource, bufStart, bufEnd);
|
||||
void initSourceDesc(ScriptSource *scriptSource, uint32_t bufStart, uint32_t bufEnd) {
|
||||
sourceDesc_.init(scriptSource, bufStart, bufEnd);
|
||||
}
|
||||
const PostLinkFailureInfo &postLinkFailureInfo() const {
|
||||
return postLinkFailureInfo_;
|
||||
const AsmJSModuleSourceDesc &sourceDesc() const {
|
||||
return sourceDesc_;
|
||||
}
|
||||
|
||||
void detachIonCompilation(size_t exitIndex) const {
|
||||
|
@ -1137,6 +1137,22 @@ js::IsInRequest(JSContext *cx)
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
AsmJSModuleSourceDesc::init(ScriptSource *scriptSource, uint32_t bufStart, uint32_t bufEnd)
|
||||
{
|
||||
JS_ASSERT(scriptSource_ == NULL);
|
||||
scriptSource_ = scriptSource;
|
||||
bufStart_ = bufStart;
|
||||
bufEnd_ = bufEnd;
|
||||
scriptSource_->incref();
|
||||
}
|
||||
|
||||
AsmJSModuleSourceDesc::~AsmJSModuleSourceDesc()
|
||||
{
|
||||
if (scriptSource_)
|
||||
scriptSource_->decref();
|
||||
}
|
||||
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
JS_FRIEND_API(void)
|
||||
JS_StoreObjectPostBarrierCallback(JSContext* cx,
|
||||
|
@ -1788,6 +1788,31 @@ extern JS_FRIEND_API(bool)
|
||||
CheckDefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value,
|
||||
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
|
||||
|
||||
class ScriptSource;
|
||||
|
||||
// An AsmJSModuleSourceDesc object holds a reference to the ScriptSource
|
||||
// containing an asm.js module as well as the [begin, end) range of the
|
||||
// module's chars within the ScriptSource.
|
||||
class AsmJSModuleSourceDesc
|
||||
{
|
||||
ScriptSource *scriptSource_;
|
||||
uint32_t bufStart_;
|
||||
uint32_t bufEnd_;
|
||||
|
||||
public:
|
||||
AsmJSModuleSourceDesc() : scriptSource_(NULL), bufStart_(UINT32_MAX), bufEnd_(UINT32_MAX) {}
|
||||
void init(ScriptSource *scriptSource, uint32_t bufStart, uint32_t bufEnd);
|
||||
~AsmJSModuleSourceDesc();
|
||||
|
||||
ScriptSource *scriptSource() const { JS_ASSERT(scriptSource_ != NULL); return scriptSource_; }
|
||||
uint32_t bufStart() const { JS_ASSERT(bufStart_ != UINT32_MAX); return bufStart_; }
|
||||
uint32_t bufEnd() const { JS_ASSERT(bufStart_ != UINT32_MAX); return bufEnd_; }
|
||||
|
||||
private:
|
||||
AsmJSModuleSourceDesc(const AsmJSModuleSourceDesc &) MOZ_DELETE;
|
||||
void operator=(const AsmJSModuleSourceDesc &) MOZ_DELETE;
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
|
Loading…
Reference in New Issue
Block a user