Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eee9cce

Browse filesBrowse files
committed
[BigInt] Implement ValueBitXor into DFG
https://bugs.webkit.org/show_bug.cgi?id=190264 Reviewed by Yusuke Suzuki. JSTests: * stress/big-int-bitwise-xor-jit.js: Added. * stress/big-int-bitwise-xor-memory-stress.js: Added. * stress/big-int-bitwise-xor-untyped.js: Added. Source/JavaScriptCore: This patch is splitting the BitXor node into ArithBitXor and ValueBitXor. This is necessary due the introduction of BigInt, since BitXor operations now can result into Int32 or BigInt. In such case, we use ArithBitXor when operands are Int and fallback to ValueBitXor when operands are anything else. In the case of ValueBitXor, we speculate BigInt when op1 and op2 are predicted as BigInt as well. BigInt specialization consist into call `operationBigIntBitXor` function, that calls JSBigInt::bitXor. * bytecode/BytecodeList.rb: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::arithProfileForPC): * bytecode/Opcode.h: (JSC::padOpcodeName): * bytecompiler/BytecodeGenerator.h: * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGBackwardsPropagationPhase.cpp: (JSC::DFG::BackwardsPropagationPhase::isWithinPowerOfTwo): (JSC::DFG::BackwardsPropagationPhase::propagate): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGNodeType.h: * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileValueBitwiseOp): (JSC::DFG::SpeculativeJIT::compileBitwiseOp): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::bitOp): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGStrengthReductionPhase.cpp: (JSC::DFG::StrengthReductionPhase::handleNode): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileValueBitXor): (JSC::FTL::DFG::LowerDFGToB3::compileArithBitXor): (JSC::FTL::DFG::LowerDFGToB3::compileBitXor): Deleted. * jit/JITArithmetic.cpp: (JSC::JIT::emit_op_bitxor): * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): Canonical link: https://commits.webkit.org/206876@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent b39d3fc commit eee9cce
Copy full SHA for eee9cce

31 files changed

+261-67Lines changed: 261 additions & 67 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎JSTests/ChangeLog‎

Copy file name to clipboardExpand all lines: JSTests/ChangeLog
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2018-11-30 Caio Lima <ticaiolima@gmail.com>
2+
3+
[BigInt] Implement ValueBitXor into DFG
4+
https://bugs.webkit.org/show_bug.cgi?id=190264
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
* stress/big-int-bitwise-xor-jit.js: Added.
9+
* stress/big-int-bitwise-xor-memory-stress.js: Added.
10+
* stress/big-int-bitwise-xor-untyped.js: Added.
11+
112
2018-11-27 Saam barati <sbarati@apple.com>
213

314
r238510 broke scopes of size zero
Collapse file
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ runBigIntEnabled
2+
3+
let assert = {
4+
sameValue: function(i, e) {
5+
if (i !== e)
6+
throw new Error(m);
7+
}
8+
}
9+
10+
function bigIntBitXor(a, b) {
11+
return (a ^ b) ^ (a ^ 0b11n);
12+
13+
}
14+
noInline(bigIntBitXor);
15+
16+
for (let i = 0; i < 10000; i++) {
17+
let r = bigIntBitXor(0b11n, 0b1010n);
18+
assert.sameValue(r, 0b1001n);
19+
}
20+
21+
for (let i = 0; i < 10000; i++) {
22+
let r = bigIntBitXor(0xfffafafaf19281fefafeafebcn, 0b1010n);
23+
assert.sameValue(r, 0b1001n);
24+
}
25+
Collapse file
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ runBigIntEnabled
2+
3+
function assert(a) {
4+
if (!a)
5+
throw new Error("Bad assertion");
6+
}
7+
8+
let a = 0b11n;
9+
for (let i = 0; i < 1000000; i++) {
10+
a ^= 0b01n;
11+
}
12+
13+
assert(a === 0b11n);
14+
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@ runBigIntEnabled
2+
3+
function assert(v, e) {
4+
if (v !== e)
5+
throw new Error("Expected value: " + e + " but got: " + v)
6+
}
7+
8+
function bigIntOperations(a, b) {
9+
let c = a ^ b;
10+
return a ^ c;
11+
}
12+
noInline(bigIntOperations);
13+
14+
c = 0;
15+
let o = { valueOf: function () {
16+
c++;
17+
return 0b1111n;
18+
}};
19+
20+
for (let i = 0; i < 100000; i++) {
21+
let out = bigIntOperations(o, 0b1010n);
22+
assert(out, 0b1010n);
23+
}
24+
25+
assert(c, 200000);
26+
Collapse file

