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

Side by Side Diff: src/runtime.cc

Issue 178583006: Introduce intrinsics for double values in Javascript. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 7652 matching lines...) Expand 10 before | Expand all | Expand 10 after
7663 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \ 7663 return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \
7664 } 7664 }
7665 7665
7666 RUNTIME_UNARY_MATH(acos) 7666 RUNTIME_UNARY_MATH(acos)
7667 RUNTIME_UNARY_MATH(asin) 7667 RUNTIME_UNARY_MATH(asin)
7668 RUNTIME_UNARY_MATH(atan) 7668 RUNTIME_UNARY_MATH(atan)
7669 RUNTIME_UNARY_MATH(log) 7669 RUNTIME_UNARY_MATH(log)
7670 #undef RUNTIME_UNARY_MATH 7670 #undef RUNTIME_UNARY_MATH
7671 7671
7672 7672
7673 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) {
7674 SealHandleScope shs(isolate);
7675 ASSERT(args.length() == 1);
7676 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7677 return isolate->heap()->NumberFromDouble(
7678 static_cast<int32_t>(double_to_uint64(x) >> 32));
7679 }
7680
7681
7682 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) {
7683 SealHandleScope shs(isolate);
7684 ASSERT(args.length() == 1);
7685 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7686 return isolate->heap()->NumberFromDouble(
7687 static_cast<int32_t>(double_to_uint64(x) & 0xffffffff));
Sven Panne 2014/03/03 11:28:27 Add an unsigned suffix 'u' to the hexadecimal cons
7688 }
7689
7690
7691 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) {
7692 SealHandleScope shs(isolate);
7693 ASSERT(args.length() == 2);
7694 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]);
7695 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]);
7696 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo;
7697 return isolate->heap()->AllocateHeapNumber(uint64_to_double(result));
7698 }
7699
7700
7673 // Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm 7701 // Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm
7674 // Using initial approximation adapted from Kahan's cbrt and 4 iterations 7702 // Using initial approximation adapted from Kahan's cbrt and 4 iterations
7675 // of Newton's method. 7703 // of Newton's method.
7676 inline double CubeRootNewtonIteration(double approx, double x) { 7704 inline double CubeRootNewtonIteration(double approx, double x) {
7677 return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); 7705 return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx);
7678 } 7706 }
7679 7707
7680 7708
7681 inline double CubeRoot(double x) { 7709 inline double CubeRoot(double x) {
7682 static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000); 7710 static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000);
(...skipping 7282 matching lines...) Expand 10 before | Expand all | Expand 10 after
14965 // Handle last resort GC and make sure to allow future allocations 14993 // Handle last resort GC and make sure to allow future allocations
14966 // to grow the heap without causing GCs (if possible). 14994 // to grow the heap without causing GCs (if possible).
14967 isolate->counters()->gc_last_resort_from_js()->Increment(); 14995 isolate->counters()->gc_last_resort_from_js()->Increment();
14968 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14996 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14969 "Runtime::PerformGC"); 14997 "Runtime::PerformGC");
14970 } 14998 }
14971 } 14999 }
14972 15000
14973 15001
14974 } } // namespace v8::internal 15002 } } // namespace v8::internal
OLDNEW
« src/full-codegen.cc ('K') | « src/runtime.h ('k') | test/mjsunit/double-intrinsics.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698