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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 2834022: Ensure that ToPrimitive is called on all objects involved in comparisons <, <... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.js ('k') | test/mjsunit/to_number_order.js » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 8941 matching lines...) Expand 10 before | Expand all | Expand 10 after
8952 __ CompareRoot(rdx, Heap::kUndefinedValueRootIndex); 8952 __ CompareRoot(rdx, Heap::kUndefinedValueRootIndex);
8953 __ j(not_equal, &check_for_nan); 8953 __ j(not_equal, &check_for_nan);
8954 __ Set(rax, NegativeComparisonResult(cc_)); 8954 __ Set(rax, NegativeComparisonResult(cc_));
8955 __ ret(0); 8955 __ ret(0);
8956 __ bind(&check_for_nan); 8956 __ bind(&check_for_nan);
8957 } 8957 }
8958 8958
8959 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), 8959 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(),
8960 // so we do the second best thing - test it ourselves. 8960 // so we do the second best thing - test it ourselves.
8961 // Note: if cc_ != equal, never_nan_nan_ is not used. 8961 // Note: if cc_ != equal, never_nan_nan_ is not used.
8962 __ Set(rax, EQUAL); 8962 // We cannot set rax to EQUAL until just before return because
8963 // rax must be unchanged on jump to not_identical.
8964
8963 if (never_nan_nan_ && (cc_ == equal)) { 8965 if (never_nan_nan_ && (cc_ == equal)) {
8966 __ Set(rax, EQUAL);
8964 __ ret(0); 8967 __ ret(0);
8965 } else { 8968 } else {
8966 Label heap_number; 8969 Label heap_number;
8967 // If it's not a heap number, then return equal. 8970 // If it's not a heap number, then return equal for (in)equality operator.
8968 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), 8971 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset),
8969 Factory::heap_number_map()); 8972 Factory::heap_number_map());
8970 __ j(equal, &heap_number); 8973 if (cc_ == equal) {
8971 __ ret(0); 8974 __ j(equal, &heap_number);
8975 __ Set(rax, EQUAL);
8976 __ ret(0);
8977 } else {
8978 // Identical objects must still be converted to primitive for < and >.
8979 __ j(not_equal, &not_identical);
8980 }
8972 8981
8973 __ bind(&heap_number); 8982 __ bind(&heap_number);
8974 // It is a heap number, so return equal if it's not NaN. 8983 // It is a heap number, so return equal if it's not NaN.
8975 // For NaN, return 1 for every condition except greater and 8984 // For NaN, return 1 for every condition except greater and
8976 // greater-equal. Return -1 for them, so the comparison yields 8985 // greater-equal. Return -1 for them, so the comparison yields
8977 // false for all conditions except not-equal. 8986 // false for all conditions except not-equal.
8978 8987 __ Set(rax, EQUAL);
8979 __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); 8988 __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset));
8980 __ ucomisd(xmm0, xmm0); 8989 __ ucomisd(xmm0, xmm0);
8981 __ setcc(parity_even, rax); 8990 __ setcc(parity_even, rax);
8982 // rax is 0 for equal non-NaN heapnumbers, 1 for NaNs. 8991 // rax is 0 for equal non-NaN heapnumbers, 1 for NaNs.
8983 if (cc_ == greater_equal || cc_ == greater) { 8992 if (cc_ == greater_equal || cc_ == greater) {
8984 __ neg(rax); 8993 __ neg(rax);
8985 } 8994 }
8986 __ ret(0); 8995 __ ret(0);
8987 } 8996 }
8988 8997
(...skipping 2912 matching lines...) Expand 10 before | Expand all | Expand 10 after
11901 } 11910 }
11902 11911
11903 #endif 11912 #endif
11904 11913
11905 11914
11906 #undef __ 11915 #undef __
11907 11916
11908 } } // namespace v8::internal 11917 } } // namespace v8::internal
11909 11918
11910 #endif // V8_TARGET_ARCH_X64 11919 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime.js ('k') | test/mjsunit/to_number_order.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698