‎Source/JavaScriptCore/ChangeLog‎

Copy file name to clipboardExpand all lines: Source/JavaScriptCore/ChangeLog
+67Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,70 @@
1+
2018-11-30 Caio Lima <ticaiolima@gmail.com>
2+
3+
[BigInt] Implement ValueBitXor into DFG
4+
https://bugs.webkit.org/show_bug.cgi?id=190264
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
This patch is splitting the BitXor node into ArithBitXor and
9+
ValueBitXor. This is necessary due the introduction of
10+
BigInt, since BitXor operations now can result into Int32 or BigInt.
11+
In such case, we use ArithBitXor when operands are Int and fallback to
12+
ValueBitXor when operands are anything else. In the case of
13+
ValueBitXor, we speculate BigInt when op1 and op2 are predicted as
14+
BigInt as well. BigInt specialization consist into call
15+
`operationBigIntBitXor` function, that calls JSBigInt::bitXor.
16+
17+
* bytecode/BytecodeList.rb:
18+
* bytecode/CodeBlock.cpp:
19+
(JSC::CodeBlock::finishCreation):
20+
(JSC::CodeBlock::arithProfileForPC):
21+
* bytecode/Opcode.h:
22+
(JSC::padOpcodeName):
23+
* bytecompiler/BytecodeGenerator.h:
24+
* dfg/DFGAbstractInterpreterInlines.h:
25+
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
26+
* dfg/DFGBackwardsPropagationPhase.cpp:
27+
(JSC::DFG::BackwardsPropagationPhase::isWithinPowerOfTwo):
28+
(JSC::DFG::BackwardsPropagationPhase::propagate):
29+
* dfg/DFGByteCodeParser.cpp:
30+
(JSC::DFG::ByteCodeParser::parseBlock):
31+
* dfg/DFGClobberize.h:
32+
(JSC::DFG::clobberize):
33+
* dfg/DFGDoesGC.cpp:
34+
(JSC::DFG::doesGC):
35+
* dfg/DFGFixupPhase.cpp:
36+
(JSC::DFG::FixupPhase::fixupNode):
37+
* dfg/DFGNodeType.h:
38+
* dfg/DFGOperations.cpp:
39+
* dfg/DFGOperations.h:
40+
* dfg/DFGPredictionPropagationPhase.cpp:
41+
* dfg/DFGSafeToExecute.h:
42+
(JSC::DFG::safeToExecute):
43+
* dfg/DFGSpeculativeJIT.cpp:
44+
(JSC::DFG::SpeculativeJIT::compileValueBitwiseOp):
45+
(JSC::DFG::SpeculativeJIT::compileBitwiseOp):
46+
* dfg/DFGSpeculativeJIT.h:
47+
(JSC::DFG::SpeculativeJIT::bitOp):
48+
* dfg/DFGSpeculativeJIT32_64.cpp:
49+
(JSC::DFG::SpeculativeJIT::compile):
50+
* dfg/DFGSpeculativeJIT64.cpp:
51+
(JSC::DFG::SpeculativeJIT::compile):
52+
* dfg/DFGStrengthReductionPhase.cpp:
53+
(JSC::DFG::StrengthReductionPhase::handleNode):
54+
* ftl/FTLCapabilities.cpp:
55+
(JSC::FTL::canCompile):
56+
* ftl/FTLLowerDFGToB3.cpp:
57+
(JSC::FTL::DFG::LowerDFGToB3::compileNode):
58+
(JSC::FTL::DFG::LowerDFGToB3::compileValueBitXor):
59+
(JSC::FTL::DFG::LowerDFGToB3::compileArithBitXor):
60+
(JSC::FTL::DFG::LowerDFGToB3::compileBitXor): Deleted.
61+
* jit/JITArithmetic.cpp:
62+
(JSC::JIT::emit_op_bitxor):
63+
* llint/LowLevelInterpreter32_64.asm:
64+
* llint/LowLevelInterpreter64.asm:
65+
* runtime/CommonSlowPaths.cpp:
66+
(JSC::SLOW_PATH_DECL):
67+
168
2018-11-29 Justin Michaud <justin_michaud@apple.com>
269

370
CSS Painting API should pass 'this' correctly to paint callback, and repaint when properties change.
Collapse file

‎Source/JavaScriptCore/bytecode/BytecodeList.rb‎

