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

Unified Diff: src/code-stubs.cc

Issue 26824002: Truncate booleans to 0/1 in truncating t-to-i. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: add a testcase Created 7 years, 2 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/arm/lithium-codegen-arm.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index 2283f847bab674029ae9e6d1f881e431589a60fc..2a60d1532e1f630cf30b02d49337d5e2396fbec9 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -585,9 +585,9 @@ void BinaryOpStub::UpdateStatus(Handle<Object> left,
if (old_state == GetExtraICState()) {
// Tagged operations can lead to non-truncating HChanges
- if (left->IsUndefined()) {
+ if (left->IsUndefined() || left->IsBoolean()) {
left_state_ = GENERIC;
- } else if (right->IsUndefined()) {
+ } else if (right->IsUndefined() || right->IsBoolean()) {
right_state_ = GENERIC;
} else {
// Since the fpu is to precise, we might bail out on numbers which
@@ -602,14 +602,17 @@ void BinaryOpStub::UpdateStatus(Handle<Object> left,
void BinaryOpStub::UpdateStatus(Handle<Object> object,
State* state) {
+ bool is_truncating = (op_ == Token::BIT_AND || op_ == Token::BIT_OR ||
+ op_ == Token::BIT_XOR || op_ == Token::SAR ||
+ op_ == Token::SHL || op_ == Token::SHR);
v8::internal::TypeInfo type = v8::internal::TypeInfo::FromValue(object);
+ if (object->IsBoolean() && is_truncating) {
+ // Booleans are converted by truncating by HChange.
+ type = TypeInfo::Integer32();
+ }
if (object->IsUndefined()) {
// Undefined will be automatically truncated for us by HChange.
- type = (op_ == Token::BIT_AND || op_ == Token::BIT_OR ||
- op_ == Token::BIT_XOR || op_ == Token::SAR ||
- op_ == Token::SHL || op_ == Token::SHR)
- ? TypeInfo::Integer32()
- : TypeInfo::Double();
+ type = is_truncating ? TypeInfo::Integer32() : TypeInfo::Double();
}
State int_state = SmiValuesAre32Bits() ? NUMBER : INT32;
State new_state = NONE;
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698