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/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.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/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 isolate(), | 910 isolate(), |
911 isolate()->heap()->AllocateExternalArray(length, | 911 isolate()->heap()->AllocateExternalArray(length, |
912 array_type, | 912 array_type, |
913 external_pointer, | 913 external_pointer, |
914 pretenure), | 914 pretenure), |
915 ExternalArray); | 915 ExternalArray); |
916 } | 916 } |
917 | 917 |
918 | 918 |
919 Handle<FixedTypedArrayBase> Factory::NewFixedTypedArray( | 919 Handle<FixedTypedArrayBase> Factory::NewFixedTypedArray( |
920 int length, | 920 int length, ExternalArrayType array_type, bool initialize, |
921 ExternalArrayType array_type, | |
922 PretenureFlag pretenure) { | 921 PretenureFlag pretenure) { |
923 DCHECK(0 <= length && length <= Smi::kMaxValue); | 922 DCHECK(0 <= length && length <= Smi::kMaxValue); |
924 CALL_HEAP_FUNCTION( | 923 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateFixedTypedArray( |
925 isolate(), | 924 length, array_type, initialize, pretenure), |
926 isolate()->heap()->AllocateFixedTypedArray(length, | 925 FixedTypedArrayBase); |
927 array_type, | |
928 pretenure), | |
929 FixedTypedArrayBase); | |
930 } | 926 } |
931 | 927 |
932 | 928 |
933 Handle<Cell> Factory::NewCell(Handle<Object> value) { | 929 Handle<Cell> Factory::NewCell(Handle<Object> value) { |
934 AllowDeferredHandleDereference convert_to_cell; | 930 AllowDeferredHandleDereference convert_to_cell; |
935 CALL_HEAP_FUNCTION( | 931 CALL_HEAP_FUNCTION( |
936 isolate(), | 932 isolate(), |
937 isolate()->heap()->AllocateCell(*value), | 933 isolate()->heap()->AllocateCell(*value), |
938 Cell); | 934 Cell); |
939 } | 935 } |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 obj->set_byte_length(*byte_length_object); | 1951 obj->set_byte_length(*byte_length_object); |
1956 Handle<Object> length_object = NewNumberFromSize(number_of_elements); | 1952 Handle<Object> length_object = NewNumberFromSize(number_of_elements); |
1957 obj->set_length(*length_object); | 1953 obj->set_length(*length_object); |
1958 | 1954 |
1959 Handle<JSArrayBuffer> buffer = isolate()->factory()->NewJSArrayBuffer(); | 1955 Handle<JSArrayBuffer> buffer = isolate()->factory()->NewJSArrayBuffer(); |
1960 Runtime::SetupArrayBuffer(isolate(), buffer, true, NULL, byte_length, | 1956 Runtime::SetupArrayBuffer(isolate(), buffer, true, NULL, byte_length, |
1961 SharedFlag::kNotShared); | 1957 SharedFlag::kNotShared); |
1962 obj->set_buffer(*buffer); | 1958 obj->set_buffer(*buffer); |
1963 Handle<FixedTypedArrayBase> elements = | 1959 Handle<FixedTypedArrayBase> elements = |
1964 isolate()->factory()->NewFixedTypedArray( | 1960 isolate()->factory()->NewFixedTypedArray( |
1965 static_cast<int>(number_of_elements), array_type); | 1961 static_cast<int>(number_of_elements), array_type, true); |
1966 obj->set_elements(*elements); | 1962 obj->set_elements(*elements); |
1967 return obj; | 1963 return obj; |
1968 } | 1964 } |
1969 | 1965 |
1970 | 1966 |
1971 Handle<JSDataView> Factory::NewJSDataView(Handle<JSArrayBuffer> buffer, | 1967 Handle<JSDataView> Factory::NewJSDataView(Handle<JSArrayBuffer> buffer, |
1972 size_t byte_offset, | 1968 size_t byte_offset, |
1973 size_t byte_length) { | 1969 size_t byte_length) { |
1974 Handle<JSDataView> obj = NewJSDataView(); | 1970 Handle<JSDataView> obj = NewJSDataView(); |
1975 SetupArrayBufferView(isolate(), obj, buffer, byte_offset, byte_length); | 1971 SetupArrayBufferView(isolate(), obj, buffer, byte_offset, byte_length); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 return Handle<Object>::null(); | 2460 return Handle<Object>::null(); |
2465 } | 2461 } |
2466 | 2462 |
2467 | 2463 |
2468 Handle<Object> Factory::ToBoolean(bool value) { | 2464 Handle<Object> Factory::ToBoolean(bool value) { |
2469 return value ? true_value() : false_value(); | 2465 return value ? true_value() : false_value(); |
2470 } | 2466 } |
2471 | 2467 |
2472 | 2468 |
2473 } } // namespace v8::internal | 2469 } } // namespace v8::internal |
OLD | NEW |