| 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 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 JSFunction::EnsureHasInitialMap(function); | 1710 JSFunction::EnsureHasInitialMap(function); |
| 1711 Handle<Map> map(function->initial_map()); | 1711 Handle<Map> map(function->initial_map()); |
| 1712 DCHECK(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); | 1712 DCHECK(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); |
| 1713 CALL_HEAP_FUNCTION( | 1713 CALL_HEAP_FUNCTION( |
| 1714 isolate(), | 1714 isolate(), |
| 1715 isolate()->heap()->AllocateJSObjectFromMap(*map), | 1715 isolate()->heap()->AllocateJSObjectFromMap(*map), |
| 1716 JSGeneratorObject); | 1716 JSGeneratorObject); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 | 1719 |
| 1720 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared) { | 1720 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { |
| 1721 Handle<JSFunction> array_buffer_fun( | 1721 Handle<JSFunction> array_buffer_fun( |
| 1722 shared == SharedFlag::kShared | 1722 isolate()->native_context()->array_buffer_fun()); |
| 1723 ? isolate()->native_context()->shared_array_buffer_fun() | |
| 1724 : isolate()->native_context()->array_buffer_fun()); | |
| 1725 CALL_HEAP_FUNCTION( | 1723 CALL_HEAP_FUNCTION( |
| 1726 isolate(), | 1724 isolate(), |
| 1727 isolate()->heap()->AllocateJSObject(*array_buffer_fun), | 1725 isolate()->heap()->AllocateJSObject(*array_buffer_fun), |
| 1728 JSArrayBuffer); | 1726 JSArrayBuffer); |
| 1729 } | 1727 } |
| 1730 | 1728 |
| 1731 | 1729 |
| 1732 Handle<JSDataView> Factory::NewJSDataView() { | 1730 Handle<JSDataView> Factory::NewJSDataView() { |
| 1733 Handle<JSFunction> data_view_fun( | 1731 Handle<JSFunction> data_view_fun( |
| 1734 isolate()->native_context()->data_view_fun()); | 1732 isolate()->native_context()->data_view_fun()); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 size_t byte_length = number_of_elements * element_size; | 1927 size_t byte_length = number_of_elements * element_size; |
| 1930 | 1928 |
| 1931 obj->set_byte_offset(Smi::FromInt(0)); | 1929 obj->set_byte_offset(Smi::FromInt(0)); |
| 1932 i::Handle<i::Object> byte_length_object = | 1930 i::Handle<i::Object> byte_length_object = |
| 1933 isolate()->factory()->NewNumberFromSize(byte_length); | 1931 isolate()->factory()->NewNumberFromSize(byte_length); |
| 1934 obj->set_byte_length(*byte_length_object); | 1932 obj->set_byte_length(*byte_length_object); |
| 1935 Handle<Object> length_object = NewNumberFromSize(number_of_elements); | 1933 Handle<Object> length_object = NewNumberFromSize(number_of_elements); |
| 1936 obj->set_length(*length_object); | 1934 obj->set_length(*length_object); |
| 1937 | 1935 |
| 1938 Handle<JSArrayBuffer> buffer = isolate()->factory()->NewJSArrayBuffer(); | 1936 Handle<JSArrayBuffer> buffer = isolate()->factory()->NewJSArrayBuffer(); |
| 1939 Runtime::SetupArrayBuffer(isolate(), buffer, true, NULL, byte_length, | 1937 Runtime::SetupArrayBuffer(isolate(), buffer, true, NULL, byte_length); |
| 1940 SharedFlag::kNotShared); | |
| 1941 obj->set_buffer(*buffer); | 1938 obj->set_buffer(*buffer); |
| 1942 Handle<FixedTypedArrayBase> elements = | 1939 Handle<FixedTypedArrayBase> elements = |
| 1943 isolate()->factory()->NewFixedTypedArray( | 1940 isolate()->factory()->NewFixedTypedArray( |
| 1944 static_cast<int>(number_of_elements), array_type); | 1941 static_cast<int>(number_of_elements), array_type); |
| 1945 obj->set_elements(*elements); | 1942 obj->set_elements(*elements); |
| 1946 return obj; | 1943 return obj; |
| 1947 } | 1944 } |
| 1948 | 1945 |
| 1949 | 1946 |
| 1950 Handle<JSDataView> Factory::NewJSDataView(Handle<JSArrayBuffer> buffer, | 1947 Handle<JSDataView> Factory::NewJSDataView(Handle<JSArrayBuffer> buffer, |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2429 return Handle<Object>::null(); | 2426 return Handle<Object>::null(); |
| 2430 } | 2427 } |
| 2431 | 2428 |
| 2432 | 2429 |
| 2433 Handle<Object> Factory::ToBoolean(bool value) { | 2430 Handle<Object> Factory::ToBoolean(bool value) { |
| 2434 return value ? true_value() : false_value(); | 2431 return value ? true_value() : false_value(); |
| 2435 } | 2432 } |
| 2436 | 2433 |
| 2437 | 2434 |
| 2438 } } // namespace v8::internal | 2435 } } // namespace v8::internal |
| OLD | NEW |