Bug 950701 - SpiderMonkey: Tidy up some uses of the Vector API. r=waldo
authorDan Gohman <sunfish@google.com>
Mon, 16 Dec 2013 22:47:04 -0800
changeset 176777 f75c03ae992c397cef4ac556c82a6e69f08d108a
parent 176776 d9da95c84b246e266e4d3526ae75a154e428d643
child 176778 c93234bf8a979a56993e89cdb9c92d35468696bc
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs950701
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 950701 - SpiderMonkey: Tidy up some uses of the Vector API. r=waldo
js/src/jit/AsmJS.cpp
js/src/jit/AsmJSModule.cpp
js/src/jit/BaselineCompiler.cpp
js/src/jit/CodeGenerator.cpp
js/src/jit/IonBuilder.cpp
js/src/jit/IonBuilder.h
js/src/jit/LIR.cpp
js/src/jit/MIR.cpp
js/src/jit/MIR.h
js/src/jit/PerfSpewer.cpp
js/src/jit/TypeRepresentationSet.cpp
js/src/jit/shared/BaselineCompiler-shared.h
js/src/jit/shared/CodeGenerator-shared.cpp
--- a/js/src/jit/AsmJS.cpp
+++ b/js/src/jit/AsmJS.cpp
@@ -2532,19 +2532,18 @@ class FunctionCompiler
         }
         curBlock_ = body;
         return true;
     }
 
   private:
     ParseNode *popLoop()
     {
-        ParseNode *pn = loopStack_.back();
+        ParseNode *pn = loopStack_.popCopy();
         JS_ASSERT(!unlabeledContinues_.has(pn));
-        loopStack_.popBack();
         breakableStack_.popBack();
         return pn;
     }
 
   public:
     bool closeLoop(MBasicBlock *loopEntry, MBasicBlock *afterLoop)
     {
         ParseNode *pn = popLoop();
--- a/js/src/jit/AsmJSModule.cpp
+++ b/js/src/jit/AsmJSModule.cpp
@@ -460,17 +460,17 @@ SerializedNameSize(PropertyName *name)
 {
     return sizeof(uint32_t) +
            (name ? name->length() * sizeof(jschar) : 0);
 }
 
 static uint8_t *
 SerializeName(uint8_t *cursor, PropertyName *name)
 {
-    JS_ASSERT_IF(name, name->length() != 0);
+    JS_ASSERT_IF(name, !name->empty());
     if (name) {
         cursor = WriteScalar<uint32_t>(cursor, name->length());
         cursor = WriteBytes(cursor, name->chars(), name->length() * sizeof(jschar));
     } else {
         cursor = WriteScalar<uint32_t>(cursor, 0);
     }
     return cursor;
 }
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -689,17 +689,17 @@ BaselineCompiler::emitDebugTrap()
     bool enabled = script->stepModeEnabled() || script->hasBreakpointsAt(pc);
 
     // Emit patchable call to debug trap handler.
     IonCode *handler = cx->runtime()->jitRuntime()->debugTrapHandler(cx);
     mozilla::DebugOnly<CodeOffsetLabel> offset = masm.toggledCall(handler, enabled);
 
 #ifdef DEBUG
     // Patchable call offset has to match the pc mapping offset.
-    PCMappingEntry &entry = pcMappingEntries_[pcMappingEntries_.length() - 1];
+    PCMappingEntry &entry = pcMappingEntries_.back();
     JS_ASSERT((&offset)->offset() == entry.nativeOffset);
 #endif
 
     // Add an IC entry for the return offset -> pc mapping.
     ICEntry icEntry(script->pcToOffset(pc), false);
     icEntry.setReturnOffset(masm.currentOffset());
     if (!icEntries_.append(icEntry))
         return false;
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -6036,17 +6036,17 @@ CodeGenerator::link(JSContext *cx, types
         }
     }
 
     SetIonScript(script, executionMode, ionScript);
 
     // In parallel execution mode, when we first compile a script, we
     // don't know that its potential callees are compiled, so set a
     // flag warning that the callees may not be fully compiled.
