| 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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/base/utils/random-number-generator.h" | 9 #include "src/base/utils/random-number-generator.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 JSArrayBuffer::Setup(buffer, isolate, is_external, *data, byte_length, | 1804 JSArrayBuffer::Setup(buffer, isolate, is_external, *data, byte_length, |
| 1805 SharedFlag::kNotShared); | 1805 SharedFlag::kNotShared); |
| 1806 return isolate->factory()->NewJSTypedArray(type, buffer, 0, num_elements, | 1806 return isolate->factory()->NewJSTypedArray(type, buffer, 0, num_elements, |
| 1807 TENURED); | 1807 TENURED); |
| 1808 } | 1808 } |
| 1809 | 1809 |
| 1810 | 1810 |
| 1811 bool Genesis::InitializeBuiltinTypedArrays() { | 1811 bool Genesis::InitializeBuiltinTypedArrays() { |
| 1812 HandleScope scope(isolate()); | 1812 HandleScope scope(isolate()); |
| 1813 Handle<JSTypedArray> rng_state; | 1813 Handle<JSTypedArray> rng_state; |
| 1814 Handle<JSTypedArray> math_constants; | |
| 1815 Handle<JSTypedArray> rempio2result; | 1814 Handle<JSTypedArray> rempio2result; |
| 1816 | 1815 |
| 1817 { | 1816 { |
| 1818 // Seed the per-context RNG using the per-isolate RNG. | 1817 // Seed the per-context RNG using the per-isolate RNG. |
| 1819 const size_t num_elements = 2; | 1818 const size_t num_elements = 2; |
| 1820 const size_t num_bytes = num_elements * sizeof(uint32_t); | 1819 const size_t num_bytes = num_elements * sizeof(uint32_t); |
| 1821 uint32_t* state = NULL; | 1820 uint32_t* state = NULL; |
| 1822 rng_state = | 1821 rng_state = |
| 1823 CreateTypedArray(isolate(), kExternalUint32Array, num_elements, &state); | 1822 CreateTypedArray(isolate(), kExternalUint32Array, num_elements, &state); |
| 1824 do { | 1823 do { |
| 1825 isolate()->random_number_generator()->NextBytes(state, num_bytes); | 1824 isolate()->random_number_generator()->NextBytes(state, num_bytes); |
| 1826 } while (state[0] == 0 || state[1] == 0); | 1825 } while (state[0] == 0 || state[1] == 0); |
| 1827 } | 1826 } |
| 1828 | 1827 |
| 1829 { // Initialize trigonometric lookup tables and constants. | |
| 1830 const size_t num_elements = arraysize(fdlibm::MathConstants::constants); | |
| 1831 double* constants = const_cast<double*>(fdlibm::MathConstants::constants); | |
| 1832 math_constants = CreateTypedArray(isolate(), kExternalFloat64Array, | |
| 1833 num_elements, &constants); | |
| 1834 } | |
| 1835 | |
| 1836 { // Initialize a result array for rempio2 calculation | 1828 { // Initialize a result array for rempio2 calculation |
| 1837 const size_t num_elements = 2; | 1829 const size_t num_elements = 2; |
| 1838 double* data = NULL; | 1830 double* data = NULL; |
| 1839 rempio2result = | 1831 rempio2result = |
| 1840 CreateTypedArray(isolate(), kExternalFloat64Array, num_elements, &data); | 1832 CreateTypedArray(isolate(), kExternalFloat64Array, num_elements, &data); |
| 1841 for (size_t i = 0; i < num_elements; i++) data[i] = 0; | 1833 for (size_t i = 0; i < num_elements; i++) data[i] = 0; |
| 1842 } | 1834 } |
| 1843 | 1835 |
| 1844 Handle<JSObject> utils = | 1836 Handle<JSObject> utils = |
| 1845 Handle<JSObject>::cast(isolate()->natives_utils_object()); | 1837 Handle<JSObject>::cast(isolate()->natives_utils_object()); |
| 1846 Handle<String> name_string = isolate()->factory()->NewStringFromAsciiChecked( | 1838 Handle<String> name_string = isolate()->factory()->NewStringFromAsciiChecked( |
| 1847 "InitializeBuiltinTypedArrays"); | 1839 "InitializeBuiltinTypedArrays"); |
| 1848 Handle<Object> fun = JSObject::GetDataProperty(utils, name_string); | 1840 Handle<Object> fun = JSObject::GetDataProperty(utils, name_string); |
| 1849 Handle<Object> receiver = isolate()->factory()->undefined_value(); | 1841 Handle<Object> receiver = isolate()->factory()->undefined_value(); |
| 1850 Handle<Object> args[] = {utils, rng_state, math_constants, rempio2result}; | 1842 Handle<Object> args[] = {utils, rng_state, rempio2result}; |
| 1851 return !Execution::Call(isolate(), fun, receiver, arraysize(args), args) | 1843 return !Execution::Call(isolate(), fun, receiver, arraysize(args), args) |
| 1852 .is_null(); | 1844 .is_null(); |
| 1853 } | 1845 } |
| 1854 | 1846 |
| 1855 | 1847 |
| 1856 void Genesis::ConfigureUtilsObject(ContextType context_type) { | 1848 void Genesis::ConfigureUtilsObject(ContextType context_type) { |
| 1857 switch (context_type) { | 1849 switch (context_type) { |
| 1858 // We still need the utils object to find debug functions. | 1850 // We still need the utils object to find debug functions. |
| 1859 case DEBUG_CONTEXT: | 1851 case DEBUG_CONTEXT: |
| 1860 return; | 1852 return; |
| (...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3326 } | 3318 } |
| 3327 | 3319 |
| 3328 | 3320 |
| 3329 // Called when the top-level V8 mutex is destroyed. | 3321 // Called when the top-level V8 mutex is destroyed. |
| 3330 void Bootstrapper::FreeThreadResources() { | 3322 void Bootstrapper::FreeThreadResources() { |
| 3331 DCHECK(!IsActive()); | 3323 DCHECK(!IsActive()); |
| 3332 } | 3324 } |
| 3333 | 3325 |
| 3334 } // namespace internal | 3326 } // namespace internal |
| 3335 } // namespace v8 | 3327 } // namespace v8 |
| OLD | NEW |