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

Side by Side Diff: src/runtime.cc

Issue 60733022: Merged r17711 into 3.22 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.22
Patch Set: 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
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 954 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
955 holder->SetInternalField(i, Smi::FromInt(0)); 955 holder->SetInternalField(i, Smi::FromInt(0));
956 } 956 }
957 957
958 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization. 958 ExternalArrayType array_type = kExternalByteArray; // Bogus initialization.
959 size_t element_size = 1; // Bogus initialization. 959 size_t element_size = 1; // Bogus initialization.
960 ArrayIdToTypeAndSize(arrayId, &array_type, &element_size); 960 ArrayIdToTypeAndSize(arrayId, &array_type, &element_size);
961 961
962 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); 962 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
963 size_t length = NumberToSize(isolate, *length_obj); 963 size_t length = NumberToSize(isolate, *length_obj);
964 size_t byte_length = length * element_size; 964 if (length > (kMaxInt / element_size)) {
965 if (byte_length < length) { // Overflow
966 return isolate->Throw(*isolate->factory()-> 965 return isolate->Throw(*isolate->factory()->
967 NewRangeError("invalid_array_buffer_length", 966 NewRangeError("invalid_array_buffer_length",
968 HandleVector<Object>(NULL, 0))); 967 HandleVector<Object>(NULL, 0)));
969 } 968 }
969 size_t byte_length = length * element_size;
970 970
971 // NOTE: not initializing backing store. 971 // NOTE: not initializing backing store.
972 // We assume that the caller of this function will initialize holder 972 // We assume that the caller of this function will initialize holder
973 // with the loop 973 // with the loop
974 // for(i = 0; i < length; i++) { holder[i] = source[i]; } 974 // for(i = 0; i < length; i++) { holder[i] = source[i]; }
975 // We assume that the caller of this function is always a typed array 975 // We assume that the caller of this function is always a typed array
976 // constructor. 976 // constructor.
977 // If source is a typed array, this loop will always run to completion, 977 // If source is a typed array, this loop will always run to completion,
978 // so we are sure that the backing store will be initialized. 978 // so we are sure that the backing store will be initialized.
979 // Otherwise, the indexing operation might throw, so the loop will not 979 // Otherwise, the indexing operation might throw, so the loop will not
(...skipping 13886 matching lines...) Expand 10 before | Expand all | Expand 10 after
14866 // Handle last resort GC and make sure to allow future allocations 14866 // Handle last resort GC and make sure to allow future allocations
14867 // to grow the heap without causing GCs (if possible). 14867 // to grow the heap without causing GCs (if possible).
14868 isolate->counters()->gc_last_resort_from_js()->Increment(); 14868 isolate->counters()->gc_last_resort_from_js()->Increment();
14869 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14869 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14870 "Runtime::PerformGC"); 14870 "Runtime::PerformGC");
14871 } 14871 }
14872 } 14872 }
14873 14873
14874 14874
14875 } } // namespace v8::internal 14875 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698