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

Side by Side Diff: src/runtime/runtime-numbers.cc

Issue 648643003: Drop obsolete misc-intrinsics.h file. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/misc-intrinsics.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
9 #include "src/codegen.h" 10 #include "src/codegen.h"
10 #include "src/misc-intrinsics.h"
11 #include "src/runtime/runtime.h" 11 #include "src/runtime/runtime.h"
12 #include "src/runtime/runtime-utils.h" 12 #include "src/runtime/runtime-utils.h"
13 13
14 14
15 #ifndef _STLP_VENDOR_CSTD 15 #ifndef _STLP_VENDOR_CSTD
16 // STLPort doesn't import fpclassify and isless into the std namespace. 16 // STLPort doesn't import fpclassify and isless into the std namespace.
17 using std::fpclassify; 17 using std::fpclassify;
18 using std::isless; 18 using std::isless;
19 #endif 19 #endif
20 20
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 100 * 1000 * 1000, 1000 * 1000 * 1000}; 519 100 * 1000 * 1000, 1000 * 1000 * 1000};
520 520
521 // If the integers have the same number of decimal digits they can be 521 // If the integers have the same number of decimal digits they can be
522 // compared directly as the numeric order is the same as the 522 // compared directly as the numeric order is the same as the
523 // lexicographic order. If one integer has fewer digits, it is scaled 523 // lexicographic order. If one integer has fewer digits, it is scaled
524 // by some power of 10 to have the same number of digits as the longer 524 // by some power of 10 to have the same number of digits as the longer
525 // integer. If the scaled integers are equal it means the shorter 525 // integer. If the scaled integers are equal it means the shorter
526 // integer comes first in the lexicographic order. 526 // integer comes first in the lexicographic order.
527 527
528 // From http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 528 // From http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
529 int x_log2 = IntegerLog2(x_scaled); 529 int x_log2 = 31 - base::bits::CountLeadingZeros32(x_scaled);
530 int x_log10 = ((x_log2 + 1) * 1233) >> 12; 530 int x_log10 = ((x_log2 + 1) * 1233) >> 12;
531 x_log10 -= x_scaled < kPowersOf10[x_log10]; 531 x_log10 -= x_scaled < kPowersOf10[x_log10];
532 532
533 int y_log2 = IntegerLog2(y_scaled); 533 int y_log2 = 31 - base::bits::CountLeadingZeros32(y_scaled);
534 int y_log10 = ((y_log2 + 1) * 1233) >> 12; 534 int y_log10 = ((y_log2 + 1) * 1233) >> 12;
535 y_log10 -= y_scaled < kPowersOf10[y_log10]; 535 y_log10 -= y_scaled < kPowersOf10[y_log10];
536 536
537 int tie = EQUAL; 537 int tie = EQUAL;
538 538
539 if (x_log10 < y_log10) { 539 if (x_log10 < y_log10) {
540 // X has fewer digits. We would like to simply scale up X but that 540 // X has fewer digits. We would like to simply scale up X but that
541 // might overflow, e.g when comparing 9 with 1_000_000_000, 9 would 541 // might overflow, e.g when comparing 9 with 1_000_000_000, 9 would
542 // be scaled up to 9_000_000_000. So we scale up by the next 542 // be scaled up to 9_000_000_000. So we scale up by the next
543 // smallest power and scale down Y to drop one digit. It is OK to 543 // smallest power and scale down Y to drop one digit. It is OK to
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 589
590 RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) { 590 RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) {
591 SealHandleScope shs(isolate); 591 SealHandleScope shs(isolate);
592 DCHECK(args.length() == 1); 592 DCHECK(args.length() == 1);
593 CONVERT_ARG_CHECKED(Object, obj, 0); 593 CONVERT_ARG_CHECKED(Object, obj, 0);
594 return isolate->heap()->ToBoolean(obj->IsSmi() && 594 return isolate->heap()->ToBoolean(obj->IsSmi() &&
595 Smi::cast(obj)->value() >= 0); 595 Smi::cast(obj)->value() >= 0);
596 } 596 }
597 } 597 }
598 } // namespace v8::internal 598 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/misc-intrinsics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698