classilla / tenfourfox

Mozilla for Power Macintosh.
http://www.tenfourfox.com/
Other
276 stars 41 forks source link

TypeMonitor maybe could be less branchy? #287

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In bool
ICTypeMonitor_PrimitiveSet::Compiler::generateStubCode(MacroAssembler &masm)

It seems to me that if multiple flags are set, we could try to use a bitmask 
instead of repeated branches and make only one branch to success.

Original issue reported on code.google.com by classi...@floodgap.com on 15 Sep 2014 at 3:40

GoogleCodeExporter commented 9 years ago
This only works if the bits don't overlap, so we could generate code only in 
specific circumstances.

158 typedef uint32_t JSValueTag;
159 #define JSVAL_TAG_CLEAR              ((uint32_t)(0xFFFFFF80))
160 #define JSVAL_TAG_INT32              ((uint32_t)(JSVAL_TAG_CLEAR | 
JSVAL_TYPE_INT32))
161 #define JSVAL_TAG_UNDEFINED          ((uint32_t)(JSVAL_TAG_CLEAR | 
JSVAL_TYPE_UNDEFINED))
162 #define JSVAL_TAG_STRING             ((uint32_t)(JSVAL_TAG_CLEAR | 
JSVAL_TYPE_STRING))
163 #define JSVAL_TAG_SYMBOL             ((uint32_t)(JSVAL_TAG_CLEAR | 
JSVAL_TYPE_SYMBOL))
164 #define JSVAL_TAG_BOOLEAN            ((uint32_t)(JSVAL_TAG_CLEAR | 
JSVAL_TYPE_BOOLEAN))
165 #define JSVAL_TAG_MAGIC              ((uint32_t)(JSVAL_TAG_CLEAR | 
JSVAL_TYPE_MAGIC))
166 #define JSVAL_TAG_NULL               ((uint32_t)(JSVAL_TAG_CLEAR | 
JSVAL_TYPE_NULL))
167 #define JSVAL_TAG_OBJECT             ((uint32_t)(JSVAL_TAG_CLEAR | 
JSVAL_TYPE_OBJECT))

So
f81
f82
f83
f84
f85
f86
f87
f88

f81 f82 f83 could be a co-set
f82 f86 could be a co-set
f81 f84 f85 could be a co-set
f81 f82 f83 f84 f85 f86 f87 could be a co-set

(f88 usually separate)

Original comment by classi...@floodgap.com on 15 Sep 2014 at 4:16

GoogleCodeExporter commented 9 years ago
Let's do this in 31 first:

    JSVAL_TAG_CLEAR                = 0xFFFFFF80,
    JSVAL_TAG_INT32                = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32,
    JSVAL_TAG_UNDEFINED            = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED,
    JSVAL_TAG_STRING               = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING,
    JSVAL_TAG_BOOLEAN              = JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN,
    JSVAL_TAG_MAGIC                = JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC,
    JSVAL_TAG_NULL                 = JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL,
    JSVAL_TAG_OBJECT               = JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT

typedef uint8_t JSValueType;
#define JSVAL_TYPE_DOUBLE            ((uint8_t)0x00)
#define JSVAL_TYPE_INT32             ((uint8_t)0x01)
#define JSVAL_TYPE_UNDEFINED         ((uint8_t)0x02)
#define JSVAL_TYPE_BOOLEAN           ((uint8_t)0x03)
#define JSVAL_TYPE_MAGIC             ((uint8_t)0x04)
#define JSVAL_TYPE_STRING            ((uint8_t)0x05)
#define JSVAL_TYPE_NULL              ((uint8_t)0x06)
#define JSVAL_TYPE_OBJECT            ((uint8_t)0x07)

Doubles are checked for separately; if double and int32 acceptable, NO int32 
check is generated. Do the double test last. Don't clobber R0.

Original comment by classi...@floodgap.com on 5 Oct 2014 at 4:38

GoogleCodeExporter commented 9 years ago
(G5 running G3)

js/src/v8/% ../../../obj-ff-dbg/dist/bin/js --no-ion -f run.js
81 85 generated
Richards: 167
DeltaBlue: 163
Crypto: 25.0
82 86 generated
81 82 83 generated
81 85 generated
RayTrace: 534
81 85 generated
81 82 83 generated
EarleyBoyer: 491
RegExp: 489
Splay: 802
NavierStokes: 74.0
----
Score (version 7): 218

Original comment by classi...@floodgap.com on 5 Oct 2014 at 5:14

GoogleCodeExporter commented 9 years ago
SunSpider generates 81 85. So that seems to be the most profitable.

We can only do bitmasks that overlap. 81 82 83 84 85 86 87 can't be generated. 
So:

81 82 83: and #ffff fffc xor #ffff 8000
82 84 86 doesn't appear to be generated
81 83    doesn't appear to be generated
81 85:    xor #ffff ff81 and #ffff fffb
82 86:    xor #ffff ff82 and #ffff fffb

Original comment by classi...@floodgap.com on 5 Oct 2014 at 5:20

GoogleCodeExporter commented 9 years ago
Correction: RayTrace and Earley-Boyer generate 81 83, not 81 82 83. So we just 
do the two-test versions for 81 83/81 85/82 86.

Original comment by classi...@floodgap.com on 5 Oct 2014 at 5:25

GoogleCodeExporter commented 9 years ago
Looks like a wash. We don't spend enough time in this code. Not implementing.

js/src/v8/% ../../../obj-ff-dbg/dist/bin/js --no-ion -f run.js 
Richards: 171
DeltaBlue: 163
Crypto: 24.9
RayTrace: 524
EarleyBoyer: 484
RegExp: 487
Splay: 778
NavierStokes: 72.3
----
Score (version 7): 216

Original comment by classi...@floodgap.com on 5 Oct 2014 at 6:54