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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/codegen-arm.cc ('k') | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 Vector<Label*> case_targets, 1616 Vector<Label*> case_targets,
1617 Vector<Label> case_labels) { 1617 Vector<Label> case_labels) {
1618 // Notice: Internal references, used by both the jmp instruction and 1618 // Notice: Internal references, used by both the jmp instruction and
1619 // the table entries, need to be relocated if the buffer grows. This 1619 // the table entries, need to be relocated if the buffer grows. This
1620 // prevents the forward use of Labels, since a displacement cannot 1620 // prevents the forward use of Labels, since a displacement cannot
1621 // survive relocation, and it also cannot safely be distinguished 1621 // survive relocation, and it also cannot safely be distinguished
1622 // from a real address. Instead we put in zero-values as 1622 // from a real address. Instead we put in zero-values as
1623 // placeholders, and fill in the addresses after the labels have been 1623 // placeholders, and fill in the addresses after the labels have been
1624 // bound. 1624 // bound.
1625 1625
1626 frame_->Pop(eax); // supposed smi 1626 frame_->Pop(eax); // supposed Smi
1627 // check range of value, if outside [0..length-1] jump to default/end label. 1627 // check range of value, if outside [0..length-1] jump to default/end label.
1628 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 1628 ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
1629
1630 // Test whether input is a HeapNumber that is really a Smi
1631 Label is_smi;
1632 __ test(eax, Immediate(kSmiTagMask));
1633 __ j(equal, &is_smi);
1634 // It's a heap object, not a Smi or a Failure
1635 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
1636 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
1637 __ cmp(ebx, HEAP_NUMBER_TYPE);
1638 __ j(not_equal, fail_label);
1639 // eax points to a heap number.
1640 __ push(eax);
1641 __ CallRuntime(Runtime::kNumberToSmi, 1);
1642 __ bind(&is_smi);
1643
1629 if (min_index != 0) { 1644 if (min_index != 0) {
1630 __ sub(Operand(eax), Immediate(min_index << kSmiTagSize)); 1645 __ sub(Operand(eax), Immediate(min_index << kSmiTagSize));
1631 } 1646 }
1632 __ test(eax, Immediate(0x80000000 | kSmiTagMask)); // negative or not Smi 1647 __ test(eax, Immediate(0x80000000 | kSmiTagMask)); // negative or not Smi
1633 __ j(not_equal, fail_label, not_taken); 1648 __ j(not_equal, fail_label, not_taken);
1634 __ cmp(eax, range << kSmiTagSize); 1649 __ cmp(eax, range << kSmiTagSize);
1635 __ j(greater_equal, fail_label, not_taken); 1650 __ j(greater_equal, fail_label, not_taken);
1636 1651
1637 // 0 is placeholder. 1652 // 0 is placeholder.
1638 __ jmp(Operand(eax, times_2, 0x0, RelocInfo::INTERNAL_REFERENCE)); 1653 __ jmp(Operand(eax, times_2, 0x0, RelocInfo::INTERNAL_REFERENCE));
(...skipping 3495 matching lines...) Expand 10 before | Expand all | Expand 10 after
5134 5149
5135 // Slow-case: Go through the JavaScript implementation. 5150 // Slow-case: Go through the JavaScript implementation.
5136 __ bind(&slow); 5151 __ bind(&slow);
5137 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 5152 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
5138 } 5153 }
5139 5154
5140 5155
5141 #undef __ 5156 #undef __
5142 5157
5143 } } // namespace v8::internal 5158 } } // namespace v8::internal
OLDNEW
« 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