Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (230149 => 230150)
--- trunk/Source/_javascript_Core/ChangeLog 2018-04-02 05:59:28 UTC (rev 230149)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-04-02 07:51:17 UTC (rev 230150)
@@ -1,3 +1,34 @@
+2018-04-02 Yusuke Suzuki <[email protected]>
+
+ [DFG] More aggressive removal of duplicate 32bit DFG code
+ https://bugs.webkit.org/show_bug.cgi?id=184089
+
+ Reviewed by Saam Barati.
+
+ This patch more aggressively removes duplicate 32bit DFG code
+ by leveraging JSValueRegs and meta-programmed callOperation.
+
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileGetByValWithThis):
+ (JSC::DFG::SpeculativeJIT::compileArithMinMax):
+ (JSC::DFG::SpeculativeJIT::compileNewArray):
+ (JSC::DFG::SpeculativeJIT::compileCheckCell):
+ (JSC::DFG::SpeculativeJIT::compileGetGlobalVariable):
+ (JSC::DFG::SpeculativeJIT::compilePutGlobalVariable):
+ (JSC::DFG::SpeculativeJIT::compileGetClosureVar):
+ (JSC::DFG::SpeculativeJIT::compilePutClosureVar):
+ (JSC::DFG::SpeculativeJIT::compileGetByOffset):
+ (JSC::DFG::SpeculativeJIT::compilePutByOffset):
+ (JSC::DFG::SpeculativeJIT::compileGetExecutable):
+ (JSC::DFG::SpeculativeJIT::compileNewArrayBuffer):
+ (JSC::DFG::SpeculativeJIT::compileToThis):
+ (JSC::DFG::SpeculativeJIT::compileIdentity):
+ * dfg/DFGSpeculativeJIT.h:
+ * dfg/DFGSpeculativeJIT32_64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ * dfg/DFGSpeculativeJIT64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+
2018-04-01 Filip Pizlo <[email protected]>
Raise the for-call inlining threshold to 190 to fix JetStream/richards regression
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (230149 => 230150)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2018-04-02 05:59:28 UTC (rev 230149)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2018-04-02 07:51:17 UTC (rev 230150)
@@ -3270,6 +3270,24 @@
noResult(node);
}
+void SpeculativeJIT::compileGetByValWithThis(Node* node)
+{
+ JSValueOperand base(this, node->child1());
+ JSValueRegs baseRegs = base.jsValueRegs();
+ JSValueOperand thisValue(this, node->child2());
+ JSValueRegs thisValueRegs = thisValue.jsValueRegs();
+ JSValueOperand subscript(this, node->child3());
+ JSValueRegs subscriptRegs = subscript.jsValueRegs();
+
+ flushRegisters();
+ JSValueRegsFlushedCallResult result(this);
+ JSValueRegs resultRegs = result.regs();
+ callOperation(operationGetByValWithThis, resultRegs, baseRegs, thisValueRegs, subscriptRegs);
+ m_jit.exceptionCheck();
+
+ jsValueResult(resultRegs, node);
+}
+
void SpeculativeJIT::compileInstanceOfForObject(Node*, GPRReg valueReg, GPRReg prototypeReg, GPRReg scratchReg, GPRReg scratch2Reg, GPRReg scratch3Reg)
{
// Check that prototype is an object.
@@ -5502,6 +5520,76 @@
doubleResult(result.fpr(), node);
}
+void SpeculativeJIT::compileArithMinMax(Node* node)
+{
+ switch (node->binaryUseKind()) {
+ case Int32Use: {
+ SpeculateStrictInt32Operand op1(this, node->child1());
+ SpeculateStrictInt32Operand op2(this, node->child2());
+ GPRTemporary result(this, Reuse, op1);
+
+ GPRReg op1GPR = op1.gpr();
+ GPRReg op2GPR = op2.gpr();
+ GPRReg resultGPR = result.gpr();
+
+ MacroAssembler::Jump op1Less = m_jit.branch32(node->op() == ArithMin ? MacroAssembler::LessThan : MacroAssembler::GreaterThan, op1GPR, op2GPR);
+ m_jit.move(op2GPR, resultGPR);
+ if (op1GPR != resultGPR) {
+ MacroAssembler::Jump done = m_jit.jump();
+ op1Less.link(&m_jit);
+ m_jit.move(op1GPR, resultGPR);
+ done.link(&m_jit);
+ } else
+ op1Less.link(&m_jit);
+
+ int32Result(resultGPR, node);
+ break;
+ }
+
+ case DoubleRepUse: {
+ SpeculateDoubleOperand op1(this, node->child1());
+ SpeculateDoubleOperand op2(this, node->child2());
+ FPRTemporary result(this, op1);
+
+ FPRReg op1FPR = op1.fpr();
+ FPRReg op2FPR = op2.fpr();
+ FPRReg resultFPR = result.fpr();
+
+ MacroAssembler::JumpList done;
+
+ MacroAssembler::Jump op1Less = m_jit.branchDouble(node->op() == ArithMin ? MacroAssembler::DoubleLessThan : MacroAssembler::DoubleGreaterThan, op1FPR, op2FPR);
+
+ // op2 is eather the lesser one or one of then is NaN
+ MacroAssembler::Jump op2Less = m_jit.branchDouble(node->op() == ArithMin ? MacroAssembler::DoubleGreaterThanOrEqual : MacroAssembler::DoubleLessThanOrEqual, op1FPR, op2FPR);
+
+ // Unordered case. We don't know which of op1, op2 is NaN. Manufacture NaN by adding
+ // op1 + op2 and putting it into result.
+ m_jit.addDouble(op1FPR, op2FPR, resultFPR);
+ done.append(m_jit.jump());
+
+ op2Less.link(&m_jit);
+ m_jit.moveDouble(op2FPR, resultFPR);
+
+ if (op1FPR != resultFPR) {
+ done.append(m_jit.jump());
+
+ op1Less.link(&m_jit);
+ m_jit.moveDouble(op1FPR, resultFPR);
+ } else
+ op1Less.link(&m_jit);
+
+ done.link(&m_jit);
+
+ doubleResult(resultFPR, node);
+ break;
+ }
+
+ default:
+ DFG_CRASH(m_jit.graph(), node, "Bad use kind");
+ break;
+ }
+}
+
// For small positive integers , it is worth doing a tiny inline loop to exponentiate the base.
// Every register is clobbered by this helper.
static MacroAssembler::Jump compileArithPowIntegerFastPath(JITCompiler& assembler, FPRReg xOperand, GPRReg yOperand, FPRReg result)
@@ -7448,6 +7536,170 @@
}
}
+void SpeculativeJIT::compileNewArray(Node* node)
+{
+ JSGlobalObject* globalObject = m_jit.graph().globalObjectFor(node->origin.semantic);
+ if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(node->indexingType())) {
+ RegisteredStructure structure = m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
+ DFG_ASSERT(m_jit.graph(), node, structure->indexingType() == node->indexingType(), structure->indexingType(), node->indexingType());
+ ASSERT(
+ hasUndecided(structure->indexingType())
+ || hasInt32(structure->indexingType())
+ || hasDouble(structure->indexingType())
+ || hasContiguous(structure->indexingType()));
+
+ unsigned numElements = node->numChildren();
+ unsigned vectorLengthHint = node->vectorLengthHint();
+ ASSERT(vectorLengthHint >= numElements);
+
+ GPRTemporary result(this);
+ GPRTemporary storage(this);
+
+ GPRReg resultGPR = result.gpr();
+ GPRReg storageGPR = storage.gpr();
+
+ emitAllocateRawObject(resultGPR, structure, storageGPR, numElements, vectorLengthHint);
+
+ // At this point, one way or another, resultGPR and storageGPR have pointers to
+ // the JSArray and the Butterfly, respectively.
+
+ ASSERT(!hasUndecided(structure->indexingType()) || !node->numChildren());
+
+ for (unsigned operandIdx = 0; operandIdx < node->numChildren(); ++operandIdx) {
+ Edge use = m_jit.graph().m_varArgChildren[node->firstChild() + operandIdx];
+ switch (node->indexingType()) {
+ case ALL_BLANK_INDEXING_TYPES:
+ case ALL_UNDECIDED_INDEXING_TYPES:
+ CRASH();
+ break;
+ case ALL_DOUBLE_INDEXING_TYPES: {
+ SpeculateDoubleOperand operand(this, use);
+ FPRReg opFPR = operand.fpr();
+ DFG_TYPE_CHECK(
+ JSValueRegs(), use, SpecDoubleReal,
+ m_jit.branchDouble(
+ MacroAssembler::DoubleNotEqualOrUnordered, opFPR, opFPR));
+ m_jit.storeDouble(opFPR, MacroAssembler::Address(storageGPR, sizeof(double) * operandIdx));
+ break;
+ }
+ case ALL_INT32_INDEXING_TYPES:
+ case ALL_CONTIGUOUS_INDEXING_TYPES: {
+ JSValueOperand operand(this, use, ManualOperandSpeculation);
+ JSValueRegs operandRegs = operand.jsValueRegs();
+ if (hasInt32(node->indexingType())) {
+ DFG_TYPE_CHECK(
+ operandRegs, use, SpecInt32Only,
+ m_jit.branchIfNotInt32(operandRegs));
+ }
+ m_jit.storeValue(operandRegs, MacroAssembler::Address(storageGPR, sizeof(JSValue) * operandIdx));
+ break;
+ }
+ default:
+ CRASH();
+ break;
+ }
+ }
+
+ // Yuck, we should *really* have a way of also returning the storageGPR. But
+ // that's the least of what's wrong with this code. We really shouldn't be
+ // allocating the array after having computed - and probably spilled to the
+ // stack - all of the things that will go into the array. The solution to that
+ // bigger problem will also likely fix the redundancy in reloading the storage
+ // pointer that we currently have.
+
+ cellResult(resultGPR, node);
+ return;
+ }
+
+ if (!node->numChildren()) {
+ flushRegisters();
+ GPRFlushedCallResult result(this);
+ callOperation(operationNewEmptyArray, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())));
+ m_jit.exceptionCheck();
+ cellResult(result.gpr(), node);
+ return;
+ }
+
+ size_t scratchSize = sizeof(EncodedJSValue) * node->numChildren();
+ ScratchBuffer* scratchBuffer = m_jit.vm()->scratchBufferForSize(scratchSize);
+ EncodedJSValue* buffer = scratchBuffer ? static_cast<EncodedJSValue*>(scratchBuffer->dataBuffer()) : nullptr;
+
+ for (unsigned operandIdx = 0; operandIdx < node->numChildren(); ++operandIdx) {
+ // Need to perform the speculations that this node promises to perform. If we're
+ // emitting code here and the indexing type is not array storage then there is
+ // probably something hilarious going on and we're already failing at all the
+ // things, but at least we're going to be sound.
+ Edge use = m_jit.graph().m_varArgChildren[node->firstChild() + operandIdx];
+ switch (node->indexingType()) {
+ case ALL_BLANK_INDEXING_TYPES:
+ case ALL_UNDECIDED_INDEXING_TYPES:
+ CRASH();
+ break;
+ case ALL_DOUBLE_INDEXING_TYPES: {
+ SpeculateDoubleOperand operand(this, use);
+ FPRReg opFPR = operand.fpr();
+ DFG_TYPE_CHECK(
+ JSValueRegs(), use, SpecDoubleReal,
+ m_jit.branchDouble(
+ MacroAssembler::DoubleNotEqualOrUnordered, opFPR, opFPR));
+#if USE(JSVALUE64)
+ JSValueRegsTemporary scratch(this);
+ JSValueRegs scratchRegs = scratch.regs();
+ m_jit.boxDouble(opFPR, scratchRegs);
+ m_jit.storeValue(scratchRegs, buffer + operandIdx);
+#else
+ m_jit.storeDouble(opFPR, TrustedImmPtr(buffer + operandIdx));
+#endif
+ operand.use();
+ break;
+ }
+ case ALL_INT32_INDEXING_TYPES:
+ case ALL_CONTIGUOUS_INDEXING_TYPES:
+ case ALL_ARRAY_STORAGE_INDEXING_TYPES: {
+ JSValueOperand operand(this, use, ManualOperandSpeculation);
+ JSValueRegs operandRegs = operand.jsValueRegs();
+ if (hasInt32(node->indexingType())) {
+ DFG_TYPE_CHECK(
+ operandRegs, use, SpecInt32Only,
+ m_jit.branchIfNotInt32(operandRegs));
+ }
+ m_jit.storeValue(operandRegs, buffer + operandIdx);
+ operand.use();
+ break;
+ }
+ default:
+ CRASH();
+ break;
+ }
+ }
+
+ flushRegisters();
+
+ if (scratchSize) {
+ GPRTemporary scratch(this);
+
+ // Tell GC mark phase how much of the scratch buffer is active during call.
+ m_jit.move(TrustedImmPtr(scratchBuffer->addressOfActiveLength()), scratch.gpr());
+ m_jit.storePtr(TrustedImmPtr(scratchSize), scratch.gpr());
+ }
+
+ GPRFlushedCallResult result(this);
+
+ callOperation(
+ operationNewArray, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())),
+ static_cast<void*>(buffer), size_t(node->numChildren()));
+ m_jit.exceptionCheck();
+
+ if (scratchSize) {
+ GPRTemporary scratch(this);
+
+ m_jit.move(TrustedImmPtr(scratchBuffer->addressOfActiveLength()), scratch.gpr());
+ m_jit.storePtr(TrustedImmPtr(nullptr), scratch.gpr());
+ }
+
+ cellResult(result.gpr(), node, UseChildrenCalledExplicitly);
+}
+
void SpeculativeJIT::compileNewArrayWithSpread(Node* node)
{
ASSERT(node->op() == NewArrayWithSpread);
@@ -8437,6 +8689,13 @@
}
}
+void SpeculativeJIT::compileCheckCell(Node* node)
+{
+ SpeculateCellOperand cell(this, node->child1());
+ speculationCheck(BadCell, JSValueSource::unboxedCell(cell.gpr()), node->child1(), m_jit.branchWeakPtr(JITCompiler::NotEqual, cell.gpr(), node->cellOperand()->cell()));
+ noResult(node);
+}
+
void SpeculativeJIT::compileCheckStructure(Node* node)
{
switch (node->child1().useKind()) {
@@ -10436,7 +10695,23 @@
m_jit.exceptionCheck();
jsValueResult(resultRegs, node);
}
-
+
+void SpeculativeJIT::compileGetGlobalVariable(Node* node)
+{
+ JSValueRegsTemporary result(this);
+ JSValueRegs resultRegs = result.regs();
+ m_jit.loadValue(node->variablePointer(), resultRegs);
+ jsValueResult(resultRegs, node);
+}
+
+void SpeculativeJIT::compilePutGlobalVariable(Node* node)
+{
+ JSValueOperand value(this, node->child2());
+ JSValueRegs valueRegs = value.jsValueRegs();
+ m_jit.storeValue(valueRegs, node->variablePointer());
+ noResult(node);
+}
+
void SpeculativeJIT::compileGetDynamicVar(Node* node)
{
SpeculateCellOperand scope(this, node->child1());
@@ -10463,6 +10738,30 @@
noResult(node);
}
+void SpeculativeJIT::compileGetClosureVar(Node* node)
+{
+ SpeculateCellOperand base(this, node->child1());
+ JSValueRegsTemporary result(this);
+
+ GPRReg baseGPR = base.gpr();
+ JSValueRegs resultRegs = result.regs();
+
+ m_jit.loadValue(JITCompiler::Address(baseGPR, JSLexicalEnvironment::offsetOfVariable(node->scopeOffset())), resultRegs);
+ jsValueResult(resultRegs, node);
+}
+
+void SpeculativeJIT::compilePutClosureVar(Node* node)
+{
+ SpeculateCellOperand base(this, node->child1());
+ JSValueOperand value(this, node->child2());
+
+ GPRReg baseGPR = base.gpr();
+ JSValueRegs valueRegs = value.jsValueRegs();
+
+ m_jit.storeValue(valueRegs, JITCompiler::Address(baseGPR, JSLexicalEnvironment::offsetOfVariable(node->scopeOffset())));
+ noResult(node);
+}
+
void SpeculativeJIT::compilePutAccessorByVal(Node* node)
{
SpeculateCellOperand base(this, node->child1());
@@ -11292,6 +11591,38 @@
noResult(node);
}
+void SpeculativeJIT::compileGetByOffset(Node* node)
+{
+ StorageOperand storage(this, node->child1());
+ JSValueRegsTemporary result(this, Reuse, storage);
+
+ GPRReg storageGPR = storage.gpr();
+ JSValueRegs resultRegs = result.regs();
+
+ StorageAccessData& storageAccessData = node->storageAccessData();
+
+ m_jit.loadValue(JITCompiler::Address(storageGPR, offsetRelativeToBase(storageAccessData.offset)), resultRegs);
+
+ jsValueResult(resultRegs, node);
+}
+
+void SpeculativeJIT::compilePutByOffset(Node* node)
+{
+ StorageOperand storage(this, node->child1());
+ JSValueOperand value(this, node->child3());
+
+ GPRReg storageGPR = storage.gpr();
+ JSValueRegs valueRegs = value.jsValueRegs();
+
+ speculate(node, node->child2());
+
+ StorageAccessData& storageAccessData = node->storageAccessData();
+
+ m_jit.storeValue(valueRegs, JITCompiler::Address(storageGPR, offsetRelativeToBase(storageAccessData.offset)));
+
+ noResult(node);
+}
+
void SpeculativeJIT::compileHasStructureProperty(Node* node)
{
JSValueOperand base(this, node->child1());
@@ -11380,6 +11711,20 @@
jsValueResult(resultRegs, node);
}
+void SpeculativeJIT::compileGetExecutable(Node* node)
+{
+ SpeculateCellOperand function(this, node->child1());
+ GPRTemporary result(this, Reuse, function);
+ GPRReg functionGPR = function.gpr();
+ GPRReg resultGPR = result.gpr();
+ speculateCellType(node->child1(), functionGPR, SpecFunction, JSFunctionType);
+ m_jit.loadPtr(JITCompiler::Address(functionGPR, JSFunction::offsetOfExecutable()), resultGPR);
+#if USE(JSVALUE64)
+ m_jit.xorPtr(JITCompiler::TrustedImmPtr(JSFunctionPoison::key()), resultGPR);
+#endif
+ cellResult(resultGPR, node);
+}
+
void SpeculativeJIT::compileGetGetter(Node* node)
{
SpeculateCellOperand op1(this, node->child1());
@@ -11456,6 +11801,63 @@
cellResult(result.gpr(), node);
}
+void SpeculativeJIT::compileNewArrayBuffer(Node* node)
+{
+ JSGlobalObject* globalObject = m_jit.graph().globalObjectFor(node->origin.semantic);
+ JSFixedArray* array = node->castOperand<JSFixedArray*>();
+ unsigned numElements = array->length();
+ IndexingType indexingType = node->indexingType();
+ if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(indexingType)) {
+ unsigned vectorLengthHint = node->vectorLengthHint();
+ ASSERT(vectorLengthHint >= numElements);
+
+ GPRTemporary result(this);
+ GPRTemporary storage(this);
+
+ GPRReg resultGPR = result.gpr();
+ GPRReg storageGPR = storage.gpr();
+
+ emitAllocateRawObject(resultGPR, m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), storageGPR, numElements, vectorLengthHint);
+
+ DFG_ASSERT(m_jit.graph(), node, indexingType & IsArray, indexingType);
+
+ for (unsigned index = 0; index < numElements; ++index) {
+#if USE(JSVALUE64)
+ int64_t value;
+ if (indexingType == ArrayWithDouble)
+ value = bitwise_cast<int64_t>(array->get(index).asNumber());
+ else
+ value = JSValue::encode(array->get(index));
+ static_assert(sizeof(double) == sizeof(JSValue), "");
+ m_jit.store64(Imm64(value), MacroAssembler::Address(storageGPR, sizeof(JSValue) * index));
+#else
+ union {
+ int32_t halves[2];
+ double doubleValue;
+ int64_t encodedValue;
+ } u;
+ if (node->indexingType() == ArrayWithDouble)
+ u.doubleValue = array->get(index).asNumber();
+ else
+ u.encodedValue = JSValue::encode(array->get(index));
+ static_assert(sizeof(double) == sizeof(JSValue), "");
+ m_jit.store32(Imm32(u.halves[0]), MacroAssembler::Address(storageGPR, sizeof(JSValue) * index));
+ m_jit.store32(Imm32(u.halves[1]), MacroAssembler::Address(storageGPR, sizeof(JSValue) * index + sizeof(int32_t)));
+#endif
+ }
+ cellResult(resultGPR, node);
+ return;
+ }
+
+ flushRegisters();
+ GPRFlushedCallResult result(this);
+
+ callOperation(operationNewArrayBuffer, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())), TrustedImmPtr(node->cellOperand()), size_t(numElements));
+ m_jit.exceptionCheck();
+
+ cellResult(result.gpr(), node);
+}
+
void SpeculativeJIT::compileNewArrayWithSize(Node* node)
{
JSGlobalObject* globalObject = m_jit.graph().globalObjectFor(node->origin.semantic);
@@ -11518,6 +11920,34 @@
}
}
+void SpeculativeJIT::compileToThis(Node* node)
+{
+ ASSERT(node->child1().useKind() == UntypedUse);
+ JSValueOperand thisValue(this, node->child1());
+ JSValueRegsTemporary temp(this);
+
+ JSValueRegs thisValueRegs = thisValue.jsValueRegs();
+ JSValueRegs tempRegs = temp.regs();
+
+ MacroAssembler::JumpList slowCases;
+ slowCases.append(m_jit.branchIfNotCell(thisValueRegs));
+ slowCases.append(
+ m_jit.branchTest8(
+ MacroAssembler::NonZero,
+ MacroAssembler::Address(thisValueRegs.payloadGPR(), JSCell::typeInfoFlagsOffset()),
+ MacroAssembler::TrustedImm32(OverridesToThis)));
+ m_jit.moveValueRegs(thisValueRegs, tempRegs);
+
+ J_JITOperation_EJ function;
+ if (m_jit.graph().executableFor(node->origin.semantic)->isStrictMode())
+ function = operationToThisStrict;
+ else
+ function = operationToThis;
+ addSlowPathGenerator(slowPathCall(slowCases, this, function, tempRegs, thisValueRegs));
+
+ jsValueResult(tempRegs, node);
+}
+
void SpeculativeJIT::compileCreateThis(Node* node)
{
// Note that there is not so much profit to speculate here. The only things we
@@ -11961,6 +12391,43 @@
}
}
+void SpeculativeJIT::compileIdentity(Node* node)
+{
+ speculate(node, node->child1());
+ switch (node->child1().useKind()) {
+#if USE(JSVALUE64)
+ case DoubleRepAnyIntUse:
+#endif
+ case DoubleRepUse:
+ case DoubleRepRealUse: {
+ SpeculateDoubleOperand op(this, node->child1());
+ FPRTemporary scratch(this, op);
+ m_jit.moveDouble(op.fpr(), scratch.fpr());
+ doubleResult(scratch.fpr(), node);
+ break;
+ }
+#if USE(JSVALUE64)
+ case Int52RepUse: {
+ SpeculateInt52Operand op(this, node->child1());
+ GPRTemporary result(this, Reuse, op);
+ m_jit.move(op.gpr(), result.gpr());
+ int52Result(result.gpr(), node);
+ break;
+ }
+#endif
+ default: {
+ JSValueOperand op(this, node->child1(), ManualOperandSpeculation);
+ JSValueRegsTemporary result(this, Reuse, op);
+ JSValueRegs opRegs = op.jsValueRegs();
+ JSValueRegs resultRegs = result.regs();
+ m_jit.moveValueRegs(opRegs, resultRegs);
+ jsValueResult(resultRegs, node);
+ break;
+ }
+ }
+}
+
+
} } // namespace JSC::DFG
#endif
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h (230149 => 230150)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2018-04-02 05:59:28 UTC (rev 230149)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2018-04-02 07:51:17 UTC (rev 230150)
@@ -1281,6 +1281,7 @@
void compileLoadValueFromMapBucket(Node*);
void compileExtractValueFromWeakMapGet(Node*);
void compileGetPrototypeOf(Node*);
+ void compileIdentity(Node*);
#if USE(JSVALUE32_64)
template<typename BaseOperandType, typename PropertyOperandType, typename ValueOperandType, typename TagType>
@@ -1352,6 +1353,7 @@
void compileArithRandom(Node*);
void compileArithUnary(Node*);
void compileArithSqrt(Node*);
+ void compileArithMinMax(Node*);
void compileConstantStoragePointer(Node*);
void compileGetIndexedPropertyStorage(Node*);
JITCompiler::Jump jumpForTypedArrayOutOfBounds(Node*, GPRReg baseGPR, GPRReg indexGPR);
@@ -1366,6 +1368,9 @@
void compileGetByValForObjectWithSymbol(Node*);
void compilePutByValForCellWithString(Node*, Edge& child1, Edge& child2, Edge& child3);
void compilePutByValForCellWithSymbol(Node*, Edge& child1, Edge& child2, Edge& child3);
+ void compileGetByValWithThis(Node*);
+ void compileGetByOffset(Node*);
+ void compilePutByOffset(Node*);
// If this returns false it means that we terminated speculative execution.
bool getIntTypedArrayStoreOperand(
GPRTemporary& value,
@@ -1391,6 +1396,7 @@
void compileCreateClonedArguments(Node*);
void compileCreateRest(Node*);
void compileSpread(Node*);
+ void compileNewArray(Node*);
void compileNewArrayWithSpread(Node*);
void compileGetRestLength(Node*);
void compileArraySlice(Node*);
@@ -1406,6 +1412,7 @@
void compileIsObjectOrNull(Node*);
void compileIsFunction(Node*);
void compileTypeOf(Node*);
+ void compileCheckCell(Node*);
void compileCheckStructure(Node*);
void emitStructureCheck(Node*, GPRReg cellGPR, GPRReg tempGPR);
void compilePutAccessorById(Node*);
@@ -1419,8 +1426,12 @@
void compileToObjectOrCallObjectConstructor(Node*);
void compileResolveScope(Node*);
void compileResolveScopeForHoistingFuncDeclInEval(Node*);
+ void compileGetGlobalVariable(Node*);
+ void compilePutGlobalVariable(Node*);
void compileGetDynamicVar(Node*);
void compilePutDynamicVar(Node*);
+ void compileGetClosureVar(Node*);
+ void compilePutClosureVar(Node*);
void compileCompareEqPtr(Node*);
void compileDefineDataProperty(Node*);
void compileDefineAccessorProperty(Node*);
@@ -1435,6 +1446,7 @@
void compileHasStructureProperty(Node*);
void compileGetPropertyEnumerator(Node*);
void compileGetEnumeratorPname(Node*);
+ void compileGetExecutable(Node*);
void compileGetGetter(Node*);
void compileGetSetter(Node*);
void compileGetCallee(Node*);
@@ -1441,8 +1453,10 @@
void compileGetArgumentCountIncludingThis(Node*);
void compileSetArgumentCountIncludingThis(Node*);
void compileStrCat(Node*);
+ void compileNewArrayBuffer(Node*);
void compileNewArrayWithSize(Node*);
void compileNewTypedArray(Node*);
+ void compileToThis(Node*);
void compileCreateThis(Node*);
void compileNewObject(Node*);
void compileToPrimitive(Node*);
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp (230149 => 230150)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp 2018-04-02 05:59:28 UTC (rev 230149)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp 2018-04-02 07:51:17 UTC (rev 230150)
@@ -2096,34 +2096,7 @@
break;
case Identity: {
- speculate(node, node->child1());
- switch (node->child1().useKind()) {
- case DoubleRepUse:
- case DoubleRepRealUse: {
- SpeculateDoubleOperand op(this, node->child1());
- doubleResult(op.fpr(), node);
- break;
- }
- case Int52RepUse:
- case AnyIntUse:
- case DoubleRepAnyIntUse: {
- RELEASE_ASSERT_NOT_REACHED();
- break;
- }
- default: {
- JSValueOperand op(this, node->child1(), ManualOperandSpeculation);
- GPRTemporary resultTag(this, Reuse, op, TagWord);
- GPRTemporary resultPayload(this, Reuse, op, PayloadWord);
- GPRReg sourceTag = op.tagGPR();
- GPRReg sourcePayload = op.payloadGPR();
- GPRReg resultTagGPR = resultTag.gpr();
- GPRReg resultPayloadGPR = resultPayload.gpr();
- m_jit.move(sourceTag, resultTagGPR);
- m_jit.move(sourcePayload, resultPayloadGPR);
- jsValueResult(resultTagGPR, resultPayloadGPR, node);
- break;
- }
- } // switch
+ compileIdentity(node);
break;
}
@@ -2375,72 +2348,7 @@
case ArithMin:
case ArithMax: {
- switch (node->binaryUseKind()) {
- case Int32Use: {
- SpeculateStrictInt32Operand op1(this, node->child1());
- SpeculateStrictInt32Operand op2(this, node->child2());
- GPRTemporary result(this, Reuse, op1);
-
- GPRReg op1GPR = op1.gpr();
- GPRReg op2GPR = op2.gpr();
- GPRReg resultGPR = result.gpr();
-
- MacroAssembler::Jump op1Less = m_jit.branch32(op == ArithMin ? MacroAssembler::LessThan : MacroAssembler::GreaterThan, op1GPR, op2GPR);
- m_jit.move(op2GPR, resultGPR);
- if (op1GPR != resultGPR) {
- MacroAssembler::Jump done = m_jit.jump();
- op1Less.link(&m_jit);
- m_jit.move(op1GPR, resultGPR);
- done.link(&m_jit);
- } else
- op1Less.link(&m_jit);
-
- int32Result(resultGPR, node);
- break;
- }
-
- case DoubleRepUse: {
- SpeculateDoubleOperand op1(this, node->child1());
- SpeculateDoubleOperand op2(this, node->child2());
- FPRTemporary result(this, op1);
-
- FPRReg op1FPR = op1.fpr();
- FPRReg op2FPR = op2.fpr();
- FPRReg resultFPR = result.fpr();
-
- MacroAssembler::JumpList done;
-
- MacroAssembler::Jump op1Less = m_jit.branchDouble(op == ArithMin ? MacroAssembler::DoubleLessThan : MacroAssembler::DoubleGreaterThan, op1FPR, op2FPR);
-
- // op2 is eather the lesser one or one of then is NaN
- MacroAssembler::Jump op2Less = m_jit.branchDouble(op == ArithMin ? MacroAssembler::DoubleGreaterThanOrEqual : MacroAssembler::DoubleLessThanOrEqual, op1FPR, op2FPR);
-
- // Unordered case. We don't know which of op1, op2 is NaN. Manufacture NaN by adding
- // op1 + op2 and putting it into result.
- m_jit.addDouble(op1FPR, op2FPR, resultFPR);
- done.append(m_jit.jump());
-
- op2Less.link(&m_jit);
- m_jit.moveDouble(op2FPR, resultFPR);
-
- if (op1FPR != resultFPR) {
- done.append(m_jit.jump());
-
- op1Less.link(&m_jit);
- m_jit.moveDouble(op1FPR, resultFPR);
- } else
- op1Less.link(&m_jit);
-
- done.link(&m_jit);
-
- doubleResult(resultFPR, node);
- break;
- }
-
- default:
- RELEASE_ASSERT_NOT_REACHED();
- break;
- }
+ compileArithMinMax(node);
break;
}
@@ -2843,20 +2751,7 @@
}
case GetByValWithThis: {
- JSValueOperand base(this, node->child1());
- JSValueRegs baseRegs = base.jsValueRegs();
- JSValueOperand thisValue(this, node->child2());
- JSValueRegs thisValueRegs = thisValue.jsValueRegs();
- JSValueOperand subscript(this, node->child3());
- JSValueRegs subscriptRegs = subscript.jsValueRegs();
-
- flushRegisters();
- JSValueRegsFlushedCallResult result(this);
- JSValueRegs resultRegs = result.regs();
- callOperation(operationGetByValWithThis, resultRegs, baseRegs, thisValueRegs, subscriptRegs);
- m_jit.exceptionCheck();
-
- jsValueResult(resultRegs, node);
+ compileGetByValWithThis(node);
break;
}
@@ -3511,172 +3406,7 @@
}
case NewArray: {
- JSGlobalObject* globalObject = m_jit.graph().globalObjectFor(node->origin.semantic);
- if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(node->indexingType())) {
- RegisteredStructure structure = m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
- ASSERT(structure->indexingType() == node->indexingType());
- ASSERT(
- hasUndecided(structure->indexingType())
- || hasInt32(structure->indexingType())
- || hasDouble(structure->indexingType())
- || hasContiguous(structure->indexingType()));
-
- unsigned numElements = node->numChildren();
-
- GPRTemporary result(this);
- GPRTemporary storage(this);
-
- GPRReg resultGPR = result.gpr();
- GPRReg storageGPR = storage.gpr();
-
- emitAllocateRawObject(resultGPR, structure, storageGPR, numElements, numElements);
-
- // At this point, one way or another, resultGPR and storageGPR have pointers to
- // the JSArray and the Butterfly, respectively.
-
- ASSERT(!hasUndecided(structure->indexingType()) || !node->numChildren());
-
- for (unsigned operandIdx = 0; operandIdx < node->numChildren(); ++operandIdx) {
- Edge use = m_jit.graph().m_varArgChildren[node->firstChild() + operandIdx];
- switch (node->indexingType()) {
- case ALL_BLANK_INDEXING_TYPES:
- case ALL_UNDECIDED_INDEXING_TYPES:
- CRASH();
- break;
- case ALL_DOUBLE_INDEXING_TYPES: {
- SpeculateDoubleOperand operand(this, use);
- FPRReg opFPR = operand.fpr();
- DFG_TYPE_CHECK(
- JSValueRegs(), use, SpecDoubleReal,
- m_jit.branchDouble(MacroAssembler::DoubleNotEqualOrUnordered, opFPR, opFPR));
-
- m_jit.storeDouble(opFPR, MacroAssembler::Address(storageGPR, sizeof(double) * operandIdx));
- break;
- }
- case ALL_INT32_INDEXING_TYPES: {
- SpeculateInt32Operand operand(this, use);
- m_jit.store32(TrustedImm32(JSValue::Int32Tag), MacroAssembler::Address(storageGPR, sizeof(JSValue) * operandIdx + OBJECT_OFFSETOF(JSValue, u.asBits.tag)));
- m_jit.store32(operand.gpr(), MacroAssembler::Address(storageGPR, sizeof(JSValue) * operandIdx + OBJECT_OFFSETOF(JSValue, u.asBits.payload)));
- break;
- }
- case ALL_CONTIGUOUS_INDEXING_TYPES: {
- JSValueOperand operand(this, m_jit.graph().m_varArgChildren[node->firstChild() + operandIdx]);
- GPRReg opTagGPR = operand.tagGPR();
- GPRReg opPayloadGPR = operand.payloadGPR();
- m_jit.store32(opTagGPR, MacroAssembler::Address(storageGPR, sizeof(JSValue) * operandIdx + OBJECT_OFFSETOF(JSValue, u.asBits.tag)));
- m_jit.store32(opPayloadGPR, MacroAssembler::Address(storageGPR, sizeof(JSValue) * operandIdx + OBJECT_OFFSETOF(JSValue, u.asBits.payload)));
- break;
- }
- default:
- CRASH();
- break;
- }
- }
-
- // Yuck, we should *really* have a way of also returning the storageGPR. But
- // that's the least of what's wrong with this code. We really shouldn't be
- // allocating the array after having computed - and probably spilled to the
- // stack - all of the things that will go into the array. The solution to that
- // bigger problem will also likely fix the redundancy in reloading the storage
- // pointer that we currently have.
-
- cellResult(resultGPR, node);
- break;
- }
-
- if (!node->numChildren()) {
- flushRegisters();
- GPRFlushedCallResult result(this);
- callOperation(
- operationNewEmptyArray, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())));
- m_jit.exceptionCheck();
- cellResult(result.gpr(), node);
- break;
- }
-
- size_t scratchSize = sizeof(EncodedJSValue) * node->numChildren();
- ScratchBuffer* scratchBuffer = m_jit.vm()->scratchBufferForSize(scratchSize);
- EncodedJSValue* buffer = scratchBuffer ? static_cast<EncodedJSValue*>(scratchBuffer->dataBuffer()) : 0;
-
- for (unsigned operandIdx = 0; operandIdx < node->numChildren(); ++operandIdx) {
- // Need to perform the speculations that this node promises to perform. If we're
- // emitting code here and the indexing type is not array storage then there is
- // probably something hilarious going on and we're already failing at all the
- // things, but at least we're going to be sound.
- Edge use = m_jit.graph().m_varArgChildren[node->firstChild() + operandIdx];
- switch (node->indexingType()) {
- case ALL_BLANK_INDEXING_TYPES:
- case ALL_UNDECIDED_INDEXING_TYPES:
- CRASH();
- break;
- case ALL_DOUBLE_INDEXING_TYPES: {
- SpeculateDoubleOperand operand(this, use);
- FPRReg opFPR = operand.fpr();
- DFG_TYPE_CHECK(
- JSValueRegs(), use, SpecFullRealNumber,
- m_jit.branchDouble(MacroAssembler::DoubleNotEqualOrUnordered, opFPR, opFPR));
-
- m_jit.storeDouble(opFPR, TrustedImmPtr(reinterpret_cast<char*>(buffer + operandIdx)));
- break;
- }
- case ALL_INT32_INDEXING_TYPES: {
- SpeculateInt32Operand operand(this, use);
- GPRReg opGPR = operand.gpr();
- m_jit.store32(TrustedImm32(JSValue::Int32Tag), reinterpret_cast<char*>(buffer + operandIdx) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
- m_jit.store32(opGPR, reinterpret_cast<char*>(buffer + operandIdx) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
- break;
- }
- case ALL_CONTIGUOUS_INDEXING_TYPES:
- case ALL_ARRAY_STORAGE_INDEXING_TYPES: {
- JSValueOperand operand(this, m_jit.graph().m_varArgChildren[node->firstChild() + operandIdx]);
- GPRReg opTagGPR = operand.tagGPR();
- GPRReg opPayloadGPR = operand.payloadGPR();
-
- m_jit.store32(opTagGPR, reinterpret_cast<char*>(buffer + operandIdx) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
- m_jit.store32(opPayloadGPR, reinterpret_cast<char*>(buffer + operandIdx) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
- operand.use();
- break;
- }
- default:
- CRASH();
- break;
- }
- }
-
- switch (node->indexingType()) {
- case ALL_DOUBLE_INDEXING_TYPES:
- case ALL_INT32_INDEXING_TYPES:
- useChildren(node);
- break;
- default:
- break;
- }
-
- flushRegisters();
-
- if (scratchSize) {
- GPRTemporary scratch(this);
-
- // Tell GC mark phase how much of the scratch buffer is active during call.
- m_jit.move(TrustedImmPtr(scratchBuffer->addressOfActiveLength()), scratch.gpr());
- m_jit.storePtr(TrustedImmPtr(scratchSize), scratch.gpr());
- }
-
- GPRFlushedCallResult result(this);
-
- callOperation(
- operationNewArray, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())),
- static_cast<void*>(buffer), size_t(node->numChildren()));
- m_jit.exceptionCheck();
-
- if (scratchSize) {
- GPRTemporary scratch(this);
-
- m_jit.move(TrustedImmPtr(scratchBuffer->addressOfActiveLength()), scratch.gpr());
- m_jit.storePtr(TrustedImmPtr(nullptr), scratch.gpr());
- }
-
- cellResult(result.gpr(), node, UseChildrenCalledExplicitly);
+ compileNewArray(node);
break;
}
@@ -3696,45 +3426,7 @@
}
case NewArrayBuffer: {
- JSGlobalObject* globalObject = m_jit.graph().globalObjectFor(node->origin.semantic);
- JSFixedArray* array = node->castOperand<JSFixedArray*>();
- unsigned numElements = array->length();
- IndexingType indexingType = node->indexingType();
- if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(indexingType)) {
-
- GPRTemporary result(this);
- GPRTemporary storage(this);
-
- GPRReg resultGPR = result.gpr();
- GPRReg storageGPR = storage.gpr();
-
- emitAllocateRawObject(resultGPR, m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), storageGPR, numElements, numElements);
-
- for (unsigned index = 0; index < numElements; ++index) {
- union {
- int32_t halves[2];
- double doubleValue;
- int64_t encodedValue;
- } u;
- if (node->indexingType() == ArrayWithDouble)
- u.doubleValue = array->get(index).asNumber();
- else
- u.encodedValue = JSValue::encode(array->get(index));
- static_assert(sizeof(double) == sizeof(JSValue), "");
- m_jit.store32(Imm32(u.halves[0]), MacroAssembler::Address(storageGPR, sizeof(JSValue) * index));
- m_jit.store32(Imm32(u.halves[1]), MacroAssembler::Address(storageGPR, sizeof(JSValue) * index + sizeof(int32_t)));
- }
- cellResult(resultGPR, node);
- break;
- }
-
- flushRegisters();
- GPRFlushedCallResult result(this);
-
- callOperation(operationNewArrayBuffer, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())), TrustedImmPtr(node->cellOperand()), size_t(numElements));
- m_jit.exceptionCheck();
-
- cellResult(result.gpr(), node);
+ compileNewArrayBuffer(node);
break;
}
@@ -3755,35 +3447,7 @@
}
case ToThis: {
- ASSERT(node->child1().useKind() == UntypedUse);
- JSValueOperand thisValue(this, node->child1());
- GPRTemporary temp(this);
- GPRTemporary tempTag(this);
- GPRReg thisValuePayloadGPR = thisValue.payloadGPR();
- GPRReg thisValueTagGPR = thisValue.tagGPR();
- GPRReg tempGPR = temp.gpr();
- GPRReg tempTagGPR = tempTag.gpr();
-
- MacroAssembler::JumpList slowCases;
- slowCases.append(m_jit.branchIfNotCell(thisValue.jsValueRegs()));
- slowCases.append(
- m_jit.branchTest8(
- MacroAssembler::NonZero,
- MacroAssembler::Address(thisValuePayloadGPR, JSCell::typeInfoFlagsOffset()),
- MacroAssembler::TrustedImm32(OverridesToThis)));
- m_jit.move(thisValuePayloadGPR, tempGPR);
- m_jit.move(thisValueTagGPR, tempTagGPR);
- J_JITOperation_EJ function;
- if (m_jit.graph().executableFor(node->origin.semantic)->isStrictMode())
- function = operationToThisStrict;
- else
- function = operationToThis;
- addSlowPathGenerator(
- slowPathCall(
- slowCases, this, function,
- JSValueRegs(tempTagGPR, tempGPR), JSValueRegs(thisValueTagGPR, thisValuePayloadGPR)));
-
- jsValueResult(tempTagGPR, tempGPR, node);
+ compileToThis(node);
break;
}
@@ -3828,29 +3492,12 @@
break;
case GetClosureVar: {
- SpeculateCellOperand base(this, node->child1());
- GPRTemporary resultTag(this);
- GPRTemporary resultPayload(this);
- GPRReg baseGPR = base.gpr();
- GPRReg resultTagGPR = resultTag.gpr();
- GPRReg resultPayloadGPR = resultPayload.gpr();
- m_jit.load32(JITCompiler::Address(baseGPR, JSLexicalEnvironment::offsetOfVariable(node->scopeOffset()) + TagOffset), resultTagGPR);
- m_jit.load32(JITCompiler::Address(baseGPR, JSLexicalEnvironment::offsetOfVariable(node->scopeOffset()) + PayloadOffset), resultPayloadGPR);
- jsValueResult(resultTagGPR, resultPayloadGPR, node);
+ compileGetClosureVar(node);
break;
}
case PutClosureVar: {
- SpeculateCellOperand base(this, node->child1());
- JSValueOperand value(this, node->child2());
-
- GPRReg baseGPR = base.gpr();
- GPRReg valueTagGPR = value.tagGPR();
- GPRReg valuePayloadGPR = value.payloadGPR();
-
- m_jit.store32(valueTagGPR, JITCompiler::Address(baseGPR, JSLexicalEnvironment::offsetOfVariable(node->scopeOffset()) + TagOffset));
- m_jit.store32(valuePayloadGPR, JITCompiler::Address(baseGPR, JSLexicalEnvironment::offsetOfVariable(node->scopeOffset()) + PayloadOffset));
- noResult(node);
+ compilePutClosureVar(node);
break;
}
@@ -4018,9 +3665,7 @@
}
case CheckCell: {
- SpeculateCellOperand cell(this, node->child1());
- speculationCheck(BadCell, JSValueSource::unboxedCell(cell.gpr()), node->child1(), m_jit.branchWeakPtr(JITCompiler::NotEqual, cell.gpr(), node->cellOperand()->cell()));
- noResult(node);
+ compileCheckCell(node);
break;
}
@@ -4037,13 +3682,7 @@
break;
case GetExecutable: {
- SpeculateCellOperand function(this, node->child1());
- GPRTemporary result(this, Reuse, function);
- GPRReg functionGPR = function.gpr();
- GPRReg resultGPR = result.gpr();
- speculateCellType(node->child1(), functionGPR, SpecFunction, JSFunctionType);
- m_jit.loadPtr(JITCompiler::Address(functionGPR, JSFunction::offsetOfExecutable()), resultGPR);
- cellResult(resultGPR, node);
+ compileGetExecutable(node);
break;
}
@@ -4107,20 +3746,7 @@
}
case GetByOffset: {
- StorageOperand storage(this, node->child1());
- GPRTemporary resultTag(this, Reuse, storage);
- GPRTemporary resultPayload(this);
-
- GPRReg storageGPR = storage.gpr();
- GPRReg resultTagGPR = resultTag.gpr();
- GPRReg resultPayloadGPR = resultPayload.gpr();
-
- StorageAccessData& storageAccessData = node->storageAccessData();
-
- m_jit.load32(JITCompiler::Address(storageGPR, offsetRelativeToBase(storageAccessData.offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)), resultPayloadGPR);
- m_jit.load32(JITCompiler::Address(storageGPR, offsetRelativeToBase(storageAccessData.offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)), resultTagGPR);
-
- jsValueResult(resultTagGPR, resultPayloadGPR, node);
+ compileGetByOffset(node);
break;
}
@@ -4150,21 +3776,7 @@
}
case PutByOffset: {
- StorageOperand storage(this, node->child1());
- JSValueOperand value(this, node->child3());
-
- GPRReg storageGPR = storage.gpr();
- GPRReg valueTagGPR = value.tagGPR();
- GPRReg valuePayloadGPR = value.payloadGPR();
-
- speculate(node, node->child2());
-
- StorageAccessData& storageAccessData = node->storageAccessData();
-
- m_jit.storePtr(valueTagGPR, JITCompiler::Address(storageGPR, offsetRelativeToBase(storageAccessData.offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)));
- m_jit.storePtr(valuePayloadGPR, JITCompiler::Address(storageGPR, offsetRelativeToBase(storageAccessData.offset) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)));
-
- noResult(node);
+ compilePutByOffset(node);
break;
}
@@ -4251,28 +3863,12 @@
case GetGlobalLexicalVariable:
case GetGlobalVar: {
- GPRTemporary resultPayload(this);
- GPRTemporary resultTag(this);
-
- m_jit.move(TrustedImmPtr(node->variablePointer()), resultPayload.gpr());
- m_jit.load32(JITCompiler::Address(resultPayload.gpr(), OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)), resultTag.gpr());
- m_jit.load32(JITCompiler::Address(resultPayload.gpr(), OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)), resultPayload.gpr());
-
- jsValueResult(resultTag.gpr(), resultPayload.gpr(), node);
+ compileGetGlobalVariable(node);
break;
}
case PutGlobalVariable: {
- JSValueOperand value(this, node->child2());
-
- // FIXME: if we happen to have a spare register - and _ONLY_ if we happen to have
- // a spare register - a good optimization would be to put the register pointer into
- // a register and then do a zero offset store followed by a four-offset store (or
- // vice-versa depending on endianness).
- m_jit.store32(value.tagGPR(), node->variablePointer()->tagPointer());
- m_jit.store32(value.payloadGPR(), node->variablePointer()->payloadPointer());
-
- noResult(node);
+ compilePutGlobalVariable(node);
break;
}
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp (230149 => 230150)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp 2018-04-02 05:59:28 UTC (rev 230149)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp 2018-04-02 07:51:17 UTC (rev 230150)
@@ -2202,32 +2202,7 @@
break;
case Identity: {
- speculate(node, node->child1());
- switch (node->child1().useKind()) {
- case DoubleRepUse:
- case DoubleRepRealUse:
- case DoubleRepAnyIntUse: {
- SpeculateDoubleOperand op(this, node->child1());
- FPRTemporary scratch(this, op);
- m_jit.moveDouble(op.fpr(), scratch.fpr());
- doubleResult(scratch.fpr(), node);
- break;
- }
- case Int52RepUse: {
- SpeculateInt52Operand op(this, node->child1());
- GPRTemporary result(this, Reuse, op);
- m_jit.move(op.gpr(), result.gpr());
- int52Result(result.gpr(), node);
- break;
- }
- default: {
- JSValueOperand op(this, node->child1(), ManualOperandSpeculation);
- GPRTemporary result(this, Reuse, op);
- m_jit.move(op.gpr(), result.gpr());
- jsValueResult(result.gpr(), node);
- break;
- }
- } // switch
+ compileIdentity(node);
break;
}
@@ -2516,68 +2491,7 @@
case ArithMin:
case ArithMax: {
- switch (node->binaryUseKind()) {
- case Int32Use: {
- SpeculateStrictInt32Operand op1(this, node->child1());
- SpeculateStrictInt32Operand op2(this, node->child2());
- GPRTemporary result(this, Reuse, op1);
-
- MacroAssembler::Jump op1Less = m_jit.branch32(op == ArithMin ? MacroAssembler::LessThan : MacroAssembler::GreaterThan, op1.gpr(), op2.gpr());
- m_jit.move(op2.gpr(), result.gpr());
- if (op1.gpr() != result.gpr()) {
- MacroAssembler::Jump done = m_jit.jump();
- op1Less.link(&m_jit);
- m_jit.move(op1.gpr(), result.gpr());
- done.link(&m_jit);
- } else
- op1Less.link(&m_jit);
-
- int32Result(result.gpr(), node);
- break;
- }
-
- case DoubleRepUse: {
- SpeculateDoubleOperand op1(this, node->child1());
- SpeculateDoubleOperand op2(this, node->child2());
- FPRTemporary result(this, op1);
-
- FPRReg op1FPR = op1.fpr();
- FPRReg op2FPR = op2.fpr();
- FPRReg resultFPR = result.fpr();
-
- MacroAssembler::JumpList done;
-
- MacroAssembler::Jump op1Less = m_jit.branchDouble(op == ArithMin ? MacroAssembler::DoubleLessThan : MacroAssembler::DoubleGreaterThan, op1FPR, op2FPR);
-
- // op2 is eather the lesser one or one of then is NaN
- MacroAssembler::Jump op2Less = m_jit.branchDouble(op == ArithMin ? MacroAssembler::DoubleGreaterThanOrEqual : MacroAssembler::DoubleLessThanOrEqual, op1FPR, op2FPR);
-
- // Unordered case. We don't know which of op1, op2 is NaN. Manufacture NaN by adding
- // op1 + op2 and putting it into result.
- m_jit.addDouble(op1FPR, op2FPR, resultFPR);
- done.append(m_jit.jump());
-
- op2Less.link(&m_jit);
- m_jit.moveDouble(op2FPR, resultFPR);
-
- if (op1FPR != resultFPR) {
- done.append(m_jit.jump());
-
- op1Less.link(&m_jit);
- m_jit.moveDouble(op1FPR, resultFPR);
- } else
- op1Less.link(&m_jit);
-
- done.link(&m_jit);
-
- doubleResult(resultFPR, node);
- break;
- }
-
- default:
- DFG_CRASH(m_jit.graph(), node, "Bad use kind");
- break;
- }
+ compileArithMinMax(node);
break;
}
@@ -2917,20 +2831,7 @@
}
case GetByValWithThis: {
- JSValueOperand base(this, node->child1());
- GPRReg baseGPR = base.gpr();
- JSValueOperand thisValue(this, node->child2());
- GPRReg thisValueGPR = thisValue.gpr();
- JSValueOperand subscript(this, node->child3());
- GPRReg subscriptGPR = subscript.gpr();
-
- flushRegisters();
- GPRFlushedCallResult result(this);
- GPRReg resultGPR = result.gpr();
- callOperation(operationGetByValWithThis, resultGPR, baseGPR, thisValueGPR, subscriptGPR);
- m_jit.exceptionCheck();
-
- jsValueResult(resultGPR, node);
+ compileGetByValWithThis(node);
break;
}
@@ -3707,177 +3608,7 @@
}
case NewArray: {
- JSGlobalObject* globalObject = m_jit.graph().globalObjectFor(node->origin.semantic);
- if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(node->indexingType())) {
- RegisteredStructure structure = m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
- DFG_ASSERT(m_jit.graph(), node, structure->indexingType() == node->indexingType(), structure->indexingType(), node->indexingType());
- ASSERT(
- hasUndecided(structure->indexingType())
- || hasInt32(structure->indexingType())
- || hasDouble(structure->indexingType())
- || hasContiguous(structure->indexingType()));
-
- unsigned numElements = node->numChildren();
- unsigned vectorLengthHint = node->vectorLengthHint();
- ASSERT(vectorLengthHint >= numElements);
-
- GPRTemporary result(this);
- GPRTemporary storage(this);
-
- GPRReg resultGPR = result.gpr();
- GPRReg storageGPR = storage.gpr();
-
- emitAllocateRawObject(resultGPR, structure, storageGPR, numElements, vectorLengthHint);
-
- // At this point, one way or another, resultGPR and storageGPR have pointers to
- // the JSArray and the Butterfly, respectively.
-
- ASSERT(!hasUndecided(structure->indexingType()) || !node->numChildren());
-
- for (unsigned operandIdx = 0; operandIdx < node->numChildren(); ++operandIdx) {
- Edge use = m_jit.graph().m_varArgChildren[node->firstChild() + operandIdx];
- switch (node->indexingType()) {
- case ALL_BLANK_INDEXING_TYPES:
- case ALL_UNDECIDED_INDEXING_TYPES:
- CRASH();
- break;
- case ALL_DOUBLE_INDEXING_TYPES: {
- SpeculateDoubleOperand operand(this, use);
- FPRReg opFPR = operand.fpr();
- DFG_TYPE_CHECK(
- JSValueRegs(), use, SpecDoubleReal,
- m_jit.branchDouble(
- MacroAssembler::DoubleNotEqualOrUnordered, opFPR, opFPR));
- m_jit.storeDouble(opFPR, MacroAssembler::Address(storageGPR, sizeof(double) * operandIdx));
- break;
- }
- case ALL_INT32_INDEXING_TYPES:
- case ALL_CONTIGUOUS_INDEXING_TYPES: {
- JSValueOperand operand(this, use, ManualOperandSpeculation);
- GPRReg opGPR = operand.gpr();
- if (hasInt32(node->indexingType())) {
- DFG_TYPE_CHECK(
- JSValueRegs(opGPR), use, SpecInt32Only,
- m_jit.branch64(
- MacroAssembler::Below, opGPR, GPRInfo::tagTypeNumberRegister));
- }
- m_jit.store64(opGPR, MacroAssembler::Address(storageGPR, sizeof(JSValue) * operandIdx));
- break;
- }
- default:
- CRASH();
- break;
- }
- }
-
- // Yuck, we should *really* have a way of also returning the storageGPR. But
- // that's the least of what's wrong with this code. We really shouldn't be
- // allocating the array after having computed - and probably spilled to the
- // stack - all of the things that will go into the array. The solution to that
- // bigger problem will also likely fix the redundancy in reloading the storage
- // pointer that we currently have.
-
- cellResult(resultGPR, node);
- break;
- }
-
- if (!node->numChildren()) {
- flushRegisters();
- GPRFlushedCallResult result(this);
- callOperation(operationNewEmptyArray, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())));
- m_jit.exceptionCheck();
- cellResult(result.gpr(), node);
- break;
- }
-
- size_t scratchSize = sizeof(EncodedJSValue) * node->numChildren();
- ScratchBuffer* scratchBuffer = m_jit.vm()->scratchBufferForSize(scratchSize);
- EncodedJSValue* buffer = scratchBuffer ? static_cast<EncodedJSValue*>(scratchBuffer->dataBuffer()) : 0;
-
- for (unsigned operandIdx = 0; operandIdx < node->numChildren(); ++operandIdx) {
- // Need to perform the speculations that this node promises to perform. If we're
- // emitting code here and the indexing type is not array storage then there is
- // probably something hilarious going on and we're already failing at all the
- // things, but at least we're going to be sound.
- Edge use = m_jit.graph().m_varArgChildren[node->firstChild() + operandIdx];
- switch (node->indexingType()) {
- case ALL_BLANK_INDEXING_TYPES:
- case ALL_UNDECIDED_INDEXING_TYPES:
- CRASH();
- break;
- case ALL_DOUBLE_INDEXING_TYPES: {
- SpeculateDoubleOperand operand(this, use);
- GPRTemporary scratch(this);
- FPRReg opFPR = operand.fpr();
- GPRReg scratchGPR = scratch.gpr();
- DFG_TYPE_CHECK(
- JSValueRegs(), use, SpecDoubleReal,
- m_jit.branchDouble(
- MacroAssembler::DoubleNotEqualOrUnordered, opFPR, opFPR));
- m_jit.boxDouble(opFPR, scratchGPR);
- m_jit.store64(scratchGPR, buffer + operandIdx);
- break;
- }
- case ALL_INT32_INDEXING_TYPES: {
- JSValueOperand operand(this, use, ManualOperandSpeculation);
- GPRReg opGPR = operand.gpr();
- if (hasInt32(node->indexingType())) {
- DFG_TYPE_CHECK(
- JSValueRegs(opGPR), use, SpecInt32Only,
- m_jit.branch64(
- MacroAssembler::Below, opGPR, GPRInfo::tagTypeNumberRegister));
- }
- m_jit.store64(opGPR, buffer + operandIdx);
- break;
- }
- case ALL_CONTIGUOUS_INDEXING_TYPES:
- case ALL_ARRAY_STORAGE_INDEXING_TYPES: {
- JSValueOperand operand(this, use);
- GPRReg opGPR = operand.gpr();
- m_jit.store64(opGPR, buffer + operandIdx);
- operand.use();
- break;
- }
- default:
- CRASH();
- break;
- }
- }
-
- switch (node->indexingType()) {
- case ALL_DOUBLE_INDEXING_TYPES:
- case ALL_INT32_INDEXING_TYPES:
- useChildren(node);
- break;
- default:
- break;
- }
-
- flushRegisters();
-
- if (scratchSize) {
- GPRTemporary scratch(this);
-
- // Tell GC mark phase how much of the scratch buffer is active during call.
- m_jit.move(TrustedImmPtr(scratchBuffer->addressOfActiveLength()), scratch.gpr());
- m_jit.storePtr(TrustedImmPtr(scratchSize), scratch.gpr());
- }
-
- GPRFlushedCallResult result(this);
-
- callOperation(
- operationNewArray, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())),
- static_cast<void*>(buffer), size_t(node->numChildren()));
- m_jit.exceptionCheck();
-
- if (scratchSize) {
- GPRTemporary scratch(this);
-
- m_jit.move(TrustedImmPtr(scratchBuffer->addressOfActiveLength()), scratch.gpr());
- m_jit.storePtr(TrustedImmPtr(nullptr), scratch.gpr());
- }
-
- cellResult(result.gpr(), node, UseChildrenCalledExplicitly);
+ compileNewArray(node);
break;
}
@@ -3897,44 +3628,7 @@
}
case NewArrayBuffer: {
- JSGlobalObject* globalObject = m_jit.graph().globalObjectFor(node->origin.semantic);
- JSFixedArray* array = node->castOperand<JSFixedArray*>();
- unsigned numElements = array->length();
- IndexingType indexingType = node->indexingType();
- if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(indexingType)) {
- unsigned vectorLengthHint = node->vectorLengthHint();
- ASSERT(vectorLengthHint >= numElements);
-
- GPRTemporary result(this);
- GPRTemporary storage(this);
-
- GPRReg resultGPR = result.gpr();
- GPRReg storageGPR = storage.gpr();
-
- emitAllocateRawObject(resultGPR, m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), storageGPR, numElements, vectorLengthHint);
-
- DFG_ASSERT(m_jit.graph(), node, indexingType & IsArray, indexingType);
-
- for (unsigned index = 0; index < numElements; ++index) {
- int64_t value;
- if (indexingType == ArrayWithDouble)
- value = bitwise_cast<int64_t>(array->get(index).asNumber());
- else
- value = JSValue::encode(array->get(index));
- static_assert(sizeof(double) == sizeof(JSValue), "");
- m_jit.store64(Imm64(value), MacroAssembler::Address(storageGPR, sizeof(JSValue) * index));
- }
- cellResult(resultGPR, node);
- break;
- }
-
- flushRegisters();
- GPRFlushedCallResult result(this);
-
- callOperation(operationNewArrayBuffer, result.gpr(), m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(node->indexingType())), TrustedImmPtr(node->cellOperand()), size_t(numElements));
- m_jit.exceptionCheck();
-
- cellResult(result.gpr(), node);
+ compileNewArrayBuffer(node);
break;
}
@@ -3955,29 +3649,7 @@
}
case ToThis: {
- ASSERT(node->child1().useKind() == UntypedUse);
- JSValueOperand thisValue(this, node->child1());
- GPRTemporary temp(this);
- GPRReg thisValueGPR = thisValue.gpr();
- GPRReg tempGPR = temp.gpr();
-
- MacroAssembler::JumpList slowCases;
- slowCases.append(m_jit.branchIfNotCell(JSValueRegs(thisValueGPR)));
- slowCases.append(
- m_jit.branchTest8(
- MacroAssembler::NonZero,
- MacroAssembler::Address(thisValueGPR, JSCell::typeInfoFlagsOffset()),
- MacroAssembler::TrustedImm32(OverridesToThis)));
- m_jit.move(thisValueGPR, tempGPR);
- J_JITOperation_EJ function;
- if (m_jit.graph().executableFor(node->origin.semantic)->isStrictMode())
- function = operationToThisStrict;
- else
- function = operationToThis;
- addSlowPathGenerator(
- slowPathCall(slowCases, this, function, tempGPR, thisValueGPR));
-
- jsValueResult(tempGPR, node);
+ compileToThis(node);
break;
}
@@ -4027,24 +3699,11 @@
break;
case GetClosureVar: {
- SpeculateCellOperand base(this, node->child1());
- GPRTemporary result(this);
- GPRReg baseGPR = base.gpr();
- GPRReg resultGPR = result.gpr();
-
- m_jit.load64(JITCompiler::Address(baseGPR, JSLexicalEnvironment::offsetOfVariable(node->scopeOffset())), resultGPR);
- jsValueResult(resultGPR, node);
+ compileGetClosureVar(node);
break;
}
case PutClosureVar: {
- SpeculateCellOperand base(this, node->child1());
- JSValueOperand value(this, node->child2());
-
- GPRReg baseGPR = base.gpr();
- GPRReg valueGPR = value.gpr();
-
- m_jit.store64(valueGPR, JITCompiler::Address(baseGPR, JSLexicalEnvironment::offsetOfVariable(node->scopeOffset())));
- noResult(node);
+ compilePutClosureVar(node);
break;
}
@@ -4200,9 +3859,7 @@
}
case CheckCell: {
- SpeculateCellOperand cell(this, node->child1());
- speculationCheck(BadCell, JSValueSource::unboxedCell(cell.gpr()), node->child1(), m_jit.branchWeakPtr(JITCompiler::NotEqual, cell.gpr(), node->cellOperand()->cell()));
- noResult(node);
+ compileCheckCell(node);
break;
}
@@ -4231,14 +3888,7 @@
break;
case GetExecutable: {
- SpeculateCellOperand function(this, node->child1());
- GPRTemporary result(this, Reuse, function);
- GPRReg functionGPR = function.gpr();
- GPRReg resultGPR = result.gpr();
- speculateCellType(node->child1(), functionGPR, SpecFunction, JSFunctionType);
- m_jit.loadPtr(JITCompiler::Address(functionGPR, JSFunction::offsetOfExecutable()), resultGPR);
- m_jit.xorPtr(JITCompiler::TrustedImmPtr(JSFunctionPoison::key()), resultGPR);
- cellResult(resultGPR, node);
+ compileGetExecutable(node);
break;
}
@@ -4319,17 +3969,7 @@
case GetByOffset:
case GetGetterSetterByOffset: {
- StorageOperand storage(this, node->child1());
- GPRTemporary result(this, Reuse, storage);
-
- GPRReg storageGPR = storage.gpr();
- GPRReg resultGPR = result.gpr();
-
- StorageAccessData& storageAccessData = node->storageAccessData();
-
- m_jit.load64(JITCompiler::Address(storageGPR, offsetRelativeToBase(storageAccessData.offset)), resultGPR);
-
- jsValueResult(resultGPR, node);
+ compileGetByOffset(node);
break;
}
@@ -4344,19 +3984,7 @@
}
case PutByOffset: {
- StorageOperand storage(this, node->child1());
- JSValueOperand value(this, node->child3());
-
- GPRReg storageGPR = storage.gpr();
- GPRReg valueGPR = value.gpr();
-
- speculate(node, node->child2());
-
- StorageAccessData& storageAccessData = node->storageAccessData();
-
- m_jit.store64(valueGPR, JITCompiler::Address(storageGPR, offsetRelativeToBase(storageAccessData.offset)));
-
- noResult(node);
+ compilePutByOffset(node);
break;
}
@@ -4458,20 +4086,12 @@
case GetGlobalLexicalVariable:
case GetGlobalVar: {
- GPRTemporary result(this);
-
- m_jit.load64(node->variablePointer(), result.gpr());
-
- jsValueResult(result.gpr(), node);
+ compileGetGlobalVariable(node);
break;
}
case PutGlobalVariable: {
- JSValueOperand value(this, node->child2());
-
- m_jit.store64(value.gpr(), node->variablePointer());
-
- noResult(node);
+ compilePutGlobalVariable(node);
break;
}