~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to src/math.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2006-2008 the V8 project authors. All rights reserved.
 
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
4
4
// met:
119
119
// ECMA 262 - 15.8.2.11
120
120
function MathMax(arg1, arg2) {  // length == 2
121
121
  var length = %_ArgumentsLength();
 
122
  if (length == 2) {
 
123
    if (!IS_NUMBER(arg1)) arg1 = NonNumberToNumber(arg1);
 
124
    if (!IS_NUMBER(arg2)) arg2 = NonNumberToNumber(arg2);
 
125
    if (arg2 > arg1) return arg2;
 
126
    if (arg1 > arg2) return arg1;
 
127
    if (arg1 == arg2) {
 
128
      // Make sure -0 is considered less than +0.  -0 is never a Smi, +0 can be
 
129
      // a Smi or a heap number.
 
130
      return (arg1 == 0 && !%_IsSmi(arg1) && 1 / arg1 < 0) ? arg2 : arg1;
 
131
    }
 
132
    // All comparisons failed, one of the arguments must be NaN.
 
133
    return 0/0;  // Compiler constant-folds this to NaN.
 
134
  }
122
135
  if (length == 0) {
123
136
    return -1/0;  // Compiler constant-folds this to -Infinity.
124
137
  }
131
144
    if (NUMBER_IS_NAN(n)) return n;
132
145
    // Make sure +0 is considered greater than -0.  -0 is never a Smi, +0 can be
133
146
    // a Smi or heap number.
134
 
    if (n > r || (r === 0 && n === 0 && !%_IsSmi(r) && 1 / r < 0)) r = n;
 
147
    if (n > r || (r == 0 && n == 0 && !%_IsSmi(r) && 1 / r < 0)) r = n;
135
148
  }
136
149
  return r;
137
150
}
139
152
// ECMA 262 - 15.8.2.12
140
153
function MathMin(arg1, arg2) {  // length == 2
141
154
  var length = %_ArgumentsLength();
 
155
  if (length == 2) {
 
156
    if (!IS_NUMBER(arg1)) arg1 = NonNumberToNumber(arg1);
 
157
    if (!IS_NUMBER(arg2)) arg2 = NonNumberToNumber(arg2);
 
158
    if (arg2 > arg1) return arg1;
 
159
    if (arg1 > arg2) return arg2;
 
160
    if (arg1 == arg2) {
 
161
      // Make sure -0 is considered less than +0.  -0 is never a Smi, +0 can be
 
162
      // a Smi or a heap number.
 
163
      return (arg1 == 0 && !%_IsSmi(arg1) && 1 / arg1 < 0) ? arg1 : arg2;
 
164
    }
 
165
    // All comparisons failed, one of the arguments must be NaN.
 
166
    return 0/0;  // Compiler constant-folds this to NaN.
 
167
  }
142
168
  if (length == 0) {
143
169
    return 1/0;  // Compiler constant-folds this to Infinity.
144
170
  }
149
175
    var n = %_Arguments(i);
150
176
    if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
151
177
    if (NUMBER_IS_NAN(n)) return n;
152
 
    // Make sure -0 is considered less than +0.  -0 is never a Smi, +0 can b a
 
178
    // Make sure -0 is considered less than +0.  -0 is never a Smi, +0 can be a
153
179
    // Smi or a heap number.
154
 
    if (n < r || (r === 0 && n === 0 && !%_IsSmi(n) && 1 / n < 0)) r = n;
 
180
    if (n < r || (r == 0 && n == 0 && !%_IsSmi(n) && 1 / n < 0)) r = n;
155
181
  }
156
182
  return r;
157
183
}