Commit ade53c42 authored by lrn@chromium.org's avatar lrn@chromium.org

X64: Make the ToBoolean inline code do even less if the value is known to be a smi.

Review URL: http://codereview.chromium.org/2834028

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4978 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d539095b
...@@ -296,14 +296,14 @@ function RegExpTest(string) { ...@@ -296,14 +296,14 @@ function RegExpTest(string) {
return cache.answer; return cache.answer;
} }
// Remove irrelevant preceeding '.*' in a test regexp. The expression // Remove irrelevant preceeding '.*' in a test regexp. The expression
// checks whether this.source starts with '.*' and that the third // checks whether this.source starts with '.*' and that the third
// char is not a '?' // char is not a '?'
if (%_StringCharCodeAt(this.source,0) == 46 && // '.' if (%_StringCharCodeAt(this.source,0) == 46 && // '.'
%_StringCharCodeAt(this.source,1) == 42 && // '*' %_StringCharCodeAt(this.source,1) == 42 && // '*'
%_StringCharCodeAt(this.source,2) != 63) { // '?' %_StringCharCodeAt(this.source,2) != 63) { // '?'
if (!%_ObjectEquals(regexp_key, this)) { if (!%_ObjectEquals(regexp_key, this)) {
regexp_key = this; regexp_key = this;
regexp_val = new $RegExp(this.source.substring(2, this.source.length), regexp_val = new $RegExp(this.source.substring(2, this.source.length),
(this.global ? 'g' : '') (this.global ? 'g' : '')
+ (this.ignoreCase ? 'i' : '') + (this.ignoreCase ? 'i' : '')
...@@ -311,7 +311,7 @@ function RegExpTest(string) { ...@@ -311,7 +311,7 @@ function RegExpTest(string) {
} }
if (!regexp_val.test(s)) return false; if (!regexp_val.test(s)) return false;
} }
var length = s.length; var length = s.length;
var i = this.global ? TO_INTEGER(lastIndex) : 0; var i = this.global ? TO_INTEGER(lastIndex) : 0;
......
...@@ -5342,13 +5342,18 @@ void CodeGenerator::ToBoolean(ControlDestination* dest) { ...@@ -5342,13 +5342,18 @@ void CodeGenerator::ToBoolean(ControlDestination* dest) {
} }
// Smi => false iff zero. // Smi => false iff zero.
__ SmiCompare(value.reg(), Smi::FromInt(0)); __ SmiCompare(value.reg(), Smi::FromInt(0));
dest->false_target()->Branch(equal); if (value.is_smi()) {
Condition is_smi = masm_->CheckSmi(value.reg()); value.Unuse();
dest->true_target()->Branch(is_smi); dest->Split(not_zero);
__ xorpd(xmm0, xmm0); } else {
__ ucomisd(xmm0, FieldOperand(value.reg(), HeapNumber::kValueOffset)); dest->false_target()->Branch(equal);
value.Unuse(); Condition is_smi = masm_->CheckSmi(value.reg());
dest->Split(not_zero); dest->true_target()->Branch(is_smi);
__ xorpd(xmm0, xmm0);
__ ucomisd(xmm0, FieldOperand(value.reg(), HeapNumber::kValueOffset));
value.Unuse();
dest->Split(not_zero);
}
} else { } else {
// Fast case checks. // Fast case checks.
// 'false' => false. // 'false' => false.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment