Reviewers: alph, Benedikt Meurer,

Message:
Here is the assembler code for the function without and with volatile:

=> 0x085647e0 <+0>:    sub    $0x2c,%esp
   0x085647e3 <+3>:       lea    0x18(%esp),%eax
   0x085647e7 <+7>:       movl   $0x0,0x4(%esp)
   0x085647ef <+15>:      mov    %eax,(%esp)
   0x085647f2 <+18>:      call   0x804a0d0 <gettimeofday@plt>
   0x085647f7 <+23>:      test   %eax,%eax
   0x085647f9 <+25>:      js     0x8564818
<_ZN2v88internal2OS17TimeCurrentMillisEv+56>
   0x085647fb <+27>:      fildl  0x18(%esp)
   0x085647ff <+31>:      flds   0x8ebb0d4
   0x08564805 <+37>:      fmul   %st,%st(1)
   0x08564807 <+39>:      fildl  0x1c(%esp)
   0x0856480b <+43>:      add    $0x2c,%esp
   0x0856480e <+46>:      fdivp  %st,%st(1)
   0x08564810 <+48>:      faddp  %st,%st(1)
   0x08564812 <+50>:      ret
   0x08564813 <+51>:      nop
   0x08564814 <+52>:      lea    0x0(%esi,%eiz,1),%esi
   0x08564818 <+56>:      fldz
   0x0856481a <+58>:      add    $0x2c,%esp
   0x0856481d <+61>:      ret


=> 0x085647e0 <+0>:    sub    $0x2c,%esp
   0x085647e3 <+3>:       lea    0x18(%esp),%eax
   0x085647e7 <+7>:       movl   $0x0,0x4(%esp)
   0x085647ef <+15>:      mov    %eax,(%esp)
   0x085647f2 <+18>:      call   0x804a0d0 <gettimeofday@plt>
   0x085647f7 <+23>:      test   %eax,%eax
   0x085647f9 <+25>:      js     0x8564820
<_ZN2v88internal2OS17TimeCurrentMillisEv+64>
   0x085647fb <+27>:      fildl  0x18(%esp)
   0x085647ff <+31>:      flds   0x8ebb0d4
   0x08564805 <+37>:      fmul   %st,%st(1)
   0x08564807 <+39>:      fildl  0x1c(%esp)
   0x0856480b <+43>:      fdivp  %st,%st(1)
   0x0856480d <+45>:      faddp  %st,%st(1)
   0x0856480f <+47>:      fstpl  0x10(%esp)
   0x08564813 <+51>:      fldl   0x10(%esp)
   0x08564817 <+55>:      add    $0x2c,%esp
   0x0856481a <+58>:      ret
   0x0856481b <+59>:      nop
   0x0856481c <+60>:      lea    0x0(%esi,%eiz,1),%esi
   0x08564820 <+64>:      fldz
   0x08564822 <+66>:      add    $0x2c,%esp
   0x08564825 <+69>:      ret


Description:
OS::TimeCurrentMillis should return double not long double

Make sure the value returned from OS::TimeCurrentMillis is cast to double (not
long double). I also tried assigning the result of the expression to double
variable and doing static_cast<double> but those are not enough on gcc. Not sure if we want this patch. I'm going to change profiler code to return microseconds
as int64_t anyways.

BUG=v8:2824

Please review this at https://codereview.chromium.org/21848004/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/platform-posix.cc


Index: src/platform-posix.cc
diff --git a/src/platform-posix.cc b/src/platform-posix.cc
index 13b819bd1e79c1452979961fd082c2af73171e56..758e09d7a51bf3618e52fb3ea4856f138afaff58 100644
--- a/src/platform-posix.cc
+++ b/src/platform-posix.cc
@@ -320,8 +320,10 @@ int OS::GetUserTime(uint32_t* secs,  uint32_t* usecs) {
 double OS::TimeCurrentMillis() {
   struct timeval tv;
   if (gettimeofday(&tv, NULL) < 0) return 0.0;
-  return (static_cast<double>(tv.tv_sec) * 1000) +
-         (static_cast<double>(tv.tv_usec) / 1000);
+  volatile double result =
+      (static_cast<double>(tv.tv_sec) * 1000) +
+      (static_cast<double>(tv.tv_usec) / 1000);
+  return result;
 }




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to