From 9adb7a582a845fb0bf0116159dacecd4bdc879cd Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 27 Sep 2013 16:29:58 -0400 Subject: [PATCH] Bug 784739 - Switch from NULL to nullptr in js/src/jit/ (6/7); r=ehsan --HG-- extra : rebase_source : e5b3e4e45ab587f6953605a67a63814eea9c8056 --- js/src/jit/MIRGenerator.h | 2 +- js/src/jit/MIRGraph.cpp | 70 +++++++++++------------ js/src/jit/MIRGraph.h | 12 ++-- js/src/jit/MoveResolver.cpp | 2 +- js/src/jit/ParallelFunctions.cpp | 14 ++--- js/src/jit/ParallelFunctions.h | 4 +- js/src/jit/ParallelSafetyAnalysis.cpp | 12 ++-- js/src/jit/PcScriptCache.h | 2 +- js/src/jit/PerfSpewer.cpp | 4 +- js/src/jit/RangeAnalysis.cpp | 70 +++++++++++------------ js/src/jit/RangeAnalysis.h | 18 +++--- js/src/jit/RegisterAllocator.cpp | 2 +- js/src/jit/RegisterAllocator.h | 2 +- js/src/jit/Registers.h | 4 +- js/src/jit/StupidAllocator.cpp | 4 +- js/src/jit/StupidAllocator.h | 2 +- js/src/jit/TypePolicy.cpp | 2 +- js/src/jit/TypeRepresentationSet.cpp | 4 +- js/src/jit/UnreachableCodeElimination.cpp | 10 ++-- js/src/jit/VMFunctions.cpp | 32 +++++------ js/src/jit/VMFunctions.h | 15 ++--- js/src/jit/ValueNumbering.cpp | 24 ++++---- js/src/jit/ValueNumbering.h | 2 +- 23 files changed, 157 insertions(+), 156 deletions(-) diff --git a/js/src/jit/MIRGenerator.h b/js/src/jit/MIRGenerator.h index a75d28cf236..cb0d9399ce2 100644 --- a/js/src/jit/MIRGenerator.h +++ b/js/src/jit/MIRGenerator.h @@ -79,7 +79,7 @@ class MIRGenerator } bool compilingAsmJS() const { - return info_->script() == NULL; + return info_->script() == nullptr; } uint32_t maxAsmJSStackArgBytes() const { diff --git a/js/src/jit/MIRGraph.cpp b/js/src/jit/MIRGraph.cpp index 92b000a430e..64df7b74f75 100644 --- a/js/src/jit/MIRGraph.cpp +++ b/js/src/jit/MIRGraph.cpp @@ -91,7 +91,7 @@ MIRGraph::removeBlock(MBasicBlock *block) // share the same resumepoints and we cannot distinguish between them. if (block == osrBlock_) - osrBlock_ = NULL; + osrBlock_ = nullptr; if (exitAccumulator_) { size_t i = 0; @@ -140,7 +140,7 @@ MIRGraph::forkJoinSlice() MBasicBlock *entry = entryBlock(); JS_ASSERT(entry->info().executionMode() == ParallelExecution); - MInstruction *start = NULL; + MInstruction *start = nullptr; for (MInstructionIterator ins(entry->begin()); ins != entry->end(); ins++) { if (ins->isForkJoinSlice()) return *ins; @@ -158,14 +158,14 @@ MBasicBlock * MBasicBlock::New(MIRGraph &graph, BytecodeAnalysis *analysis, CompileInfo &info, MBasicBlock *pred, jsbytecode *entryPc, Kind kind) { - JS_ASSERT(entryPc != NULL); + JS_ASSERT(entryPc != nullptr); MBasicBlock *block = new MBasicBlock(graph, info, entryPc, kind); if (!block->init()) - return NULL; + return nullptr; if (!block->inherit(analysis, pred, 0)) - return NULL; + return nullptr; return block; } @@ -176,10 +176,10 @@ MBasicBlock::NewPopN(MIRGraph &graph, CompileInfo &info, { MBasicBlock *block = new MBasicBlock(graph, info, entryPc, kind); if (!block->init()) - return NULL; + return nullptr; - if (!block->inherit(NULL, pred, popped)) - return NULL; + if (!block->inherit(nullptr, pred, popped)) + return nullptr; return block; } @@ -195,10 +195,10 @@ MBasicBlock::NewWithResumePoint(MIRGraph &graph, CompileInfo &info, block->entryResumePoint_ = resumePoint; if (!block->init()) - return NULL; + return nullptr; if (!block->inheritResumePoint(pred)) - return NULL; + return nullptr; return block; } @@ -207,14 +207,14 @@ MBasicBlock * MBasicBlock::NewPendingLoopHeader(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred, jsbytecode *entryPc) { - return MBasicBlock::New(graph, NULL, info, pred, entryPc, PENDING_LOOP_HEADER); + return MBasicBlock::New(graph, nullptr, info, pred, entryPc, PENDING_LOOP_HEADER); } MBasicBlock * MBasicBlock::NewSplitEdge(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred) { return pred->pc() - ? MBasicBlock::New(graph, NULL, info, pred, pred->pc(), SPLIT_EDGE) + ? MBasicBlock::New(graph, nullptr, info, pred, pred->pc(), SPLIT_EDGE) : MBasicBlock::NewAsmJS(graph, info, pred, SPLIT_EDGE); } @@ -229,10 +229,10 @@ MBasicBlock::NewAbortPar(MIRGraph &graph, CompileInfo &info, block->entryResumePoint_ = resumePoint; if (!block->init()) - return NULL; + return nullptr; if (!block->addPredecessorWithoutPhis(pred)) - return NULL; + return nullptr; block->end(new MAbortPar()); return block; @@ -241,9 +241,9 @@ MBasicBlock::NewAbortPar(MIRGraph &graph, CompileInfo &info, MBasicBlock * MBasicBlock::NewAsmJS(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred, Kind kind) { - MBasicBlock *block = new MBasicBlock(graph, info, /* entryPC = */ NULL, kind); + MBasicBlock *block = new MBasicBlock(graph, info, /* entryPC = */ nullptr, kind); if (!block->init()) - return NULL; + return nullptr; if (pred) { block->stackPosition_ = pred->stackPosition_; @@ -266,7 +266,7 @@ MBasicBlock::NewAsmJS(MIRGraph &graph, CompileInfo &info, MBasicBlock *pred, Kin } if (!block->predecessors_.append(pred)) - return NULL; + return nullptr; } return block; @@ -277,19 +277,19 @@ MBasicBlock::MBasicBlock(MIRGraph &graph, CompileInfo &info, jsbytecode *pc, Kin graph_(graph), info_(info), stackPosition_(info_.firstStackSlot()), - lastIns_(NULL), + lastIns_(nullptr), pc_(pc), - lir_(NULL), - start_(NULL), - entryResumePoint_(NULL), - successorWithPhis_(NULL), + lir_(nullptr), + start_(nullptr), + entryResumePoint_(nullptr), + successorWithPhis_(nullptr), positionInPhiSuccessor_(0), kind_(kind), loopDepth_(0), mark_(false), - immediateDominator_(NULL), + immediateDominator_(nullptr), numDominated_(0), - loopHeader_(NULL), + loopHeader_(nullptr), trackedPc_(pc) #if defined (JS_ION_PERF) , lineno_(0u), @@ -339,7 +339,7 @@ MBasicBlock::inherit(BytecodeAnalysis *analysis, MBasicBlock *pred, uint32_t pop JS_ASSERT(!entryResumePoint_); // Propagate the caller resume point from the inherited block. - MResumePoint *callerResumePoint = pred ? pred->callerResumePoint() : NULL; + MResumePoint *callerResumePoint = pred ? pred->callerResumePoint() : nullptr; // Create a resume point using our initial stack state. entryResumePoint_ = new MResumePoint(this, pc(), callerResumePoint, MResumePoint::ResumeAt); @@ -385,7 +385,7 @@ MBasicBlock::inheritResumePoint(MBasicBlock *pred) JS_ASSERT(info_.nslots() >= stackPosition_); JS_ASSERT(kind_ != PENDING_LOOP_HEADER); - JS_ASSERT(pred != NULL); + JS_ASSERT(pred != nullptr); if (!predecessors_.append(pred)) return false; @@ -622,7 +622,7 @@ MBasicBlock::discardLastIns() { JS_ASSERT(lastIns_); discard(lastIns_); - lastIns_ = NULL; + lastIns_ = nullptr; } void @@ -710,7 +710,7 @@ MBasicBlock::discardAllInstructions() iter->discardOperand(i); iter = instructions_.removeAt(iter); } - lastIns_ = NULL; + lastIns_ = nullptr; } void @@ -723,7 +723,7 @@ MBasicBlock::discardAllPhiOperands() } for (MBasicBlock **pred = predecessors_.begin(); pred != predecessors_.end(); pred++) - (*pred)->setSuccessorWithPhis(NULL, 0); + (*pred)->setSuccessorWithPhis(nullptr, 0); } void @@ -804,7 +804,7 @@ MBasicBlock::discardPhiAt(MPhiIterator &at) if (phis_.empty()) { for (MBasicBlock **pred = predecessors_.begin(); pred != predecessors_.end(); pred++) - (*pred)->setSuccessorWithPhis(NULL, 0); + (*pred)->setSuccessorWithPhis(nullptr, 0); } return result; } @@ -1072,7 +1072,7 @@ MBasicBlock::replacePredecessor(MBasicBlock *old, MBasicBlock *split) void MBasicBlock::clearDominatorInfo() { - setImmediateDominator(NULL); + setImmediateDominator(nullptr); immediatelyDominated_.clear(); numDominated_ = 0; } @@ -1155,11 +1155,11 @@ MBasicBlock::immediateDominatorBranch(BranchDirection *pdirection) *pdirection = FALSE_BRANCH; if (numPredecessors() != 1) - return NULL; + return nullptr; MBasicBlock *dom = immediateDominator(); if (dom != getPredecessor(0)) - return NULL; + return nullptr; // Look for a trailing MTest branching to this block. MInstruction *ins = dom->lastIns(); @@ -1168,13 +1168,13 @@ MBasicBlock::immediateDominatorBranch(BranchDirection *pdirection) JS_ASSERT(test->ifTrue() == this || test->ifFalse() == this); if (test->ifTrue() == this && test->ifFalse() == this) - return NULL; + return nullptr; *pdirection = (test->ifTrue() == this) ? TRUE_BRANCH : FALSE_BRANCH; return test; } - return NULL; + return nullptr; } void diff --git a/js/src/jit/MIRGraph.h b/js/src/jit/MIRGraph.h index 0933c438c0a..bfd6c2dae99 100644 --- a/js/src/jit/MIRGraph.h +++ b/js/src/jit/MIRGraph.h @@ -65,7 +65,7 @@ class MBasicBlock : public TempObject, public InlineListNode ////////// BEGIN GRAPH BUILDING INSTRUCTIONS ////////// /////////////////////////////////////////////////////// - // Creates a new basic block for a MIR generator. If |pred| is not NULL, + // Creates a new basic block for a MIR generator. If |pred| is not nullptr, // its slots and stack depth are initialized from |pred|. static MBasicBlock *New(MIRGraph &graph, BytecodeAnalysis *analysis, CompileInfo &info, MBasicBlock *pred, jsbytecode *entryPc, Kind kind); @@ -149,8 +149,8 @@ class MBasicBlock : public TempObject, public InlineListNode MDefinition *pop(); void popn(uint32_t n); - // Adds an instruction to this block's instruction list. |ins| may be NULL - // to simplify OOM checking. + // Adds an instruction to this block's instruction list. |ins| may be + // nullptr to simplify OOM checking. void add(MInstruction *ins); // Marks the last instruction of the block; no further instructions @@ -550,11 +550,11 @@ class MIRGraph public: MIRGraph(TempAllocator *alloc) : alloc_(alloc), - exitAccumulator_(NULL), + exitAccumulator_(nullptr), blockIdGen_(0), idGen_(0), - osrBlock_(NULL), - osrStart_(NULL), + osrBlock_(nullptr), + osrStart_(nullptr), numBlocks_(0), hasTryBlock_(false) { } diff --git a/js/src/jit/MoveResolver.cpp b/js/src/jit/MoveResolver.cpp index 68268ec3013..522bd3b1747 100644 --- a/js/src/jit/MoveResolver.cpp +++ b/js/src/jit/MoveResolver.cpp @@ -49,7 +49,7 @@ MoveResolver::findBlockingMove(const PendingMove *last) } // No blocking moves found. - return NULL; + return nullptr; } bool diff --git a/js/src/jit/ParallelFunctions.cpp b/js/src/jit/ParallelFunctions.cpp index e8b0a57a0bc..1bbea8ebc25 100644 --- a/js/src/jit/ParallelFunctions.cpp +++ b/js/src/jit/ParallelFunctions.cpp @@ -127,7 +127,7 @@ jit::CheckOverRecursedPar(ForkJoinSlice *slice) if (!JS_CHECK_STACK_SIZE(realStackLimit, &stackDummy_)) { slice->bailoutRecord->setCause(ParallelBailoutOverRecursed, - NULL, NULL, NULL); + nullptr, nullptr, nullptr); return false; } @@ -160,7 +160,7 @@ jit::PushPar(PushParArgs *args) JSObject::EnsureDenseResult res = args->object->parExtendDenseElements(slice, &args->value, 1); if (res != JSObject::ED_OK) - return NULL; + return nullptr; return args->object; } @@ -168,9 +168,9 @@ JSObject * jit::ExtendArrayPar(ForkJoinSlice *slice, JSObject *array, uint32_t length) { JSObject::EnsureDenseResult res = - array->parExtendDenseElements(slice, NULL, length); + array->parExtendDenseElements(slice, nullptr, length); if (res != JSObject::ED_OK) - return NULL; + return nullptr; return array; } @@ -471,8 +471,8 @@ jit::AbortPar(ParallelBailoutCause cause, JSScript *outermostScript, JSScript *c (currentScript ? PCToLineNumber(currentScript, bytecode) : 0)); JS_ASSERT(InParallelSection()); - JS_ASSERT(outermostScript != NULL); - JS_ASSERT(currentScript != NULL); + JS_ASSERT(outermostScript != nullptr); + JS_ASSERT(currentScript != nullptr); JS_ASSERT(outermostScript->hasParallelIonScript()); ForkJoinSlice *slice = ForkJoinSlice::Current(); @@ -497,7 +497,7 @@ jit::PropagateAbortPar(JSScript *outermostScript, JSScript *currentScript) ForkJoinSlice *slice = ForkJoinSlice::Current(); if (currentScript) - slice->bailoutRecord->addTrace(currentScript, NULL); + slice->bailoutRecord->addTrace(currentScript, nullptr); } void diff --git a/js/src/jit/ParallelFunctions.h b/js/src/jit/ParallelFunctions.h index ca91ab46531..2a2cda55cd8 100644 --- a/js/src/jit/ParallelFunctions.h +++ b/js/src/jit/ParallelFunctions.h @@ -28,11 +28,11 @@ struct PushParArgs { }; // Extends the given object with the given value (like `Array.push`). -// Returns NULL on failure or else `args->object`, which is convenient +// Returns nullptr on failure or else `args->object`, which is convenient // during code generation. JSObject *PushPar(PushParArgs *args); -// Extends the given array with `length` new holes. Returns NULL on +// Extends the given array with `length` new holes. Returns nullptr on // failure or else `array`, which is convenient during code // generation. JSObject *ExtendArrayPar(ForkJoinSlice *slice, JSObject *array, uint32_t length); diff --git a/js/src/jit/ParallelSafetyAnalysis.cpp b/js/src/jit/ParallelSafetyAnalysis.cpp index 56addc9323e..73f91f4f3a9 100644 --- a/js/src/jit/ParallelSafetyAnalysis.cpp +++ b/js/src/jit/ParallelSafetyAnalysis.cpp @@ -90,7 +90,7 @@ class ParallelSafetyVisitor : public MInstructionVisitor ParallelSafetyVisitor(MIRGraph &graph) : graph_(graph), unsafe_(false), - slice_(NULL) + slice_(nullptr) { } void clearUnsafe() { unsafe_ = false; } @@ -327,7 +327,7 @@ ParallelSafetyAnalysis::analyze() // if we encounter an inherently unsafe operation, in // which case we will transform this block into a bailout // block. - MInstruction *instr = NULL; + MInstruction *instr = nullptr; for (MInstructionIterator ins(block->begin()); ins != block->end() && !visitor.unsafe();) { @@ -412,14 +412,14 @@ ParallelSafetyAnalysis::removeResumePointOperands() // But the call to foo() is dead and has been removed, leading to // an inconsistent IR and assertions at codegen time. - MConstant *udef = NULL; + MConstant *udef = nullptr; for (ReversePostorderIterator block(graph_.rpoBegin()); block != graph_.rpoEnd(); block++) { if (udef) replaceOperandsOnResumePoint(block->entryResumePoint(), udef); for (MInstructionIterator ins(block->begin()); ins != block->end(); ins++) { if (ins->isStart()) { - JS_ASSERT(udef == NULL); + JS_ASSERT(udef == nullptr); udef = MConstant::New(UndefinedValue()); block->insertAfter(*ins, udef); } else if (udef) { @@ -474,7 +474,7 @@ ParallelSafetyVisitor::convertToBailout(MBasicBlock *block, MInstruction *ins) // if `block` had phis, we are replacing it with `bailBlock` which does not if (pred->successorWithPhis() == block) - pred->setSuccessorWithPhis(NULL, 0); + pred->setSuccessorWithPhis(nullptr, 0); // redirect the predecessor to the bailout block uint32_t succIdx = pred->getSuccessorIndex(block); @@ -558,7 +558,7 @@ ParallelSafetyVisitor::visitRest(MRest *ins) bool ParallelSafetyVisitor::visitMathFunction(MMathFunction *ins) { - return replace(ins, MMathFunction::New(ins->input(), ins->function(), NULL)); + return replace(ins, MMathFunction::New(ins->input(), ins->function(), nullptr)); } bool diff --git a/js/src/jit/PcScriptCache.h b/js/src/jit/PcScriptCache.h index cf4cb757854..9b040908f66 100644 --- a/js/src/jit/PcScriptCache.h +++ b/js/src/jit/PcScriptCache.h @@ -36,7 +36,7 @@ struct PcScriptCache void clear(uint64_t gcNumber) { for (uint32_t i = 0; i < Length; i++) - entries[i].returnAddress = NULL; + entries[i].returnAddress = nullptr; this->gcNumber = gcNumber; } diff --git a/js/src/jit/PerfSpewer.cpp b/js/src/jit/PerfSpewer.cpp index a4428d31fce..ff1da251bcc 100644 --- a/js/src/jit/PerfSpewer.cpp +++ b/js/src/jit/PerfSpewer.cpp @@ -46,7 +46,7 @@ static uint32_t PerfMode = 0; static bool PerfChecked = false; -static FILE *PerfFilePtr = NULL; +static FILE *PerfFilePtr = nullptr; #ifdef JS_THREADSAFE # include "jslock.h" @@ -75,7 +75,7 @@ void js::jit::CheckPerf() { if (!PerfChecked) { const char *env = getenv("IONPERF"); - if (env == NULL) { + if (env == nullptr) { PerfMode = PERF_MODE_NONE; fprintf(stderr, "Warning: JIT perf reporting requires IONPERF set to \"block\" or \"func\". "); fprintf(stderr, "Perf mapping will be deactivated.\n"); diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index b0c1586095b..86c3c18d9e2 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -148,7 +148,7 @@ RangeAnalysis::addBetaNodes() MDefinition *left = compare->getOperand(0); MDefinition *right = compare->getOperand(1); int32_t bound; - MDefinition *val = NULL; + MDefinition *val = nullptr; JSOp jsop = compare->jsop(); @@ -163,8 +163,8 @@ RangeAnalysis::addBetaNodes() bound = right->toConstant()->value().toInt32(); val = left; } else if (left->type() == MIRType_Int32 && right->type() == MIRType_Int32) { - MDefinition *smaller = NULL; - MDefinition *greater = NULL; + MDefinition *smaller = nullptr; + MDefinition *greater = nullptr; if (jsop == JSOP_LT) { smaller = left; greater = right; @@ -310,7 +310,7 @@ Range::intersect(const Range *lhs, const Range *rhs, bool *emptyRange) *emptyRange = false; if (!lhs && !rhs) - return NULL; + return nullptr; if (!lhs) return new Range(*rhs); @@ -336,7 +336,7 @@ Range::intersect(const Range *lhs, const Range *rhs, bool *emptyRange) // (Bug 765127) if (newUpper < newLower) { *emptyRange = true; - return NULL; + return nullptr; } Range *r = new Range( @@ -371,8 +371,8 @@ Range::unionWith(const Range *other) } Range::Range(const MDefinition *def) - : symbolicLower_(NULL), - symbolicUpper_(NULL) + : symbolicLower_(nullptr), + symbolicUpper_(nullptr) { const Range *other = def->range(); if (!other) { @@ -382,12 +382,12 @@ Range::Range(const MDefinition *def) set(0, 1); else set(NoInt32LowerBound, NoInt32UpperBound, true, MaxDoubleExponent); - symbolicLower_ = symbolicUpper_ = NULL; + symbolicLower_ = symbolicUpper_ = nullptr; return; } *this = *other; - symbolicLower_ = symbolicUpper_ = NULL; + symbolicLower_ = symbolicUpper_ = nullptr; if (def->type() == MIRType_Boolean) wrapAroundToBoolean(); @@ -766,7 +766,7 @@ MPhi::computeRange() if (type() != MIRType_Int32 && type() != MIRType_Double) return; - Range *range = NULL; + Range *range = nullptr; JS_ASSERT(getOperand(0)->op() != MDefinition::Op_OsrValue); for (size_t i = 0, e = numOperands(); i < e; i++) { if (getOperand(i)->block()->earlyAbort()) { @@ -780,7 +780,7 @@ MPhi::computeRange() Range *input = getOperand(i)->range(); if (!input) { - range = NULL; + range = nullptr; break; } @@ -1146,7 +1146,7 @@ static Range *GetTypedArrayRange(int type) break; } - return NULL; + return nullptr; } void @@ -1258,7 +1258,7 @@ RangeAnalysis::analyzeLoop(MBasicBlock *header) if (!markBlocksInLoopBody(header, backedge)) return false; - LoopIterationBound *iterationBound = NULL; + LoopIterationBound *iterationBound = nullptr; MBasicBlock *block = backedge; do { @@ -1344,21 +1344,21 @@ LoopIterationBound * RangeAnalysis::analyzeLoopIterationCount(MBasicBlock *header, MTest *test, BranchDirection direction) { - SimpleLinearSum lhs(NULL, 0); + SimpleLinearSum lhs(nullptr, 0); MDefinition *rhs; bool lessEqual; if (!ExtractLinearInequality(test, direction, &lhs, &rhs, &lessEqual)) - return NULL; + return nullptr; // Ensure the rhs is a loop invariant term. if (rhs && rhs->block()->isMarked()) { if (lhs.term && lhs.term->block()->isMarked()) - return NULL; + return nullptr; MDefinition *temp = lhs.term; lhs.term = rhs; rhs = temp; if (!SafeSub(0, lhs.constant, &lhs.constant)) - return NULL; + return nullptr; lessEqual = !lessEqual; } @@ -1366,7 +1366,7 @@ RangeAnalysis::analyzeLoopIterationCount(MBasicBlock *header, // Ensure the lhs is a phi node from the start of the loop body. if (!lhs.term || !lhs.term->isPhi() || lhs.term->block() != header) - return NULL; + return nullptr; // Check that the value of the lhs changes by a constant amount with each // loop iteration. This requires that the lhs be written in every loop @@ -1374,14 +1374,14 @@ RangeAnalysis::analyzeLoopIterationCount(MBasicBlock *header, // the start of the iteration. if (lhs.term->toPhi()->numOperands() != 2) - return NULL; + return nullptr; // The first operand of the phi should be the lhs' value at the start of // the first executed iteration, and not a value written which could // replace the second operand below during the middle of execution. MDefinition *lhsInitial = lhs.term->toPhi()->getOperand(0); if (lhsInitial->block()->isMarked()) - return NULL; + return nullptr; // The second operand of the phi should be a value written by an add/sub // in every loop iteration, i.e. in a block which dominates the backedge. @@ -1389,13 +1389,13 @@ RangeAnalysis::analyzeLoopIterationCount(MBasicBlock *header, if (lhsWrite->isBeta()) lhsWrite = lhsWrite->getOperand(0); if (!lhsWrite->isAdd() && !lhsWrite->isSub()) - return NULL; + return nullptr; if (!lhsWrite->block()->isMarked()) - return NULL; + return nullptr; MBasicBlock *bb = header->backedge(); for (; bb != lhsWrite->block() && bb != header; bb = bb->immediateDominator()) {} if (bb != lhsWrite->block()) - return NULL; + return nullptr; SimpleLinearSum lhsModified = ExtractLinearSum(lhsWrite); @@ -1407,7 +1407,7 @@ RangeAnalysis::analyzeLoopIterationCount(MBasicBlock *header, // iteration, and if it were stored in another variable its use here would // be as an operand to a phi node for that variable. if (lhsModified.term != lhs.term) - return NULL; + return nullptr; LinearSum bound; @@ -1421,16 +1421,16 @@ RangeAnalysis::analyzeLoopIterationCount(MBasicBlock *header, if (rhs) { if (!bound.add(rhs, 1)) - return NULL; + return nullptr; } if (!bound.add(lhsInitial, -1)) - return NULL; + return nullptr; int32_t lhsConstant; if (!SafeSub(0, lhs.constant, &lhsConstant)) - return NULL; + return nullptr; if (!bound.add(lhsConstant)) - return NULL; + return nullptr; } else if (lhsModified.constant == -1 && lessEqual) { // The value of lhs is 'initial(lhs) - iterCount'. Similar to the above // case, an upper bound on the number of backedges executed is: @@ -1439,15 +1439,15 @@ RangeAnalysis::analyzeLoopIterationCount(MBasicBlock *header, // iterCount == initial(lhs) - rhs + lhsN if (!bound.add(lhsInitial, 1)) - return NULL; + return nullptr; if (rhs) { if (!bound.add(rhs, -1)) - return NULL; + return nullptr; } if (!bound.add(lhs.constant)) - return NULL; + return nullptr; } else { - return NULL; + return nullptr; } return new LoopIterationBound(header, test, bound); @@ -1515,12 +1515,12 @@ RangeAnalysis::analyzeLoopPhi(MBasicBlock *header, LoopIterationBound *loopBound if (modified.constant > 0) { if (initRange && initRange->hasInt32LowerBound()) phi->range()->setLower(initRange->lower()); - phi->range()->setSymbolicLower(new SymbolicBound(NULL, initialSum)); + phi->range()->setSymbolicLower(new SymbolicBound(nullptr, initialSum)); phi->range()->setSymbolicUpper(new SymbolicBound(loopBound, limitSum)); } else { if (initRange && initRange->hasInt32UpperBound()) phi->range()->setUpper(initRange->upper()); - phi->range()->setSymbolicUpper(new SymbolicBound(NULL, initialSum)); + phi->range()->setSymbolicUpper(new SymbolicBound(nullptr, initialSum)); phi->range()->setSymbolicLower(new SymbolicBound(loopBound, limitSum)); } @@ -1548,7 +1548,7 @@ SymbolicBoundIsValid(MBasicBlock *header, MBoundsCheck *ins, const SymbolicBound static inline MDefinition * ConvertLinearSum(MBasicBlock *block, const LinearSum &sum) { - MDefinition *def = NULL; + MDefinition *def = nullptr; for (size_t i = 0; i < sum.numTerms(); i++) { LinearTerm term = sum.term(i); diff --git a/js/src/jit/RangeAnalysis.h b/js/src/jit/RangeAnalysis.h index dc53337fb12..8e21d5b0206 100644 --- a/js/src/jit/RangeAnalysis.h +++ b/js/src/jit/RangeAnalysis.h @@ -48,10 +48,10 @@ struct SymbolicBound : public TempObject { // Any loop iteration bound from which this was derived. // - // If non-NULL, then 'sum' is only valid within the loop body, at points - // dominated by the loop bound's test (see LoopIterationBound). + // If non-nullptr, then 'sum' is only valid within the loop body, at + // points dominated by the loop bound's test (see LoopIterationBound). // - // If NULL, then 'sum' is always valid. + // If nullptr, then 'sum' is always valid. LoopIterationBound *loop; // Computed symbolic bound, see above. @@ -196,8 +196,8 @@ class Range : public TempObject { hasInt32UpperBound_(false), canHaveFractionalPart_(true), max_exponent_(MaxDoubleExponent), - symbolicLower_(NULL), - symbolicUpper_(NULL) + symbolicLower_(nullptr), + symbolicUpper_(nullptr) { JS_ASSERT_IF(!hasInt32LowerBound_, lower_ == JSVAL_INT_MIN); JS_ASSERT_IF(!hasInt32UpperBound_, upper_ == JSVAL_INT_MAX); @@ -208,8 +208,8 @@ class Range : public TempObject { hasInt32UpperBound_(false), canHaveFractionalPart_(f), max_exponent_(e), - symbolicLower_(NULL), - symbolicUpper_(NULL) + symbolicLower_(nullptr), + symbolicUpper_(nullptr) { JS_ASSERT(e >= (h == INT64_MIN ? MaxDoubleExponent : mozilla::FloorLog2(mozilla::Abs(h)))); JS_ASSERT(e >= (l == INT64_MIN ? MaxDoubleExponent : mozilla::FloorLog2(mozilla::Abs(l)))); @@ -228,8 +228,8 @@ class Range : public TempObject { hasInt32UpperBound_(other.hasInt32UpperBound_), canHaveFractionalPart_(other.canHaveFractionalPart_), max_exponent_(other.max_exponent_), - symbolicLower_(NULL), - symbolicUpper_(NULL) + symbolicLower_(nullptr), + symbolicUpper_(nullptr) { JS_ASSERT_IF(!hasInt32LowerBound_, lower_ == JSVAL_INT_MIN); JS_ASSERT_IF(!hasInt32UpperBound_, upper_ == JSVAL_INT_MAX); diff --git a/js/src/jit/RegisterAllocator.cpp b/js/src/jit/RegisterAllocator.cpp index cf19d3b5172..dc58cafd9d3 100644 --- a/js/src/jit/RegisterAllocator.cpp +++ b/js/src/jit/RegisterAllocator.cpp @@ -19,7 +19,7 @@ AllocationIntegrityState::record() if (!instructions.appendN(InstructionInfo(), graph.numInstructions())) return false; - if (!virtualRegisters.appendN((LDefinition *)NULL, graph.numVirtualRegisters())) + if (!virtualRegisters.appendN((LDefinition *)nullptr, graph.numVirtualRegisters())) return false; if (!blocks.reserve(graph.numBlocks())) diff --git a/js/src/jit/RegisterAllocator.h b/js/src/jit/RegisterAllocator.h index c4332fcd483..e11ba14cda9 100644 --- a/js/src/jit/RegisterAllocator.h +++ b/js/src/jit/RegisterAllocator.h @@ -254,7 +254,7 @@ class InstructionDataMap public: InstructionDataMap() - : insData_(NULL), + : insData_(nullptr), numIns_(0) { } diff --git a/js/src/jit/Registers.h b/js/src/jit/Registers.h index abdc0edeacf..fe224d7ecb3 100644 --- a/js/src/jit/Registers.h +++ b/js/src/jit/Registers.h @@ -111,10 +111,10 @@ class MachineState } bool has(Register reg) const { - return regs_[reg.code()] != NULL; + return regs_[reg.code()] != nullptr; } bool has(FloatRegister reg) const { - return fpregs_[reg.code()] != NULL; + return fpregs_[reg.code()] != nullptr; } uintptr_t read(Register reg) const { return *regs_[reg.code()]; diff --git a/js/src/jit/StupidAllocator.cpp b/js/src/jit/StupidAllocator.cpp index 7da1a081220..a956aa50a7a 100644 --- a/js/src/jit/StupidAllocator.cpp +++ b/js/src/jit/StupidAllocator.cpp @@ -45,7 +45,7 @@ StupidAllocator::init() if (!RegisterAllocator::init()) return false; - if (!virtualRegisters.appendN((LDefinition *)NULL, graph.numVirtualRegisters())) + if (!virtualRegisters.appendN((LDefinition *)nullptr, graph.numVirtualRegisters())) return false; for (size_t i = 0; i < graph.numBlocks(); i++) { @@ -278,7 +278,7 @@ StupidAllocator::syncForBlockEnd(LBlock *block, LInstruction *ins) for (size_t i = 0; i < registerCount; i++) syncRegister(ins, i); - LMoveGroup *group = NULL; + LMoveGroup *group = nullptr; MBasicBlock *successor = block->mir()->successorWithPhis(); if (successor) { diff --git a/js/src/jit/StupidAllocator.h b/js/src/jit/StupidAllocator.h index 7e242e723ac..1a39458c9e5 100644 --- a/js/src/jit/StupidAllocator.h +++ b/js/src/jit/StupidAllocator.h @@ -31,7 +31,7 @@ class StupidAllocator : public RegisterAllocator // Whether the physical register is not synced with the backing stack slot. bool dirty; - void set(uint32_t vreg, LInstruction *ins = NULL, bool dirty = false) { + void set(uint32_t vreg, LInstruction *ins = nullptr, bool dirty = false) { this->vreg = vreg; this->age = ins ? ins->id() : 0; this->dirty = dirty; diff --git a/js/src/jit/TypePolicy.cpp b/js/src/jit/TypePolicy.cpp index c926b37a2f1..f95055b9e21 100644 --- a/js/src/jit/TypePolicy.cpp +++ b/js/src/jit/TypePolicy.cpp @@ -95,7 +95,7 @@ BinaryStringPolicy::adjustInputs(MInstruction *ins) if (in->type() == MIRType_String) continue; - MInstruction *replace = NULL; + MInstruction *replace = nullptr; if (in->type() == MIRType_Int32 || in->type() == MIRType_Double) { replace = MToString::New(in); } else { diff --git a/js/src/jit/TypeRepresentationSet.cpp b/js/src/jit/TypeRepresentationSet.cpp index d8e447ece1c..e4221968944 100644 --- a/js/src/jit/TypeRepresentationSet.cpp +++ b/js/src/jit/TypeRepresentationSet.cpp @@ -100,7 +100,7 @@ TypeRepresentationSetBuilder::insert(TypeRepresentation *typeRepr) if (min == entries_.length()) return entries_.append(typeRepr); TypeRepresentation **insertLoc = &entries_[min]; - return entries_.insert(insertLoc, typeRepr) != NULL; + return entries_.insert(insertLoc, typeRepr) != nullptr; } bool @@ -156,7 +156,7 @@ TypeRepresentationSet::TypeRepresentationSet(size_t length, TypeRepresentationSet::TypeRepresentationSet() : length_(0), - entries_(NULL) + entries_(nullptr) {} bool diff --git a/js/src/jit/UnreachableCodeElimination.cpp b/js/src/jit/UnreachableCodeElimination.cpp index ba89e677562..f72329b650f 100644 --- a/js/src/jit/UnreachableCodeElimination.cpp +++ b/js/src/jit/UnreachableCodeElimination.cpp @@ -112,16 +112,16 @@ UnreachableCodeElimination::optimizableSuccessor(MBasicBlock *block) { // If the last instruction in `block` is a test instruction of a // constant value, returns the successor that the branch will - // always branch to at runtime. Otherwise, returns NULL. + // always branch to at runtime. Otherwise, returns nullptr. MControlInstruction *ins = block->lastIns(); if (!ins->isTest()) - return NULL; + return nullptr; MTest *testIns = ins->toTest(); MDefinition *v = testIns->getOperand(0); if (!v->isConstant()) - return NULL; + return nullptr; const Value &val = v->toConstant()->value(); BranchDirection bdir = ToBoolean(val) ? TRUE_BRANCH : FALSE_BRANCH; @@ -194,7 +194,7 @@ UnreachableCodeElimination::prunePointlessBranchesAndMarkReachableBlocks() block->end(gotoIns); MBasicBlock *successorWithPhis = block->successorWithPhis(); if (successorWithPhis && successorWithPhis != succ) - block->setSuccessorWithPhis(NULL, 0); + block->setSuccessorWithPhis(nullptr, 0); } return true; @@ -250,7 +250,7 @@ UnreachableCodeElimination::removeUnmarkedBlocksAndClearDominators() // predecessors need to have the successorWithPhis // flag cleared. for (size_t i = 0; i < block->numPredecessors(); i++) - block->getPredecessor(i)->setSuccessorWithPhis(NULL, 0); + block->getPredecessor(i)->setSuccessorWithPhis(nullptr, 0); } if (block->isLoopBackedge()) { diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 210ecfd2a2c..6ea8c48fafa 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -38,7 +38,7 @@ VMFunction::addToFunctions() static bool initialized = false; if (!initialized) { initialized = true; - functions = NULL; + functions = nullptr; } this->next = functions; functions = this; @@ -103,7 +103,7 @@ bool CheckOverRecursed(JSContext *cx) { // IonMonkey's stackLimit is equal to nativeStackLimit by default. When we - // want to trigger an operation callback, we set the ionStackLimit to NULL, + // want to trigger an operation callback, we set the ionStackLimit to nullptr, // which causes the stack limit check to fail. // // There are two states we're concerned about here: @@ -169,7 +169,7 @@ InitProp(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValue v if (name == cx->names().proto) return baseops::SetPropertyHelper(cx, obj, obj, id, 0, &rval, false); - return DefineNativeProperty(cx, obj, id, rval, NULL, NULL, JSPROP_ENUMERATE, 0, 0, 0); + return DefineNativeProperty(cx, obj, id, rval, nullptr, nullptr, JSPROP_ENUMERATE, 0, 0, 0); } template @@ -257,7 +257,7 @@ NewInitParallelArray(JSContext *cx, HandleObject templateObject) RootedObject obj(cx, ParallelArrayObject::newInstance(cx, TenuredObject)); if (!obj) - return NULL; + return nullptr; obj->setType(templateObject->type()); @@ -271,9 +271,9 @@ NewInitArray(JSContext *cx, uint32_t count, types::TypeObject *typeArg) NewObjectKind newKind = !type ? SingletonObject : GenericObject; if (type && type->isLongLivedForJITAlloc()) newKind = TenuredObject; - RootedObject obj(cx, NewDenseAllocatedArray(cx, count, NULL, newKind)); + RootedObject obj(cx, NewDenseAllocatedArray(cx, count, nullptr, newKind)); if (!obj) - return NULL; + return nullptr; if (!type) types::TypeScript::Monitor(cx, ObjectValue(*obj)); @@ -292,7 +292,7 @@ NewInitObject(JSContext *cx, HandleObject templateObject) RootedObject obj(cx, CopyInitializerObject(cx, templateObject, newKind)); if (!obj) - return NULL; + return nullptr; if (templateObject->hasSingletonType()) types::TypeScript::Monitor(cx, ObjectValue(*obj)); @@ -317,7 +317,7 @@ NewInitObjectWithClassPrototype(JSContext *cx, HandleObject templateObject) cx->global(), newKind); if (!obj) - return NULL; + return nullptr; obj->setType(templateObject->type()); @@ -383,19 +383,19 @@ ArrayConcatDense(JSContext *cx, HandleObject obj1, HandleObject obj2, HandleObje { Rooted arr1(cx, &obj1->as()); Rooted arr2(cx, &obj2->as()); - Rooted arrRes(cx, objRes ? &objRes->as() : NULL); + Rooted arrRes(cx, objRes ? &objRes->as() : nullptr); if (arrRes) { // Fast path if we managed to allocate an object inline. if (!js::array_concat_dense(cx, arr1, arr2, arrRes)) - return NULL; + return nullptr; return arrRes; } Value argv[] = { UndefinedValue(), ObjectValue(*arr1), ObjectValue(*arr2) }; AutoValueArray ava(cx, argv, 3); if (!js::array_concat(cx, 1, argv)) - return NULL; + return nullptr; return &argv[0].toObject(); } @@ -471,7 +471,7 @@ NewSlots(JSRuntime *rt, unsigned nslots) Value *slots = reinterpret_cast(rt->malloc_(nslots * sizeof(Value))); if (!slots) - return NULL; + return nullptr; for (unsigned i = 0; i < nslots; i++) slots[i] = UndefinedValue(); @@ -598,8 +598,8 @@ GetDynamicName(JSContext *cx, JSObject *scopeChain, JSString *str, Value *vp) return; } - Shape *shape = NULL; - JSObject *scope = NULL, *pobj = NULL; + Shape *shape = nullptr; + JSObject *scope = nullptr, *pobj = nullptr; if (LookupNameNoGC(cx, atom->asPropertyName(), scopeChain, &scope, &pobj, &shape)) { if (FetchNameNoGC(pobj, shape, MutableHandleValue::fromMarkedLocation(vp))) return; @@ -762,7 +762,7 @@ InitRestParameter(JSContext *cx, uint32_t length, Value *rest, HandleObject temp // slots. if (length > 0) { if (!arrRes->ensureElements(cx, length)) - return NULL; + return nullptr; arrRes->setDenseInitializedLength(length); arrRes->initDenseElements(0, rest, length); arrRes->setLengthInt32(length); @@ -773,7 +773,7 @@ InitRestParameter(JSContext *cx, uint32_t length, Value *rest, HandleObject temp NewObjectKind newKind = templateObj->type()->isLongLivedForJITAlloc() ? TenuredObject : GenericObject; - ArrayObject *arrRes = NewDenseCopiedArray(cx, length, rest, NULL, newKind); + ArrayObject *arrRes = NewDenseCopiedArray(cx, length, rest, nullptr, newKind); if (arrRes) arrRes->setType(templateObj->type()); return arrRes; diff --git a/js/src/jit/VMFunctions.h b/js/src/jit/VMFunctions.h index 90aa78b1ac3..2db56ee6584 100644 --- a/js/src/jit/VMFunctions.h +++ b/js/src/jit/VMFunctions.h @@ -43,10 +43,11 @@ struct PopValues // Contains information about a virtual machine function that can be called // from JIT code. Functions described in this manner must conform to a simple // protocol: the return type must have a special "failure" value (for example, -// false for bool, or NULL for Objects). If the function is designed to return -// a value that does not meet this requirement - such as object-or-NULL, or an -// integer, an optional, final outParam can be specified. In this case, the -// return type must be boolean to indicate failure. +// false for bool, or nullptr for Objects). If the function is designed to +// return a value that does not meet this requirement - such as +// object-or-nullptr, or an integer, an optional, final outParam can be +// specified. In this case, the return type must be boolean to indicate +// failure. // // All functions described by VMFunction take a JSContext * as a first // argument, and are treated as re-entrant into the VM and therefore fallible. @@ -92,7 +93,7 @@ struct VMFunction // constructor. If the C function use an outparam (!= Type_Void), then // the only valid failure/return type is boolean -- object pointers are // pointless because the wrapper will only use it to compare it against - // NULL before discarding its value. + // nullptr before discarding its value. DataType returnType; // Note: a maximum of seven root types is supported. @@ -188,7 +189,7 @@ struct VMFunction } VMFunction() - : wrapped(NULL), + : wrapped(nullptr), explicitArgs(0), argumentProperties(0), argumentPassedInFloatRegs(0), @@ -555,7 +556,7 @@ class AutoDetectInvalidation bool disabled_; public: - AutoDetectInvalidation(JSContext *cx, Value *rval, IonScript *ionScript = NULL) + AutoDetectInvalidation(JSContext *cx, Value *rval, IonScript *ionScript = nullptr) : cx_(cx), ionScript_(ionScript ? ionScript : GetTopIonJSScript(cx)->ionScript()), rval_(rval), diff --git a/js/src/jit/ValueNumbering.cpp b/js/src/jit/ValueNumbering.cpp index 3be1ab2ded6..b91ce3654ee 100644 --- a/js/src/jit/ValueNumbering.cpp +++ b/js/src/jit/ValueNumbering.cpp @@ -305,7 +305,7 @@ ValueNumberer::findDominatingDef(InstructionMap &defs, MDefinition *ins, size_t value.validUntil = index + ins->block()->numDominated(); if(!defs.put(ins->valueNumber(), value)) - return NULL; + return nullptr; dom = ins; } else { @@ -444,7 +444,7 @@ uint32_t MDefinition::valueNumber() const { JS_ASSERT(block_); - if (valueNumber_ == NULL) + if (valueNumber_ == nullptr) return 0; return valueNumber_->valueNumber(); } @@ -464,7 +464,7 @@ MDefinition * ValueNumberer::findSplit(MDefinition *def) { for (MDefinition *vncheck = def->valueNumberData()->classNext; - vncheck != NULL; + vncheck != nullptr; vncheck = vncheck->valueNumberData()->classNext) { if (!def->congruentTo(vncheck)) { IonSpew(IonSpew_GVN, "Proceeding with split because %d is not congruent to %d", @@ -472,7 +472,7 @@ ValueNumberer::findSplit(MDefinition *def) return vncheck; } } - return NULL; + return nullptr; } void @@ -481,9 +481,9 @@ ValueNumberer::breakClass(MDefinition *def) if (def->valueNumber() == def->id()) { IonSpew(IonSpew_GVN, "Breaking congruence with itself: %d", def->id()); ValueNumberData *defdata = def->valueNumberData(); - JS_ASSERT(defdata->classPrev == NULL); + JS_ASSERT(defdata->classPrev == nullptr); // If the def was the only member of the class, then there is nothing to do. - if (defdata->classNext == NULL) + if (defdata->classNext == nullptr) return; // If upon closer inspection, we are still equivalent to this class // then there isn't anything for us to do. @@ -510,10 +510,10 @@ ValueNumberer::breakClass(MDefinition *def) //lastOld is now the last element of the old list (congruent to //|def|) - lastOld->valueNumberData()->classNext = NULL; + lastOld->valueNumberData()->classNext = nullptr; #ifdef DEBUG - for (MDefinition *tmp = def; tmp != NULL; tmp = tmp->valueNumberData()->classNext) { + for (MDefinition *tmp = def; tmp != nullptr; tmp = tmp->valueNumberData()->classNext) { JS_ASSERT(tmp->valueNumber() == def->valueNumber()); JS_ASSERT(tmp->congruentTo(def)); JS_ASSERT(tmp != newRep); @@ -522,11 +522,11 @@ ValueNumberer::breakClass(MDefinition *def) //|newRep| is now the first element of a new list, therefore it is the //new canonical element. Mark the remaining elements in the list //(including |newRep|) - newdata->classPrev = NULL; + newdata->classPrev = nullptr; IonSpew(IonSpew_GVN, "Choosing a new representative: %d", newRep->id()); // make the VN of every member in the class the VN of the new representative number. - for (MDefinition *tmp = newRep; tmp != NULL; tmp = tmp->valueNumberData()->classNext) { + for (MDefinition *tmp = newRep; tmp != nullptr; tmp = tmp->valueNumberData()->classNext) { // if this instruction is already scheduled to be processed, don't do anything. if (tmp->isInWorklist()) continue; @@ -551,7 +551,7 @@ ValueNumberer::breakClass(MDefinition *def) defdata->classNext->valueNumberData()->classPrev = defdata->classPrev; // Make sure there is no nastinees accidentally linking elements into the old list later. - defdata->classPrev = NULL; - defdata->classNext = NULL; + defdata->classPrev = nullptr; + defdata->classNext = nullptr; } } diff --git a/js/src/jit/ValueNumbering.h b/js/src/jit/ValueNumbering.h index 6225f258add..763588c7e7d 100644 --- a/js/src/jit/ValueNumbering.h +++ b/js/src/jit/ValueNumbering.h @@ -96,7 +96,7 @@ class ValueNumberData : public TempObject { MDefinition *classPrev; public: - ValueNumberData() : number(0), classNext(NULL), classPrev(NULL) {} + ValueNumberData() : number(0), classNext(nullptr), classPrev(nullptr) {} void setValueNumber(uint32_t number_) { number = number_;