-    if (callTargets.length() != 0)
+    if (!callTargets.empty())
         ionScript->setHasUncompiledCallTarget();
 
     invalidateEpilogueData_.fixup(&masm);
     Assembler::patchDataWithValueCheck(CodeLocationLabel(code, invalidateEpilogueData_),
                                        ImmPtr(ionScript),
                                        ImmPtr((void*)-1));
 
     IonSpew(IonSpew_Codegen, "Created IonScript %p (raw %p)",
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -257,17 +257,17 @@ IonBuilder::getSingleCallTarget(types::T
 
     return &obj->as<JSFunction>();
 }
 
 bool
 IonBuilder::getPolyCallTargets(types::TemporaryTypeSet *calleeTypes, bool constructing,
                                ObjectVector &targets, uint32_t maxTargets, bool *gotLambda)
 {
-    JS_ASSERT(targets.length() == 0);
+    JS_ASSERT(targets.empty());
     JS_ASSERT(gotLambda);
     *gotLambda = false;
 
     if (!calleeTypes)
         return true;
 
     if (calleeTypes->baseFlags() != 0)
         return true;
@@ -3929,17 +3929,17 @@ IonBuilder::inlineScriptedCall(CallInfo 
     if (instrumentedProfiling())
         returnBlock->add(MFunctionBoundary::New(alloc(), nullptr, MFunctionBoundary::Inline_Exit));
 
     // Inherit the slots from current and pop |fun|.
     returnBlock->inheritSlots(current);
     returnBlock->pop();
 
     // Accumulate return values.
-    if (returns.length() == 0) {
+    if (returns.empty()) {
         // Inlining of functions that have no exit is not supported.
         calleeScript->setUninlineable();
         abortReason_ = AbortReason_Inlining;
         return false;
     }
     MDefinition *retvalDefn = patchInlinedReturns(callInfo, returns, returnBlock);
     if (!retvalDefn)
         return false;
@@ -4200,17 +4200,17 @@ IonBuilder::inlineSingleCall(CallInfo &c
 
 IonBuilder::InliningStatus
 IonBuilder::inlineCallsite(ObjectVector &targets, ObjectVector &originals,
                            bool lambda, CallInfo &callInfo)
 {
     if (!inliningEnabled())
         return InliningStatus_NotInlined;
 
-    if (targets.length() == 0)
+    if (targets.empty())
         return InliningStatus_NotInlined;
 
     // Is the function provided by an MGetPropertyCache?
     // If so, the cache may be movable to a fallback path, with a dispatch
     // instruction guarding on the incoming TypeObject.
     MGetPropertyCache *propCache = getInlineableGetPropertyCache(callInfo);
 
     // Inline single targets -- unless they derive from a cache, in which case
@@ -4987,17 +4987,17 @@ IonBuilder::jsop_funapplyarguments(uint3
     MPassArg *passVp = current->pop()->toPassArg();
     passVp->getArgument()->setFoldedUnchecked();
     passVp->replaceAllUsesWith(passVp->getArgument());
     passVp->block()->discard(passVp);
 
     // Arguments
     MDefinitionVector args(alloc());
     if (inliningDepth_) {
-        if (!args.append(inlineCallInfo_->argv().begin(), inlineCallInfo_->argv().end()))
+        if (!args.appendAll(inlineCallInfo_->argv()))
             return false;
     }
     callInfo.setArgs(&args);
 
     // This
     MPassArg *passThis = current->pop()->toPassArg();
     MDefinition *argThis = passThis->getArgument();
     passThis->replaceAllUsesWith(argThis);
--- a/js/src/jit/IonBuilder.h
+++ b/js/src/jit/IonBuilder.h
@@ -861,24 +861,24 @@ class CallInfo
     { }
 
     bool init(CallInfo &callInfo) {
         JS_ASSERT(constructing_ == callInfo.constructing());
 
         fun_ = callInfo.fun();
         thisArg_ = callInfo.thisArg();
 
-        if (!args_.append(callInfo.argv().begin(), callInfo.argv().end()))
+        if (!args_.appendAll(callInfo.argv()))
             return false;
 
         return true;
     }
 
     bool init(MBasicBlock *current, uint32_t argc) {
-        JS_ASSERT(args_.length() == 0);
+        JS_ASSERT(args_.empty());
 
         // Get the arguments in the right order
         if (!args_.reserve(argc))
             return false;
         for (int32_t i = argc; i > 0; i--)
             args_.infallibleAppend(current->peek(-i));
         current->popn(argc);
 
@@ -904,18 +904,18 @@ class CallInfo
     uint32_t argc() const {
         return args_.length();
     }
     uint32_t numFormals() const {
         return argc() + 2;
     }
 
     void setArgs(MDefinitionVector *args) {
-        JS_ASSERT(args_.length() == 0);
-        args_.append(args->begin(), args->end());
+        JS_ASSERT(args_.empty());
+        args_.appendAll(*args);
     }
 
     MDefinitionVector &argv() {
         return args_;
     }
 
     const MDefinitionVector &argv() const {
         return args_;
--- a/js/src/jit/LIR.cpp
+++ b/js/src/jit/LIR.cpp
@@ -38,17 +38,17 @@ LIRGraph::addConstantToPool(const Value 
     *index = constantPool_.length();
     return constantPool_.append(v);
 }
 
 bool
 LIRGraph::noteNeedsSafepoint(LInstruction *ins)
 {
     // Instructions with safepoints must be in linear order.
-    JS_ASSERT_IF(safepoints_.length(), safepoints_[safepoints_.length() - 1]->id() < ins->id());
+    JS_ASSERT_IF(!safepoints_.empty(), safepoints_.back()->id() < ins->id());
     if (!ins->isCall() && !nonCallSafepoints_.append(ins))
         return false;
     return safepoints_.append(ins);
 }
 
 void
 LIRGraph::removeBlock(size_t i)
 {
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -790,17 +790,17 @@ MPhi::removeOperand(size_t index)
 
     // truncate the inputs_ list:
     inputs_.shrinkBy(1);
 }
 
 MDefinition *
 MPhi::foldsTo(TempAllocator &alloc, bool useValueNumbers)
 {
-    JS_ASSERT(inputs_.length() != 0);
+    JS_ASSERT(!inputs_.empty());
 
     MDefinition *first = getOperand(0);
 
     for (size_t i = 1; i < inputs_.length(); i++) {
         // Phis need dominator information to fold based on value numbers. For
         // simplicity, we only compare SSA names right now (bug 714727).
         if (!EqualValues(false, getOperand(i), first))
             return this;
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -1109,17 +1109,17 @@ class MTableSwitch MOZ_FINAL
     static MTableSwitch *New(TempAllocator &alloc, MDefinition *ins, int32_t low, int32_t high);
 
     size_t numSuccessors() const {
         return successors_.length();
     }
 
     size_t addSuccessor(MBasicBlock *successor) {
         JS_ASSERT(successors_.length() < (size_t)(high_ - low_ + 2));
-        JS_ASSERT(successors_.length() != 0);
+        JS_ASSERT(!successors_.empty());
         successors_.append(successor);
         return successors_.length() - 1;
     }
 
     MBasicBlock *getSuccessor(size_t i) const {
         JS_ASSERT(i < numSuccessors());
         return successors_[i];
     }
@@ -1153,17 +1153,17 @@ class MTableSwitch MOZ_FINAL
         return getSuccessor(cases_[i]);
     }
 
     size_t numCases() const {
         return high() - low() + 1;
     }
 
     size_t addDefault(MBasicBlock *block) {
-        JS_ASSERT(successors_.length() == 0);
+        JS_ASSERT(successors_.empty());
         successors_.append(block);
         return 0;
     }
 
     void addCase(size_t successorIndex) {
         cases_.append(successorIndex);
     }
 
--- a/js/src/jit/PerfSpewer.cpp
+++ b/js/src/jit/PerfSpewer.cpp
@@ -180,17 +180,17 @@ PerfSpewer::startBasicBlock(MBasicBlock 
 }
 
 bool
 PerfSpewer::endBasicBlock(MacroAssembler &masm)
 {
     if (!PerfBlockEnabled())
         return true;
 
-    masm.bind(&basicBlocks_[basicBlocks_.length() - 1].end);
+    masm.bind(&basicBlocks_.back().end);
     return true;
 }
 
 bool
 PerfSpewer::noteEndInlineCode(MacroAssembler &masm)
 {
     if (!PerfBlockEnabled())
         return true;
@@ -367,17 +367,17 @@ AsmJSPerfSpewer::noteBlocksOffsets()
 }
 
 void
 js::jit::writePerfSpewerAsmJSBlocksMap(uintptr_t baseAddress, size_t funcStartOffset,
                                        size_t funcEndInlineOffset, size_t funcSize,
                                        const char *filename, const char *funcName,
                                        const js::jit::BasicBlocksVector &basicBlocks)
 {
-    if (!PerfBlockEnabled() || basicBlocks.length() == 0)
+    if (!PerfBlockEnabled() || basicBlocks.empty())
         return;
 
     if (!lockPerfMap())
         return;
 
     // function begins with the prologue, which is located before the first basic block
     size_t prologueSize = basicBlocks[0].startOffset - funcStartOffset;
     size_t cur = baseAddress + funcStartOffset + prologueSize;
--- a/js/src/jit/TypeRepresentationSet.cpp
+++ b/js/src/jit/TypeRepresentationSet.cpp
@@ -49,17 +49,17 @@ TypeRepresentationSetBuilder::TypeRepres
 {}
 
 bool
 TypeRepresentationSetBuilder::insert(TypeRepresentation *typeRepr)
 {
     if (invalid_)
         return true;
 
-    if (entries_.length() == 0)
+    if (entries_.empty())
         return entries_.append(typeRepr);
 
     // Check that this new type repr is of the same basic kind as the
     // ones we have seen thus far. If not, for example if we have an
     // `int` and a `struct`, then convert this set to the invalid set.
     TypeRepresentation *entry0 = entries_[0];
     if (typeRepr->kind() != entry0->kind()) {
         invalid_ = true;
--- a/js/src/jit/shared/BaselineCompiler-shared.h
+++ b/js/src/jit/shared/BaselineCompiler-shared.h
@@ -73,17 +73,17 @@ class BaselineCompilerShared
 
     ICEntry *allocateICEntry(ICStub *stub, bool isForOp) {
         if (!stub)
             return nullptr;
 
         // Create the entry and add it to the vector.
         if (!icEntries_.append(ICEntry(script->pcToOffset(pc), isForOp)))
             return nullptr;
-        ICEntry &vecEntry = icEntries_[icEntries_.length() - 1];
+        ICEntry &vecEntry = icEntries_.back();
 
         // Set the first stub for the IC entry to the fallback stub
         vecEntry.setFirstStub(stub);
 
         // Return pointer to the IC entry
         return &vecEntry;
     }
 
--- a/js/src/jit/shared/CodeGenerator-shared.cpp
+++ b/js/src/jit/shared/CodeGenerator-shared.cpp
@@ -389,17 +389,17 @@ bool
 CodeGeneratorShared::markSafepoint(LInstruction *ins)
 {
     return markSafepointAt(masm.currentOffset(), ins);
 }
 
 bool
 CodeGeneratorShared::markSafepointAt(uint32_t offset, LInstruction *ins)
 {
-    JS_ASSERT_IF(safepointIndices_.length(),
+    JS_ASSERT_IF(!safepointIndices_.empty(),
                  offset - safepointIndices_.back().displacement() >= sizeof(uint32_t));
     return safepointIndices_.append(SafepointIndex(offset, ins->safepoint()));
 }
 
 void
 CodeGeneratorShared::ensureOsiSpace()
 {
     // For a refresher, an invalidation point is of the form:
@@ -799,18 +799,17 @@ void
 CodeGeneratorShared::emitPreBarrier(Address address, MIRType type)
 {
     masm.patchableCallPreBarrier(address, type);
 }
 
 void
 CodeGeneratorShared::dropArguments(unsigned argc)
 {
-    for (unsigned i = 0; i < argc; i++)
-        pushedArgumentSlots_.popBack();
+    pushedArgumentSlots_.shrinkBy(argc);
 }
 
 bool
 CodeGeneratorShared::markArgumentSlots(LSafepoint *safepoint)
 {
     for (size_t i = 0; i < pushedArgumentSlots_.length(); i++) {
         if (!safepoint->addValueSlot(pushedArgumentSlots_[i]))
             return false;