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/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray( | 1087 Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray( |
1088 Handle<FixedDoubleArray> array) { | 1088 Handle<FixedDoubleArray> array) { |
1089 CALL_HEAP_FUNCTION(isolate(), | 1089 CALL_HEAP_FUNCTION(isolate(), |
1090 isolate()->heap()->CopyFixedDoubleArray(*array), | 1090 isolate()->heap()->CopyFixedDoubleArray(*array), |
1091 FixedDoubleArray); | 1091 FixedDoubleArray); |
1092 } | 1092 } |
1093 | 1093 |
1094 | 1094 |
1095 Handle<Object> Factory::NewNumber(double value, | 1095 Handle<Object> Factory::NewNumber(double value, |
1096 PretenureFlag pretenure) { | 1096 PretenureFlag pretenure) { |
1097 // We need to distinguish the minus zero value and this cannot be | 1097 // Materialize as a SMI if possible |
1098 // done after conversion to int. Doing this by comparing bit | 1098 int32_t int_value; |
1099 // patterns is faster than using fpclassify() et al. | 1099 if (DoubleToSmiInteger(value, &int_value)) { |
1100 if (IsMinusZero(value)) return NewHeapNumber(-0.0, IMMUTABLE, pretenure); | |
1101 | |
1102 int int_value = FastD2IChecked(value); | |
1103 if (value == int_value && Smi::IsValid(int_value)) { | |
1104 return handle(Smi::FromInt(int_value), isolate()); | 1100 return handle(Smi::FromInt(int_value), isolate()); |
1105 } | 1101 } |
1106 | 1102 |
1107 // Materialize the value in the heap. | 1103 // Materialize the value in the heap. |
1108 return NewHeapNumber(value, IMMUTABLE, pretenure); | 1104 return NewHeapNumber(value, IMMUTABLE, pretenure); |
1109 } | 1105 } |
1110 | 1106 |
1111 | 1107 |
1112 Handle<Object> Factory::NewNumberFromInt(int32_t value, | 1108 Handle<Object> Factory::NewNumberFromInt(int32_t value, |
1113 PretenureFlag pretenure) { | 1109 PretenureFlag pretenure) { |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2506 Handle<AccessorInfo> prototype = | 2502 Handle<AccessorInfo> prototype = |
2507 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2503 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2508 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2504 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2509 prototype, attribs); | 2505 prototype, attribs); |
2510 map->AppendDescriptor(&d); | 2506 map->AppendDescriptor(&d); |
2511 } | 2507 } |
2512 } | 2508 } |
2513 | 2509 |
2514 } // namespace internal | 2510 } // namespace internal |
2515 } // namespace v8 | 2511 } // namespace v8 |
OLD | NEW |