Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1848)

Unified Diff: src/x64/lithium-codegen-x64.cc

Issue 7497063: Simplify and optimize ToBoolean handling. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/x64/lithium-codegen-x64.cc
===================================================================
--- src/x64/lithium-codegen-x64.cc (revision 8868)
+++ src/x64/lithium-codegen-x64.cc (working copy)
@@ -1410,40 +1410,19 @@
// undefined -> false.
__ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
__ j(equal, false_label);
- } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
- // We've seen undefined for the first time -> deopt.
- __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
- DeoptimizeIf(equal, instr->environment());
}
-
if (expected.Contains(ToBooleanStub::BOOLEAN)) {
// true -> true.
__ CompareRoot(reg, Heap::kTrueValueRootIndex);
__ j(equal, true_label);
- } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
- // We've seen a boolean for the first time -> deopt.
- __ CompareRoot(reg, Heap::kTrueValueRootIndex);
- DeoptimizeIf(equal, instr->environment());
- }
-
- if (expected.Contains(ToBooleanStub::BOOLEAN)) {
// false -> false.
__ CompareRoot(reg, Heap::kFalseValueRootIndex);
__ j(equal, false_label);
- } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
- // We've seen a boolean for the first time -> deopt.
- __ CompareRoot(reg, Heap::kFalseValueRootIndex);
- DeoptimizeIf(equal, instr->environment());
}
-
if (expected.Contains(ToBooleanStub::NULL_TYPE)) {
// 'null' -> false.
__ CompareRoot(reg, Heap::kNullValueRootIndex);
__ j(equal, false_label);
- } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
- // We've seen null for the first time -> deopt.
- __ CompareRoot(reg, Heap::kNullValueRootIndex);
- DeoptimizeIf(equal, instr->environment());
}
if (expected.Contains(ToBooleanStub::SMI)) {
@@ -1460,21 +1439,19 @@
const Register map = kScratchRegister;
if (expected.NeedsMap()) {
__ movq(map, FieldOperand(reg, HeapObject::kMapOffset));
- // Everything with a map could be undetectable, so check this now.
- __ testb(FieldOperand(map, Map::kBitFieldOffset),
- Immediate(1 << Map::kIsUndetectable));
- // Undetectable -> false.
- __ j(not_zero, false_label);
+
+ if (expected.CanBeUndetectable()) {
+ // Undetectable -> false.
+ __ testb(FieldOperand(map, Map::kBitFieldOffset),
+ Immediate(1 << Map::kIsUndetectable));
+ __ j(not_zero, false_label);
+ }
}
if (expected.Contains(ToBooleanStub::SPEC_OBJECT)) {
// spec object -> true.
__ CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE);
__ j(above_equal, true_label);
- } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
- // We've seen a spec object for the first time -> deopt.
- __ CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE);
- DeoptimizeIf(above_equal, instr->environment());
}
if (expected.Contains(ToBooleanStub::STRING)) {
@@ -1486,10 +1463,6 @@
__ j(not_zero, true_label);
__ jmp(false_label);
__ bind(&not_string);
- } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
- // We've seen a string for the first time -> deopt
- __ CmpInstanceType(map, FIRST_NONSTRING_TYPE);
- DeoptimizeIf(below, instr->environment());
}
if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) {
@@ -1502,19 +1475,10 @@
__ j(zero, false_label);
__ jmp(true_label);
__ bind(&not_heap_number);
- } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
- // We've seen a heap number for the first time -> deopt.
- __ CompareRoot(map, Heap::kHeapNumberMapRootIndex);
- DeoptimizeIf(equal, instr->environment());
}
- if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
- // internal objects -> true
- __ jmp(true_label);
- } else {
- // We've seen something for the first time -> deopt.
- DeoptimizeIf(no_condition, instr->environment());
- }
+ // We've seen something for the first time -> deopt.
+ DeoptimizeIf(no_condition, instr->environment());
}
}
}
« src/apinatives.js ('K') | « src/x64/code-stubs-x64.cc ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698