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/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 } | 1599 } |
1600 | 1600 |
1601 { // -- A r r a y B u f f e r | 1601 { // -- A r r a y B u f f e r |
1602 Handle<JSFunction> array_buffer_fun = | 1602 Handle<JSFunction> array_buffer_fun = |
1603 InstallArrayBuffer(global, "ArrayBuffer"); | 1603 InstallArrayBuffer(global, "ArrayBuffer"); |
1604 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, | 1604 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, |
1605 Context::ARRAY_BUFFER_FUN_INDEX); | 1605 Context::ARRAY_BUFFER_FUN_INDEX); |
1606 } | 1606 } |
1607 | 1607 |
1608 { // -- T y p e d A r r a y s | 1608 { // -- T y p e d A r r a y s |
1609 // Create the %TypedArrayPrototype% | |
1610 Handle<JSObject> typed_array_prototype = | |
1611 factory->NewJSObject(isolate->object_function(), TENURED); | |
1612 native_context()->set_typed_array_prototype(*typed_array_prototype); | |
1613 | |
1614 Handle<JSFunction> typed_array_fun = CreateFunction( | |
1615 isolate, factory->InternalizeUtf8String("TypedArray"), JS_OBJECT_TYPE, | |
1616 JSObject::kHeaderSize, typed_array_prototype, Builtins::kIllegal); | |
1617 InstallWithIntrinsicDefaultProto(isolate, typed_array_fun, | |
1618 Context::TYPED_ARRAY_FUN_INDEX); | |
1619 | |
1620 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ | 1609 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
1621 { \ | 1610 { \ |
1622 Handle<JSFunction> fun; \ | 1611 Handle<JSFunction> fun; \ |
1623 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun); \ | 1612 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun); \ |
1624 InstallWithIntrinsicDefaultProto(isolate, fun, \ | 1613 InstallWithIntrinsicDefaultProto(isolate, fun, \ |
1625 Context::TYPE##_ARRAY_FUN_INDEX); \ | 1614 Context::TYPE##_ARRAY_FUN_INDEX); \ |
1626 } | 1615 } |
1627 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) | 1616 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) |
1628 #undef INSTALL_TYPED_ARRAY | 1617 #undef INSTALL_TYPED_ARRAY |
1629 | 1618 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); | 1921 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); |
1933 native_context()->set_call_as_constructor_delegate(*delegate); | 1922 native_context()->set_call_as_constructor_delegate(*delegate); |
1934 delegate->shared()->DontAdaptArguments(); | 1923 delegate->shared()->DontAdaptArguments(); |
1935 } | 1924 } |
1936 } // NOLINT(readability/fn_size) | 1925 } // NOLINT(readability/fn_size) |
1937 | 1926 |
1938 | 1927 |
1939 void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind, | 1928 void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind, |
1940 Handle<JSFunction>* fun) { | 1929 Handle<JSFunction>* fun) { |
1941 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1930 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
1942 | 1931 Handle<JSFunction> result = InstallFunction( |
1943 Handle<JSObject> typed_array_prototype = | 1932 global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, |
1944 Handle<JSObject>(isolate()->typed_array_prototype()); | 1933 isolate()->initial_object_prototype(), Builtins::kIllegal); |
1945 Handle<JSFunction> typed_array_function = | |
1946 Handle<JSFunction>(isolate()->typed_array_function()); | |
1947 | |
1948 Handle<JSObject> prototype = | |
1949 factory()->NewJSObject(isolate()->object_function(), TENURED); | |
1950 Handle<JSFunction> result = | |
1951 InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, | |
1952 prototype, Builtins::kIllegal); | |
1953 | 1934 |
1954 Handle<Map> initial_map = isolate()->factory()->NewMap( | 1935 Handle<Map> initial_map = isolate()->factory()->NewMap( |
1955 JS_TYPED_ARRAY_TYPE, | 1936 JS_TYPED_ARRAY_TYPE, |
1956 JSTypedArray::kSizeWithInternalFields, | 1937 JSTypedArray::kSizeWithInternalFields, |
1957 elements_kind); | 1938 elements_kind); |
1958 JSFunction::SetInitialMap(result, initial_map, | 1939 JSFunction::SetInitialMap(result, initial_map, |
1959 handle(initial_map->prototype(), isolate())); | 1940 handle(initial_map->prototype(), isolate())); |
1960 | |
1961 CHECK(JSObject::SetPrototype(result, typed_array_function, false, | |
1962 Object::DONT_THROW) | |
1963 .FromJust()); | |
1964 | |
1965 CHECK(JSObject::SetPrototype(prototype, typed_array_prototype, false, | |
1966 Object::DONT_THROW) | |
1967 .FromJust()); | |
1968 | |
1969 *fun = result; | 1941 *fun = result; |
1970 } | 1942 } |
1971 | 1943 |
1972 | 1944 |
1973 void Genesis::InitializeExperimentalGlobal() { | 1945 void Genesis::InitializeExperimentalGlobal() { |
1974 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); | 1946 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); |
1975 | 1947 |
1976 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) | 1948 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) |
1977 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) | 1949 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) |
1978 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) | 1950 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) |
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3728 } | 3700 } |
3729 | 3701 |
3730 | 3702 |
3731 // Called when the top-level V8 mutex is destroyed. | 3703 // Called when the top-level V8 mutex is destroyed. |
3732 void Bootstrapper::FreeThreadResources() { | 3704 void Bootstrapper::FreeThreadResources() { |
3733 DCHECK(!IsActive()); | 3705 DCHECK(!IsActive()); |
3734 } | 3706 } |
3735 | 3707 |
3736 } // namespace internal | 3708 } // namespace internal |
3737 } // namespace v8 | 3709 } // namespace v8 |
OLD | NEW |