haikuwebkit/PerformanceTests/ARES-6/Air/reg.js

141 lines
4.0 KiB
JavaScript
Raw Permalink Normal View History

Implement Air::allocateStack() in ES6 to see how much of a bad idea that is https://bugs.webkit.org/show_bug.cgi?id=158318 Reviewed by Saam Barati. PerformanceTests: This adds a new benchmark for us to play with called JSAir. It's a complete ES6 implementation of Air's allocateStack() phase along with all of Air needed to run that phase. This includes things like stack slots, registers, temporaries, basic blocks, instructions, and all of the code for iterating over, inspecting, and modifying those things. To make this work, JSC can now dump Air just before allocateStack() in the form of JS code that creates a Code object that matches exactly what C++ Air saw. This benchmark comprises four Air IRs: - Octane/gbemu's largest function, executeIteration. - Kraken/imaging-gaussian-blur's largest function in OSR entry mode, gaussuanBlur. - Octane/typescript's largest function that is actually hot, scanIdentifier. - JSAir's largest hot function, which is anonymous, so we call it by its hash (ACLj8C). This runs in about 2 seconds on my machine in JSC trunk. It includes both a commandline harness and a web harness. JSAir is almost exactly 100x slower in ES6 in WebKit than the C++ Air::allocateStack() phase on which it is based. JSAir uses the following ES6 features: - Symbol. - for-of. - arrow functions. - Map/Set. - let/const. - classes. All of these things are used in anger and should end up on the hot path. There is also code that uses Proxies, but it ends up being dead. We can improve this even more: I still need to add result validation: https://bugs.webkit.org/show_bug.cgi?id=158493 I want to make it use more ES6 features: https://bugs.webkit.org/show_bug.cgi?id=158497 * JSAir: Added. * JSAir/all.js: Added. * JSAir/allocate_stack.js: Added. (allocateStack.attemptAssignment): (allocateStack.assign): (allocateStack.interfere): (allocateStack.): (allocateStack): * JSAir/arg.js: Added. (Arg): (Arg.isAnyUse): (Arg.isColdUse): (Arg.isWarmUse): (Arg.cooled): (Arg.isEarlyUse): (Arg.isLateUse): (Arg.isAnyDef): (Arg.isEarlyDef): (Arg.isLateDef): (Arg.isZDef): (Arg.typeForB3Type): (Arg.widthForB3Type): (Arg.conservativeWidth): (Arg.minimumWidth): (Arg.bytes): (Arg.widthForBytes): (Arg.createTmp): (Arg.fromReg): (Arg.createImm): (Arg.createBigImm): (Arg.createBitImm): (Arg.createBitImm64): (Arg.createAddr): (Arg.createStack): (Arg.createCallArg): (Arg.createStackAddr): (Arg.isValidScale): (Arg.logScale): (Arg.createIndex): (Arg.createRelCond): (Arg.createResCond): (Arg.createDoubleCond): (Arg.createWidth): (Arg.prototype.get kind): (Arg.prototype.get isTmp): (Arg.prototype.get isImm): (Arg.prototype.get isBigImm): (Arg.prototype.get isBitImm): (Arg.prototype.get isBitImm64): (Arg.prototype.get isSomeImm): (Arg.prototype.get isAddr): (Arg.prototype.get isStack): (Arg.prototype.get isCallArg): (Arg.prototype.get isIndex): (Arg.prototype.get isMemory): (Arg.prototype.get isStackMemory): (Arg.prototype.get isRelCond): (Arg.prototype.get isResCond): (Arg.prototype.get isDoubleCond): (Arg.prototype.get isCondition): (Arg.prototype.get isWidth): (Arg.prototype.get isAlive): (Arg.prototype.get tmp): (Arg.prototype.get value): (Arg.prototype.get base): (Arg.prototype.get hasOffset): (Arg.prototype.get offset): (Arg.prototype.get stackSlot): (Arg.prototype.get index): (Arg.prototype.get scale): (Arg.prototype.get logScale): (Arg.prototype.get width): (Arg.prototype.get isGPTmp): (Arg.prototype.get isFPTmp): (Arg.prototype.get isGP): (Arg.prototype.get isFP): (Arg.prototype.get hasType): (Arg.prototype.get type): (Arg.prototype.isType): (Arg.prototype.isCompatibleType): (Arg.prototype.get isGPR): (Arg.prototype.get gpr): (Arg.prototype.get isFPR): (Arg.prototype.get fpr): (Arg.prototype.get isReg): (Arg.prototype.get reg): (Arg.isValidImmForm): (Arg.isValidBitImmForm): (Arg.isValidBitImm64Form): (Arg.isValidAddrForm): (Arg.isValidIndexForm): (Arg.prototype.isValidForm): (Arg.prototype.forEachTmpFast): (Arg.prototype.usesTmp): (Arg.prototype.forEachTmp): (Arg.prototype.is): (Arg.prototype.as): (Arg.prototype.forEachFast): (Arg.prototype.forEach): (Arg.extract): (Arg.forEachFast): (Arg.forEach): (Arg.prototype.get condition): (Arg.prototype.get isInvertible): (Arg.prototype.toString): * JSAir/basic_block.js: Added. (BasicBlock): (BasicBlock.prototype.get index): (BasicBlock.prototype.get size): (BasicBlock.prototype.Symbol.iterator): (BasicBlock.prototype.at): (BasicBlock.get last): (BasicBlock.get insts): (BasicBlock.get numSuccessors): (BasicBlock.get successors): (BasicBlock.get successorBlocks.): (BasicBlock.get successorBlocks): (BasicBlock.set get numPredecessors): (BasicBlock.get predecessors): (BasicBlock.get frequency): (BasicBlock.get headerString): (BasicBlock.get footerString): * JSAir/benchmark.js: Added. (benchmark): * JSAir/code.js: Added. (Code): (Code.prototype.addBlock): (Code.prototype.addStackSlot): (Code.prototype.newTmp): (Code.prototype.get size): (Code.prototype.at): (Code.prototype.Symbol.iterator): (Code.prototype.get blocks): (Code.prototype.get stackSlots): (Code.prototype.tmps): (Code.prototype.get callArgAreaSize): (Code.prototype.requestCallArgAreaSize): (Code.prototype.get frameSize): (Code.prototype.setFrameSize): (Code.prototype.toString): * JSAir/custom.js: Added. (const.ShuffleCustom.forEachArg): (const.ShuffleCustom.hasNonArgNonControlEffects): (const.PatchCustom.forEachArg): (const.PatchCustom.hasNonArgNonControlEffects): (const.CCallCustom.forEachArg): (const.CCallCustom.hasNonArgNonControlEffects): (const.ColdCCallCustom.forEachArg): (const.ColdCCallCustom.hasNonArgNonControlEffects): * JSAir/frequented_block.js: Added. (FrequentedBlock): (FrequentedBlock.prototype.toString): * JSAir/insertion_set.js: Added. (Insertion): (Insertion.prototype.get index): (Insertion.prototype.get element): (Insertion.prototype.lessThan): (InsertionSet): (InsertionSet.prototype.appendInsertion): (InsertionSet.prototype.append): (InsertionSet.prototype.execute): * JSAir/inst.js: Added. (Inst): (Inst.prototype.append): (Inst.prototype.clear): (Inst.prototype.get opcode): (Inst.prototype.get args): (Inst.prototype.visitArg): (Inst.prototype.forEachTmpFast): (Inst.prototype.forEachArg): (Inst.prototype.forEachTmp): (Inst.prototype.forEach): (Inst.forEachDef): (Inst.forEachDefWithExtraClobberedRegs): (Inst.prototype.get hasNonArgEffects): (Inst.prototype.toString): * JSAir/liveness.js: Added. (Liveness): (Liveness.prototype.get thing): (Liveness.prototype.get code): (Liveness.prototype.get liveAtHead): (Liveness.prototype.get liveAtTail): (Liveness.prototype.localCalc.LocalCalc): (Liveness.prototype.localCalc.LocalCalc.prototype.get liveSet): (Liveness.prototype.localCalc.LocalCalc.prototype.execute): (Liveness.prototype.localCalc): * JSAir/opcode.js: Added. (Inst_forEachArg): (Inst_hasNonArgEffects): * JSAir/payload-gbemu-executeIteration.js: Added. (createPayloadGbemuExecuteIteration): * JSAir/payload-imaging-gaussian-blur-gaussianBlur.js: Added. (createPayloadImagingGaussianBlurGaussianBlur): * JSAir/payload-jsair-ACLj8C.js: Added. (createPayloadJSAirACLj8C): * JSAir/payload-typescript-scanIdentifier.js: Added. (createPayloadTypescriptScanIdentifier): * JSAir/reg.js: Added. (Reg): (Reg.fromReg): (Reg.prototype.get index): (Reg.prototype.get type): (Reg.prototype.get name): (Reg.prototype.get isCalleeSave): (Reg.prototype.get isReg): (Reg.prototype.toString): (Reg.extract): (Reg.forEachFast): (Reg.forEach): (newGPR): (Reg.gprs.Reg.fprs.Reg.calleeSaveGPRs.Reg.calleeSaveFPRs.Reg.calleeSaves): * JSAir/stack_slot.js: Added. (StackSlot): (StackSlot.prototype.get byteSize): (StackSlot.prototype.get kind): (StackSlot.prototype.get isLocked): (StackSlot.prototype.get isSpill): (StackSlot.prototype.get index): (StackSlot.prototype.ensureSize): (StackSlot.prototype.get alignment): (StackSlot.prototype.get offsetFromFP): (StackSlot.prototype.setOffsetFromFP): (StackSlot.prototype.toString): (StackSlot.extract): (StackSlot.forEachFast): (StackSlot.forEach): * JSAir/symbols.js: Added. * JSAir/test.html: Added. * JSAir/test.js: Added. * JSAir/tmp.js: Added. (Tmp): (Tmp.fromReg): (Tmp.prototype.get index): (Tmp.prototype.get type): (Tmp.prototype.get isReg): (Tmp.prototype.toString): (Tmp.extract): (Tmp.forEachFast): (Tmp.forEach): * JSAir/tmp_base.js: Added. (TmpBase.prototype.get isGP): (TmpBase.prototype.get isFP): (TmpBase.prototype.get isGPR): (TmpBase.prototype.get isFPR): (TmpBase.prototype.get reg): (TmpBase.prototype.get gpr): (TmpBase.prototype.get fpr): (TmpBase): * JSAir/util.js: Added. (isRepresentableAsInt32): (addIndexed): (roundUpToMultipleOf): (symbolName): (mergeIntoSet): (nonEmptyRangesOverlap): (rangesOverlap): (removeAllMatching): (swap): (bubble): (bubbleSort): (currentTime): (else.currentTime): Source/JavaScriptCore: Most of these changes are to support dumpAsJS(). But I also found some duplicate and dead code while rewriting it to JS. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/air/AirAllocateStack.cpp: * b3/air/AirArg.h: (JSC::B3::Air::Arg::isSomeImm): (JSC::B3::Air::Arg::isAddr): (JSC::B3::Air::Arg::tmpIndex): (JSC::B3::Air::Arg::isValidImmForm): (JSC::B3::Air::Arg::withOffset): Deleted. This was dead code. * b3/air/AirArgInlines.h: It turns out that Inst has a ForEach thing that duplicated some of the logic of ArgThingHelper, so I just made ArgThingHelper more powerful. (JSC::B3::Air::ArgThingHelper<Arg>::forEach): (JSC::B3::Air::ArgThingHelper<Reg>::is): (JSC::B3::Air::ArgThingHelper<Reg>::as): (JSC::B3::Air::ArgThingHelper<Reg>::forEachFast): (JSC::B3::Air::ArgThingHelper<Reg>::forEach): (JSC::B3::Air::Arg::is): * b3/air/AirDumpAsJS.cpp: Added. (JSC::B3::Air::dumpAsJS): * b3/air/AirDumpAsJS.h: Added. * b3/air/AirFixObviousSpills.cpp: * b3/air/AirGenerate.cpp: (JSC::B3::Air::prepareForGeneration): * b3/air/AirInstInlines.h: (JSC::B3::Air::Inst::forEach): (JSC::B3::Air::Inst::extraClobberedRegs): (JSC::B3::Air::ForEach<Tmp>::forEach): Deleted. This was doing what ArgThingHelper would have done but not as well. (JSC::B3::Air::ForEach<Arg>::forEach): Deleted. (JSC::B3::Air::ForEach<Reg>::forEach): Deleted. * b3/air/AirLogRegisterPressure.cpp: * b3/air/AirReportUsedRegisters.cpp: * b3/air/AirSpillEverything.cpp: * b3/air/opcode_generator.rb: Make this dump opcode.js, which is like what it dumps for C++. * jit/Reg.cpp: (JSC::Reg::debugName): (JSC::Reg::dump): * jit/Reg.h: (JSC::Reg::hash): * jsc.cpp: Fix jsc so that it reports the filename and line number of parser errors. (dumpException): * parser/ParserError.h: Make it easier to debug this code. (WTF::printInternal): * runtime/Options.h: Source/WTF: * wtf/Insertion.h: (WTF::executeInsertions): I found a bug while rewriting this code in JS. * wtf/PrintStream.h: (WTF::PrintStream::print): (WTF::PrintStream::println): This is useful to have. Canonical link: https://commits.webkit.org/176569@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 01:43:35 +00:00
/*
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
"use strict";
class Reg extends TmpBase {
constructor(index, type, name, isCalleeSave)
{
super();
this._index = index;
this._type = type;
this._name = name;
this._isCalleeSave = !!isCalleeSave;
}
static fromReg(reg)
{
return reg;
}
get index() { return this._index; }
get type() { return this._type; }
get name() { return this._name; }
get isCalleeSave() { return this._isCalleeSave; }
get isReg() { return true; }
Add result validation to JSAir https://bugs.webkit.org/show_bug.cgi?id=158493 Reviewed by Saam Barati. PerformanceTests: This adds the ability to hash a Code in a way that matches the C++ code's hashing of Code. This allows us to check if the Code that JSAir sees is the code that C++ saw. We use this to check the Code before and after allocateStack, and compare against hashes we got from C++. Doing this uncovered bugs. roundUpToMultipleOf wasn't doing anything. allocateStack was not allocating things correctly because I was concatting a Set to an Array, which doesn't really work. Now these bugs are fixed. The checking step adds to the running time so I reduced the number of iterations. The benchmark spends a decent amount of its time computing Code hashes; I think it's around 1/3 total. This is probably OK. It's better to verify the results even if the running time is not all in the "core" of the algorithm. Also add a run-jsc-stress-tests yaml file to allow this to run as a test. * JSAir/allocate_stack.js: * JSAir/arg.js: (Arg.createImm): (Arg.createBigImm): (Arg.createBitImm): (Arg.createBitImm64): (Arg.createWidth): (Arg.createSpecial): (Arg.prototype.get kind): (Arg.prototype.get isTmp): (Arg.prototype.get isImm): (Arg.prototype.get isSomeImm): (Arg.prototype.get isSomeBigImm): (Arg.prototype.get isCondition): (Arg.prototype.get isWidth): (Arg.prototype.get isSpecial): (Arg.prototype.get isAlive): (Arg.prototype.get tmp): (Arg.prototype.get value): (Arg.prototype.get lowValue): (Arg.prototype.get highValue): (Arg.prototype.get base): (Arg.prototype.get isGP): (Arg.prototype.get isFP): (Arg.prototype.isValidForm): (Arg.prototype.get isInvertible): (Arg.kindCode): (Arg.prototype.hash): (Arg.prototype.toString): (Arg): * JSAir/basic_block.js: (BasicBlock.get successorBlocks): * JSAir/benchmark.js: (benchmark): * JSAir/code.js: (Code.prototype.setFrameSize): (Code.prototype.hash): (Code.prototype.toString): (Code): * JSAir/inst.js: (Inst.prototype.get hasNonArgEffects): (Inst.prototype.hash): (Inst.prototype.toString): (Inst): * JSAir/jsair-tests.yaml: Added. * JSAir/opcode.js: (Inst_forEachArg): (Inst_hasNonArgEffects): (opcodeCode): * JSAir/payload-gbemu-executeIteration.js: (createPayloadGbemuExecuteIteration): * JSAir/payload-imaging-gaussian-blur-gaussianBlur.js: (createPayloadImagingGaussianBlurGaussianBlur): * JSAir/payload-jsair-ACLj8C.js: (createPayloadJSAirACLj8C): * JSAir/payload-typescript-scanIdentifier.js: (createPayloadTypescriptScanIdentifier): * JSAir/reg.js: (Reg.prototype.get isReg): (Reg.prototype.hash): (Reg.prototype.toString): * JSAir/stack_slot.js: (StackSlot.prototype.setOffsetFromFP): (StackSlot.prototype.hash): (StackSlot.prototype.toString): * JSAir/symbols.js: (relCondCode): (resCondCode): (doubleCondCode): * JSAir/test.html: * JSAir/tmp.js: (Tmp.prototype.get isReg): (Tmp.prototype.hash): (Tmp.prototype.toString): * JSAir/util.js: (roundUpToMultipleOf): (symbolName): Source/JavaScriptCore: Add a ::jsHash() method to some things, to compute a hash code that is suitable for comparing a C++ Code to a JSAir Code. This is different from existing hashing functionality because it errs on the side of easy reproducibility from JS rather than speed. * b3/air/AirArg.cpp: (JSC::B3::Air::Arg::isCompatibleType): (JSC::B3::Air::Arg::jsHash): (JSC::B3::Air::Arg::dump): * b3/air/AirArg.h: (JSC::B3::Air::Arg::asDoubleCondition): (JSC::B3::Air::Arg::isInvertible): (JSC::B3::Air::Arg::isUnsignedCond): (JSC::B3::Air::Arg::Arg): * b3/air/AirCode.cpp: (JSC::B3::Air::Code::addFastTmp): (JSC::B3::Air::Code::jsHash): * b3/air/AirCode.h: (JSC::B3::Air::Code::lastPhaseName): * b3/air/AirDumpAsJS.cpp: (JSC::B3::Air::dumpAsJS): * b3/air/AirGenerate.cpp: (JSC::B3::Air::prepareForGeneration): * b3/air/AirInst.cpp: (JSC::B3::Air::Inst::hasArgEffects): (JSC::B3::Air::Inst::jsHash): (JSC::B3::Air::Inst::dump): * b3/air/AirInst.h: * b3/air/AirStackSlot.cpp: (JSC::B3::Air::StackSlot::setOffsetFromFP): (JSC::B3::Air::StackSlot::jsHash): (JSC::B3::Air::StackSlot::dump): * b3/air/AirStackSlot.h: * b3/air/opcode_generator.rb: Tools: Run JSAir. * Scripts/run-javascriptcore-tests: (runJSCStressTests): Canonical link: https://commits.webkit.org/176590@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201807 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 17:21:52 +00:00
hash()
{
if (this.isGP)
return 1 + this._index;
return -1 - this._index;
}
Implement Air::allocateStack() in ES6 to see how much of a bad idea that is https://bugs.webkit.org/show_bug.cgi?id=158318 Reviewed by Saam Barati. PerformanceTests: This adds a new benchmark for us to play with called JSAir. It's a complete ES6 implementation of Air's allocateStack() phase along with all of Air needed to run that phase. This includes things like stack slots, registers, temporaries, basic blocks, instructions, and all of the code for iterating over, inspecting, and modifying those things. To make this work, JSC can now dump Air just before allocateStack() in the form of JS code that creates a Code object that matches exactly what C++ Air saw. This benchmark comprises four Air IRs: - Octane/gbemu's largest function, executeIteration. - Kraken/imaging-gaussian-blur's largest function in OSR entry mode, gaussuanBlur. - Octane/typescript's largest function that is actually hot, scanIdentifier. - JSAir's largest hot function, which is anonymous, so we call it by its hash (ACLj8C). This runs in about 2 seconds on my machine in JSC trunk. It includes both a commandline harness and a web harness. JSAir is almost exactly 100x slower in ES6 in WebKit than the C++ Air::allocateStack() phase on which it is based. JSAir uses the following ES6 features: - Symbol. - for-of. - arrow functions. - Map/Set. - let/const. - classes. All of these things are used in anger and should end up on the hot path. There is also code that uses Proxies, but it ends up being dead. We can improve this even more: I still need to add result validation: https://bugs.webkit.org/show_bug.cgi?id=158493 I want to make it use more ES6 features: https://bugs.webkit.org/show_bug.cgi?id=158497 * JSAir: Added. * JSAir/all.js: Added. * JSAir/allocate_stack.js: Added. (allocateStack.attemptAssignment): (allocateStack.assign): (allocateStack.interfere): (allocateStack.): (allocateStack): * JSAir/arg.js: Added. (Arg): (Arg.isAnyUse): (Arg.isColdUse): (Arg.isWarmUse): (Arg.cooled): (Arg.isEarlyUse): (Arg.isLateUse): (Arg.isAnyDef): (Arg.isEarlyDef): (Arg.isLateDef): (Arg.isZDef): (Arg.typeForB3Type): (Arg.widthForB3Type): (Arg.conservativeWidth): (Arg.minimumWidth): (Arg.bytes): (Arg.widthForBytes): (Arg.createTmp): (Arg.fromReg): (Arg.createImm): (Arg.createBigImm): (Arg.createBitImm): (Arg.createBitImm64): (Arg.createAddr): (Arg.createStack): (Arg.createCallArg): (Arg.createStackAddr): (Arg.isValidScale): (Arg.logScale): (Arg.createIndex): (Arg.createRelCond): (Arg.createResCond): (Arg.createDoubleCond): (Arg.createWidth): (Arg.prototype.get kind): (Arg.prototype.get isTmp): (Arg.prototype.get isImm): (Arg.prototype.get isBigImm): (Arg.prototype.get isBitImm): (Arg.prototype.get isBitImm64): (Arg.prototype.get isSomeImm): (Arg.prototype.get isAddr): (Arg.prototype.get isStack): (Arg.prototype.get isCallArg): (Arg.prototype.get isIndex): (Arg.prototype.get isMemory): (Arg.prototype.get isStackMemory): (Arg.prototype.get isRelCond): (Arg.prototype.get isResCond): (Arg.prototype.get isDoubleCond): (Arg.prototype.get isCondition): (Arg.prototype.get isWidth): (Arg.prototype.get isAlive): (Arg.prototype.get tmp): (Arg.prototype.get value): (Arg.prototype.get base): (Arg.prototype.get hasOffset): (Arg.prototype.get offset): (Arg.prototype.get stackSlot): (Arg.prototype.get index): (Arg.prototype.get scale): (Arg.prototype.get logScale): (Arg.prototype.get width): (Arg.prototype.get isGPTmp): (Arg.prototype.get isFPTmp): (Arg.prototype.get isGP): (Arg.prototype.get isFP): (Arg.prototype.get hasType): (Arg.prototype.get type): (Arg.prototype.isType): (Arg.prototype.isCompatibleType): (Arg.prototype.get isGPR): (Arg.prototype.get gpr): (Arg.prototype.get isFPR): (Arg.prototype.get fpr): (Arg.prototype.get isReg): (Arg.prototype.get reg): (Arg.isValidImmForm): (Arg.isValidBitImmForm): (Arg.isValidBitImm64Form): (Arg.isValidAddrForm): (Arg.isValidIndexForm): (Arg.prototype.isValidForm): (Arg.prototype.forEachTmpFast): (Arg.prototype.usesTmp): (Arg.prototype.forEachTmp): (Arg.prototype.is): (Arg.prototype.as): (Arg.prototype.forEachFast): (Arg.prototype.forEach): (Arg.extract): (Arg.forEachFast): (Arg.forEach): (Arg.prototype.get condition): (Arg.prototype.get isInvertible): (Arg.prototype.toString): * JSAir/basic_block.js: Added. (BasicBlock): (BasicBlock.prototype.get index): (BasicBlock.prototype.get size): (BasicBlock.prototype.Symbol.iterator): (BasicBlock.prototype.at): (BasicBlock.get last): (BasicBlock.get insts): (BasicBlock.get numSuccessors): (BasicBlock.get successors): (BasicBlock.get successorBlocks.): (BasicBlock.get successorBlocks): (BasicBlock.set get numPredecessors): (BasicBlock.get predecessors): (BasicBlock.get frequency): (BasicBlock.get headerString): (BasicBlock.get footerString): * JSAir/benchmark.js: Added. (benchmark): * JSAir/code.js: Added. (Code): (Code.prototype.addBlock): (Code.prototype.addStackSlot): (Code.prototype.newTmp): (Code.prototype.get size): (Code.prototype.at): (Code.prototype.Symbol.iterator): (Code.prototype.get blocks): (Code.prototype.get stackSlots): (Code.prototype.tmps): (Code.prototype.get callArgAreaSize): (Code.prototype.requestCallArgAreaSize): (Code.prototype.get frameSize): (Code.prototype.setFrameSize): (Code.prototype.toString): * JSAir/custom.js: Added. (const.ShuffleCustom.forEachArg): (const.ShuffleCustom.hasNonArgNonControlEffects): (const.PatchCustom.forEachArg): (const.PatchCustom.hasNonArgNonControlEffects): (const.CCallCustom.forEachArg): (const.CCallCustom.hasNonArgNonControlEffects): (const.ColdCCallCustom.forEachArg): (const.ColdCCallCustom.hasNonArgNonControlEffects): * JSAir/frequented_block.js: Added. (FrequentedBlock): (FrequentedBlock.prototype.toString): * JSAir/insertion_set.js: Added. (Insertion): (Insertion.prototype.get index): (Insertion.prototype.get element): (Insertion.prototype.lessThan): (InsertionSet): (InsertionSet.prototype.appendInsertion): (InsertionSet.prototype.append): (InsertionSet.prototype.execute): * JSAir/inst.js: Added. (Inst): (Inst.prototype.append): (Inst.prototype.clear): (Inst.prototype.get opcode): (Inst.prototype.get args): (Inst.prototype.visitArg): (Inst.prototype.forEachTmpFast): (Inst.prototype.forEachArg): (Inst.prototype.forEachTmp): (Inst.prototype.forEach): (Inst.forEachDef): (Inst.forEachDefWithExtraClobberedRegs): (Inst.prototype.get hasNonArgEffects): (Inst.prototype.toString): * JSAir/liveness.js: Added. (Liveness): (Liveness.prototype.get thing): (Liveness.prototype.get code): (Liveness.prototype.get liveAtHead): (Liveness.prototype.get liveAtTail): (Liveness.prototype.localCalc.LocalCalc): (Liveness.prototype.localCalc.LocalCalc.prototype.get liveSet): (Liveness.prototype.localCalc.LocalCalc.prototype.execute): (Liveness.prototype.localCalc): * JSAir/opcode.js: Added. (Inst_forEachArg): (Inst_hasNonArgEffects): * JSAir/payload-gbemu-executeIteration.js: Added. (createPayloadGbemuExecuteIteration): * JSAir/payload-imaging-gaussian-blur-gaussianBlur.js: Added. (createPayloadImagingGaussianBlurGaussianBlur): * JSAir/payload-jsair-ACLj8C.js: Added. (createPayloadJSAirACLj8C): * JSAir/payload-typescript-scanIdentifier.js: Added. (createPayloadTypescriptScanIdentifier): * JSAir/reg.js: Added. (Reg): (Reg.fromReg): (Reg.prototype.get index): (Reg.prototype.get type): (Reg.prototype.get name): (Reg.prototype.get isCalleeSave): (Reg.prototype.get isReg): (Reg.prototype.toString): (Reg.extract): (Reg.forEachFast): (Reg.forEach): (newGPR): (Reg.gprs.Reg.fprs.Reg.calleeSaveGPRs.Reg.calleeSaveFPRs.Reg.calleeSaves): * JSAir/stack_slot.js: Added. (StackSlot): (StackSlot.prototype.get byteSize): (StackSlot.prototype.get kind): (StackSlot.prototype.get isLocked): (StackSlot.prototype.get isSpill): (StackSlot.prototype.get index): (StackSlot.prototype.ensureSize): (StackSlot.prototype.get alignment): (StackSlot.prototype.get offsetFromFP): (StackSlot.prototype.setOffsetFromFP): (StackSlot.prototype.toString): (StackSlot.extract): (StackSlot.forEachFast): (StackSlot.forEach): * JSAir/symbols.js: Added. * JSAir/test.html: Added. * JSAir/test.js: Added. * JSAir/tmp.js: Added. (Tmp): (Tmp.fromReg): (Tmp.prototype.get index): (Tmp.prototype.get type): (Tmp.prototype.get isReg): (Tmp.prototype.toString): (Tmp.extract): (Tmp.forEachFast): (Tmp.forEach): * JSAir/tmp_base.js: Added. (TmpBase.prototype.get isGP): (TmpBase.prototype.get isFP): (TmpBase.prototype.get isGPR): (TmpBase.prototype.get isFPR): (TmpBase.prototype.get reg): (TmpBase.prototype.get gpr): (TmpBase.prototype.get fpr): (TmpBase): * JSAir/util.js: Added. (isRepresentableAsInt32): (addIndexed): (roundUpToMultipleOf): (symbolName): (mergeIntoSet): (nonEmptyRangesOverlap): (rangesOverlap): (removeAllMatching): (swap): (bubble): (bubbleSort): (currentTime): (else.currentTime): Source/JavaScriptCore: Most of these changes are to support dumpAsJS(). But I also found some duplicate and dead code while rewriting it to JS. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/air/AirAllocateStack.cpp: * b3/air/AirArg.h: (JSC::B3::Air::Arg::isSomeImm): (JSC::B3::Air::Arg::isAddr): (JSC::B3::Air::Arg::tmpIndex): (JSC::B3::Air::Arg::isValidImmForm): (JSC::B3::Air::Arg::withOffset): Deleted. This was dead code. * b3/air/AirArgInlines.h: It turns out that Inst has a ForEach thing that duplicated some of the logic of ArgThingHelper, so I just made ArgThingHelper more powerful. (JSC::B3::Air::ArgThingHelper<Arg>::forEach): (JSC::B3::Air::ArgThingHelper<Reg>::is): (JSC::B3::Air::ArgThingHelper<Reg>::as): (JSC::B3::Air::ArgThingHelper<Reg>::forEachFast): (JSC::B3::Air::ArgThingHelper<Reg>::forEach): (JSC::B3::Air::Arg::is): * b3/air/AirDumpAsJS.cpp: Added. (JSC::B3::Air::dumpAsJS): * b3/air/AirDumpAsJS.h: Added. * b3/air/AirFixObviousSpills.cpp: * b3/air/AirGenerate.cpp: (JSC::B3::Air::prepareForGeneration): * b3/air/AirInstInlines.h: (JSC::B3::Air::Inst::forEach): (JSC::B3::Air::Inst::extraClobberedRegs): (JSC::B3::Air::ForEach<Tmp>::forEach): Deleted. This was doing what ArgThingHelper would have done but not as well. (JSC::B3::Air::ForEach<Arg>::forEach): Deleted. (JSC::B3::Air::ForEach<Reg>::forEach): Deleted. * b3/air/AirLogRegisterPressure.cpp: * b3/air/AirReportUsedRegisters.cpp: * b3/air/AirSpillEverything.cpp: * b3/air/opcode_generator.rb: Make this dump opcode.js, which is like what it dumps for C++. * jit/Reg.cpp: (JSC::Reg::debugName): (JSC::Reg::dump): * jit/Reg.h: (JSC::Reg::hash): * jsc.cpp: Fix jsc so that it reports the filename and line number of parser errors. (dumpException): * parser/ParserError.h: Make it easier to debug this code. (WTF::printInternal): * runtime/Options.h: Source/WTF: * wtf/Insertion.h: (WTF::executeInsertions): I found a bug while rewriting this code in JS. * wtf/PrintStream.h: (WTF::PrintStream::print): (WTF::PrintStream::println): This is useful to have. Canonical link: https://commits.webkit.org/176569@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 01:43:35 +00:00
toString()
{
Use more ES6 features in JSAir https://bugs.webkit.org/show_bug.cgi?id=158497 Reviewed by Keith Miller. This improves JSAir with the following ES6 features suggested by JoePeck: - String interpolation. - Destructuring inside PatchCustom. - Default arguments. All of these things are on hot paths. Note that I didn't use string interpolation everywhere that I could, only in those places where it made the code more readable. In Ruby, I used the style that if the interpolation expression has any non-trivial stuff (like a ternary operator, a chain of calls, or embedded strings) then it's better to use regular strcat. I think that's what I carried over to here. Note that the previous change (Add result validation to JSAir) also made the Proxy code not dead, though it's not necessarily on the hot path. The Proxy isn't called into frequently but it's used from a function that is otherwise hot, so if calling into the Proxy prevents that function from being optimized then it will hurt so good. I also reenabled tail calls in a few places. This change doesn't seem to change the performance of the benchmark for us. That's expected since these ES6 features are cheap. Note that this claim doesn't include Proxy, which was added in a separate change and that change did make the benchmark overall more expensive. * JSAir/allocate_stack.js: (allocateStack): * JSAir/arg.js: (Arg.createBitImm64): (Arg.createAddr): (Arg.createStack): (Arg.logScale): (Arg.createIndex): * JSAir/basic_block.js: (BasicBlock.get headerString): (BasicBlock.prototype.get if): (BasicBlock): * JSAir/benchmark.js: (benchmark): * JSAir/code.js: (Code): (Code.prototype.addBlock): (Code.prototype.addStackSlot): (Code.prototype.newTmp): (Code.prototype.get size): (Code.prototype.get blocks): (Code.prototype.get stackSlots): (Code.prototype.tmps): (Code.prototype.get callArgAreaSize): (Code.prototype.toString): * JSAir/custom.js: (const.PatchCustom.forEachArg): * JSAir/inst.js: (Inst): * JSAir/reg.js: (Reg.prototype.toString): * JSAir/util.js: (symbolName): (lowerSymbolName): Canonical link: https://commits.webkit.org/176596@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 18:13:20 +00:00
return `%${this._name}`;
Implement Air::allocateStack() in ES6 to see how much of a bad idea that is https://bugs.webkit.org/show_bug.cgi?id=158318 Reviewed by Saam Barati. PerformanceTests: This adds a new benchmark for us to play with called JSAir. It's a complete ES6 implementation of Air's allocateStack() phase along with all of Air needed to run that phase. This includes things like stack slots, registers, temporaries, basic blocks, instructions, and all of the code for iterating over, inspecting, and modifying those things. To make this work, JSC can now dump Air just before allocateStack() in the form of JS code that creates a Code object that matches exactly what C++ Air saw. This benchmark comprises four Air IRs: - Octane/gbemu's largest function, executeIteration. - Kraken/imaging-gaussian-blur's largest function in OSR entry mode, gaussuanBlur. - Octane/typescript's largest function that is actually hot, scanIdentifier. - JSAir's largest hot function, which is anonymous, so we call it by its hash (ACLj8C). This runs in about 2 seconds on my machine in JSC trunk. It includes both a commandline harness and a web harness. JSAir is almost exactly 100x slower in ES6 in WebKit than the C++ Air::allocateStack() phase on which it is based. JSAir uses the following ES6 features: - Symbol. - for-of. - arrow functions. - Map/Set. - let/const. - classes. All of these things are used in anger and should end up on the hot path. There is also code that uses Proxies, but it ends up being dead. We can improve this even more: I still need to add result validation: https://bugs.webkit.org/show_bug.cgi?id=158493 I want to make it use more ES6 features: https://bugs.webkit.org/show_bug.cgi?id=158497 * JSAir: Added. * JSAir/all.js: Added. * JSAir/allocate_stack.js: Added. (allocateStack.attemptAssignment): (allocateStack.assign): (allocateStack.interfere): (allocateStack.): (allocateStack): * JSAir/arg.js: Added. (Arg): (Arg.isAnyUse): (Arg.isColdUse): (Arg.isWarmUse): (Arg.cooled): (Arg.isEarlyUse): (Arg.isLateUse): (Arg.isAnyDef): (Arg.isEarlyDef): (Arg.isLateDef): (Arg.isZDef): (Arg.typeForB3Type): (Arg.widthForB3Type): (Arg.conservativeWidth): (Arg.minimumWidth): (Arg.bytes): (Arg.widthForBytes): (Arg.createTmp): (Arg.fromReg): (Arg.createImm): (Arg.createBigImm): (Arg.createBitImm): (Arg.createBitImm64): (Arg.createAddr): (Arg.createStack): (Arg.createCallArg): (Arg.createStackAddr): (Arg.isValidScale): (Arg.logScale): (Arg.createIndex): (Arg.createRelCond): (Arg.createResCond): (Arg.createDoubleCond): (Arg.createWidth): (Arg.prototype.get kind): (Arg.prototype.get isTmp): (Arg.prototype.get isImm): (Arg.prototype.get isBigImm): (Arg.prototype.get isBitImm): (Arg.prototype.get isBitImm64): (Arg.prototype.get isSomeImm): (Arg.prototype.get isAddr): (Arg.prototype.get isStack): (Arg.prototype.get isCallArg): (Arg.prototype.get isIndex): (Arg.prototype.get isMemory): (Arg.prototype.get isStackMemory): (Arg.prototype.get isRelCond): (Arg.prototype.get isResCond): (Arg.prototype.get isDoubleCond): (Arg.prototype.get isCondition): (Arg.prototype.get isWidth): (Arg.prototype.get isAlive): (Arg.prototype.get tmp): (Arg.prototype.get value): (Arg.prototype.get base): (Arg.prototype.get hasOffset): (Arg.prototype.get offset): (Arg.prototype.get stackSlot): (Arg.prototype.get index): (Arg.prototype.get scale): (Arg.prototype.get logScale): (Arg.prototype.get width): (Arg.prototype.get isGPTmp): (Arg.prototype.get isFPTmp): (Arg.prototype.get isGP): (Arg.prototype.get isFP): (Arg.prototype.get hasType): (Arg.prototype.get type): (Arg.prototype.isType): (Arg.prototype.isCompatibleType): (Arg.prototype.get isGPR): (Arg.prototype.get gpr): (Arg.prototype.get isFPR): (Arg.prototype.get fpr): (Arg.prototype.get isReg): (Arg.prototype.get reg): (Arg.isValidImmForm): (Arg.isValidBitImmForm): (Arg.isValidBitImm64Form): (Arg.isValidAddrForm): (Arg.isValidIndexForm): (Arg.prototype.isValidForm): (Arg.prototype.forEachTmpFast): (Arg.prototype.usesTmp): (Arg.prototype.forEachTmp): (Arg.prototype.is): (Arg.prototype.as): (Arg.prototype.forEachFast): (Arg.prototype.forEach): (Arg.extract): (Arg.forEachFast): (Arg.forEach): (Arg.prototype.get condition): (Arg.prototype.get isInvertible): (Arg.prototype.toString): * JSAir/basic_block.js: Added. (BasicBlock): (BasicBlock.prototype.get index): (BasicBlock.prototype.get size): (BasicBlock.prototype.Symbol.iterator): (BasicBlock.prototype.at): (BasicBlock.get last): (BasicBlock.get insts): (BasicBlock.get numSuccessors): (BasicBlock.get successors): (BasicBlock.get successorBlocks.): (BasicBlock.get successorBlocks): (BasicBlock.set get numPredecessors): (BasicBlock.get predecessors): (BasicBlock.get frequency): (BasicBlock.get headerString): (BasicBlock.get footerString): * JSAir/benchmark.js: Added. (benchmark): * JSAir/code.js: Added. (Code): (Code.prototype.addBlock): (Code.prototype.addStackSlot): (Code.prototype.newTmp): (Code.prototype.get size): (Code.prototype.at): (Code.prototype.Symbol.iterator): (Code.prototype.get blocks): (Code.prototype.get stackSlots): (Code.prototype.tmps): (Code.prototype.get callArgAreaSize): (Code.prototype.requestCallArgAreaSize): (Code.prototype.get frameSize): (Code.prototype.setFrameSize): (Code.prototype.toString): * JSAir/custom.js: Added. (const.ShuffleCustom.forEachArg): (const.ShuffleCustom.hasNonArgNonControlEffects): (const.PatchCustom.forEachArg): (const.PatchCustom.hasNonArgNonControlEffects): (const.CCallCustom.forEachArg): (const.CCallCustom.hasNonArgNonControlEffects): (const.ColdCCallCustom.forEachArg): (const.ColdCCallCustom.hasNonArgNonControlEffects): * JSAir/frequented_block.js: Added. (FrequentedBlock): (FrequentedBlock.prototype.toString): * JSAir/insertion_set.js: Added. (Insertion): (Insertion.prototype.get index): (Insertion.prototype.get element): (Insertion.prototype.lessThan): (InsertionSet): (InsertionSet.prototype.appendInsertion): (InsertionSet.prototype.append): (InsertionSet.prototype.execute): * JSAir/inst.js: Added. (Inst): (Inst.prototype.append): (Inst.prototype.clear): (Inst.prototype.get opcode): (Inst.prototype.get args): (Inst.prototype.visitArg): (Inst.prototype.forEachTmpFast): (Inst.prototype.forEachArg): (Inst.prototype.forEachTmp): (Inst.prototype.forEach): (Inst.forEachDef): (Inst.forEachDefWithExtraClobberedRegs): (Inst.prototype.get hasNonArgEffects): (Inst.prototype.toString): * JSAir/liveness.js: Added. (Liveness): (Liveness.prototype.get thing): (Liveness.prototype.get code): (Liveness.prototype.get liveAtHead): (Liveness.prototype.get liveAtTail): (Liveness.prototype.localCalc.LocalCalc): (Liveness.prototype.localCalc.LocalCalc.prototype.get liveSet): (Liveness.prototype.localCalc.LocalCalc.prototype.execute): (Liveness.prototype.localCalc): * JSAir/opcode.js: Added. (Inst_forEachArg): (Inst_hasNonArgEffects): * JSAir/payload-gbemu-executeIteration.js: Added. (createPayloadGbemuExecuteIteration): * JSAir/payload-imaging-gaussian-blur-gaussianBlur.js: Added. (createPayloadImagingGaussianBlurGaussianBlur): * JSAir/payload-jsair-ACLj8C.js: Added. (createPayloadJSAirACLj8C): * JSAir/payload-typescript-scanIdentifier.js: Added. (createPayloadTypescriptScanIdentifier): * JSAir/reg.js: Added. (Reg): (Reg.fromReg): (Reg.prototype.get index): (Reg.prototype.get type): (Reg.prototype.get name): (Reg.prototype.get isCalleeSave): (Reg.prototype.get isReg): (Reg.prototype.toString): (Reg.extract): (Reg.forEachFast): (Reg.forEach): (newGPR): (Reg.gprs.Reg.fprs.Reg.calleeSaveGPRs.Reg.calleeSaveFPRs.Reg.calleeSaves): * JSAir/stack_slot.js: Added. (StackSlot): (StackSlot.prototype.get byteSize): (StackSlot.prototype.get kind): (StackSlot.prototype.get isLocked): (StackSlot.prototype.get isSpill): (StackSlot.prototype.get index): (StackSlot.prototype.ensureSize): (StackSlot.prototype.get alignment): (StackSlot.prototype.get offsetFromFP): (StackSlot.prototype.setOffsetFromFP): (StackSlot.prototype.toString): (StackSlot.extract): (StackSlot.forEachFast): (StackSlot.forEach): * JSAir/symbols.js: Added. * JSAir/test.html: Added. * JSAir/test.js: Added. * JSAir/tmp.js: Added. (Tmp): (Tmp.fromReg): (Tmp.prototype.get index): (Tmp.prototype.get type): (Tmp.prototype.get isReg): (Tmp.prototype.toString): (Tmp.extract): (Tmp.forEachFast): (Tmp.forEach): * JSAir/tmp_base.js: Added. (TmpBase.prototype.get isGP): (TmpBase.prototype.get isFP): (TmpBase.prototype.get isGPR): (TmpBase.prototype.get isFPR): (TmpBase.prototype.get reg): (TmpBase.prototype.get gpr): (TmpBase.prototype.get fpr): (TmpBase): * JSAir/util.js: Added. (isRepresentableAsInt32): (addIndexed): (roundUpToMultipleOf): (symbolName): (mergeIntoSet): (nonEmptyRangesOverlap): (rangesOverlap): (removeAllMatching): (swap): (bubble): (bubbleSort): (currentTime): (else.currentTime): Source/JavaScriptCore: Most of these changes are to support dumpAsJS(). But I also found some duplicate and dead code while rewriting it to JS. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/air/AirAllocateStack.cpp: * b3/air/AirArg.h: (JSC::B3::Air::Arg::isSomeImm): (JSC::B3::Air::Arg::isAddr): (JSC::B3::Air::Arg::tmpIndex): (JSC::B3::Air::Arg::isValidImmForm): (JSC::B3::Air::Arg::withOffset): Deleted. This was dead code. * b3/air/AirArgInlines.h: It turns out that Inst has a ForEach thing that duplicated some of the logic of ArgThingHelper, so I just made ArgThingHelper more powerful. (JSC::B3::Air::ArgThingHelper<Arg>::forEach): (JSC::B3::Air::ArgThingHelper<Reg>::is): (JSC::B3::Air::ArgThingHelper<Reg>::as): (JSC::B3::Air::ArgThingHelper<Reg>::forEachFast): (JSC::B3::Air::ArgThingHelper<Reg>::forEach): (JSC::B3::Air::Arg::is): * b3/air/AirDumpAsJS.cpp: Added. (JSC::B3::Air::dumpAsJS): * b3/air/AirDumpAsJS.h: Added. * b3/air/AirFixObviousSpills.cpp: * b3/air/AirGenerate.cpp: (JSC::B3::Air::prepareForGeneration): * b3/air/AirInstInlines.h: (JSC::B3::Air::Inst::forEach): (JSC::B3::Air::Inst::extraClobberedRegs): (JSC::B3::Air::ForEach<Tmp>::forEach): Deleted. This was doing what ArgThingHelper would have done but not as well. (JSC::B3::Air::ForEach<Arg>::forEach): Deleted. (JSC::B3::Air::ForEach<Reg>::forEach): Deleted. * b3/air/AirLogRegisterPressure.cpp: * b3/air/AirReportUsedRegisters.cpp: * b3/air/AirSpillEverything.cpp: * b3/air/opcode_generator.rb: Make this dump opcode.js, which is like what it dumps for C++. * jit/Reg.cpp: (JSC::Reg::debugName): (JSC::Reg::dump): * jit/Reg.h: (JSC::Reg::hash): * jsc.cpp: Fix jsc so that it reports the filename and line number of parser errors. (dumpException): * parser/ParserError.h: Make it easier to debug this code. (WTF::printInternal): * runtime/Options.h: Source/WTF: * wtf/Insertion.h: (WTF::executeInsertions): I found a bug while rewriting this code in JS. * wtf/PrintStream.h: (WTF::PrintStream::print): (WTF::PrintStream::println): This is useful to have. Canonical link: https://commits.webkit.org/176569@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 01:43:35 +00:00
}
static extract(arg)
{
if (arg.isReg)
return arg.reg;
return null;
}
static forEachFast(arg, func)
{
return arg.forEachTmpFast(tmp => {
if (!tmp.isReg)
return;
return func(tmp);
});
}
static forEach(arg, argRole, argType, argWidth, func)
{
return arg.forEachTmp(
argRole, argType, argWidth,
(tmp, role, type, width) => {
if (!tmp.isReg)
return;
return func(tmp, role, type, width);
});
}
}
{
Reg.regs = [];
function newReg(...args)
{
let result = new Reg(...args);
Reg.regs.push(result);
return result;
}
// Define X86_64 GPRs
{
let index = 0;
function newGPR(name, isCalleeSave) { return newReg(index++, GP, name, isCalleeSave); }
Reg.rax = newGPR("rax");
Reg.rcx = newGPR("rcx");
Reg.rdx = newGPR("rdx");
Reg.rbx = newGPR("rbx", true);
Reg.rsp = newGPR("rsp");
Reg.rbp = newGPR("rbp", true);
Reg.rsi = newGPR("rsi");
Reg.rdi = newGPR("rdi");
for (let i = 8; i <= 15; ++i)
Use more ES6 features in JSAir https://bugs.webkit.org/show_bug.cgi?id=158497 Reviewed by Keith Miller. This improves JSAir with the following ES6 features suggested by JoePeck: - String interpolation. - Destructuring inside PatchCustom. - Default arguments. All of these things are on hot paths. Note that I didn't use string interpolation everywhere that I could, only in those places where it made the code more readable. In Ruby, I used the style that if the interpolation expression has any non-trivial stuff (like a ternary operator, a chain of calls, or embedded strings) then it's better to use regular strcat. I think that's what I carried over to here. Note that the previous change (Add result validation to JSAir) also made the Proxy code not dead, though it's not necessarily on the hot path. The Proxy isn't called into frequently but it's used from a function that is otherwise hot, so if calling into the Proxy prevents that function from being optimized then it will hurt so good. I also reenabled tail calls in a few places. This change doesn't seem to change the performance of the benchmark for us. That's expected since these ES6 features are cheap. Note that this claim doesn't include Proxy, which was added in a separate change and that change did make the benchmark overall more expensive. * JSAir/allocate_stack.js: (allocateStack): * JSAir/arg.js: (Arg.createBitImm64): (Arg.createAddr): (Arg.createStack): (Arg.logScale): (Arg.createIndex): * JSAir/basic_block.js: (BasicBlock.get headerString): (BasicBlock.prototype.get if): (BasicBlock): * JSAir/benchmark.js: (benchmark): * JSAir/code.js: (Code): (Code.prototype.addBlock): (Code.prototype.addStackSlot): (Code.prototype.newTmp): (Code.prototype.get size): (Code.prototype.get blocks): (Code.prototype.get stackSlots): (Code.prototype.tmps): (Code.prototype.get callArgAreaSize): (Code.prototype.toString): * JSAir/custom.js: (const.PatchCustom.forEachArg): * JSAir/inst.js: (Inst): * JSAir/reg.js: (Reg.prototype.toString): * JSAir/util.js: (symbolName): (lowerSymbolName): Canonical link: https://commits.webkit.org/176596@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 18:13:20 +00:00
Reg[`r${i}`] = newGPR(`r${i}`, i >= 12);
Implement Air::allocateStack() in ES6 to see how much of a bad idea that is https://bugs.webkit.org/show_bug.cgi?id=158318 Reviewed by Saam Barati. PerformanceTests: This adds a new benchmark for us to play with called JSAir. It's a complete ES6 implementation of Air's allocateStack() phase along with all of Air needed to run that phase. This includes things like stack slots, registers, temporaries, basic blocks, instructions, and all of the code for iterating over, inspecting, and modifying those things. To make this work, JSC can now dump Air just before allocateStack() in the form of JS code that creates a Code object that matches exactly what C++ Air saw. This benchmark comprises four Air IRs: - Octane/gbemu's largest function, executeIteration. - Kraken/imaging-gaussian-blur's largest function in OSR entry mode, gaussuanBlur. - Octane/typescript's largest function that is actually hot, scanIdentifier. - JSAir's largest hot function, which is anonymous, so we call it by its hash (ACLj8C). This runs in about 2 seconds on my machine in JSC trunk. It includes both a commandline harness and a web harness. JSAir is almost exactly 100x slower in ES6 in WebKit than the C++ Air::allocateStack() phase on which it is based. JSAir uses the following ES6 features: - Symbol. - for-of. - arrow functions. - Map/Set. - let/const. - classes. All of these things are used in anger and should end up on the hot path. There is also code that uses Proxies, but it ends up being dead. We can improve this even more: I still need to add result validation: https://bugs.webkit.org/show_bug.cgi?id=158493 I want to make it use more ES6 features: https://bugs.webkit.org/show_bug.cgi?id=158497 * JSAir: Added. * JSAir/all.js: Added. * JSAir/allocate_stack.js: Added. (allocateStack.attemptAssignment): (allocateStack.assign): (allocateStack.interfere): (allocateStack.): (allocateStack): * JSAir/arg.js: Added. (Arg): (Arg.isAnyUse): (Arg.isColdUse): (Arg.isWarmUse): (Arg.cooled): (Arg.isEarlyUse): (Arg.isLateUse): (Arg.isAnyDef): (Arg.isEarlyDef): (Arg.isLateDef): (Arg.isZDef): (Arg.typeForB3Type): (Arg.widthForB3Type): (Arg.conservativeWidth): (Arg.minimumWidth): (Arg.bytes): (Arg.widthForBytes): (Arg.createTmp): (Arg.fromReg): (Arg.createImm): (Arg.createBigImm): (Arg.createBitImm): (Arg.createBitImm64): (Arg.createAddr): (Arg.createStack): (Arg.createCallArg): (Arg.createStackAddr): (Arg.isValidScale): (Arg.logScale): (Arg.createIndex): (Arg.createRelCond): (Arg.createResCond): (Arg.createDoubleCond): (Arg.createWidth): (Arg.prototype.get kind): (Arg.prototype.get isTmp): (Arg.prototype.get isImm): (Arg.prototype.get isBigImm): (Arg.prototype.get isBitImm): (Arg.prototype.get isBitImm64): (Arg.prototype.get isSomeImm): (Arg.prototype.get isAddr): (Arg.prototype.get isStack): (Arg.prototype.get isCallArg): (Arg.prototype.get isIndex): (Arg.prototype.get isMemory): (Arg.prototype.get isStackMemory): (Arg.prototype.get isRelCond): (Arg.prototype.get isResCond): (Arg.prototype.get isDoubleCond): (Arg.prototype.get isCondition): (Arg.prototype.get isWidth): (Arg.prototype.get isAlive): (Arg.prototype.get tmp): (Arg.prototype.get value): (Arg.prototype.get base): (Arg.prototype.get hasOffset): (Arg.prototype.get offset): (Arg.prototype.get stackSlot): (Arg.prototype.get index): (Arg.prototype.get scale): (Arg.prototype.get logScale): (Arg.prototype.get width): (Arg.prototype.get isGPTmp): (Arg.prototype.get isFPTmp): (Arg.prototype.get isGP): (Arg.prototype.get isFP): (Arg.prototype.get hasType): (Arg.prototype.get type): (Arg.prototype.isType): (Arg.prototype.isCompatibleType): (Arg.prototype.get isGPR): (Arg.prototype.get gpr): (Arg.prototype.get isFPR): (Arg.prototype.get fpr): (Arg.prototype.get isReg): (Arg.prototype.get reg): (Arg.isValidImmForm): (Arg.isValidBitImmForm): (Arg.isValidBitImm64Form): (Arg.isValidAddrForm): (Arg.isValidIndexForm): (Arg.prototype.isValidForm): (Arg.prototype.forEachTmpFast): (Arg.prototype.usesTmp): (Arg.prototype.forEachTmp): (Arg.prototype.is): (Arg.prototype.as): (Arg.prototype.forEachFast): (Arg.prototype.forEach): (Arg.extract): (Arg.forEachFast): (Arg.forEach): (Arg.prototype.get condition): (Arg.prototype.get isInvertible): (Arg.prototype.toString): * JSAir/basic_block.js: Added. (BasicBlock): (BasicBlock.prototype.get index): (BasicBlock.prototype.get size): (BasicBlock.prototype.Symbol.iterator): (BasicBlock.prototype.at): (BasicBlock.get last): (BasicBlock.get insts): (BasicBlock.get numSuccessors): (BasicBlock.get successors): (BasicBlock.get successorBlocks.): (BasicBlock.get successorBlocks): (BasicBlock.set get numPredecessors): (BasicBlock.get predecessors): (BasicBlock.get frequency): (BasicBlock.get headerString): (BasicBlock.get footerString): * JSAir/benchmark.js: Added. (benchmark): * JSAir/code.js: Added. (Code): (Code.prototype.addBlock): (Code.prototype.addStackSlot): (Code.prototype.newTmp): (Code.prototype.get size): (Code.prototype.at): (Code.prototype.Symbol.iterator): (Code.prototype.get blocks): (Code.prototype.get stackSlots): (Code.prototype.tmps): (Code.prototype.get callArgAreaSize): (Code.prototype.requestCallArgAreaSize): (Code.prototype.get frameSize): (Code.prototype.setFrameSize): (Code.prototype.toString): * JSAir/custom.js: Added. (const.ShuffleCustom.forEachArg): (const.ShuffleCustom.hasNonArgNonControlEffects): (const.PatchCustom.forEachArg): (const.PatchCustom.hasNonArgNonControlEffects): (const.CCallCustom.forEachArg): (const.CCallCustom.hasNonArgNonControlEffects): (const.ColdCCallCustom.forEachArg): (const.ColdCCallCustom.hasNonArgNonControlEffects): * JSAir/frequented_block.js: Added. (FrequentedBlock): (FrequentedBlock.prototype.toString): * JSAir/insertion_set.js: Added. (Insertion): (Insertion.prototype.get index): (Insertion.prototype.get element): (Insertion.prototype.lessThan): (InsertionSet): (InsertionSet.prototype.appendInsertion): (InsertionSet.prototype.append): (InsertionSet.prototype.execute): * JSAir/inst.js: Added. (Inst): (Inst.prototype.append): (Inst.prototype.clear): (Inst.prototype.get opcode): (Inst.prototype.get args): (Inst.prototype.visitArg): (Inst.prototype.forEachTmpFast): (Inst.prototype.forEachArg): (Inst.prototype.forEachTmp): (Inst.prototype.forEach): (Inst.forEachDef): (Inst.forEachDefWithExtraClobberedRegs): (Inst.prototype.get hasNonArgEffects): (Inst.prototype.toString): * JSAir/liveness.js: Added. (Liveness): (Liveness.prototype.get thing): (Liveness.prototype.get code): (Liveness.prototype.get liveAtHead): (Liveness.prototype.get liveAtTail): (Liveness.prototype.localCalc.LocalCalc): (Liveness.prototype.localCalc.LocalCalc.prototype.get liveSet): (Liveness.prototype.localCalc.LocalCalc.prototype.execute): (Liveness.prototype.localCalc): * JSAir/opcode.js: Added. (Inst_forEachArg): (Inst_hasNonArgEffects): * JSAir/payload-gbemu-executeIteration.js: Added. (createPayloadGbemuExecuteIteration): * JSAir/payload-imaging-gaussian-blur-gaussianBlur.js: Added. (createPayloadImagingGaussianBlurGaussianBlur): * JSAir/payload-jsair-ACLj8C.js: Added. (createPayloadJSAirACLj8C): * JSAir/payload-typescript-scanIdentifier.js: Added. (createPayloadTypescriptScanIdentifier): * JSAir/reg.js: Added. (Reg): (Reg.fromReg): (Reg.prototype.get index): (Reg.prototype.get type): (Reg.prototype.get name): (Reg.prototype.get isCalleeSave): (Reg.prototype.get isReg): (Reg.prototype.toString): (Reg.extract): (Reg.forEachFast): (Reg.forEach): (newGPR): (Reg.gprs.Reg.fprs.Reg.calleeSaveGPRs.Reg.calleeSaveFPRs.Reg.calleeSaves): * JSAir/stack_slot.js: Added. (StackSlot): (StackSlot.prototype.get byteSize): (StackSlot.prototype.get kind): (StackSlot.prototype.get isLocked): (StackSlot.prototype.get isSpill): (StackSlot.prototype.get index): (StackSlot.prototype.ensureSize): (StackSlot.prototype.get alignment): (StackSlot.prototype.get offsetFromFP): (StackSlot.prototype.setOffsetFromFP): (StackSlot.prototype.toString): (StackSlot.extract): (StackSlot.forEachFast): (StackSlot.forEach): * JSAir/symbols.js: Added. * JSAir/test.html: Added. * JSAir/test.js: Added. * JSAir/tmp.js: Added. (Tmp): (Tmp.fromReg): (Tmp.prototype.get index): (Tmp.prototype.get type): (Tmp.prototype.get isReg): (Tmp.prototype.toString): (Tmp.extract): (Tmp.forEachFast): (Tmp.forEach): * JSAir/tmp_base.js: Added. (TmpBase.prototype.get isGP): (TmpBase.prototype.get isFP): (TmpBase.prototype.get isGPR): (TmpBase.prototype.get isFPR): (TmpBase.prototype.get reg): (TmpBase.prototype.get gpr): (TmpBase.prototype.get fpr): (TmpBase): * JSAir/util.js: Added. (isRepresentableAsInt32): (addIndexed): (roundUpToMultipleOf): (symbolName): (mergeIntoSet): (nonEmptyRangesOverlap): (rangesOverlap): (removeAllMatching): (swap): (bubble): (bubbleSort): (currentTime): (else.currentTime): Source/JavaScriptCore: Most of these changes are to support dumpAsJS(). But I also found some duplicate and dead code while rewriting it to JS. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/air/AirAllocateStack.cpp: * b3/air/AirArg.h: (JSC::B3::Air::Arg::isSomeImm): (JSC::B3::Air::Arg::isAddr): (JSC::B3::Air::Arg::tmpIndex): (JSC::B3::Air::Arg::isValidImmForm): (JSC::B3::Air::Arg::withOffset): Deleted. This was dead code. * b3/air/AirArgInlines.h: It turns out that Inst has a ForEach thing that duplicated some of the logic of ArgThingHelper, so I just made ArgThingHelper more powerful. (JSC::B3::Air::ArgThingHelper<Arg>::forEach): (JSC::B3::Air::ArgThingHelper<Reg>::is): (JSC::B3::Air::ArgThingHelper<Reg>::as): (JSC::B3::Air::ArgThingHelper<Reg>::forEachFast): (JSC::B3::Air::ArgThingHelper<Reg>::forEach): (JSC::B3::Air::Arg::is): * b3/air/AirDumpAsJS.cpp: Added. (JSC::B3::Air::dumpAsJS): * b3/air/AirDumpAsJS.h: Added. * b3/air/AirFixObviousSpills.cpp: * b3/air/AirGenerate.cpp: (JSC::B3::Air::prepareForGeneration): * b3/air/AirInstInlines.h: (JSC::B3::Air::Inst::forEach): (JSC::B3::Air::Inst::extraClobberedRegs): (JSC::B3::Air::ForEach<Tmp>::forEach): Deleted. This was doing what ArgThingHelper would have done but not as well. (JSC::B3::Air::ForEach<Arg>::forEach): Deleted. (JSC::B3::Air::ForEach<Reg>::forEach): Deleted. * b3/air/AirLogRegisterPressure.cpp: * b3/air/AirReportUsedRegisters.cpp: * b3/air/AirSpillEverything.cpp: * b3/air/opcode_generator.rb: Make this dump opcode.js, which is like what it dumps for C++. * jit/Reg.cpp: (JSC::Reg::debugName): (JSC::Reg::dump): * jit/Reg.h: (JSC::Reg::hash): * jsc.cpp: Fix jsc so that it reports the filename and line number of parser errors. (dumpException): * parser/ParserError.h: Make it easier to debug this code. (WTF::printInternal): * runtime/Options.h: Source/WTF: * wtf/Insertion.h: (WTF::executeInsertions): I found a bug while rewriting this code in JS. * wtf/PrintStream.h: (WTF::PrintStream::print): (WTF::PrintStream::println): This is useful to have. Canonical link: https://commits.webkit.org/176569@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 01:43:35 +00:00
}
// Define X86_64 FPRs.
for (let i = 0; i <= 15; ++i)
Use more ES6 features in JSAir https://bugs.webkit.org/show_bug.cgi?id=158497 Reviewed by Keith Miller. This improves JSAir with the following ES6 features suggested by JoePeck: - String interpolation. - Destructuring inside PatchCustom. - Default arguments. All of these things are on hot paths. Note that I didn't use string interpolation everywhere that I could, only in those places where it made the code more readable. In Ruby, I used the style that if the interpolation expression has any non-trivial stuff (like a ternary operator, a chain of calls, or embedded strings) then it's better to use regular strcat. I think that's what I carried over to here. Note that the previous change (Add result validation to JSAir) also made the Proxy code not dead, though it's not necessarily on the hot path. The Proxy isn't called into frequently but it's used from a function that is otherwise hot, so if calling into the Proxy prevents that function from being optimized then it will hurt so good. I also reenabled tail calls in a few places. This change doesn't seem to change the performance of the benchmark for us. That's expected since these ES6 features are cheap. Note that this claim doesn't include Proxy, which was added in a separate change and that change did make the benchmark overall more expensive. * JSAir/allocate_stack.js: (allocateStack): * JSAir/arg.js: (Arg.createBitImm64): (Arg.createAddr): (Arg.createStack): (Arg.logScale): (Arg.createIndex): * JSAir/basic_block.js: (BasicBlock.get headerString): (BasicBlock.prototype.get if): (BasicBlock): * JSAir/benchmark.js: (benchmark): * JSAir/code.js: (Code): (Code.prototype.addBlock): (Code.prototype.addStackSlot): (Code.prototype.newTmp): (Code.prototype.get size): (Code.prototype.get blocks): (Code.prototype.get stackSlots): (Code.prototype.tmps): (Code.prototype.get callArgAreaSize): (Code.prototype.toString): * JSAir/custom.js: (const.PatchCustom.forEachArg): * JSAir/inst.js: (Inst): * JSAir/reg.js: (Reg.prototype.toString): * JSAir/util.js: (symbolName): (lowerSymbolName): Canonical link: https://commits.webkit.org/176596@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 18:13:20 +00:00
Reg[`xmm${i}`] = newReg(i, FP, `xmm${i}`);
Implement Air::allocateStack() in ES6 to see how much of a bad idea that is https://bugs.webkit.org/show_bug.cgi?id=158318 Reviewed by Saam Barati. PerformanceTests: This adds a new benchmark for us to play with called JSAir. It's a complete ES6 implementation of Air's allocateStack() phase along with all of Air needed to run that phase. This includes things like stack slots, registers, temporaries, basic blocks, instructions, and all of the code for iterating over, inspecting, and modifying those things. To make this work, JSC can now dump Air just before allocateStack() in the form of JS code that creates a Code object that matches exactly what C++ Air saw. This benchmark comprises four Air IRs: - Octane/gbemu's largest function, executeIteration. - Kraken/imaging-gaussian-blur's largest function in OSR entry mode, gaussuanBlur. - Octane/typescript's largest function that is actually hot, scanIdentifier. - JSAir's largest hot function, which is anonymous, so we call it by its hash (ACLj8C). This runs in about 2 seconds on my machine in JSC trunk. It includes both a commandline harness and a web harness. JSAir is almost exactly 100x slower in ES6 in WebKit than the C++ Air::allocateStack() phase on which it is based. JSAir uses the following ES6 features: - Symbol. - for-of. - arrow functions. - Map/Set. - let/const. - classes. All of these things are used in anger and should end up on the hot path. There is also code that uses Proxies, but it ends up being dead. We can improve this even more: I still need to add result validation: https://bugs.webkit.org/show_bug.cgi?id=158493 I want to make it use more ES6 features: https://bugs.webkit.org/show_bug.cgi?id=158497 * JSAir: Added. * JSAir/all.js: Added. * JSAir/allocate_stack.js: Added. (allocateStack.attemptAssignment): (allocateStack.assign): (allocateStack.interfere): (allocateStack.): (allocateStack): * JSAir/arg.js: Added. (Arg): (Arg.isAnyUse): (Arg.isColdUse): (Arg.isWarmUse): (Arg.cooled): (Arg.isEarlyUse): (Arg.isLateUse): (Arg.isAnyDef): (Arg.isEarlyDef): (Arg.isLateDef): (Arg.isZDef): (Arg.typeForB3Type): (Arg.widthForB3Type): (Arg.conservativeWidth): (Arg.minimumWidth): (Arg.bytes): (Arg.widthForBytes): (Arg.createTmp): (Arg.fromReg): (Arg.createImm): (Arg.createBigImm): (Arg.createBitImm): (Arg.createBitImm64): (Arg.createAddr): (Arg.createStack): (Arg.createCallArg): (Arg.createStackAddr): (Arg.isValidScale): (Arg.logScale): (Arg.createIndex): (Arg.createRelCond): (Arg.createResCond): (Arg.createDoubleCond): (Arg.createWidth): (Arg.prototype.get kind): (Arg.prototype.get isTmp): (Arg.prototype.get isImm): (Arg.prototype.get isBigImm): (Arg.prototype.get isBitImm): (Arg.prototype.get isBitImm64): (Arg.prototype.get isSomeImm): (Arg.prototype.get isAddr): (Arg.prototype.get isStack): (Arg.prototype.get isCallArg): (Arg.prototype.get isIndex): (Arg.prototype.get isMemory): (Arg.prototype.get isStackMemory): (Arg.prototype.get isRelCond): (Arg.prototype.get isResCond): (Arg.prototype.get isDoubleCond): (Arg.prototype.get isCondition): (Arg.prototype.get isWidth): (Arg.prototype.get isAlive): (Arg.prototype.get tmp): (Arg.prototype.get value): (Arg.prototype.get base): (Arg.prototype.get hasOffset): (Arg.prototype.get offset): (Arg.prototype.get stackSlot): (Arg.prototype.get index): (Arg.prototype.get scale): (Arg.prototype.get logScale): (Arg.prototype.get width): (Arg.prototype.get isGPTmp): (Arg.prototype.get isFPTmp): (Arg.prototype.get isGP): (Arg.prototype.get isFP): (Arg.prototype.get hasType): (Arg.prototype.get type): (Arg.prototype.isType): (Arg.prototype.isCompatibleType): (Arg.prototype.get isGPR): (Arg.prototype.get gpr): (Arg.prototype.get isFPR): (Arg.prototype.get fpr): (Arg.prototype.get isReg): (Arg.prototype.get reg): (Arg.isValidImmForm): (Arg.isValidBitImmForm): (Arg.isValidBitImm64Form): (Arg.isValidAddrForm): (Arg.isValidIndexForm): (Arg.prototype.isValidForm): (Arg.prototype.forEachTmpFast): (Arg.prototype.usesTmp): (Arg.prototype.forEachTmp): (Arg.prototype.is): (Arg.prototype.as): (Arg.prototype.forEachFast): (Arg.prototype.forEach): (Arg.extract): (Arg.forEachFast): (Arg.forEach): (Arg.prototype.get condition): (Arg.prototype.get isInvertible): (Arg.prototype.toString): * JSAir/basic_block.js: Added. (BasicBlock): (BasicBlock.prototype.get index): (BasicBlock.prototype.get size): (BasicBlock.prototype.Symbol.iterator): (BasicBlock.prototype.at): (BasicBlock.get last): (BasicBlock.get insts): (BasicBlock.get numSuccessors): (BasicBlock.get successors): (BasicBlock.get successorBlocks.): (BasicBlock.get successorBlocks): (BasicBlock.set get numPredecessors): (BasicBlock.get predecessors): (BasicBlock.get frequency): (BasicBlock.get headerString): (BasicBlock.get footerString): * JSAir/benchmark.js: Added. (benchmark): * JSAir/code.js: Added. (Code): (Code.prototype.addBlock): (Code.prototype.addStackSlot): (Code.prototype.newTmp): (Code.prototype.get size): (Code.prototype.at): (Code.prototype.Symbol.iterator): (Code.prototype.get blocks): (Code.prototype.get stackSlots): (Code.prototype.tmps): (Code.prototype.get callArgAreaSize): (Code.prototype.requestCallArgAreaSize): (Code.prototype.get frameSize): (Code.prototype.setFrameSize): (Code.prototype.toString): * JSAir/custom.js: Added. (const.ShuffleCustom.forEachArg): (const.ShuffleCustom.hasNonArgNonControlEffects): (const.PatchCustom.forEachArg): (const.PatchCustom.hasNonArgNonControlEffects): (const.CCallCustom.forEachArg): (const.CCallCustom.hasNonArgNonControlEffects): (const.ColdCCallCustom.forEachArg): (const.ColdCCallCustom.hasNonArgNonControlEffects): * JSAir/frequented_block.js: Added. (FrequentedBlock): (FrequentedBlock.prototype.toString): * JSAir/insertion_set.js: Added. (Insertion): (Insertion.prototype.get index): (Insertion.prototype.get element): (Insertion.prototype.lessThan): (InsertionSet): (InsertionSet.prototype.appendInsertion): (InsertionSet.prototype.append): (InsertionSet.prototype.execute): * JSAir/inst.js: Added. (Inst): (Inst.prototype.append): (Inst.prototype.clear): (Inst.prototype.get opcode): (Inst.prototype.get args): (Inst.prototype.visitArg): (Inst.prototype.forEachTmpFast): (Inst.prototype.forEachArg): (Inst.prototype.forEachTmp): (Inst.prototype.forEach): (Inst.forEachDef): (Inst.forEachDefWithExtraClobberedRegs): (Inst.prototype.get hasNonArgEffects): (Inst.prototype.toString): * JSAir/liveness.js: Added. (Liveness): (Liveness.prototype.get thing): (Liveness.prototype.get code): (Liveness.prototype.get liveAtHead): (Liveness.prototype.get liveAtTail): (Liveness.prototype.localCalc.LocalCalc): (Liveness.prototype.localCalc.LocalCalc.prototype.get liveSet): (Liveness.prototype.localCalc.LocalCalc.prototype.execute): (Liveness.prototype.localCalc): * JSAir/opcode.js: Added. (Inst_forEachArg): (Inst_hasNonArgEffects): * JSAir/payload-gbemu-executeIteration.js: Added. (createPayloadGbemuExecuteIteration): * JSAir/payload-imaging-gaussian-blur-gaussianBlur.js: Added. (createPayloadImagingGaussianBlurGaussianBlur): * JSAir/payload-jsair-ACLj8C.js: Added. (createPayloadJSAirACLj8C): * JSAir/payload-typescript-scanIdentifier.js: Added. (createPayloadTypescriptScanIdentifier): * JSAir/reg.js: Added. (Reg): (Reg.fromReg): (Reg.prototype.get index): (Reg.prototype.get type): (Reg.prototype.get name): (Reg.prototype.get isCalleeSave): (Reg.prototype.get isReg): (Reg.prototype.toString): (Reg.extract): (Reg.forEachFast): (Reg.forEach): (newGPR): (Reg.gprs.Reg.fprs.Reg.calleeSaveGPRs.Reg.calleeSaveFPRs.Reg.calleeSaves): * JSAir/stack_slot.js: Added. (StackSlot): (StackSlot.prototype.get byteSize): (StackSlot.prototype.get kind): (StackSlot.prototype.get isLocked): (StackSlot.prototype.get isSpill): (StackSlot.prototype.get index): (StackSlot.prototype.ensureSize): (StackSlot.prototype.get alignment): (StackSlot.prototype.get offsetFromFP): (StackSlot.prototype.setOffsetFromFP): (StackSlot.prototype.toString): (StackSlot.extract): (StackSlot.forEachFast): (StackSlot.forEach): * JSAir/symbols.js: Added. * JSAir/test.html: Added. * JSAir/test.js: Added. * JSAir/tmp.js: Added. (Tmp): (Tmp.fromReg): (Tmp.prototype.get index): (Tmp.prototype.get type): (Tmp.prototype.get isReg): (Tmp.prototype.toString): (Tmp.extract): (Tmp.forEachFast): (Tmp.forEach): * JSAir/tmp_base.js: Added. (TmpBase.prototype.get isGP): (TmpBase.prototype.get isFP): (TmpBase.prototype.get isGPR): (TmpBase.prototype.get isFPR): (TmpBase.prototype.get reg): (TmpBase.prototype.get gpr): (TmpBase.prototype.get fpr): (TmpBase): * JSAir/util.js: Added. (isRepresentableAsInt32): (addIndexed): (roundUpToMultipleOf): (symbolName): (mergeIntoSet): (nonEmptyRangesOverlap): (rangesOverlap): (removeAllMatching): (swap): (bubble): (bubbleSort): (currentTime): (else.currentTime): Source/JavaScriptCore: Most of these changes are to support dumpAsJS(). But I also found some duplicate and dead code while rewriting it to JS. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * b3/air/AirAllocateStack.cpp: * b3/air/AirArg.h: (JSC::B3::Air::Arg::isSomeImm): (JSC::B3::Air::Arg::isAddr): (JSC::B3::Air::Arg::tmpIndex): (JSC::B3::Air::Arg::isValidImmForm): (JSC::B3::Air::Arg::withOffset): Deleted. This was dead code. * b3/air/AirArgInlines.h: It turns out that Inst has a ForEach thing that duplicated some of the logic of ArgThingHelper, so I just made ArgThingHelper more powerful. (JSC::B3::Air::ArgThingHelper<Arg>::forEach): (JSC::B3::Air::ArgThingHelper<Reg>::is): (JSC::B3::Air::ArgThingHelper<Reg>::as): (JSC::B3::Air::ArgThingHelper<Reg>::forEachFast): (JSC::B3::Air::ArgThingHelper<Reg>::forEach): (JSC::B3::Air::Arg::is): * b3/air/AirDumpAsJS.cpp: Added. (JSC::B3::Air::dumpAsJS): * b3/air/AirDumpAsJS.h: Added. * b3/air/AirFixObviousSpills.cpp: * b3/air/AirGenerate.cpp: (JSC::B3::Air::prepareForGeneration): * b3/air/AirInstInlines.h: (JSC::B3::Air::Inst::forEach): (JSC::B3::Air::Inst::extraClobberedRegs): (JSC::B3::Air::ForEach<Tmp>::forEach): Deleted. This was doing what ArgThingHelper would have done but not as well. (JSC::B3::Air::ForEach<Arg>::forEach): Deleted. (JSC::B3::Air::ForEach<Reg>::forEach): Deleted. * b3/air/AirLogRegisterPressure.cpp: * b3/air/AirReportUsedRegisters.cpp: * b3/air/AirSpillEverything.cpp: * b3/air/opcode_generator.rb: Make this dump opcode.js, which is like what it dumps for C++. * jit/Reg.cpp: (JSC::Reg::debugName): (JSC::Reg::dump): * jit/Reg.h: (JSC::Reg::hash): * jsc.cpp: Fix jsc so that it reports the filename and line number of parser errors. (dumpException): * parser/ParserError.h: Make it easier to debug this code. (WTF::printInternal): * runtime/Options.h: Source/WTF: * wtf/Insertion.h: (WTF::executeInsertions): I found a bug while rewriting this code in JS. * wtf/PrintStream.h: (WTF::PrintStream::print): (WTF::PrintStream::println): This is useful to have. Canonical link: https://commits.webkit.org/176569@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 01:43:35 +00:00
Reg.gprs = []
Reg.fprs = []
Reg.calleeSaveGPRs = []
Reg.calleeSaveFPRs = []
Reg.calleeSaves = []
for (let reg of Reg.regs) {
if (reg.isGP) {
Reg.gprs.push(reg);
if (reg.isCalleeSave)
Reg.calleeSaveGPRs.push(reg);
} else {
Reg.fprs.push(reg);
if (reg.isCalleeSave)
Reg.calleeSaveFPRS.push(reg);
}
if (reg.isCalleeSave)
Reg.calleeSaves.push(reg);
}
Reg.callFrameRegister = Reg.rbp;
Reg.stackPointerRegister = Reg.rsp;
}