mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 900669 - OdinMonkey: simplify how ScriptSource and source location are saved (r=bbouvier)
--HG-- extra : rebase_source : a3cabb43976f39dfc77543dc64688357e3801478
This commit is contained in:
parent
a32e9216f0
commit
1da2541e28
@ -1261,7 +1261,6 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
|
||||
char * errorString_;
|
||||
uint32_t errorOffset_;
|
||||
uint32_t bodyStart_;
|
||||
|
||||
int64_t usecBefore_;
|
||||
SlowFunctionVector slowFunctions_;
|
||||
@ -1291,7 +1290,6 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
globalAccesses_(cx),
|
||||
errorString_(NULL),
|
||||
errorOffset_(UINT32_MAX),
|
||||
bodyStart_(parser.tokenStream.currentToken().pos.end),
|
||||
usecBefore_(PRMJ_Now()),
|
||||
slowFunctions_(cx),
|
||||
finishedFunctionBodies_(false)
|
||||
@ -1339,7 +1337,12 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
return false;
|
||||
}
|
||||
|
||||
module_ = cx_->new_<AsmJSModule>();
|
||||
// The record offset in the char buffer officially begins the char
|
||||
// after the "use asm" processing directive statement (including any
|
||||
// semicolon).
|
||||
uint32_t charsBegin = parser_.tokenStream.currentToken().pos.end;
|
||||
|
||||
module_ = cx_->new_<AsmJSModule>(parser_.ss, charsBegin);
|
||||
if (!module_)
|
||||
return false;
|
||||
|
||||
@ -1676,11 +1679,7 @@ class MOZ_STACK_CLASS ModuleCompiler
|
||||
|
||||
bool extractModule(ScopedJSDeletePtr<AsmJSModule> *module, AsmJSStaticLinkData *linkData)
|
||||
{
|
||||
// Record the ScriptSource and [begin, end) range of the module in case
|
||||
// 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_->initSourceDesc(parser_.ss, bodyStart_, bodyEnd);
|
||||
module_->initCharsEnd(parser_.tokenStream.currentToken().pos.end);
|
||||
|
||||
masm_.finish();
|
||||
if (masm_.oom())
|
||||
|
@ -409,9 +409,9 @@ HandleDynamicLinkFailure(JSContext *cx, CallArgs args, AsmJSModule &module, Hand
|
||||
if (cx->isExceptionPending())
|
||||
return false;
|
||||
|
||||
const AsmJSModuleSourceDesc &desc= module.sourceDesc();
|
||||
uint32_t length = desc.bufEnd() - desc.bufStart();
|
||||
Rooted<JSStableString*> src(cx, desc.scriptSource()->substring(cx, desc.bufStart(), desc.bufEnd()));
|
||||
uint32_t begin = module.charsBegin();
|
||||
uint32_t end = module.charsEnd();
|
||||
Rooted<JSStableString*> src(cx, module.scriptSource()->substring(cx, begin, end));
|
||||
if (!src)
|
||||
return false;
|
||||
|
||||
@ -432,11 +432,11 @@ HandleDynamicLinkFailure(JSContext *cx, CallArgs args, AsmJSModule &module, Hand
|
||||
|
||||
CompileOptions options(cx);
|
||||
options.setPrincipals(cx->compartment()->principals)
|
||||
.setOriginPrincipals(desc.scriptSource()->originPrincipals())
|
||||
.setOriginPrincipals(module.scriptSource()->originPrincipals())
|
||||
.setCompileAndGo(false)
|
||||
.setNoScriptRval(false);
|
||||
|
||||
if (!frontend::CompileFunctionBody(cx, &fun, options, formals, src->chars().get(), length))
|
||||
if (!frontend::CompileFunctionBody(cx, &fun, options, formals, src->chars().get(), end - begin))
|
||||
return false;
|
||||
|
||||
// Call the function we just recompiled.
|
||||
|
@ -80,9 +80,9 @@ static void
|
||||
DeallocateExecutableMemory(uint8_t *code, size_t totalBytes)
|
||||
{
|
||||
#ifdef XP_WIN
|
||||
JS_ALWAYS_TRUE(VirtualFree(code, 0, MEM_RELEASE));
|
||||
JS_ALWAYS_TRUE(VirtualFree(code, 0, MEM_RELEASE));
|
||||
#else
|
||||
JS_ALWAYS_TRUE(munmap(code, totalBytes) == 0);
|
||||
JS_ALWAYS_TRUE(munmap(code, totalBytes) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -129,8 +129,25 @@ AsmJSModule::staticallyLink(const AsmJSStaticLinkData &linkData)
|
||||
}
|
||||
}
|
||||
|
||||
AsmJSModule::AsmJSModule(ScriptSource *scriptSource, uint32_t charsBegin)
|
||||
: globalArgumentName_(NULL),
|
||||
importArgumentName_(NULL),
|
||||
bufferArgumentName_(NULL),
|
||||
minHeapLength_(AsmJSAllocationGranularity),
|
||||
code_(NULL),
|
||||
operationCallbackExit_(NULL),
|
||||
linked_(false),
|
||||
charsBegin_(charsBegin),
|
||||
scriptSource_(scriptSource)
|
||||
{
|
||||
mozilla::PodZero(&pod);
|
||||
scriptSource_->incref();
|
||||
}
|
||||
|
||||
AsmJSModule::~AsmJSModule()
|
||||
{
|
||||
scriptSource_->decref();
|
||||
|
||||
if (code_) {
|
||||
for (unsigned i = 0; i < numExits(); i++) {
|
||||
AsmJSModule::ExitDatum &exitDatum = exitIndexToGlobalDatum(i);
|
||||
|
@ -351,6 +351,7 @@ class AsmJSModule
|
||||
#endif
|
||||
|
||||
struct Pod {
|
||||
uint32_t charsLength_;
|
||||
uint32_t numGlobalVars_;
|
||||
uint32_t numFFIs_;
|
||||
size_t funcPtrTableAndExitBytes_;
|
||||
@ -366,22 +367,13 @@ class AsmJSModule
|
||||
bool linked_;
|
||||
HeapPtr<ArrayBufferObject> maybeHeap_;
|
||||
|
||||
AsmJSModuleSourceDesc sourceDesc_;
|
||||
uint32_t charsBegin_;
|
||||
ScriptSource * scriptSource_;
|
||||
|
||||
FunctionCountsVector functionCounts_;
|
||||
|
||||
public:
|
||||
explicit AsmJSModule()
|
||||
: globalArgumentName_(NULL),
|
||||
importArgumentName_(NULL),
|
||||
bufferArgumentName_(NULL),
|
||||
minHeapLength_(AsmJSAllocationGranularity),
|
||||
code_(NULL),
|
||||
operationCallbackExit_(NULL),
|
||||
linked_(false)
|
||||
{
|
||||
mozilla::PodZero(&pod);
|
||||
}
|
||||
|
||||
explicit AsmJSModule(ScriptSource *scriptSource, uint32_t charsBegin);
|
||||
~AsmJSModule();
|
||||
|
||||
void trace(JSTracer *trc) {
|
||||
@ -414,6 +406,21 @@ class AsmJSModule
|
||||
MarkStringUnbarriered(trc, &bufferArgumentName_, "asm.js buffer argument name");
|
||||
}
|
||||
|
||||
ScriptSource *scriptSource() const {
|
||||
JS_ASSERT(scriptSource_ != NULL);
|
||||
return scriptSource_;
|
||||
}
|
||||
uint32_t charsBegin() const {
|
||||
return charsBegin_;
|
||||
}
|
||||
void initCharsEnd(uint32_t charsEnd) {
|
||||
JS_ASSERT(charsEnd >= charsBegin_);
|
||||
pod.charsLength_ = charsEnd - charsBegin_;
|
||||
}
|
||||
uint32_t charsEnd() const {
|
||||
return charsBegin_ + pod.charsLength_;
|
||||
}
|
||||
|
||||
bool addGlobalVarInitConstant(const Value &v, uint32_t *globalIndex) {
|
||||
JS_ASSERT(pod.funcPtrTableAndExitBytes_ == 0);
|
||||
if (pod.numGlobalVars_ == UINT32_MAX)
|
||||
@ -717,13 +724,6 @@ class AsmJSModule
|
||||
return bufferArgumentName_;
|
||||
}
|
||||
|
||||
void initSourceDesc(ScriptSource *scriptSource, uint32_t bufStart, uint32_t bufEnd) {
|
||||
sourceDesc_.init(scriptSource, bufStart, bufEnd);
|
||||
}
|
||||
const AsmJSModuleSourceDesc &sourceDesc() const {
|
||||
return sourceDesc_;
|
||||
}
|
||||
|
||||
void detachIonCompilation(size_t exitIndex) const {
|
||||
exitIndexToGlobalDatum(exitIndex).exit = interpExitTrampoline(exit(exitIndex));
|
||||
}
|
||||
|
@ -1143,22 +1143,6 @@ 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,
|
||||
|
@ -1574,31 +1574,6 @@ extern JS_FRIEND_API(bool)
|
||||
CheckDefineProperty(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue value,
|
||||
JSPropertyOp getter, JSStrictPropertyOp 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(bool)
|
||||
|
Loading…
Reference in New Issue
Block a user