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

Side by Side Diff: src/factory.cc

Issue 1254623002: Remove ExternalArray, derived types, and element kinds (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 5 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/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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 866
867 Handle<ByteArray> Factory::NewByteArray(int length, PretenureFlag pretenure) { 867 Handle<ByteArray> Factory::NewByteArray(int length, PretenureFlag pretenure) {
868 DCHECK(0 <= length); 868 DCHECK(0 <= length);
869 CALL_HEAP_FUNCTION( 869 CALL_HEAP_FUNCTION(
870 isolate(), 870 isolate(),
871 isolate()->heap()->AllocateByteArray(length, pretenure), 871 isolate()->heap()->AllocateByteArray(length, pretenure),
872 ByteArray); 872 ByteArray);
873 } 873 }
874 874
875 875
876 Handle<ExternalArray> Factory::NewExternalArray(int length, 876 Handle<FixedTypedArrayBase> Factory::NewExternalArray(
877 ExternalArrayType array_type, 877 int length, ExternalArrayType array_type, void* external_pointer,
878 void* external_pointer, 878 PretenureFlag pretenure) {
879 PretenureFlag pretenure) {
880 DCHECK(0 <= length && length <= Smi::kMaxValue); 879 DCHECK(0 <= length && length <= Smi::kMaxValue);
881 CALL_HEAP_FUNCTION( 880 CALL_HEAP_FUNCTION(isolate(),
882 isolate(), 881 isolate()->heap()->AllocateExternalArray(
883 isolate()->heap()->AllocateExternalArray(length, 882 length, array_type, external_pointer, pretenure),
884 array_type, 883 FixedTypedArrayBase);
885 external_pointer,
886 pretenure),
887 ExternalArray);
888 } 884 }
889 885
890 886
891 Handle<FixedTypedArrayBase> Factory::NewFixedTypedArray( 887 Handle<FixedTypedArrayBase> Factory::NewFixedTypedArray(
892 int length, ExternalArrayType array_type, bool initialize, 888 int length, ExternalArrayType array_type, bool initialize,
893 PretenureFlag pretenure) { 889 PretenureFlag pretenure) {
894 DCHECK(0 <= length && length <= Smi::kMaxValue); 890 DCHECK(0 <= length && length <= Smi::kMaxValue);
895 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateFixedTypedArray( 891 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateFixedTypedArray(
896 length, array_type, initialize, pretenure), 892 length, array_type, initialize, pretenure),
897 FixedTypedArrayBase); 893 FixedTypedArrayBase);
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 JSSetIterator); 1744 JSSetIterator);
1749 } 1745 }
1750 1746
1751 1747
1752 namespace { 1748 namespace {
1753 1749
1754 ElementsKind GetExternalArrayElementsKind(ExternalArrayType type) { 1750 ElementsKind GetExternalArrayElementsKind(ExternalArrayType type) {
1755 switch (type) { 1751 switch (type) {
1756 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1752 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1757 case kExternal##Type##Array: \ 1753 case kExternal##Type##Array: \
1758 return EXTERNAL_##TYPE##_ELEMENTS; 1754 return TYPE##_ELEMENTS;
1759 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1755 TYPED_ARRAYS(TYPED_ARRAY_CASE)
1760 } 1756 }
1761 UNREACHABLE(); 1757 UNREACHABLE();
1762 return FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND; 1758 return FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND;
1763 #undef TYPED_ARRAY_CASE 1759 #undef TYPED_ARRAY_CASE
1764 } 1760 }
1765 1761
1766 1762
1767 size_t GetExternalArrayElementSize(ExternalArrayType type) { 1763 size_t GetExternalArrayElementSize(ExternalArrayType type) {
1768 switch (type) { 1764 switch (type) {
1769 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1765 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1770 case kExternal##Type##Array: \ 1766 case kExternal##Type##Array: \
1771 return size; 1767 return size;
1772 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1768 TYPED_ARRAYS(TYPED_ARRAY_CASE)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 CHECK(byte_offset % element_size == 0); 1890 CHECK(byte_offset % element_size == 0);
1895 1891
1896 CHECK(length <= (std::numeric_limits<size_t>::max() / element_size)); 1892 CHECK(length <= (std::numeric_limits<size_t>::max() / element_size));
1897 CHECK(length <= static_cast<size_t>(Smi::kMaxValue)); 1893 CHECK(length <= static_cast<size_t>(Smi::kMaxValue));
1898 size_t byte_length = length * element_size; 1894 size_t byte_length = length * element_size;
1899 SetupArrayBufferView(isolate(), obj, buffer, byte_offset, byte_length); 1895 SetupArrayBufferView(isolate(), obj, buffer, byte_offset, byte_length);
1900 1896
1901 Handle<Object> length_object = NewNumberFromSize(length); 1897 Handle<Object> length_object = NewNumberFromSize(length);
1902 obj->set_length(*length_object); 1898 obj->set_length(*length_object);
1903 1899
1904 Handle<ExternalArray> elements = NewExternalArray( 1900 Handle<FixedTypedArrayBase> elements = NewExternalArray(
1905 static_cast<int>(length), type, 1901 static_cast<int>(length), type,
1906 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); 1902 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
1907 Handle<Map> map = JSObject::GetElementsTransitionMap(obj, elements_kind); 1903 Handle<Map> map = JSObject::GetElementsTransitionMap(obj, elements_kind);
1908 JSObject::SetMapAndElements(obj, map, elements); 1904 JSObject::SetMapAndElements(obj, map, elements);
1909 return obj; 1905 return obj;
1910 } 1906 }
1911 1907
1912 1908
1913 Handle<JSTypedArray> Factory::NewJSTypedArray(ElementsKind elements_kind, 1909 Handle<JSTypedArray> Factory::NewJSTypedArray(ElementsKind elements_kind,
1914 size_t number_of_elements) { 1910 size_t number_of_elements) {
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 } 2415 }
2420 2416
2421 2417
2422 Handle<Object> Factory::ToBoolean(bool value) { 2418 Handle<Object> Factory::ToBoolean(bool value) {
2423 return value ? true_value() : false_value(); 2419 return value ? true_value() : false_value();
2424 } 2420 }
2425 2421
2426 2422
2427 } // namespace internal 2423 } // namespace internal
2428 } // namespace v8 2424 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap-snapshot-generator.cc » ('j') | src/heap/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698