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

Unified Diff: src/code-stubs-hydrogen.cc

Issue 450273002: Extend ToBooleanStub to be able to return oddballs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index c8dd9bf0f198af82064d9487852e24ba8733d596..775916adc52b7c28250c2c2eae085b134d6dc3a3 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -1065,14 +1065,31 @@ Handle<Code> StringAddStub::GenerateCode() {
template <>
HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
ToBooleanStub* stub = casted_stub();
+ HValue* true_value = NULL;
+ HValue* false_value = NULL;
+
+ switch (stub->GetMode()) {
+ case ToBooleanStub::RESULT_AS_SMI:
+ true_value = graph()->GetConstant1();
+ false_value = graph()->GetConstant0();
+ break;
+ case ToBooleanStub::RESULT_AS_ODDBALL:
+ true_value = graph()->GetConstantTrue();
+ false_value = graph()->GetConstantFalse();
+ break;
+ case ToBooleanStub::RESULT_AS_INVERSE_ODDBALL:
+ true_value = graph()->GetConstantFalse();
+ false_value = graph()->GetConstantTrue();
+ break;
+ }
IfBuilder if_true(this);
if_true.If<HBranch>(GetParameter(0), stub->GetTypes());
if_true.Then();
- if_true.Return(graph()->GetConstant1());
+ if_true.Return(true_value);
if_true.Else();
if_true.End();
- return graph()->GetConstant0();
+ return false_value;
}
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698