Copy file name to clipboardExpand all lines: Source/JavaScriptCore/bytecode/BytecodeList.rb
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@
240240
:mul,
241241
:div,
242242
:sub,
243-
:bitxor,
244243
],
245244
args: {
246245
dst: VirtualRegister,
@@ -259,6 +258,7 @@
259258
[
260259
:bitand,
261260
:bitor,
261+
:bitxor,
262262
],
263263
args: {
264264
dst: VirtualRegister,
Collapse file

‎Source/JavaScriptCore/bytecode/CodeBlock.cpp‎

Copy file name to clipboardExpand all lines: Source/JavaScriptCore/bytecode/CodeBlock.cpp
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink
567567
LINK(OpBitand, profile)
568568
LINK(OpBitor, profile)
569569
LINK(OpBitnot, profile)
570+
LINK(OpBitxor, profile)
570571

571572
LINK(OpGetById, profile, hitCountForLLIntCaching)
572573

@@ -592,7 +593,6 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink
592593
LINK(OpMul)
593594
LINK(OpDiv)
594595
LINK(OpSub)
595-
LINK(OpBitxor)
596596

597597
LINK(OpNegate)
598598

@@ -2953,8 +2953,6 @@ ArithProfile* CodeBlock::arithProfileForPC(const Instruction* pc)
29532953
switch (pc->opcodeID()) {
29542954
case op_negate:
29552955
return &pc->as<OpNegate>().metadata(this).arithProfile;
2956-
case op_bitxor:
2957-
return &pc->as<OpBitxor>().metadata(this).arithProfile;
29582956
case op_add:
29592957
return &pc->as<OpAdd>().metadata(this).arithProfile;
29602958
case op_mul:
Collapse file

‎Source/JavaScriptCore/bytecode/Opcode.h‎

Copy file name to clipboardExpand all lines: Source/JavaScriptCore/bytecode/Opcode.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ IGNORE_WARNINGS_END
110110
macro(OpBitand) \
111111
macro(OpBitor) \
112112
macro(OpBitnot) \
113+
macro(OpBitxor) \
113114

114115
#define FOR_EACH_OPCODE_WITH_ARRAY_PROFILE(macro) \
115116
macro(OpHasIndexedProperty) \
Collapse file

‎Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h‎

Copy file name to clipboardExpand all lines: Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,9 @@ namespace JSC {
684684

685685
template<typename BinaryOp>
686686
std::enable_if_t<
687-
BinaryOp::opcodeID != op_bitxor && BinaryOp::opcodeID != op_add
688-
&& BinaryOp::opcodeID != op_mul && BinaryOp::opcodeID != op_sub
687+
BinaryOp::opcodeID != op_add
688+
&& BinaryOp::opcodeID != op_mul
689+
&& BinaryOp::opcodeID != op_sub
689690
&& BinaryOp::opcodeID != op_div,
690691
RegisterID*>
691692
emitBinaryOp(RegisterID* dst, RegisterID* src1, RegisterID* src2, OperandTypes)
@@ -696,8 +697,9 @@ namespace JSC {
696697

697698
template<typename BinaryOp>
698699
std::enable_if_t<
699-
BinaryOp::opcodeID == op_bitxor || BinaryOp::opcodeID == op_add
700-
|| BinaryOp::opcodeID == op_mul || BinaryOp::opcodeID == op_sub
700+
BinaryOp::opcodeID == op_add
701+
|| BinaryOp::opcodeID == op_mul
702+
|| BinaryOp::opcodeID == op_sub
701703
|| BinaryOp::opcodeID == op_div,
702704
RegisterID*>
703705
emitBinaryOp(RegisterID* dst, RegisterID* src1, RegisterID* src2, OperandTypes types)
Collapse file

‎Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h‎

Copy file name to clipboardExpand all lines: Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi
374374
m_state.operand(data->start.offset() + i).makeHeapTop();
375375
break;
376376
}
377-
377+
378378
case ArithBitNot: {
379379
if (node->child1().useKind() == UntypedUse) {
380380
clobberWorld();
@@ -393,8 +393,9 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi
393393
break;
394394
}
395395

396-
case ValueBitOr:
396+
case ValueBitXor:
397397
case ValueBitAnd:
398+
case ValueBitOr:
398399
clobberWorld();
399400
if (node->binaryUseKind() == BigIntUse)
400401
setTypeForNode(node, SpecBigInt);
@@ -404,7 +405,7 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi
404405

405406
case ArithBitAnd:
406407
case ArithBitOr:
407-
case BitXor:
408+
case ArithBitXor:
408409
case BitRShift:
409410
case BitLShift:
410411
case BitURShift: {
@@ -426,7 +427,7 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi
426427
case ArithBitOr:
427428
setConstant(node, JSValue(a | b));
428429
break;
429-
case BitXor:
430+
case ArithBitXor:
430431
setConstant(node, JSValue(a ^ b));
431432
break;
432433
case BitRShift:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.