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

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

Issue 2741683004: [rename] Rename internal field to embedder field. (Closed)
Patch Set: [rename] Rename internal field to embedder field. 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
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | src/snapshot/deserializer.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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 CHECK(byte_length % element_size == 0); 113 CHECK(byte_length % element_size == 0);
114 size_t length = byte_length / element_size; 114 size_t length = byte_length / element_size;
115 115
116 if (length > static_cast<unsigned>(Smi::kMaxValue)) { 116 if (length > static_cast<unsigned>(Smi::kMaxValue)) {
117 THROW_NEW_ERROR_RETURN_FAILURE( 117 THROW_NEW_ERROR_RETURN_FAILURE(
118 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength)); 118 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength));
119 } 119 }
120 120
121 // All checks are done, now we can modify objects. 121 // All checks are done, now we can modify objects.
122 122
123 DCHECK_EQ(v8::ArrayBufferView::kInternalFieldCount, 123 DCHECK_EQ(v8::ArrayBufferView::kEmbedderFieldCount,
124 holder->GetInternalFieldCount()); 124 holder->GetEmbedderFieldCount());
125 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 125 for (int i = 0; i < v8::ArrayBufferView::kEmbedderFieldCount; i++) {
126 holder->SetInternalField(i, Smi::kZero); 126 holder->SetEmbedderField(i, Smi::kZero);
127 } 127 }
128 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); 128 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
129 holder->set_length(*length_obj); 129 holder->set_length(*length_obj);
130 holder->set_byte_offset(*byte_offset_object); 130 holder->set_byte_offset(*byte_offset_object);
131 holder->set_byte_length(*byte_length_object); 131 holder->set_byte_length(*byte_length_object);
132 132
133 if (!maybe_buffer->IsNull(isolate)) { 133 if (!maybe_buffer->IsNull(isolate)) {
134 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer); 134 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
135 holder->set_buffer(*buffer); 135 holder->set_buffer(*buffer);
136 136
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 CHECK(TryNumberToSize(*length_obj, &length)); 186 CHECK(TryNumberToSize(*length_obj, &length));
187 } 187 }
188 188
189 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || 189 if ((length > static_cast<unsigned>(Smi::kMaxValue)) ||
190 (length > (kMaxInt / element_size))) { 190 (length > (kMaxInt / element_size))) {
191 THROW_NEW_ERROR_RETURN_FAILURE( 191 THROW_NEW_ERROR_RETURN_FAILURE(
192 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength)); 192 isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength));
193 } 193 }
194 size_t byte_length = length * element_size; 194 size_t byte_length = length * element_size;
195 195
196 DCHECK_EQ(v8::ArrayBufferView::kInternalFieldCount, 196 DCHECK_EQ(v8::ArrayBufferView::kEmbedderFieldCount,
197 holder->GetInternalFieldCount()); 197 holder->GetEmbedderFieldCount());
198 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 198 for (int i = 0; i < v8::ArrayBufferView::kEmbedderFieldCount; i++) {
199 holder->SetInternalField(i, Smi::kZero); 199 holder->SetEmbedderField(i, Smi::kZero);
200 } 200 }
201 201
202 // NOTE: not initializing backing store. 202 // NOTE: not initializing backing store.
203 // We assume that the caller of this function will initialize holder 203 // We assume that the caller of this function will initialize holder
204 // with the loop 204 // with the loop
205 // for(i = 0; i < length; i++) { holder[i] = source[i]; } 205 // for(i = 0; i < length; i++) { holder[i] = source[i]; }
206 // We assume that the caller of this function is always a typed array 206 // We assume that the caller of this function is always a typed array
207 // constructor. 207 // constructor.
208 // If source is a typed array, this loop will always run to completion, 208 // If source is a typed array, this loop will always run to completion,
209 // so we are sure that the backing store will be initialized. 209 // so we are sure that the backing store will be initialized.
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return isolate->heap()->false_value(); 456 return isolate->heap()->false_value();
457 } 457 }
458 458
459 Handle<JSTypedArray> obj(JSTypedArray::cast(args[0])); 459 Handle<JSTypedArray> obj(JSTypedArray::cast(args[0]));
460 return isolate->heap()->ToBoolean(obj->GetBuffer()->is_shared() && 460 return isolate->heap()->ToBoolean(obj->GetBuffer()->is_shared() &&
461 obj->type() == kExternalInt32Array); 461 obj->type() == kExternalInt32Array);
462 } 462 }
463 463
464 } // namespace internal 464 } // namespace internal
465 } // namespace v8 465 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | src/snapshot/deserializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698