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 #ifndef V8_FACTORY_H_ | 5 #ifndef V8_FACTORY_H_ |
6 #define V8_FACTORY_H_ | 6 #define V8_FACTORY_H_ |
7 | 7 |
8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/type-feedback-vector.h" | 10 #include "src/type-feedback-vector.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 Handle<Object> NewNumberFromSize(size_t value, | 365 Handle<Object> NewNumberFromSize(size_t value, |
366 PretenureFlag pretenure = NOT_TENURED) { | 366 PretenureFlag pretenure = NOT_TENURED) { |
367 // We can't use Smi::IsValid() here because that operates on a signed | 367 // We can't use Smi::IsValid() here because that operates on a signed |
368 // intptr_t, and casting from size_t could create a bogus sign bit. | 368 // intptr_t, and casting from size_t could create a bogus sign bit. |
369 if (value <= static_cast<size_t>(Smi::kMaxValue)) { | 369 if (value <= static_cast<size_t>(Smi::kMaxValue)) { |
370 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)), | 370 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)), |
371 isolate()); | 371 isolate()); |
372 } | 372 } |
373 return NewNumber(static_cast<double>(value), pretenure); | 373 return NewNumber(static_cast<double>(value), pretenure); |
374 } | 374 } |
| 375 Handle<Object> NewNumberFromInt64(int64_t value, |
| 376 PretenureFlag pretenure = NOT_TENURED) { |
| 377 if (value <= std::numeric_limits<int32_t>::max() && |
| 378 value >= std::numeric_limits<int32_t>::min() && |
| 379 Smi::IsValid(static_cast<int32_t>(value))) { |
| 380 return Handle<Object>(Smi::FromInt(static_cast<int32_t>(value)), |
| 381 isolate()); |
| 382 } |
| 383 return NewNumber(static_cast<double>(value), pretenure); |
| 384 } |
375 Handle<HeapNumber> NewHeapNumber(double value, | 385 Handle<HeapNumber> NewHeapNumber(double value, |
376 MutableMode mode = IMMUTABLE, | 386 MutableMode mode = IMMUTABLE, |
377 PretenureFlag pretenure = NOT_TENURED); | 387 PretenureFlag pretenure = NOT_TENURED); |
378 | 388 |
379 #define SIMD128_NEW_DECL(TYPE, Type, type, lane_count, lane_type) \ | 389 #define SIMD128_NEW_DECL(TYPE, Type, type, lane_count, lane_type) \ |
380 Handle<Type> New##Type(lane_type lanes[lane_count], \ | 390 Handle<Type> New##Type(lane_type lanes[lane_count], \ |
381 PretenureFlag pretenure = NOT_TENURED); | 391 PretenureFlag pretenure = NOT_TENURED); |
382 SIMD128_TYPES(SIMD128_NEW_DECL) | 392 SIMD128_TYPES(SIMD128_NEW_DECL) |
383 #undef SIMD128_NEW_DECL | 393 #undef SIMD128_NEW_DECL |
384 | 394 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 726 |
717 // Create a JSArray with no elements and no length. | 727 // Create a JSArray with no elements and no length. |
718 Handle<JSArray> NewJSArray(ElementsKind elements_kind, | 728 Handle<JSArray> NewJSArray(ElementsKind elements_kind, |
719 PretenureFlag pretenure = NOT_TENURED); | 729 PretenureFlag pretenure = NOT_TENURED); |
720 }; | 730 }; |
721 | 731 |
722 } // namespace internal | 732 } // namespace internal |
723 } // namespace v8 | 733 } // namespace v8 |
724 | 734 |
725 #endif // V8_FACTORY_H_ | 735 #endif // V8_FACTORY_H_ |
OLD | NEW |