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

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

Issue 1330153003: Adding template parameter to PrototypeIterator GetCurrent for casting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: simplifications Created 5 years, 3 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/prototype.h ('k') | src/runtime/runtime-object.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 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/conversions-inl.h" 8 #include "src/conversions-inl.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 HandleScope scope(isolate); 196 HandleScope scope(isolate);
197 DCHECK(args.length() == 2); 197 DCHECK(args.length() == 2);
198 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 198 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
199 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); 199 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
200 if (array->elements()->IsDictionary()) { 200 if (array->elements()->IsDictionary()) {
201 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array(); 201 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array();
202 for (PrototypeIterator iter(isolate, array, 202 for (PrototypeIterator iter(isolate, array,
203 PrototypeIterator::START_AT_RECEIVER); 203 PrototypeIterator::START_AT_RECEIVER);
204 !iter.IsAtEnd(); iter.Advance()) { 204 !iter.IsAtEnd(); iter.Advance()) {
205 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() || 205 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() ||
206 JSObject::cast(*PrototypeIterator::GetCurrent(iter)) 206 PrototypeIterator::GetCurrent<JSObject>(iter)
207 ->HasIndexedInterceptor()) { 207 ->HasIndexedInterceptor()) {
208 // Bail out if we find a proxy or interceptor, likely not worth 208 // Bail out if we find a proxy or interceptor, likely not worth
209 // collecting keys in that case. 209 // collecting keys in that case.
210 return *isolate->factory()->NewNumberFromUint(length); 210 return *isolate->factory()->NewNumberFromUint(length);
211 } 211 }
212 Handle<JSObject> current = 212 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter);
213 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
214 Handle<FixedArray> current_keys = 213 Handle<FixedArray> current_keys =
215 isolate->factory()->NewFixedArray(current->NumberOfOwnElements(NONE)); 214 isolate->factory()->NewFixedArray(current->NumberOfOwnElements(NONE));
216 current->GetOwnElementKeys(*current_keys, NONE); 215 current->GetOwnElementKeys(*current_keys, NONE);
217 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 216 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
218 isolate, keys, FixedArray::UnionOfKeys(keys, current_keys)); 217 isolate, keys, FixedArray::UnionOfKeys(keys, current_keys));
219 } 218 }
220 // Erase any keys >= length. 219 // Erase any keys >= length.
221 // TODO(adamk): Remove this step when the contract of %GetArrayKeys 220 // TODO(adamk): Remove this step when the contract of %GetArrayKeys
222 // is changed to let this happen on the JS side. 221 // is changed to let this happen on the JS side.
223 for (int i = 0; i < keys->length(); i++) { 222 for (int i = 0; i < keys->length(); i++) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 RUNTIME_FUNCTION(Runtime_HasComplexElements) { 446 RUNTIME_FUNCTION(Runtime_HasComplexElements) {
448 HandleScope scope(isolate); 447 HandleScope scope(isolate);
449 DCHECK(args.length() == 1); 448 DCHECK(args.length() == 1);
450 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 449 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
451 for (PrototypeIterator iter(isolate, array, 450 for (PrototypeIterator iter(isolate, array,
452 PrototypeIterator::START_AT_RECEIVER); 451 PrototypeIterator::START_AT_RECEIVER);
453 !iter.IsAtEnd(); iter.Advance()) { 452 !iter.IsAtEnd(); iter.Advance()) {
454 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { 453 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) {
455 return isolate->heap()->true_value(); 454 return isolate->heap()->true_value();
456 } 455 }
457 Handle<JSObject> current = 456 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter);
458 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
459 if (current->HasIndexedInterceptor()) { 457 if (current->HasIndexedInterceptor()) {
460 return isolate->heap()->true_value(); 458 return isolate->heap()->true_value();
461 } 459 }
462 if (!current->HasDictionaryElements()) continue; 460 if (!current->HasDictionaryElements()) continue;
463 if (current->element_dictionary()->HasComplexElements()) { 461 if (current->element_dictionary()->HasComplexElements()) {
464 return isolate->heap()->true_value(); 462 return isolate->heap()->true_value();
465 } 463 }
466 } 464 }
467 return isolate->heap()->false_value(); 465 return isolate->heap()->false_value();
468 } 466 }
(...skipping 24 matching lines...) Expand all
493 491
494 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { 492 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) {
495 SealHandleScope shs(isolate); 493 SealHandleScope shs(isolate);
496 DCHECK(args.length() == 2); 494 DCHECK(args.length() == 2);
497 // Returning undefined means that this fast path fails and one has to resort 495 // Returning undefined means that this fast path fails and one has to resort
498 // to a slow path. 496 // to a slow path.
499 return isolate->heap()->undefined_value(); 497 return isolate->heap()->undefined_value();
500 } 498 }
501 } // namespace internal 499 } // namespace internal
502 } // namespace v8 500 } // namespace v8
OLDNEW
« no previous file with comments | « src/prototype.h ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698