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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 Handle<Object> NewNumberFromSize(size_t value, | 373 Handle<Object> NewNumberFromSize(size_t value, |
374 PretenureFlag pretenure = NOT_TENURED) { | 374 PretenureFlag pretenure = NOT_TENURED) { |
375 // We can't use Smi::IsValid() here because that operates on a signed | 375 // We can't use Smi::IsValid() here because that operates on a signed |
376 // intptr_t, and casting from size_t could create a bogus sign bit. | 376 // intptr_t, and casting from size_t could create a bogus sign bit. |
377 if (value <= static_cast<size_t>(Smi::kMaxValue)) { | 377 if (value <= static_cast<size_t>(Smi::kMaxValue)) { |
378 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)), | 378 return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)), |
379 isolate()); | 379 isolate()); |
380 } | 380 } |
381 return NewNumber(static_cast<double>(value), pretenure); | 381 return NewNumber(static_cast<double>(value), pretenure); |
382 } | 382 } |
| 383 Handle<Object> NewNumberFromInt64(int64_t value, |
| 384 PretenureFlag pretenure = NOT_TENURED) { |
| 385 if (value <= std::numeric_limits<int32_t>::max() && |
| 386 value >= std::numeric_limits<int32_t>::min() && |
| 387 Smi::IsValid(static_cast<int32_t>(value))) { |
| 388 return Handle<Object>(Smi::FromInt(static_cast<int32_t>(value)), |
| 389 isolate()); |
| 390 } |
| 391 return NewNumber(static_cast<double>(value), pretenure); |
| 392 } |
383 Handle<HeapNumber> NewHeapNumber(double value, | 393 Handle<HeapNumber> NewHeapNumber(double value, |
384 MutableMode mode = IMMUTABLE, | 394 MutableMode mode = IMMUTABLE, |
385 PretenureFlag pretenure = NOT_TENURED); | 395 PretenureFlag pretenure = NOT_TENURED); |
386 | 396 |
387 #define SIMD128_NEW_DECL(TYPE, Type, type, lane_count, lane_type) \ | 397 #define SIMD128_NEW_DECL(TYPE, Type, type, lane_count, lane_type) \ |
388 Handle<Type> New##Type(lane_type lanes[lane_count], \ | 398 Handle<Type> New##Type(lane_type lanes[lane_count], \ |
389 PretenureFlag pretenure = NOT_TENURED); | 399 PretenureFlag pretenure = NOT_TENURED); |
390 SIMD128_TYPES(SIMD128_NEW_DECL) | 400 SIMD128_TYPES(SIMD128_NEW_DECL) |
391 #undef SIMD128_NEW_DECL | 401 #undef SIMD128_NEW_DECL |
392 | 402 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 FunctionMode function_mode); | 750 FunctionMode function_mode); |
741 | 751 |
742 void SetStrictFunctionInstanceDescriptor(Handle<Map> map, | 752 void SetStrictFunctionInstanceDescriptor(Handle<Map> map, |
743 FunctionMode function_mode); | 753 FunctionMode function_mode); |
744 }; | 754 }; |
745 | 755 |
746 } // namespace internal | 756 } // namespace internal |
747 } // namespace v8 | 757 } // namespace v8 |
748 | 758 |
749 #endif // V8_FACTORY_H_ | 759 #endif // V8_FACTORY_H_ |
OLD | NEW |