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

Unified Diff: src/ia32/register-allocator-ia32.cc

Issue 975001: Use untagged int32 values in evaluation of side-effect free expressions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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/ia32/codegen-ia32.cc ('k') | src/ia32/virtual-frame-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/register-allocator-ia32.cc
===================================================================
--- src/ia32/register-allocator-ia32.cc (revision 4147)
+++ src/ia32/register-allocator-ia32.cc (working copy)
@@ -42,7 +42,33 @@
if (is_constant()) {
Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate();
ASSERT(fresh.is_valid());
- if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) {
+ if (is_untagged_int32()) {
+ fresh.set_untagged_int32(true);
+ if (handle()->IsSmi()) {
+ CodeGeneratorScope::Current()->masm()->Set(
+ fresh.reg(),
+ Immediate(Smi::cast(*handle())->value()));
+ } else if (handle()->IsHeapNumber()) {
+ double double_value = HeapNumber::cast(*handle())->value();
+ int32_t value = DoubleToInt32(double_value);
+ if (double_value == 0 && signbit(double_value)) {
+ // Negative zero must not be converted to an int32 unless
+ // the context allows it.
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal);
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal);
+ } else if (double_value == value) {
+ CodeGeneratorScope::Current()->masm()->Set(
+ fresh.reg(), Immediate(value));
+ } else {
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal);
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal);
+ }
+ } else {
+ // Constant is not a number. This was not predicted by AST analysis.
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal);
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal);
+ }
+ } else if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) {
CodeGeneratorScope::Current()->MoveUnsafeSmi(fresh.reg(), handle());
} else {
CodeGeneratorScope::Current()->masm()->Set(fresh.reg(),
@@ -65,13 +91,38 @@
CodeGeneratorScope::Current()->masm()->mov(fresh.reg(), reg());
} else {
ASSERT(is_constant());
- if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) {
- CodeGeneratorScope::Current()->MoveUnsafeSmi(fresh.reg(), handle());
+ if (is_untagged_int32()) {
+ if (handle()->IsSmi()) {
+ CodeGeneratorScope::Current()->masm()->Set(
+ fresh.reg(),
+ Immediate(Smi::cast(*handle())->value()));
+ } else {
+ ASSERT(handle()->IsHeapNumber());
+ double double_value = HeapNumber::cast(*handle())->value();
+ int32_t value = DoubleToInt32(double_value);
+ if (double_value == 0 && signbit(double_value)) {
+ // Negative zero must not be converted to an int32 unless
+ // the context allows it.
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal);
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal);
+ } else if (double_value == value) {
+ CodeGeneratorScope::Current()->masm()->Set(
+ fresh.reg(), Immediate(value));
+ } else {
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal);
+ CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal);
+ }
+ }
} else {
- CodeGeneratorScope::Current()->masm()->Set(fresh.reg(),
- Immediate(handle()));
+ if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) {
+ CodeGeneratorScope::Current()->MoveUnsafeSmi(fresh.reg(), handle());
+ } else {
+ CodeGeneratorScope::Current()->masm()->Set(fresh.reg(),
+ Immediate(handle()));
+ }
}
}
+ fresh.set_untagged_int32(is_untagged_int32());
*this = fresh;
} else if (is_register() && reg().is(target)) {
ASSERT(CodeGeneratorScope::Current()->has_valid_frame());
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/ia32/virtual-frame-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698