| OLD | NEW |
| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/messages.h" | 8 #include "src/messages.h" |
| 9 #include "src/runtime/runtime-utils.h" | 9 #include "src/runtime/runtime-utils.h" |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); | 95 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); |
| 96 int length = Smi::cast(array->length())->value(); | 96 int length = Smi::cast(array->length())->value(); |
| 97 FixedArray* elements = FixedArray::cast(array->elements()); | 97 FixedArray* elements = FixedArray::cast(array->elements()); |
| 98 for (int i = 0; i < length; i++) { | 98 for (int i = 0; i < length; i++) { |
| 99 if (elements->get(i) == *element) return isolate->heap()->false_value(); | 99 if (elements->get(i) == *element) return isolate->heap()->false_value(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // Strict not needed. Used for cycle detection in Array join implementation. | 102 // Strict not needed. Used for cycle detection in Array join implementation. |
| 103 RETURN_FAILURE_ON_EXCEPTION( | 103 RETURN_FAILURE_ON_EXCEPTION( |
| 104 isolate, JSObject::AddDataElement(array, length, element, NONE)); | 104 isolate, JSObject::AddDataElement(array, length, element, NONE)); |
| 105 JSObject::ValidateElements(array); |
| 105 return isolate->heap()->true_value(); | 106 return isolate->heap()->true_value(); |
| 106 } | 107 } |
| 107 | 108 |
| 108 | 109 |
| 109 /** | 110 /** |
| 110 * A simple visitor visits every element of Array's. | 111 * A simple visitor visits every element of Array's. |
| 111 * The backend storage can be a fixed array for fast elements case, | 112 * The backend storage can be a fixed array for fast elements case, |
| 112 * or a dictionary for sparse array. Since Dictionary is a subtype | 113 * or a dictionary for sparse array. Since Dictionary is a subtype |
| 113 * of FixedArray, the class can be used by both fast and slow cases. | 114 * of FixedArray, the class can be used by both fast and slow cases. |
| 114 * The second parameter of the constructor, fast_elements, specifies | 115 * The second parameter of the constructor, fast_elements, specifies |
| (...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 | 1316 |
| 1316 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { | 1317 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { |
| 1317 SealHandleScope shs(isolate); | 1318 SealHandleScope shs(isolate); |
| 1318 DCHECK(args.length() == 2); | 1319 DCHECK(args.length() == 2); |
| 1319 // Returning undefined means that this fast path fails and one has to resort | 1320 // Returning undefined means that this fast path fails and one has to resort |
| 1320 // to a slow path. | 1321 // to a slow path. |
| 1321 return isolate->heap()->undefined_value(); | 1322 return isolate->heap()->undefined_value(); |
| 1322 } | 1323 } |
| 1323 } // namespace internal | 1324 } // namespace internal |
| 1324 } // namespace v8 | 1325 } // namespace v8 |
| OLD | NEW |