OLD | NEW |
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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 double value = HeapNumber::cast(obj)->value(); | 201 double value = HeapNumber::cast(obj)->value(); |
202 int int_value = FastD2I(value); | 202 int int_value = FastD2I(value); |
203 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 203 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
204 return Smi::FromInt(int_value); | 204 return Smi::FromInt(int_value); |
205 } | 205 } |
206 } | 206 } |
207 return isolate->heap()->nan_value(); | 207 return isolate->heap()->nan_value(); |
208 } | 208 } |
209 | 209 |
210 | 210 |
211 RUNTIME_FUNCTION(Runtime_NumberImul) { | |
212 HandleScope scope(isolate); | |
213 DCHECK(args.length() == 2); | |
214 | |
215 // We rely on implementation-defined behavior below, but at least not on | |
216 // undefined behavior. | |
217 CONVERT_NUMBER_CHECKED(uint32_t, x, Int32, args[0]); | |
218 CONVERT_NUMBER_CHECKED(uint32_t, y, Int32, args[1]); | |
219 int32_t product = static_cast<int32_t>(x * y); | |
220 return *isolate->factory()->NewNumberFromInt(product); | |
221 } | |
222 | |
223 | |
224 // Compare two Smis as if they were converted to strings and then | 211 // Compare two Smis as if they were converted to strings and then |
225 // compared lexicographically. | 212 // compared lexicographically. |
226 RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) { | 213 RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) { |
227 SealHandleScope shs(isolate); | 214 SealHandleScope shs(isolate); |
228 DCHECK(args.length() == 2); | 215 DCHECK(args.length() == 2); |
229 CONVERT_SMI_ARG_CHECKED(x_value, 0); | 216 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
230 CONVERT_SMI_ARG_CHECKED(y_value, 1); | 217 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
231 | 218 |
232 // If the integers are equal so are the string representations. | 219 // If the integers are equal so are the string representations. |
233 if (x_value == y_value) return Smi::FromInt(EQUAL); | 220 if (x_value == y_value) return Smi::FromInt(EQUAL); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 315 |
329 RUNTIME_FUNCTION(Runtime_GetHoleNaNLower) { | 316 RUNTIME_FUNCTION(Runtime_GetHoleNaNLower) { |
330 HandleScope scope(isolate); | 317 HandleScope scope(isolate); |
331 DCHECK(args.length() == 0); | 318 DCHECK(args.length() == 0); |
332 return *isolate->factory()->NewNumberFromUint(kHoleNanLower32); | 319 return *isolate->factory()->NewNumberFromUint(kHoleNanLower32); |
333 } | 320 } |
334 | 321 |
335 | 322 |
336 } // namespace internal | 323 } // namespace internal |
337 } // namespace v8 | 324 } // namespace v8 |
OLD | NEW |