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

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

Issue 2741683004: [rename] Rename internal field to embedder field. (Closed)
Patch Set: DEPRECATE_SOON(GetInternalField) Created 3 years, 9 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/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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 CHECK(byte_length % element_size == 0); 99 CHECK(byte_length % element_size == 0);
100 size_t length = byte_length / element_size; 100 size_t length = byte_length / element_size;
101 101
102 if (length > static_cast<unsigned>(Smi::kMaxValue)) { 102 if (length > static_cast<unsigned>(Smi::kMaxValue)) {
103 THROW_NEW_ERROR_RETURN_FAILURE( 103 THROW_NEW_ERROR_RETURN_FAILURE(
104 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength)); 104 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength));
105 } 105 }
106 106
107 // All checks are done, now we can modify objects. 107 // All checks are done, now we can modify objects.
108 108
109 DCHECK_EQ(v8::ArrayBufferView::kInternalFieldCount, 109 DCHECK_EQ(v8::ArrayBufferView::kEmbedderFieldCount,
110 holder->GetInternalFieldCount()); 110 holder->GetEmbedderFieldCount());
111 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 111 for (int i = 0; i < v8::ArrayBufferView::kEmbedderFieldCount; i++) {
112 holder->SetInternalField(i, Smi::kZero); 112 holder->SetEmbedderField(i, Smi::kZero);
113 } 113 }
114 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); 114 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
115 holder->set_length(*length_obj); 115 holder->set_length(*length_obj);
116 holder->set_byte_offset(*byte_offset_object); 116 holder->set_byte_offset(*byte_offset_object);
117 holder->set_byte_length(*byte_length_object); 117 holder->set_byte_length(*byte_length_object);
118 118
119 if (!maybe_buffer->IsNull(isolate)) { 119 if (!maybe_buffer->IsNull(isolate)) {
120 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer); 120 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
121 holder->set_buffer(*buffer); 121 holder->set_buffer(*buffer);
122 122
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 CHECK(TryNumberToSize(*length_obj, &length)); 172 CHECK(TryNumberToSize(*length_obj, &length));
173 } 173 }
174 174
175 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || 175 if ((length > static_cast<unsigned>(Smi::kMaxValue)) ||
176 (length > (kMaxInt / element_size))) { 176 (length > (kMaxInt / element_size))) {
177 THROW_NEW_ERROR_RETURN_FAILURE( 177 THROW_NEW_ERROR_RETURN_FAILURE(
178 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength)); 178 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength));
179 } 179 }
180 size_t byte_length = length * element_size; 180 size_t byte_length = length * element_size;
181 181
182 DCHECK_EQ(v8::ArrayBufferView::kInternalFieldCount, 182 DCHECK_EQ(v8::ArrayBufferView::kEmbedderFieldCount,
183 holder->GetInternalFieldCount()); 183 holder->GetEmbedderFieldCount());
184 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 184 for (int i = 0; i < v8::ArrayBufferView::kEmbedderFieldCount; i++) {
185 holder->SetInternalField(i, Smi::kZero); 185 holder->SetEmbedderField(i, Smi::kZero);
186 } 186 }
187 187
188 // NOTE: not initializing backing store. 188 // NOTE: not initializing backing store.
189 // We assume that the caller of this function will initialize holder 189 // We assume that the caller of this function will initialize holder
190 // with the loop 190 // with the loop
191 // for(i = 0; i < length; i++) { holder[i] = source[i]; } 191 // for(i = 0; i < length; i++) { holder[i] = source[i]; }
192 // We assume that the caller of this function is always a typed array 192 // We assume that the caller of this function is always a typed array
193 // constructor. 193 // constructor.
194 // If source is a typed array, this loop will always run to completion, 194 // If source is a typed array, this loop will always run to completion,
195 // so we are sure that the backing store will be initialized. 195 // so we are sure that the backing store will be initialized.
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return isolate->heap()->false_value(); 442 return isolate->heap()->false_value();
443 } 443 }
444 444
445 Handle<JSTypedArray> obj(JSTypedArray::cast(args[0])); 445 Handle<JSTypedArray> obj(JSTypedArray::cast(args[0]));
446 return isolate->heap()->ToBoolean(obj->GetBuffer()->is_shared() && 446 return isolate->heap()->ToBoolean(obj->GetBuffer()->is_shared() &&
447 obj->type() == kExternalInt32Array); 447 obj->type() == kExternalInt32Array);
448 } 448 }
449 449
450 } // namespace internal 450 } // namespace internal
451 } // namespace v8 451 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698