Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: src/bootstrapper.cc

Issue 1949863002: Fix TypedArray Property optimizations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 } 1598 }
1599 1599
1600 { // -- A r r a y B u f f e r 1600 { // -- A r r a y B u f f e r
1601 Handle<JSFunction> array_buffer_fun = 1601 Handle<JSFunction> array_buffer_fun =
1602 InstallArrayBuffer(global, "ArrayBuffer"); 1602 InstallArrayBuffer(global, "ArrayBuffer");
1603 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, 1603 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun,
1604 Context::ARRAY_BUFFER_FUN_INDEX); 1604 Context::ARRAY_BUFFER_FUN_INDEX);
1605 } 1605 }
1606 1606
1607 { // -- T y p e d A r r a y s 1607 { // -- T y p e d A r r a y s
1608 // Create the %TypedArrayPrototype%
1609 Handle<JSObject> typed_array_prototype =
1610 factory->NewJSObject(isolate->object_function(), TENURED);
1611 native_context()->set_typed_array_prototype(*typed_array_prototype);
1612
1613 Handle<JSFunction> typed_array_fun = InstallFunction(
1614 global, "TypedArray", JS_OBJECT_TYPE, JSObject::kHeaderSize,
adamk 2016/05/04 18:44:36 I don't think you want to install this on the glob
gsathya 2016/05/05 21:16:06 Makes sense. But, I still need to create this JSFu
1615 typed_array_prototype, Builtins::kIllegal);
1616 InstallWithIntrinsicDefaultProto(isolate, typed_array_fun,
1617 Context::TYPED_ARRAY_FUN_INDEX);
1618
1608 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ 1619 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
1609 { \ 1620 { \
1610 Handle<JSFunction> fun; \ 1621 Handle<JSFunction> fun; \
1611 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun); \ 1622 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun); \
1612 InstallWithIntrinsicDefaultProto(isolate, fun, \ 1623 InstallWithIntrinsicDefaultProto(isolate, fun, \
1613 Context::TYPE##_ARRAY_FUN_INDEX); \ 1624 Context::TYPE##_ARRAY_FUN_INDEX); \
1614 } 1625 }
1615 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) 1626 TYPED_ARRAYS(INSTALL_TYPED_ARRAY)
1616 #undef INSTALL_TYPED_ARRAY 1627 #undef INSTALL_TYPED_ARRAY
1617 1628
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); 1931 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize);
1921 native_context()->set_call_as_constructor_delegate(*delegate); 1932 native_context()->set_call_as_constructor_delegate(*delegate);
1922 delegate->shared()->DontAdaptArguments(); 1933 delegate->shared()->DontAdaptArguments();
1923 } 1934 }
1924 } // NOLINT(readability/fn_size) 1935 } // NOLINT(readability/fn_size)
1925 1936
1926 1937
1927 void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind, 1938 void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind,
1928 Handle<JSFunction>* fun) { 1939 Handle<JSFunction>* fun) {
1929 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); 1940 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1930 Handle<JSFunction> result = InstallFunction( 1941
1931 global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, 1942 Handle<JSObject> typed_array_prototype =
1932 isolate()->initial_object_prototype(), Builtins::kIllegal); 1943 Handle<JSObject>(native_context()->typed_array_prototype());
adamk 2016/05/04 18:44:36 You can use the shorter "isolate()->typed_array_pr
gsathya 2016/05/05 21:16:06 Done.
1944 Handle<JSFunction> typed_array_function =
1945 Handle<JSFunction>(native_context()->typed_array_function());
adamk 2016/05/04 18:44:36 Same here, isolate()->typed_array_function().
gsathya 2016/05/05 21:16:06 Done.
1946
1947 Handle<JSObject> prototype =
1948 factory()->NewJSObject(isolate()->object_function(), TENURED);
1949 Handle<JSFunction> result =
1950 InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize,
1951 prototype, Builtins::kIllegal);
1933 1952
1934 Handle<Map> initial_map = isolate()->factory()->NewMap( 1953 Handle<Map> initial_map = isolate()->factory()->NewMap(
1935 JS_TYPED_ARRAY_TYPE, 1954 JS_TYPED_ARRAY_TYPE,
1936 JSTypedArray::kSizeWithInternalFields, 1955 JSTypedArray::kSizeWithInternalFields,
1937 elements_kind); 1956 elements_kind);
1938 JSFunction::SetInitialMap(result, initial_map, 1957 JSFunction::SetInitialMap(result, initial_map,
1939 handle(initial_map->prototype(), isolate())); 1958 handle(initial_map->prototype(), isolate()));
1959
1960 if (JSReceiver::SetPrototype(result, typed_array_function, false,
adamk 2016/05/04 18:44:36 I'd use JSObject::SetPrototype() here since you kn
gsathya 2016/05/05 21:16:06 Done.
1961 Object::THROW_ON_ERROR)
1962 .IsNothing()) {
1963 DCHECK(false);
Dan Ehrenberg 2016/05/04 18:11:13 Nit: DCHECK(false) is rather unidiomatic (although
adamk 2016/05/04 18:44:36 I agree with this approach, though a slight modifi
gsathya 2016/05/05 21:16:06 Done.
1964 }
1965
1966 if (JSReceiver::SetPrototype(prototype, typed_array_prototype, false,
adamk 2016/05/04 18:44:36 Same here, JSObject::SetPrototype.
gsathya 2016/05/05 21:16:06 Done.
1967 Object::THROW_ON_ERROR)
1968 .IsNothing()) {
1969 DCHECK(false);
1970 }
1971
1940 *fun = result; 1972 *fun = result;
1941 } 1973 }
1942 1974
1943 1975
1944 void Genesis::InitializeExperimentalGlobal() { 1976 void Genesis::InitializeExperimentalGlobal() {
1945 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); 1977 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id();
1946 1978
1947 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) 1979 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL)
1948 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) 1980 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL)
1949 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) 1981 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL)
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
3685 } 3717 }
3686 3718
3687 3719
3688 // Called when the top-level V8 mutex is destroyed. 3720 // Called when the top-level V8 mutex is destroyed.
3689 void Bootstrapper::FreeThreadResources() { 3721 void Bootstrapper::FreeThreadResources() {
3690 DCHECK(!IsActive()); 3722 DCHECK(!IsActive());
3691 } 3723 }
3692 3724
3693 } // namespace internal 3725 } // namespace internal
3694 } // namespace v8 3726 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698