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

Side by Side Diff: src/runtime/runtime-typedarray.cc

Issue 2060213002: Revert of Replace all remaining Oddball checks with new function (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « src/runtime/runtime-strings.cc ('k') | src/runtime/runtime-utils.h » ('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 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 CHECK(TryNumberToSize(isolate, *byte_offset_object, &byte_offset)); 120 CHECK(TryNumberToSize(isolate, *byte_offset_object, &byte_offset));
121 CHECK(TryNumberToSize(isolate, *byte_length_object, &byte_length)); 121 CHECK(TryNumberToSize(isolate, *byte_length_object, &byte_length));
122 122
123 if (maybe_buffer->IsJSArrayBuffer()) { 123 if (maybe_buffer->IsJSArrayBuffer()) {
124 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer); 124 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
125 size_t array_buffer_byte_length = 125 size_t array_buffer_byte_length =
126 NumberToSize(isolate, buffer->byte_length()); 126 NumberToSize(isolate, buffer->byte_length());
127 CHECK(byte_offset <= array_buffer_byte_length); 127 CHECK(byte_offset <= array_buffer_byte_length);
128 CHECK(array_buffer_byte_length - byte_offset >= byte_length); 128 CHECK(array_buffer_byte_length - byte_offset >= byte_length);
129 } else { 129 } else {
130 CHECK(maybe_buffer->IsNull(isolate)); 130 CHECK(maybe_buffer->IsNull());
131 } 131 }
132 132
133 CHECK(byte_length % element_size == 0); 133 CHECK(byte_length % element_size == 0);
134 size_t length = byte_length / element_size; 134 size_t length = byte_length / element_size;
135 135
136 if (length > static_cast<unsigned>(Smi::kMaxValue)) { 136 if (length > static_cast<unsigned>(Smi::kMaxValue)) {
137 THROW_NEW_ERROR_RETURN_FAILURE( 137 THROW_NEW_ERROR_RETURN_FAILURE(
138 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength)); 138 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength));
139 } 139 }
140 140
141 // All checks are done, now we can modify objects. 141 // All checks are done, now we can modify objects.
142 142
143 DCHECK_EQ(v8::ArrayBufferView::kInternalFieldCount, 143 DCHECK_EQ(v8::ArrayBufferView::kInternalFieldCount,
144 holder->GetInternalFieldCount()); 144 holder->GetInternalFieldCount());
145 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 145 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
146 holder->SetInternalField(i, Smi::FromInt(0)); 146 holder->SetInternalField(i, Smi::FromInt(0));
147 } 147 }
148 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); 148 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
149 holder->set_length(*length_obj); 149 holder->set_length(*length_obj);
150 holder->set_byte_offset(*byte_offset_object); 150 holder->set_byte_offset(*byte_offset_object);
151 holder->set_byte_length(*byte_length_object); 151 holder->set_byte_length(*byte_length_object);
152 152
153 if (!maybe_buffer->IsNull(isolate)) { 153 if (!maybe_buffer->IsNull()) {
154 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer); 154 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
155 holder->set_buffer(*buffer); 155 holder->set_buffer(*buffer);
156 156
157 Handle<FixedTypedArrayBase> elements = 157 Handle<FixedTypedArrayBase> elements =
158 isolate->factory()->NewFixedTypedArrayWithExternalPointer( 158 isolate->factory()->NewFixedTypedArrayWithExternalPointer(
159 static_cast<int>(length), array_type, 159 static_cast<int>(length), array_type,
160 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); 160 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
161 holder->set_elements(*elements); 161 holder->set_elements(*elements);
162 } else { 162 } else {
163 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); 163 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 DATA_VIEW_SETTER(Uint16, uint16_t) 634 DATA_VIEW_SETTER(Uint16, uint16_t)
635 DATA_VIEW_SETTER(Int16, int16_t) 635 DATA_VIEW_SETTER(Int16, int16_t)
636 DATA_VIEW_SETTER(Uint32, uint32_t) 636 DATA_VIEW_SETTER(Uint32, uint32_t)
637 DATA_VIEW_SETTER(Int32, int32_t) 637 DATA_VIEW_SETTER(Int32, int32_t)
638 DATA_VIEW_SETTER(Float32, float) 638 DATA_VIEW_SETTER(Float32, float)
639 DATA_VIEW_SETTER(Float64, double) 639 DATA_VIEW_SETTER(Float64, double)
640 640
641 #undef DATA_VIEW_SETTER 641 #undef DATA_VIEW_SETTER
642 } // namespace internal 642 } // namespace internal
643 } // namespace v8 643 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-strings.cc ('k') | src/runtime/runtime-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698