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

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

Issue 1785003004: Revert of Replace PushIfAbsent by a Stack object and move StringBuilderJoin to JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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.h ('k') | src/runtime/runtime-strings.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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) { 81 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) {
82 HandleScope scope(isolate); 82 HandleScope scope(isolate);
83 RUNTIME_ASSERT(args.length() == 2); 83 RUNTIME_ASSERT(args.length() == 2);
84 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 84 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
85 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); 85 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1);
86 JSObject::TransitionElementsKind(array, map->elements_kind()); 86 JSObject::TransitionElementsKind(array, map->elements_kind());
87 return *array; 87 return *array;
88 } 88 }
89 89
90 90
91 // Push an object unto an array of objects if it is not already in the
92 // array. Returns true if the element was pushed on the stack and
93 // false otherwise.
94 RUNTIME_FUNCTION(Runtime_PushIfAbsent) {
95 HandleScope scope(isolate);
96 DCHECK(args.length() == 2);
97 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
98 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1);
99 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements());
100 int length = Smi::cast(array->length())->value();
101 FixedArray* elements = FixedArray::cast(array->elements());
102 for (int i = 0; i < length; i++) {
103 if (elements->get(i) == *element) return isolate->heap()->false_value();
104 }
105
106 // Strict not needed. Used for cycle detection in Array join implementation.
107 RETURN_FAILURE_ON_EXCEPTION(
108 isolate, JSObject::AddDataElement(array, length, element, NONE));
109 JSObject::ValidateElements(array);
110 return isolate->heap()->true_value();
111 }
112
113
91 // Moves all own elements of an object, that are below a limit, to positions 114 // Moves all own elements of an object, that are below a limit, to positions
92 // starting at zero. All undefined values are placed after non-undefined values, 115 // starting at zero. All undefined values are placed after non-undefined values,
93 // and are followed by non-existing element. Does not change the length 116 // and are followed by non-existing element. Does not change the length
94 // property. 117 // property.
95 // Returns the number of non-undefined elements collected. 118 // Returns the number of non-undefined elements collected.
96 // Returns -1 if hole removal is not supported by this method. 119 // Returns -1 if hole removal is not supported by this method.
97 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) { 120 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) {
98 HandleScope scope(isolate); 121 HandleScope scope(isolate);
99 DCHECK(args.length() == 2); 122 DCHECK(args.length() == 2);
100 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); 123 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); 497 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0);
475 Handle<Object> constructor; 498 Handle<Object> constructor;
476 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 499 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
477 isolate, constructor, 500 isolate, constructor,
478 Object::ArraySpeciesConstructor(isolate, original_array)); 501 Object::ArraySpeciesConstructor(isolate, original_array));
479 return *constructor; 502 return *constructor;
480 } 503 }
481 504
482 } // namespace internal 505 } // namespace internal
483 } // namespace v8 506 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698