47
JSValuePtr jsBoolean(bool b);
48
JSValuePtr jsUndefined();
49
JSValuePtr jsImpossibleValue();
50
JSValuePtr jsNumber(ExecState* exec, double d);
51
JSValuePtr jsNumber(ExecState*, char i);
52
JSValuePtr jsNumber(ExecState*, unsigned char i);
53
JSValuePtr jsNumber(ExecState*, short i);
54
JSValuePtr jsNumber(ExecState*, unsigned short i);
55
JSValuePtr jsNumber(ExecState* exec, int i);
56
JSValuePtr jsNumber(ExecState* exec, unsigned i);
57
JSValuePtr jsNumber(ExecState* exec, long i);
58
JSValuePtr jsNumber(ExecState* exec, unsigned long i);
59
JSValuePtr jsNumber(ExecState* exec, long long i);
60
JSValuePtr jsNumber(ExecState* exec, unsigned long long i);
61
JSValuePtr jsNumber(JSGlobalData* globalData, double d);
62
JSValuePtr jsNumber(JSGlobalData* globalData, short i);
63
JSValuePtr jsNumber(JSGlobalData* globalData, unsigned short i);
64
JSValuePtr jsNumber(JSGlobalData* globalData, int i);
65
JSValuePtr jsNumber(JSGlobalData* globalData, unsigned i);
66
JSValuePtr jsNumber(JSGlobalData* globalData, long i);
67
JSValuePtr jsNumber(JSGlobalData* globalData, unsigned long i);
68
JSValuePtr jsNumber(JSGlobalData* globalData, long long i);
69
JSValuePtr jsNumber(JSGlobalData* globalData, unsigned long long i);
71
45
#if USE(ALTERNATE_JSIMMEDIATE)
72
46
inline intptr_t reinterpretDoubleToIntptr(double value)
158
132
class JSImmediate {
160
134
friend class JIT;
161
friend class JSValuePtr;
135
friend class JSValue;
162
136
friend class JSFastMath;
163
friend JSValuePtr js0();
164
friend JSValuePtr jsNull();
165
friend JSValuePtr jsBoolean(bool b);
166
friend JSValuePtr jsUndefined();
167
friend JSValuePtr jsImpossibleValue();
168
friend JSValuePtr jsNumber(ExecState* exec, double d);
169
friend JSValuePtr jsNumber(ExecState*, char i);
170
friend JSValuePtr jsNumber(ExecState*, unsigned char i);
171
friend JSValuePtr jsNumber(ExecState*, short i);
172
friend JSValuePtr jsNumber(ExecState*, unsigned short i);
173
friend JSValuePtr jsNumber(ExecState* exec, int i);
174
friend JSValuePtr jsNumber(ExecState* exec, unsigned i);
175
friend JSValuePtr jsNumber(ExecState* exec, long i);
176
friend JSValuePtr jsNumber(ExecState* exec, unsigned long i);
177
friend JSValuePtr jsNumber(ExecState* exec, long long i);
178
friend JSValuePtr jsNumber(ExecState* exec, unsigned long long i);
179
friend JSValuePtr jsNumber(JSGlobalData* globalData, double d);
180
friend JSValuePtr jsNumber(JSGlobalData* globalData, short i);
181
friend JSValuePtr jsNumber(JSGlobalData* globalData, unsigned short i);
182
friend JSValuePtr jsNumber(JSGlobalData* globalData, int i);
183
friend JSValuePtr jsNumber(JSGlobalData* globalData, unsigned i);
184
friend JSValuePtr jsNumber(JSGlobalData* globalData, long i);
185
friend JSValuePtr jsNumber(JSGlobalData* globalData, unsigned long i);
186
friend JSValuePtr jsNumber(JSGlobalData* globalData, long long i);
187
friend JSValuePtr jsNumber(JSGlobalData* globalData, unsigned long long i);
137
friend JSValue jsNumber(ExecState* exec, double d);
138
friend JSValue jsNumber(ExecState*, char i);
139
friend JSValue jsNumber(ExecState*, unsigned char i);
140
friend JSValue jsNumber(ExecState*, short i);
141
friend JSValue jsNumber(ExecState*, unsigned short i);
142
friend JSValue jsNumber(ExecState* exec, int i);
143
friend JSValue jsNumber(ExecState* exec, unsigned i);
144
friend JSValue jsNumber(ExecState* exec, long i);
145
friend JSValue jsNumber(ExecState* exec, unsigned long i);
146
friend JSValue jsNumber(ExecState* exec, long long i);
147
friend JSValue jsNumber(ExecState* exec, unsigned long long i);
148
friend JSValue jsNumber(JSGlobalData* globalData, double d);
149
friend JSValue jsNumber(JSGlobalData* globalData, short i);
150
friend JSValue jsNumber(JSGlobalData* globalData, unsigned short i);
151
friend JSValue jsNumber(JSGlobalData* globalData, int i);
152
friend JSValue jsNumber(JSGlobalData* globalData, unsigned i);
153
friend JSValue jsNumber(JSGlobalData* globalData, long i);
154
friend JSValue jsNumber(JSGlobalData* globalData, unsigned long i);
155
friend JSValue jsNumber(JSGlobalData* globalData, long long i);
156
friend JSValue jsNumber(JSGlobalData* globalData, unsigned long long i);
189
158
#if USE(ALTERNATE_JSIMMEDIATE)
190
159
// If all bits in the mask are set, this indicates an integer number,
220
189
static const int32_t signBit = 0x80000000;
222
static ALWAYS_INLINE bool isImmediate(JSValuePtr v)
191
static ALWAYS_INLINE bool isImmediate(JSValue v)
224
193
return rawValue(v) & TagMask;
227
static ALWAYS_INLINE bool isNumber(JSValuePtr v)
196
static ALWAYS_INLINE bool isNumber(JSValue v)
229
198
return rawValue(v) & TagTypeNumber;
232
static ALWAYS_INLINE bool isIntegerNumber(JSValuePtr v)
201
static ALWAYS_INLINE bool isIntegerNumber(JSValue v)
234
203
#if USE(ALTERNATE_JSIMMEDIATE)
235
204
return (rawValue(v) & TagTypeNumber) == TagTypeNumber;
241
210
#if USE(ALTERNATE_JSIMMEDIATE)
242
static ALWAYS_INLINE bool isDoubleNumber(JSValuePtr v)
211
static ALWAYS_INLINE bool isDoubleNumber(JSValue v)
244
213
return isNumber(v) && !isIntegerNumber(v);
248
static ALWAYS_INLINE bool isPositiveIntegerNumber(JSValuePtr v)
217
static ALWAYS_INLINE bool isPositiveIntegerNumber(JSValue v)
250
219
// A single mask to check for the sign bit and the number tag all at once.
251
220
return (rawValue(v) & (signBit | TagTypeNumber)) == TagTypeNumber;
254
static ALWAYS_INLINE bool isBoolean(JSValuePtr v)
223
static ALWAYS_INLINE bool isBoolean(JSValue v)
256
225
return (rawValue(v) & FullTagTypeMask) == FullTagTypeBool;
259
static ALWAYS_INLINE bool isUndefinedOrNull(JSValuePtr v)
228
static ALWAYS_INLINE bool isUndefinedOrNull(JSValue v)
261
230
// Undefined and null share the same value, bar the 'undefined' bit in the extended tag.
262
231
return (rawValue(v) & ~ExtendedTagBitUndefined) == FullTagTypeNull;
265
static JSValuePtr from(char);
266
static JSValuePtr from(signed char);
267
static JSValuePtr from(unsigned char);
268
static JSValuePtr from(short);
269
static JSValuePtr from(unsigned short);
270
static JSValuePtr from(int);
271
static JSValuePtr from(unsigned);
272
static JSValuePtr from(long);
273
static JSValuePtr from(unsigned long);
274
static JSValuePtr from(long long);
275
static JSValuePtr from(unsigned long long);
276
static JSValuePtr from(double);
234
static JSValue from(char);
235
static JSValue from(signed char);
236
static JSValue from(unsigned char);
237
static JSValue from(short);
238
static JSValue from(unsigned short);
239
static JSValue from(int);
240
static JSValue from(unsigned);
241
static JSValue from(long);
242
static JSValue from(unsigned long);
243
static JSValue from(long long);
244
static JSValue from(unsigned long long);
245
static JSValue from(double);
278
static ALWAYS_INLINE bool isEitherImmediate(JSValuePtr v1, JSValuePtr v2)
247
static ALWAYS_INLINE bool isEitherImmediate(JSValue v1, JSValue v2)
280
249
return (rawValue(v1) | rawValue(v2)) & TagMask;
283
static ALWAYS_INLINE bool areBothImmediate(JSValuePtr v1, JSValuePtr v2)
252
static ALWAYS_INLINE bool areBothImmediate(JSValue v1, JSValue v2)
285
254
return isImmediate(v1) & isImmediate(v2);
288
static ALWAYS_INLINE bool areBothImmediateIntegerNumbers(JSValuePtr v1, JSValuePtr v2)
257
static ALWAYS_INLINE bool areBothImmediateIntegerNumbers(JSValue v1, JSValue v2)
290
259
#if USE(ALTERNATE_JSIMMEDIATE)
291
260
return (rawValue(v1) & rawValue(v2) & TagTypeNumber) == TagTypeNumber;
297
static double toDouble(JSValuePtr);
298
static bool toBoolean(JSValuePtr);
299
static JSObject* toObject(JSValuePtr, ExecState*);
300
static JSObject* toThisObject(JSValuePtr, ExecState*);
301
static UString toString(JSValuePtr);
303
static bool getUInt32(JSValuePtr, uint32_t&);
304
static bool getTruncatedInt32(JSValuePtr, int32_t&);
305
static bool getTruncatedUInt32(JSValuePtr, uint32_t&);
307
static int32_t getTruncatedInt32(JSValuePtr);
308
static uint32_t getTruncatedUInt32(JSValuePtr);
310
static JSValuePtr trueImmediate();
311
static JSValuePtr falseImmediate();
312
static JSValuePtr undefinedImmediate();
313
static JSValuePtr nullImmediate();
314
static JSValuePtr zeroImmediate();
315
static JSValuePtr oneImmediate();
317
static JSValuePtr impossibleValue();
319
static JSObject* prototype(JSValuePtr, ExecState*);
266
static double toDouble(JSValue);
267
static bool toBoolean(JSValue);
268
static JSObject* toObject(JSValue, ExecState*);
269
static JSObject* toThisObject(JSValue, ExecState*);
270
static UString toString(JSValue);
272
static bool getUInt32(JSValue, uint32_t&);
273
static bool getTruncatedInt32(JSValue, int32_t&);
274
static bool getTruncatedUInt32(JSValue, uint32_t&);
276
static int32_t getTruncatedInt32(JSValue);
277
static uint32_t getTruncatedUInt32(JSValue);
279
static JSValue trueImmediate();
280
static JSValue falseImmediate();
281
static JSValue undefinedImmediate();
282
static JSValue nullImmediate();
283
static JSValue zeroImmediate();
284
static JSValue oneImmediate();
286
static JSObject* prototype(JSValue, ExecState*);
322
289
#if USE(ALTERNATE_JSIMMEDIATE)
329
296
static const unsigned maxImmediateUInt = maxImmediateInt;
331
static ALWAYS_INLINE JSValuePtr makeValue(intptr_t integer)
298
static ALWAYS_INLINE JSValue makeValue(intptr_t integer)
333
return JSValuePtr::makeImmediate(integer);
300
return JSValue::makeImmediate(integer);
336
303
// With USE(ALTERNATE_JSIMMEDIATE) we want the argument to be zero extended, so the
337
304
// integer doesn't interfere with the tag bits in the upper word. In the default encoding,
338
305
// if intptr_t id larger then int32_t we sign extend the value through the upper word.
339
306
#if USE(ALTERNATE_JSIMMEDIATE)
340
static ALWAYS_INLINE JSValuePtr makeInt(uint32_t value)
307
static ALWAYS_INLINE JSValue makeInt(uint32_t value)
342
static ALWAYS_INLINE JSValuePtr makeInt(int32_t value)
309
static ALWAYS_INLINE JSValue makeInt(int32_t value)
345
312
return makeValue((static_cast<intptr_t>(value) << IntegerPayloadShift) | TagTypeNumber);
348
315
#if USE(ALTERNATE_JSIMMEDIATE)
349
static ALWAYS_INLINE JSValuePtr makeDouble(double value)
316
static ALWAYS_INLINE JSValue makeDouble(double value)
351
318
return makeValue(reinterpretDoubleToIntptr(value) + DoubleEncodeOffset);
355
static ALWAYS_INLINE JSValuePtr makeBool(bool b)
322
static ALWAYS_INLINE JSValue makeBool(bool b)
357
324
return makeValue((static_cast<intptr_t>(b) << ExtendedPayloadShift) | FullTagTypeBool);
360
static ALWAYS_INLINE JSValuePtr makeUndefined()
327
static ALWAYS_INLINE JSValue makeUndefined()
362
329
return makeValue(FullTagTypeUndefined);
365
static ALWAYS_INLINE JSValuePtr makeNull()
332
static ALWAYS_INLINE JSValue makeNull()
367
334
return makeValue(FullTagTypeNull);
370
337
template<typename T>
371
static JSValuePtr fromNumberOutsideIntegerRange(T);
338
static JSValue fromNumberOutsideIntegerRange(T);
373
340
#if USE(ALTERNATE_JSIMMEDIATE)
374
static ALWAYS_INLINE double doubleValue(JSValuePtr v)
341
static ALWAYS_INLINE double doubleValue(JSValue v)
376
343
return reinterpretIntptrToDouble(rawValue(v) - DoubleEncodeOffset);
380
static ALWAYS_INLINE int32_t intValue(JSValuePtr v)
347
static ALWAYS_INLINE int32_t intValue(JSValue v)
382
349
return static_cast<int32_t>(rawValue(v) >> IntegerPayloadShift);
385
static ALWAYS_INLINE uint32_t uintValue(JSValuePtr v)
352
static ALWAYS_INLINE uint32_t uintValue(JSValue v)
387
354
return static_cast<uint32_t>(rawValue(v) >> IntegerPayloadShift);
390
static ALWAYS_INLINE bool boolValue(JSValuePtr v)
357
static ALWAYS_INLINE bool boolValue(JSValue v)
392
359
return rawValue(v) & ExtendedPayloadBitBoolValue;
395
static ALWAYS_INLINE intptr_t rawValue(JSValuePtr v)
362
static ALWAYS_INLINE intptr_t rawValue(JSValue v)
397
364
return v.immediateValue();
400
367
static double nonInlineNaN();
403
ALWAYS_INLINE JSValuePtr JSImmediate::trueImmediate() { return makeBool(true); }
404
ALWAYS_INLINE JSValuePtr JSImmediate::falseImmediate() { return makeBool(false); }
405
ALWAYS_INLINE JSValuePtr JSImmediate::undefinedImmediate() { return makeUndefined(); }
406
ALWAYS_INLINE JSValuePtr JSImmediate::nullImmediate() { return makeNull(); }
407
ALWAYS_INLINE JSValuePtr JSImmediate::zeroImmediate() { return makeInt(0); }
408
ALWAYS_INLINE JSValuePtr JSImmediate::oneImmediate() { return makeInt(1); }
410
// This value is impossible because 0x4 is not a valid pointer but a tag of 0 would indicate non-immediate
411
ALWAYS_INLINE JSValuePtr JSImmediate::impossibleValue() { return makeValue(0x4); }
370
ALWAYS_INLINE JSValue JSImmediate::trueImmediate() { return makeBool(true); }
371
ALWAYS_INLINE JSValue JSImmediate::falseImmediate() { return makeBool(false); }
372
ALWAYS_INLINE JSValue JSImmediate::undefinedImmediate() { return makeUndefined(); }
373
ALWAYS_INLINE JSValue JSImmediate::nullImmediate() { return makeNull(); }
374
ALWAYS_INLINE JSValue JSImmediate::zeroImmediate() { return makeInt(0); }
375
ALWAYS_INLINE JSValue JSImmediate::oneImmediate() { return makeInt(1); }
413
377
#if USE(ALTERNATE_JSIMMEDIATE)
414
378
inline bool doubleToBoolean(double value)
416
380
return value < 0.0 || value > 0.0;
419
ALWAYS_INLINE bool JSImmediate::toBoolean(JSValuePtr v)
383
ALWAYS_INLINE bool JSImmediate::toBoolean(JSValue v)
421
385
ASSERT(isImmediate(v));
422
386
return isNumber(v) ? isIntegerNumber(v) ? v != zeroImmediate()
423
387
: doubleToBoolean(doubleValue(v)) : v == trueImmediate();
426
ALWAYS_INLINE bool JSImmediate::toBoolean(JSValuePtr v)
390
ALWAYS_INLINE bool JSImmediate::toBoolean(JSValue v)
428
392
ASSERT(isImmediate(v));
429
393
return isIntegerNumber(v) ? v != zeroImmediate() : v == trueImmediate();
433
ALWAYS_INLINE uint32_t JSImmediate::getTruncatedUInt32(JSValuePtr v)
397
ALWAYS_INLINE uint32_t JSImmediate::getTruncatedUInt32(JSValue v)
435
399
// FIXME: should probably be asserting isPositiveIntegerNumber here.
436
400
ASSERT(isIntegerNumber(v));
440
404
#if USE(ALTERNATE_JSIMMEDIATE)
441
405
template<typename T>
442
inline JSValuePtr JSImmediate::fromNumberOutsideIntegerRange(T value)
406
inline JSValue JSImmediate::fromNumberOutsideIntegerRange(T value)
444
408
return makeDouble(static_cast<double>(value));
447
411
template<typename T>
448
inline JSValuePtr JSImmediate::fromNumberOutsideIntegerRange(T)
412
inline JSValue JSImmediate::fromNumberOutsideIntegerRange(T)
454
ALWAYS_INLINE JSValuePtr JSImmediate::from(char i)
459
ALWAYS_INLINE JSValuePtr JSImmediate::from(signed char i)
464
ALWAYS_INLINE JSValuePtr JSImmediate::from(unsigned char i)
469
ALWAYS_INLINE JSValuePtr JSImmediate::from(short i)
474
ALWAYS_INLINE JSValuePtr JSImmediate::from(unsigned short i)
479
ALWAYS_INLINE JSValuePtr JSImmediate::from(int i)
418
ALWAYS_INLINE JSValue JSImmediate::from(char i)
423
ALWAYS_INLINE JSValue JSImmediate::from(signed char i)
428
ALWAYS_INLINE JSValue JSImmediate::from(unsigned char i)
433
ALWAYS_INLINE JSValue JSImmediate::from(short i)
438
ALWAYS_INLINE JSValue JSImmediate::from(unsigned short i)
443
ALWAYS_INLINE JSValue JSImmediate::from(int i)
481
445
#if !USE(ALTERNATE_JSIMMEDIATE)
482
446
if ((i < minImmediateInt) | (i > maxImmediateInt))
485
449
return makeInt(i);
488
ALWAYS_INLINE JSValuePtr JSImmediate::from(unsigned i)
490
if (i > maxImmediateUInt)
491
return fromNumberOutsideIntegerRange(i);
495
ALWAYS_INLINE JSValuePtr JSImmediate::from(long i)
497
if ((i < minImmediateInt) | (i > maxImmediateInt))
498
return fromNumberOutsideIntegerRange(i);
502
ALWAYS_INLINE JSValuePtr JSImmediate::from(unsigned long i)
504
if (i > maxImmediateUInt)
505
return fromNumberOutsideIntegerRange(i);
509
ALWAYS_INLINE JSValuePtr JSImmediate::from(long long i)
511
if ((i < minImmediateInt) | (i > maxImmediateInt))
513
return makeInt(static_cast<intptr_t>(i));
516
ALWAYS_INLINE JSValuePtr JSImmediate::from(unsigned long long i)
518
if (i > maxImmediateUInt)
519
return fromNumberOutsideIntegerRange(i);
520
return makeInt(static_cast<intptr_t>(i));
523
ALWAYS_INLINE JSValuePtr JSImmediate::from(double d)
452
ALWAYS_INLINE JSValue JSImmediate::from(unsigned i)
454
if (i > maxImmediateUInt)
455
return fromNumberOutsideIntegerRange(i);
459
ALWAYS_INLINE JSValue JSImmediate::from(long i)
461
if ((i < minImmediateInt) | (i > maxImmediateInt))
462
return fromNumberOutsideIntegerRange(i);
466
ALWAYS_INLINE JSValue JSImmediate::from(unsigned long i)
468
if (i > maxImmediateUInt)
469
return fromNumberOutsideIntegerRange(i);
473
ALWAYS_INLINE JSValue JSImmediate::from(long long i)
475
if ((i < minImmediateInt) | (i > maxImmediateInt))
477
return makeInt(static_cast<intptr_t>(i));
480
ALWAYS_INLINE JSValue JSImmediate::from(unsigned long long i)
482
if (i > maxImmediateUInt)
483
return fromNumberOutsideIntegerRange(i);
484
return makeInt(static_cast<intptr_t>(i));
487
ALWAYS_INLINE JSValue JSImmediate::from(double d)
525
489
const int intVal = static_cast<int>(d);
560
524
return rawValue(v) >> ExtendedPayloadShift;
563
ALWAYS_INLINE bool JSImmediate::getUInt32(JSValuePtr v, uint32_t& i)
527
ALWAYS_INLINE bool JSImmediate::getUInt32(JSValue v, uint32_t& i)
565
529
i = uintValue(v);
566
530
return isPositiveIntegerNumber(v);
569
ALWAYS_INLINE bool JSImmediate::getTruncatedInt32(JSValuePtr v, int32_t& i)
533
ALWAYS_INLINE bool JSImmediate::getTruncatedInt32(JSValue v, int32_t& i)
572
536
return isIntegerNumber(v);
575
ALWAYS_INLINE bool JSImmediate::getTruncatedUInt32(JSValuePtr v, uint32_t& i)
539
ALWAYS_INLINE bool JSImmediate::getTruncatedUInt32(JSValue v, uint32_t& i)
577
541
return getUInt32(v, i);
580
inline JSValuePtr js0()
582
return JSImmediate::zeroImmediate();
585
inline JSValuePtr jsNull()
587
return JSImmediate::nullImmediate();
590
inline JSValuePtr jsBoolean(bool b)
592
return b ? JSImmediate::trueImmediate() : JSImmediate::falseImmediate();
595
inline JSValuePtr jsUndefined()
597
return JSImmediate::undefinedImmediate();
600
inline JSValuePtr jsImpossibleValue()
602
return JSImmediate::impossibleValue();
605
544
// These are identical logic to the JSValue functions above, and faster than jsNumber(number).toInt32().
606
545
int32_t toInt32(double);
607
546
uint32_t toUInt32(double);
608
547
int32_t toInt32SlowCase(double, bool& ok);
609
548
uint32_t toUInt32SlowCase(double, bool& ok);
611
inline bool JSValuePtr::isUndefined() const
613
return asValue() == jsUndefined();
616
inline bool JSValuePtr::isNull() const
618
return asValue() == jsNull();
621
inline bool JSValuePtr::isUndefinedOrNull() const
550
inline JSValue::JSValue(JSNullTag)
552
*this = JSImmediate::nullImmediate();
555
inline JSValue::JSValue(JSUndefinedTag)
557
*this = JSImmediate::undefinedImmediate();
560
inline JSValue::JSValue(JSTrueTag)
562
*this = JSImmediate::trueImmediate();
565
inline JSValue::JSValue(JSFalseTag)
567
*this = JSImmediate::falseImmediate();
570
inline bool JSValue::isUndefinedOrNull() const
623
572
return JSImmediate::isUndefinedOrNull(asValue());
626
inline bool JSValuePtr::isBoolean() const
575
inline bool JSValue::isBoolean() const
628
577
return JSImmediate::isBoolean(asValue());
631
inline bool JSValuePtr::getBoolean(bool& v) const
580
inline bool JSValue::getBoolean(bool& v) const
633
582
if (JSImmediate::isBoolean(asValue())) {
634
583
v = JSImmediate::toBoolean(asValue());
699
648
return toUInt32SlowCase(toNumber(exec), ok);
702
inline bool JSValuePtr::isCell() const
651
inline bool JSValue::isCell() const
704
653
return !JSImmediate::isImmediate(asValue());
707
inline bool JSValuePtr::isInt32Fast() const
656
inline bool JSValue::isInt32Fast() const
709
658
return JSImmediate::isIntegerNumber(asValue());
712
inline int32_t JSValuePtr::getInt32Fast() const
661
inline int32_t JSValue::getInt32Fast() const
714
663
ASSERT(isInt32Fast());
715
664
return JSImmediate::getTruncatedInt32(asValue());
718
inline bool JSValuePtr::isUInt32Fast() const
667
inline bool JSValue::isUInt32Fast() const
720
669
return JSImmediate::isPositiveIntegerNumber(asValue());
723
inline uint32_t JSValuePtr::getUInt32Fast() const
672
inline uint32_t JSValue::getUInt32Fast() const
725
674
ASSERT(isUInt32Fast());
726
675
return JSImmediate::getTruncatedUInt32(asValue());
729
inline JSValuePtr JSValuePtr::makeInt32Fast(int32_t i)
678
inline JSValue JSValue::makeInt32Fast(int32_t i)
731
680
return JSImmediate::from(i);
734
inline bool JSValuePtr::areBothInt32Fast(JSValuePtr v1, JSValuePtr v2)
683
inline bool JSValue::areBothInt32Fast(JSValue v1, JSValue v2)
736
685
return JSImmediate::areBothImmediateIntegerNumbers(v1, v2);
739
688
class JSFastMath {
741
static ALWAYS_INLINE bool canDoFastBitwiseOperations(JSValuePtr v1, JSValuePtr v2)
690
static ALWAYS_INLINE bool canDoFastBitwiseOperations(JSValue v1, JSValue v2)
743
692
return JSImmediate::areBothImmediateIntegerNumbers(v1, v2);
746
static ALWAYS_INLINE JSValuePtr equal(JSValuePtr v1, JSValuePtr v2)
695
static ALWAYS_INLINE JSValue equal(JSValue v1, JSValue v2)
748
697
ASSERT(canDoFastBitwiseOperations(v1, v2));
749
698
return jsBoolean(v1 == v2);
752
static ALWAYS_INLINE JSValuePtr notEqual(JSValuePtr v1, JSValuePtr v2)
701
static ALWAYS_INLINE JSValue notEqual(JSValue v1, JSValue v2)
754
703
ASSERT(canDoFastBitwiseOperations(v1, v2));
755
704
return jsBoolean(v1 != v2);
758
static ALWAYS_INLINE JSValuePtr andImmediateNumbers(JSValuePtr v1, JSValuePtr v2)
707
static ALWAYS_INLINE JSValue andImmediateNumbers(JSValue v1, JSValue v2)
760
709
ASSERT(canDoFastBitwiseOperations(v1, v2));
761
710
return JSImmediate::makeValue(JSImmediate::rawValue(v1) & JSImmediate::rawValue(v2));
764
static ALWAYS_INLINE JSValuePtr xorImmediateNumbers(JSValuePtr v1, JSValuePtr v2)
713
static ALWAYS_INLINE JSValue xorImmediateNumbers(JSValue v1, JSValue v2)
766
715
ASSERT(canDoFastBitwiseOperations(v1, v2));
767
716
return JSImmediate::makeValue((JSImmediate::rawValue(v1) ^ JSImmediate::rawValue(v2)) | JSImmediate::TagTypeNumber);
770
static ALWAYS_INLINE JSValuePtr orImmediateNumbers(JSValuePtr v1, JSValuePtr v2)
719
static ALWAYS_INLINE JSValue orImmediateNumbers(JSValue v1, JSValue v2)
772
721
ASSERT(canDoFastBitwiseOperations(v1, v2));
773
722
return JSImmediate::makeValue(JSImmediate::rawValue(v1) | JSImmediate::rawValue(v2));
776
static ALWAYS_INLINE bool canDoFastRshift(JSValuePtr v1, JSValuePtr v2)
725
static ALWAYS_INLINE bool canDoFastRshift(JSValue v1, JSValue v2)
778
727
return JSImmediate::areBothImmediateIntegerNumbers(v1, v2);
781
static ALWAYS_INLINE bool canDoFastUrshift(JSValuePtr v1, JSValuePtr v2)
730
static ALWAYS_INLINE bool canDoFastUrshift(JSValue v1, JSValue v2)
783
732
return JSImmediate::areBothImmediateIntegerNumbers(v1, v2) && !(JSImmediate::rawValue(v1) & JSImmediate::signBit);
786
static ALWAYS_INLINE JSValuePtr rightShiftImmediateNumbers(JSValuePtr val, JSValuePtr shift)
735
static ALWAYS_INLINE JSValue rightShiftImmediateNumbers(JSValue val, JSValue shift)
788
737
ASSERT(canDoFastRshift(val, shift) || canDoFastUrshift(val, shift));
789
738
#if USE(ALTERNATE_JSIMMEDIATE)
796
static ALWAYS_INLINE bool canDoFastAdditiveOperations(JSValuePtr v)
745
static ALWAYS_INLINE bool canDoFastAdditiveOperations(JSValue v)
798
747
// Number is non-negative and an operation involving two of these can't overflow.
799
748
// Checking for allowed negative numbers takes more time than it's worth on SunSpider.
800
749
return (JSImmediate::rawValue(v) & (JSImmediate::TagTypeNumber + (JSImmediate::signBit | (JSImmediate::signBit >> 1)))) == JSImmediate::TagTypeNumber;
803
static ALWAYS_INLINE bool canDoFastAdditiveOperations(JSValuePtr v1, JSValuePtr v2)
752
static ALWAYS_INLINE bool canDoFastAdditiveOperations(JSValue v1, JSValue v2)
805
754
// Number is non-negative and an operation involving two of these can't overflow.
806
755
// Checking for allowed negative numbers takes more time than it's worth on SunSpider.
807
756
return canDoFastAdditiveOperations(v1) && canDoFastAdditiveOperations(v2);
810
static ALWAYS_INLINE JSValuePtr addImmediateNumbers(JSValuePtr v1, JSValuePtr v2)
759
static ALWAYS_INLINE JSValue addImmediateNumbers(JSValue v1, JSValue v2)
812
761
ASSERT(canDoFastAdditiveOperations(v1, v2));
813
762
return JSImmediate::makeValue(JSImmediate::rawValue(v1) + JSImmediate::rawValue(v2) - JSImmediate::TagTypeNumber);
816
static ALWAYS_INLINE JSValuePtr subImmediateNumbers(JSValuePtr v1, JSValuePtr v2)
765
static ALWAYS_INLINE JSValue subImmediateNumbers(JSValue v1, JSValue v2)
818
767
ASSERT(canDoFastAdditiveOperations(v1, v2));
819
768
return JSImmediate::makeValue(JSImmediate::rawValue(v1) - JSImmediate::rawValue(v2) + JSImmediate::TagTypeNumber);
822
static ALWAYS_INLINE JSValuePtr incImmediateNumber(JSValuePtr v)
771
static ALWAYS_INLINE JSValue incImmediateNumber(JSValue v)
824
773
ASSERT(canDoFastAdditiveOperations(v));
825
774
return JSImmediate::makeValue(JSImmediate::rawValue(v) + (1 << JSImmediate::IntegerPayloadShift));
828
static ALWAYS_INLINE JSValuePtr decImmediateNumber(JSValuePtr v)
777
static ALWAYS_INLINE JSValue decImmediateNumber(JSValue v)
830
779
ASSERT(canDoFastAdditiveOperations(v));
831
780
return JSImmediate::makeValue(JSImmediate::rawValue(v) - (1 << JSImmediate::IntegerPayloadShift));