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

Side by Side Diff: src/runtime.cc

Issue 59023003: Generate TypedArrayInitialize builtin in hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) { 824 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) {
825 HandleScope scope(isolate); 825 HandleScope scope(isolate);
826 ASSERT(args.length() == 1); 826 ASSERT(args.length() == 1);
827 CONVERT_ARG_CHECKED(Object, object, 0); 827 CONVERT_ARG_CHECKED(Object, object, 0);
828 return object->IsJSArrayBufferView() 828 return object->IsJSArrayBufferView()
829 ? isolate->heap()->true_value() 829 ? isolate->heap()->true_value()
830 : isolate->heap()->false_value(); 830 : isolate->heap()->false_value();
831 } 831 }
832 832
833 833
834 enum TypedArrayId { 834 void Runtime::ArrayIdToTypeAndSize(
835 // arrayIds below should be synchromized with typedarray.js natives.
836 ARRAY_ID_UINT8 = 1,
837 ARRAY_ID_INT8 = 2,
838 ARRAY_ID_UINT16 = 3,
839 ARRAY_ID_INT16 = 4,
840 ARRAY_ID_UINT32 = 5,
841 ARRAY_ID_INT32 = 6,
842 ARRAY_ID_FLOAT32 = 7,
843 ARRAY_ID_FLOAT64 = 8,
844 ARRAY_ID_UINT8C = 9
845 };
846
847 static void ArrayIdToTypeAndSize(
848 int arrayId, ExternalArrayType* array_type, size_t* element_size) { 835 int arrayId, ExternalArrayType* array_type, size_t* element_size) {
849 switch (arrayId) { 836 switch (arrayId) {
850 case ARRAY_ID_UINT8: 837 case ARRAY_ID_UINT8:
851 *array_type = kExternalUnsignedByteArray; 838 *array_type = kExternalUnsignedByteArray;
852 *element_size = 1; 839 *element_size = 1;
853 break; 840 break;
854 case ARRAY_ID_INT8: 841 case ARRAY_ID_INT8:
855 *array_type = kExternalByteArray; 842 *array_type = kExternalByteArray;
856 *element_size = 1; 843 *element_size = 1;
857 break; 844 break;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); 886 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4);
900 887
901 ASSERT(holder->GetInternalFieldCount() == 888 ASSERT(holder->GetInternalFieldCount() ==
902 v8::ArrayBufferView::kInternalFieldCount); 889 v8::ArrayBufferView::kInternalFieldCount);
903 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 890 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
904 holder->SetInternalField(i, Smi::FromInt(0)); 891 holder->SetInternalField(i, Smi::FromInt(0));
905 } 892 }
906 893
907 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. 894 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization.
908 size_t element_size = 1; // Bogus initialization. 895 size_t element_size = 1; // Bogus initialization.
909 ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); 896 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size);
910 897
911 holder->set_buffer(*buffer); 898 holder->set_buffer(*buffer);
912 holder->set_byte_offset(*byte_offset_object); 899 holder->set_byte_offset(*byte_offset_object);
913 holder->set_byte_length(*byte_length_object); 900 holder->set_byte_length(*byte_length_object);
914 901
915 size_t byte_offset = NumberToSize(isolate, *byte_offset_object); 902 size_t byte_offset = NumberToSize(isolate, *byte_offset_object);
916 size_t byte_length = NumberToSize(isolate, *byte_length_object); 903 size_t byte_length = NumberToSize(isolate, *byte_length_object);
917 ASSERT(byte_length % element_size == 0); 904 ASSERT(byte_length % element_size == 0);
918 size_t length = byte_length / element_size; 905 size_t length = byte_length / element_size;
919 906
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); 938 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3);
952 939
953 ASSERT(holder->GetInternalFieldCount() == 940 ASSERT(holder->GetInternalFieldCount() ==
954 v8::ArrayBufferView::kInternalFieldCount); 941 v8::ArrayBufferView::kInternalFieldCount);
955 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 942 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
956 holder->SetInternalField(i, Smi::FromInt(0)); 943 holder->SetInternalField(i, Smi::FromInt(0));
957 } 944 }
958 945
959 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. 946 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization.
960 size_t element_size = 1; // Bogus initialization. 947 size_t element_size = 1; // Bogus initialization.
961 ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); 948 Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &element_size);
962 949
963 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); 950 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
964 size_t length = NumberToSize(isolate, *length_obj); 951 size_t length = NumberToSize(isolate, *length_obj);
965 952
966 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || 953 if ((length > static_cast<unsigned>(Smi::kMaxValue)) ||
967 (length > (kMaxInt / element_size))) { 954 (length > (kMaxInt / element_size))) {
968 return isolate->Throw(*isolate->factory()-> 955 return isolate->Throw(*isolate->factory()->
969 NewRangeError("invalid_typed_array_length", 956 NewRangeError("invalid_typed_array_length",
970 HandleVector<Object>(NULL, 0))); 957 HandleVector<Object>(NULL, 0)));
971 } 958 }
(...skipping 13916 matching lines...) Expand 10 before | Expand all | Expand 10 after
14888 // Handle last resort GC and make sure to allow future allocations 14875 // Handle last resort GC and make sure to allow future allocations
14889 // to grow the heap without causing GCs (if possible). 14876 // to grow the heap without causing GCs (if possible).
14890 isolate->counters()->gc_last_resort_from_js()->Increment(); 14877 isolate->counters()->gc_last_resort_from_js()->Increment();
14891 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14878 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14892 "Runtime::PerformGC"); 14879 "Runtime::PerformGC");
14893 } 14880 }
14894 } 14881 }
14895 14882
14896 14883
14897 } } // namespace v8::internal 14884 } } // namespace v8::internal
OLDNEW
« src/hydrogen-instructions.h ('K') | « src/runtime.h ('k') | src/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698