Bug 1034330 - OdinMonkey: rename various AsmJSModule fields to be more consistent (r=bbouvier)

--HG--
extra : rebase_source : 33e70b1c85f093ce4b9c7ef9a93258231704be82
This commit is contained in:
Luke Wagner 2014-07-07 10:45:02 -05:00
parent 4ff35e504d
commit b55ea3ba52
4 changed files with 79 additions and 83 deletions

View File

@ -815,18 +815,18 @@ class MOZ_STACK_CLASS ModuleCompiler
public:
class Func
{
PropertyName *name_;
bool defined_;
uint32_t srcOffset_;
uint32_t endOffset_;
Signature sig_;
PropertyName *name_;
Label *code_;
unsigned compileTime_;
uint32_t srcBegin_;
uint32_t srcEnd_;
uint32_t compileTime_;
bool defined_;
public:
Func(PropertyName *name, Signature &&sig, Label *code)
: name_(name), defined_(false), srcOffset_(0), endOffset_(0), sig_(Move(sig)),
code_(code), compileTime_(0)
: sig_(Move(sig)), name_(name), code_(code), srcBegin_(0), srcEnd_(0),
compileTime_(0), defined_(false)
{}
PropertyName *name() const { return name_; }
@ -838,19 +838,19 @@ class MOZ_STACK_CLASS ModuleCompiler
// The begin/end char range is relative to the beginning of the module.
// hence the assertions.
JS_ASSERT(fn->pn_pos.begin > m.moduleStart());
JS_ASSERT(fn->pn_pos.begin > m.srcStart());
JS_ASSERT(fn->pn_pos.begin <= fn->pn_pos.end);
srcOffset_ = fn->pn_pos.begin - m.moduleStart();
endOffset_ = fn->pn_pos.end - m.moduleStart();
srcBegin_ = fn->pn_pos.begin - m.srcStart();
srcEnd_ = fn->pn_pos.end - m.srcStart();
}
uint32_t srcOffset() const { JS_ASSERT(defined_); return srcOffset_; }
uint32_t endOffset() const { JS_ASSERT(defined_); return endOffset_; }
uint32_t srcBegin() const { JS_ASSERT(defined_); return srcBegin_; }
uint32_t srcEnd() const { JS_ASSERT(defined_); return srcEnd_; }
Signature &sig() { return sig_; }
const Signature &sig() const { return sig_; }
Label *code() const { return code_; }
unsigned compileTime() const { return compileTime_; }
void accumulateCompileTime(unsigned ms) { compileTime_ += ms; }
uint32_t compileTime() const { return compileTime_; }
void accumulateCompileTime(uint32_t ms) { compileTime_ += ms; }
};
class Global
@ -1137,15 +1137,15 @@ class MOZ_STACK_CLASS ModuleCompiler
return false;
}
uint32_t funcStart = parser_.pc->maybeFunction->pn_body->pn_pos.begin;
uint32_t offsetToEndOfUseAsm = tokenStream().currentToken().pos.end;
uint32_t srcStart = parser_.pc->maybeFunction->pn_body->pn_pos.begin;
uint32_t srcBodyStart = tokenStream().currentToken().pos.end;
// "use strict" should be added to the source if we are in an implicit
// strict context, see also comment above addUseStrict in
// js::FunctionToString.
bool strict = parser_.pc->sc->strict && !parser_.pc->sc->hasExplicitUseStrict();
module_ = cx_->new_<AsmJSModule>(parser_.ss, funcStart, offsetToEndOfUseAsm, strict);
module_ = cx_->new_<AsmJSModule>(parser_.ss, srcStart, srcBodyStart, strict);
if (!module_)
return false;
@ -1212,7 +1212,7 @@ class MOZ_STACK_CLASS ModuleCompiler
SlowFunction sf;
sf.name = func.name();
sf.ms = func.compileTime();
tokenStream().srcCoords.lineNumAndColumnIndex(func.srcOffset(), &sf.line, &sf.column);
tokenStream().srcCoords.lineNumAndColumnIndex(func.srcBegin(), &sf.line, &sf.column);
return slowFunctions_.append(sf);
}
@ -1226,7 +1226,7 @@ class MOZ_STACK_CLASS ModuleCompiler
Label &interruptLabel() { return interruptLabel_; }
bool hasError() const { return errorString_ != nullptr; }
const AsmJSModule &module() const { return *module_.get(); }
uint32_t moduleStart() const { return module_->funcStart(); }
uint32_t srcStart() const { return module_->srcStart(); }
ParseNode *moduleFunctionNode() const { return moduleFunctionNode_; }
PropertyName *moduleFunctionName() const { return moduleFunctionName_; }
@ -1394,7 +1394,7 @@ class MOZ_STACK_CLASS ModuleCompiler
for (unsigned i = 0; i < args.length(); i++)
argCoercions[i] = args[i].toCoercion();
AsmJSModule::ReturnType retType = func->sig().retType().toModuleReturnType();
return module_->addExportedFunction(func->name(), func->srcOffset(), func->endOffset(),
return module_->addExportedFunction(func->name(), func->srcBegin(), func->srcEnd(),
maybeFieldName, Move(argCoercions), retType);
}
bool addExit(unsigned ffiIndex, PropertyName *name, Signature &&sig, unsigned *exitIndex) {
@ -1439,9 +1439,10 @@ class MOZ_STACK_CLASS ModuleCompiler
bool finishGeneratingFunction(Func &func, MIRGenerator &mir, CodeGenerator &codegen) {
JS_ASSERT(func.defined() && func.code()->bound());
uint32_t beginOffset = func.code()->offset();
uint32_t endOffset = masm_.currentOffset();
if (!module_->addFunctionCodeRange(func.name(), beginOffset, endOffset))
PropertyName *name = func.name();
uint32_t codeBegin = func.code()->offset();
uint32_t codeEnd = masm_.currentOffset();
if (!module_->addFunctionCodeRange(name, codeBegin, codeEnd))
return false;
jit::IonScriptCounts *counts = codegen.extractScriptCounts();
@ -1452,22 +1453,18 @@ class MOZ_STACK_CLASS ModuleCompiler
#if defined(MOZ_VTUNE) || defined(JS_ION_PERF)
unsigned line = 0, column = 0;
tokenStream().srcCoords.lineNumAndColumnIndex(func.srcOffset(), &line, &column);
unsigned startCodeOffset = func.code()->offset();
unsigned endCodeOffset = masm_.currentOffset();
if (!module_->addProfiledFunction(func.name(), startCodeOffset, endCodeOffset, line, column))
tokenStream().srcCoords.lineNumAndColumnIndex(func.srcBegin(), &line, &column);
if (!module_->addProfiledFunction(name, codeBegin, codeEnd, line, column))
return false;
# ifdef JS_ION_PERF
// Per-block profiling info uses significantly more memory so only store
// this information if it is actively requested.
if (PerfBlockEnabled()) {
// Per-block profiling info uses significantly more memory so only
// store this information if it is actively requested.
mir.perfSpewer().noteBlocksOffsets();
unsigned endInlineCodeOffset = mir.perfSpewer().endInlineCode.offset();
if (!module_->addPerfProfiledBlocks(func.name(), startCodeOffset, endInlineCodeOffset,
endCodeOffset, mir.perfSpewer().basicBlocks()))
{
AsmJSPerfSpewer &ps = mir.perfSpewer();
ps.noteBlocksOffsets();
unsigned inlineEnd = ps.endInlineCode.offset();
if (!module_->addProfiledBlocks(name, codeBegin, inlineEnd, codeEnd, ps.basicBlocks()))
return false;
}
}
# endif
#endif
@ -5423,11 +5420,11 @@ CheckFunctionsSequential(ModuleCompiler &m)
IonSpewNewFunction(&mir->graph(), NullPtr());
if (!OptimizeMIR(mir))
return m.failOffset(func->srcOffset(), "internal compiler failure (probably out of memory)");
return m.failOffset(func->srcBegin(), "internal compiler failure (probably out of memory)");
LIRGraph *lir = GenerateLIR(mir);
if (!lir)
return m.failOffset(func->srcOffset(), "internal compiler failure (probably out of memory)");
return m.failOffset(func->srcBegin(), "internal compiler failure (probably out of memory)");
func->accumulateCompileTime((PRMJ_Now() - before) / PRMJ_USEC_PER_MSEC);
@ -5687,7 +5684,7 @@ CheckFunctionsParallel(ModuleCompiler &m)
// If failure was triggered by a helper thread, report error.
if (void *maybeFunc = HelperThreadState().maybeAsmJSFailedFunction()) {
ModuleCompiler::Func *func = reinterpret_cast<ModuleCompiler::Func *>(maybeFunc);
return m.failOffset(func->srcOffset(), "allocation failure during compilation");
return m.failOffset(func->srcBegin(), "allocation failure during compilation");
}
// Otherwise, the error occurred on the main thread and was already reported.

View File

@ -468,8 +468,8 @@ HandleDynamicLinkFailure(JSContext *cx, CallArgs args, AsmJSModule &module, Hand
if (cx->isExceptionPending())
return false;
uint32_t begin = module.offsetToEndOfUseAsm();
uint32_t end = module.funcEndBeforeCurly();
uint32_t begin = module.srcBodyStart(); // starts right after 'use asm'
uint32_t end = module.srcEndBeforeCurly();
Rooted<JSFlatString*> src(cx, module.scriptSource()->substring(cx, begin, end));
if (!src)
return false;
@ -818,8 +818,8 @@ js::AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda
{
AsmJSModule &module = ModuleFunctionToModuleObject(fun).module();
uint32_t begin = module.funcStart();
uint32_t end = module.funcEndAfterCurly();
uint32_t begin = module.srcStart();
uint32_t end = module.srcEndAfterCurly();
ScriptSource *source = module.scriptSource();
StringBuffer out(cx);
@ -917,8 +917,8 @@ js::AsmJSFunctionToString(JSContext *cx, HandleFunction fun)
{
AsmJSModule &module = FunctionToEnclosingModule(fun);
const AsmJSModule::ExportedFunction &f = FunctionToExportedFunction(fun, module);
uint32_t begin = module.funcStart() + f.startOffsetInModule();
uint32_t end = module.funcStart() + f.endOffsetInModule();
uint32_t begin = module.srcStart() + f.startOffsetInModule();
uint32_t end = module.srcStart() + f.endOffsetInModule();
ScriptSource *source = module.scriptSource();
StringBuffer out(cx);

View File

@ -75,10 +75,10 @@ DeallocateExecutableMemory(uint8_t *code, size_t totalBytes)
#endif
}
AsmJSModule::AsmJSModule(ScriptSource *scriptSource, uint32_t funcStart,
uint32_t offsetToEndOfUseAsm, bool strict)
: funcStart_(funcStart),
offsetToEndOfUseAsm_(offsetToEndOfUseAsm),
AsmJSModule::AsmJSModule(ScriptSource *scriptSource, uint32_t srcStart, uint32_t srcBodyStart,
bool strict)
: srcStart_(srcStart),
srcBodyStart_(srcBodyStart),
scriptSource_(scriptSource),
globalArgumentName_(nullptr),
importArgumentName_(nullptr),
@ -278,10 +278,10 @@ AsmJSModule::finish(ExclusiveContext *cx, TokenStream &tokenStream, MacroAssembl
uint32_t endBeforeCurly = tokenStream.currentToken().pos.end;
uint32_t endAfterCurly = tokenStream.peekTokenPos().end;
JS_ASSERT(endBeforeCurly >= offsetToEndOfUseAsm_);
JS_ASSERT(endAfterCurly >= offsetToEndOfUseAsm_);
pod.funcLength_ = endBeforeCurly - funcStart_;
pod.funcLengthWithRightBrace_ = endAfterCurly - funcStart_;
JS_ASSERT(endBeforeCurly >= srcBodyStart_);
JS_ASSERT(endAfterCurly >= srcBodyStart_);
pod.srcLength_ = endBeforeCurly - srcStart_;
pod.srcLengthWithRightBrace_ = endAfterCurly - srcStart_;
// The global data section sits immediately after the executable (and
// other) data allocated by the MacroAssembler, so ensure it is
@ -1214,7 +1214,7 @@ AsmJSModule::clone(JSContext *cx, ScopedJSDeletePtr<AsmJSModule> *moduleOut) con
{
AutoUnprotectCodeForClone cloneGuard(cx, *this);
*moduleOut = cx->new_<AsmJSModule>(scriptSource_, funcStart_, offsetToEndOfUseAsm_, pod.strict_);
*moduleOut = cx->new_<AsmJSModule>(scriptSource_, srcStart_, srcBodyStart_, pod.strict_);
if (!*moduleOut)
return false;
@ -1671,11 +1671,11 @@ js::LookupAsmJSModuleInCache(ExclusiveContext *cx,
if (!moduleChars.match(parser))
return true;
uint32_t funcStart = parser.pc->maybeFunction->pn_body->pn_pos.begin;
uint32_t offsetToEndOfUseAsm = parser.tokenStream.currentToken().pos.end;
uint32_t srcStart = parser.pc->maybeFunction->pn_body->pn_pos.begin;
uint32_t srcBodyStart = parser.tokenStream.currentToken().pos.end;
bool strict = parser.pc->sc->strict && !parser.pc->sc->hasExplicitUseStrict();
ScopedJSDeletePtr<AsmJSModule> module(
cx->new_<AsmJSModule>(parser.ss, funcStart, offsetToEndOfUseAsm, strict));
cx->new_<AsmJSModule>(parser.ss, srcStart, srcBodyStart, strict));
if (!module)
return false;
cursor = module->deserialize(cx, cursor);
@ -1696,7 +1696,7 @@ js::LookupAsmJSModuleInCache(ExclusiveContext *cx,
module->staticallyLink(cx);
parser.tokenStream.advance(module->funcEndBeforeCurly());
parser.tokenStream.advance(module->srcEndBeforeCurly());
int64_t usecAfter = PRMJ_Now();
int ms = (usecAfter - usecBefore) / PRMJ_USEC_PER_MSEC;

View File

@ -490,8 +490,8 @@ class AsmJSModule
uint32_t minHeapLength_;
uint32_t numGlobalVars_;
uint32_t numFFIs_;
uint32_t funcLength_;
uint32_t funcLengthWithRightBrace_;
uint32_t srcLength_;
uint32_t srcLengthWithRightBrace_;
bool strict_;
bool hasArrayView_;
} pod;
@ -499,8 +499,8 @@ class AsmJSModule
// These two fields need to be kept out pod as they depend on the position
// of the module within the ScriptSource and thus aren't invariant with
// respect to caching.
const uint32_t funcStart_;
const uint32_t offsetToEndOfUseAsm_;
const uint32_t srcStart_;
const uint32_t srcBodyStart_;
Vector<Global, 0, SystemAllocPolicy> globals_;
Vector<Exit, 0, SystemAllocPolicy> exits_;
@ -533,8 +533,8 @@ class AsmJSModule
mutable bool codeIsProtected_;
public:
explicit AsmJSModule(ScriptSource *scriptSource, uint32_t functStart,
uint32_t offsetToEndOfUseAsm, bool strict);
explicit AsmJSModule(ScriptSource *scriptSource, uint32_t srcStart, uint32_t srcBodyStart,
bool strict);
void trace(JSTracer *trc);
~AsmJSModule();
@ -559,18 +559,19 @@ class AsmJSModule
return loadedFromCache_;
}
// funcStart() refers to the offset in the ScriptSource to the beginning
// of the function. If the function has been created with the Function
// constructor, this will be the first character in the function source.
// Otherwise, it will be the opening parenthesis of the arguments list.
uint32_t funcStart() const {
return funcStart_;
// srcStart() refers to the offset in the ScriptSource to the beginning of
// the asm.js module function. If the function has been created with the
// Function constructor, this will be the first character in the function
// source. Otherwise, it will be the opening parenthesis of the arguments
// list.
uint32_t srcStart() const {
return srcStart_;
}
// offsetToEndOfUseAsm() refers to the offset in the ScriptSource to the end
// srcBodyStart() refers to the offset in the ScriptSource to the end
// of the 'use asm' string-literal token.
uint32_t offsetToEndOfUseAsm() const {
return offsetToEndOfUseAsm_;
uint32_t srcBodyStart() const {
return srcBodyStart_;
}
// While these functions may be accessed at any time, their values will
@ -743,11 +744,11 @@ class AsmJSModule
return functionCounts_.append(counts);
}
#if defined(MOZ_VTUNE) || defined(JS_ION_PERF)
bool addProfiledFunction(PropertyName *name, unsigned startCodeOffset, unsigned endCodeOffset,
bool addProfiledFunction(PropertyName *name, unsigned codeStart, unsigned codeEnd,
unsigned line, unsigned column)
{
JS_ASSERT(isFinishedWithModulePrologue() && !isFinishedWithFunctionBodies());
ProfiledFunction func(name, startCodeOffset, endCodeOffset, line, column);
ProfiledFunction func(name, codeStart, codeEnd, line, column);
return profiledFunctions_.append(func);
}
unsigned numProfiledFunctions() const {
@ -760,13 +761,11 @@ class AsmJSModule
}
#endif
#ifdef JS_ION_PERF
bool addPerfProfiledBlocks(PropertyName *name, unsigned startCodeOffset,
unsigned endInlineCodeOffset, unsigned endCodeOffset,
jit::BasicBlocksVector &basicBlocks)
bool addProfiledBlocks(PropertyName *name, unsigned codeBegin, unsigned inlineEnd,
unsigned codeEnd, jit::BasicBlocksVector &basicBlocks)
{
JS_ASSERT(isFinishedWithModulePrologue() && !isFinishedWithFunctionBodies());
ProfiledBlocksFunction func(name, startCodeOffset, endInlineCodeOffset, endCodeOffset,
basicBlocks);
ProfiledBlocksFunction func(name, codeBegin, inlineEnd, codeEnd, basicBlocks);
return perfProfiledBlocksFunctions_.append(mozilla::Move(func));
}
unsigned numPerfBlocksFunctions() const {
@ -843,13 +842,13 @@ class AsmJSModule
JS_ASSERT(isFinished());
return pod.numFFIs_;
}
uint32_t funcEndBeforeCurly() const {
uint32_t srcEndBeforeCurly() const {
JS_ASSERT(isFinished());
return funcStart_ + pod.funcLength_;
return srcStart_ + pod.srcLength_;
}
uint32_t funcEndAfterCurly() const {
uint32_t srcEndAfterCurly() const {
JS_ASSERT(isFinished());
return funcStart_ + pod.funcLengthWithRightBrace_;
return srcStart_ + pod.srcLengthWithRightBrace_;
}
uint8_t *codeBase() const {
JS_ASSERT(isFinished());