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

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

Issue 2793233003: Revert of [typedarrays] Check detached buffer at start of typed array methods (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | src/compiler/js-intrinsic-lowering.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/counters.h" 7 #include "src/counters.h"
8 #include "src/elements.h" 8 #include "src/elements.h"
9 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 // ----------------------------------------------------------------------------- 14 // -----------------------------------------------------------------------------
15 // ES6 section 22.2 TypedArray Objects 15 // ES6 section 22.2 TypedArray Objects
16 16
17 // ES6 section 22.2.3.1 get %TypedArray%.prototype.buffer 17 // ES6 section 22.2.3.1 get %TypedArray%.prototype.buffer
18 BUILTIN(TypedArrayPrototypeBuffer) { 18 BUILTIN(TypedArrayPrototypeBuffer) {
19 HandleScope scope(isolate); 19 HandleScope scope(isolate);
20 CHECK_RECEIVER(JSTypedArray, typed_array, 20 CHECK_RECEIVER(JSTypedArray, typed_array, "get TypedArray.prototype.buffer");
21 "get %TypedArray%.prototype.buffer");
22 return *typed_array->GetBuffer(); 21 return *typed_array->GetBuffer();
23 } 22 }
24 23
25 namespace { 24 namespace {
26 25
27 int64_t CapRelativeIndex(Handle<Object> num, int64_t minimum, int64_t maximum) { 26 int64_t CapRelativeIndex(Handle<Object> num, int64_t minimum, int64_t maximum) {
28 int64_t relative; 27 int64_t relative;
29 if (V8_LIKELY(num->IsSmi())) { 28 if (V8_LIKELY(num->IsSmi())) {
30 relative = Smi::cast(*num)->value(); 29 relative = Smi::cast(*num)->value();
31 } else { 30 } else {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } // namespace 121 } // namespace
123 122
124 BUILTIN(TypedArrayPrototypeCopyWithin) { 123 BUILTIN(TypedArrayPrototypeCopyWithin) {
125 HandleScope scope(isolate); 124 HandleScope scope(isolate);
126 125
127 Handle<JSTypedArray> array; 126 Handle<JSTypedArray> array;
128 const char* method = "%TypedArray%.prototype.copyWithin"; 127 const char* method = "%TypedArray%.prototype.copyWithin";
129 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 128 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
130 isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method)); 129 isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
131 130
131 if (V8_UNLIKELY(array->WasNeutered())) return *array;
132
132 int64_t len = array->length_value(); 133 int64_t len = array->length_value();
133 int64_t to = 0; 134 int64_t to = 0;
134 int64_t from = 0; 135 int64_t from = 0;
135 int64_t final = len; 136 int64_t final = len;
136 137
137 if (V8_LIKELY(args.length() > 1)) { 138 if (V8_LIKELY(args.length() > 1)) {
138 Handle<Object> num; 139 Handle<Object> num;
139 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 140 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
140 isolate, num, Object::ToInteger(isolate, args.at<Object>(1))); 141 isolate, num, Object::ToInteger(isolate, args.at<Object>(1)));
141 to = CapRelativeIndex(num, 0, len); 142 to = CapRelativeIndex(num, 0, len);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 186 }
186 187
187 BUILTIN(TypedArrayPrototypeFill) { 188 BUILTIN(TypedArrayPrototypeFill) {
188 HandleScope scope(isolate); 189 HandleScope scope(isolate);
189 190
190 Handle<JSTypedArray> array; 191 Handle<JSTypedArray> array;
191 const char* method = "%TypedArray%.prototype.fill"; 192 const char* method = "%TypedArray%.prototype.fill";
192 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 193 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
193 isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method)); 194 isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
194 195
196 if (V8_UNLIKELY(array->WasNeutered())) return *array;
197
195 int64_t len = array->length_value(); 198 int64_t len = array->length_value();
196 int64_t start = 0; 199 int64_t start = 0;
197 int64_t end = len; 200 int64_t end = len;
198 201
199 if (args.length() > 2) { 202 if (args.length() > 2) {
200 Handle<Object> num = args.atOrUndefined(isolate, 2); 203 Handle<Object> num = args.atOrUndefined(isolate, 2);
201 if (!num->IsUndefined(isolate)) { 204 if (!num->IsUndefined(isolate)) {
202 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 205 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
203 isolate, num, Object::ToInteger(isolate, num)); 206 isolate, num, Object::ToInteger(isolate, num));
204 start = CapRelativeIndex(num, 0, len); 207 start = CapRelativeIndex(num, 0, len);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 333 }
331 334
332 BUILTIN(TypedArrayPrototypeReverse) { 335 BUILTIN(TypedArrayPrototypeReverse) {
333 HandleScope scope(isolate); 336 HandleScope scope(isolate);
334 337
335 Handle<JSTypedArray> array; 338 Handle<JSTypedArray> array;
336 const char* method = "%TypedArray%.prototype.reverse"; 339 const char* method = "%TypedArray%.prototype.reverse";
337 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 340 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
338 isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method)); 341 isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
339 342
343 if (V8_UNLIKELY(array->WasNeutered())) return *array;
344
340 ElementsAccessor* elements = array->GetElementsAccessor(); 345 ElementsAccessor* elements = array->GetElementsAccessor();
341 elements->Reverse(*array); 346 elements->Reverse(*array);
342 return *array; 347 return *array;
343 } 348 }
344 349
345 BUILTIN(TypedArrayPrototypeSlice) { 350 BUILTIN(TypedArrayPrototypeSlice) {
346 HandleScope scope(isolate); 351 HandleScope scope(isolate);
347 352
348 Handle<JSTypedArray> array; 353 Handle<JSTypedArray> array;
349 const char* method = "%TypedArray%.prototype.slice"; 354 const char* method = "%TypedArray%.prototype.slice";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 392
388 if (count == 0) return *result_array; 393 if (count == 0) return *result_array;
389 394
390 ElementsAccessor* accessor = array->GetElementsAccessor(); 395 ElementsAccessor* accessor = array->GetElementsAccessor();
391 return *accessor->Slice(array, static_cast<uint32_t>(start), 396 return *accessor->Slice(array, static_cast<uint32_t>(start),
392 static_cast<uint32_t>(end), result_array); 397 static_cast<uint32_t>(end), result_array);
393 } 398 }
394 399
395 } // namespace internal 400 } // namespace internal
396 } // namespace v8 401 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-intrinsic-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698