This is their initialization:
{ MaybeObject* maybe_obj = CreateOddball("true",
Smi::FromInt(1),
Oddball::kTrue);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_true_value(obj);
{ MaybeObject* maybe_obj = CreateOddball("false",
Smi::FromInt(0),
Oddball::kFalse);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_false_value(obj);
Of course, you need to know in several places that it IS a boolean, but
for arithmetic operations (most common in JIT), it seems an int is more
than enough. (Smi thing is similar to the old JSValue32 approach)
Regards,
Zoltan
> Hello,
>
> This is not the case, at least in the full-codegen, where v8 uses specific
> heap values for the boolean True and False.
> I am not sure what Crankshaft is able to optimize, but it does also use
> these values.
>
> See src/heap.h line 56
> #define UNCONDITIONAL_STRONG_ROOT_LIST(V)
> ...
> V(Object, true_value, TrueValue)
> \
> V(Object, false_value, FalseValue)
>
> For example ia32 then uses Factory::true_value() to access it.
> (full-codegen-ia32.cc)
>
> 527 // Emit the inlined tests assumed by the stub.
> 528 __ cmp(result_register(), Factory::undefined_value());
> 529 __ j(equal, if_false);
> 530 __ cmp(result_register(), Factory::true_value());
> 531 __ j(equal, if_true);
> 532 __ cmp(result_register(), Factory::false_value());
> 533 __ j(equal, if_false);
>
>
> Alexandre
>
>
> On Fri, Mar 4, 2011 at 1:37 PM, Zoltan Herczeg
> <[email protected]>wrote:
>
>> Hi,
>>
>> I found something interesting in the v8 source code. They store the true
>> and false as integers: 1 and 0. Actually it was a surprise to me, but
>> "true + 1" is "2" in JavaScript, so this kind of object handling seems
>> ok.
>>
>> Advantage of their approach: they don't need to care about boolean
>> values
>> for all arithmetic and conditional operations in JIT. This could reduce
>> the source code (maintainability), and probably faster, since you don't
>> need to check boolean values.
>>
>> Disadvantage: type resolving is a bit more difficult, but since that is
>> a
>> rare operation, I think the gain could be bigger.
>>
>> What is your opinion about it? Would it be possible to implement
>> something
>> like this for JSValue32_64? Would it worth it?
>>
>> Regards,
>> Zoltan
>>
>>
>> _______________________________________________
>> squirrelfish-dev mailing list
>> [email protected]
>> http://lists.webkit.org/mailman/listinfo.cgi/squirrelfish-dev
>>
>
_______________________________________________
squirrelfish-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/squirrelfish-dev