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

Unified Diff: src/codegen-ia32.cc

Issue 9040: * Added check for HeapNumber in the fast-cast Smi switch. (Closed)
Patch Set: Fix ofr Issue 137. Addressed reviewer comments Created 12 years, 1 month 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/codegen-arm.cc ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codegen-ia32.cc
diff --git a/src/codegen-ia32.cc b/src/codegen-ia32.cc
index eaac989061443e469179a1fedc4448e2f0d753b6..cac0f44871ea55dc58c3fc0a82e1b9e49efdf557 100644
--- a/src/codegen-ia32.cc
+++ b/src/codegen-ia32.cc
@@ -1623,9 +1623,24 @@ void CodeGenerator::GenerateFastCaseSwitchJumpTable(
// placeholders, and fill in the addresses after the labels have been
// bound.
- frame_->Pop(eax); // supposed smi
+ frame_->Pop(eax); // supposed Smi
// check range of value, if outside [0..length-1] jump to default/end label.
ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
+
+ // Test whether input is a HeapNumber that is really a Smi
+ Label is_smi;
+ __ test(eax, Immediate(kSmiTagMask));
+ __ j(equal, &is_smi);
+ // It's a heap object, not a Smi or a Failure
+ __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
+ __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
+ __ cmp(ebx, HEAP_NUMBER_TYPE);
+ __ j(not_equal, fail_label);
+ // eax points to a heap number.
+ __ push(eax);
+ __ CallRuntime(Runtime::kNumberToSmi, 1);
+ __ bind(&is_smi);
+
if (min_index != 0) {
__ sub(Operand(eax), Immediate(min_index << kSmiTagSize));
}
« no previous file with comments | « src/codegen-arm.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698