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

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

Issue 2041353003: [runtime] Deprecate RUNTIME_ASSERT from primitive ops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed offline comment. Created 4 years, 6 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 | « no previous file | src/runtime/runtime-literals.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/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/elements.h" 10 #include "src/elements.h"
11 #include "src/factory.h" 11 #include "src/factory.h"
12 #include "src/isolate-inl.h" 12 #include "src/isolate-inl.h"
13 #include "src/keys.h" 13 #include "src/keys.h"
14 #include "src/messages.h" 14 #include "src/messages.h"
15 #include "src/prototype.h" 15 #include "src/prototype.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { 20 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) {
21 HandleScope scope(isolate); 21 HandleScope scope(isolate);
22 DCHECK(args.length() == 1); 22 DCHECK(args.length() == 1);
23 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); 23 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0);
24 Object* length = prototype->length(); 24 Object* length = prototype->length();
25 RUNTIME_ASSERT(length->IsSmi() && Smi::cast(length)->value() == 0); 25 CHECK(length->IsSmi());
26 RUNTIME_ASSERT(prototype->HasFastSmiOrObjectElements()); 26 CHECK(Smi::cast(length)->value() == 0);
27 CHECK(prototype->HasFastSmiOrObjectElements());
27 // This is necessary to enable fast checks for absence of elements 28 // This is necessary to enable fast checks for absence of elements
28 // on Array.prototype and below. 29 // on Array.prototype and below.
29 prototype->set_elements(isolate->heap()->empty_fixed_array()); 30 prototype->set_elements(isolate->heap()->empty_fixed_array());
30 return Smi::FromInt(0); 31 return Smi::FromInt(0);
31 } 32 }
32 33
33 static void InstallCode(Isolate* isolate, Handle<JSObject> holder, 34 static void InstallCode(Isolate* isolate, Handle<JSObject> holder,
34 const char* name, Handle<Code> code) { 35 const char* name, Handle<Code> code) {
35 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); 36 Handle<String> key = isolate->factory()->InternalizeUtf8String(name);
36 Handle<JSFunction> optimized = 37 Handle<JSFunction> optimized =
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 CONVERT_ARG_CHECKED(FixedArray, object, 0); 79 CONVERT_ARG_CHECKED(FixedArray, object, 0);
79 CONVERT_SMI_ARG_CHECKED(index, 1); 80 CONVERT_SMI_ARG_CHECKED(index, 1);
80 CONVERT_ARG_CHECKED(Object, value, 2); 81 CONVERT_ARG_CHECKED(Object, value, 2);
81 object->set(index, value); 82 object->set(index, value);
82 return isolate->heap()->undefined_value(); 83 return isolate->heap()->undefined_value();
83 } 84 }
84 85
85 86
86 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) { 87 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) {
87 HandleScope scope(isolate); 88 HandleScope scope(isolate);
88 RUNTIME_ASSERT(args.length() == 2); 89 DCHECK(args.length() == 2);
89 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 90 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
90 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); 91 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1);
91 JSObject::TransitionElementsKind(array, map->elements_kind()); 92 JSObject::TransitionElementsKind(array, map->elements_kind());
92 return *array; 93 return *array;
93 } 94 }
94 95
95 96
96 // Moves all own elements of an object, that are below a limit, to positions 97 // Moves all own elements of an object, that are below a limit, to positions
97 // starting at zero. All undefined values are placed after non-undefined values, 98 // starting at zero. All undefined values are placed after non-undefined values,
98 // and are followed by non-existing element. Does not change the length 99 // and are followed by non-existing element. Does not change the length
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if (array->HasFastStringWrapperElements()) { 187 if (array->HasFastStringWrapperElements()) {
187 int string_length = 188 int string_length =
188 String::cast(Handle<JSValue>::cast(array)->value())->length(); 189 String::cast(Handle<JSValue>::cast(array)->value())->length();
189 int backing_store_length = array->elements()->length(); 190 int backing_store_length = array->elements()->length();
190 return *isolate->factory()->NewNumberFromUint( 191 return *isolate->factory()->NewNumberFromUint(
191 Min(length, 192 Min(length,
192 static_cast<uint32_t>(Max(string_length, backing_store_length)))); 193 static_cast<uint32_t>(Max(string_length, backing_store_length))));
193 } 194 }
194 195
195 if (!array->elements()->IsDictionary()) { 196 if (!array->elements()->IsDictionary()) {
196 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || 197 CHECK(array->HasFastSmiOrObjectElements() ||
197 array->HasFastDoubleElements()); 198 array->HasFastDoubleElements());
198 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); 199 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
199 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); 200 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length));
200 } 201 }
201 202
202 KeyAccumulator accumulator(isolate, KeyCollectionMode::kOwnOnly, 203 KeyAccumulator accumulator(isolate, KeyCollectionMode::kOwnOnly,
203 ALL_PROPERTIES); 204 ALL_PROPERTIES);
204 // No need to separate prototype levels since we only get element keys. 205 // No need to separate prototype levels since we only get element keys.
205 for (PrototypeIterator iter(isolate, array, 206 for (PrototypeIterator iter(isolate, array,
206 PrototypeIterator::START_AT_RECEIVER); 207 PrototypeIterator::START_AT_RECEIVER);
207 !iter.IsAtEnd(); iter.Advance()) { 208 !iter.IsAtEnd(); iter.Advance()) {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 : Handle<AllocationSite>::cast(raw_site); 403 : Handle<AllocationSite>::cast(raw_site);
403 Arguments constructor_args(argument_count, argument_base); 404 Arguments constructor_args(argument_count, argument_base);
404 return ArrayConstructorCommon(isolate, constructor, constructor, casted_site, 405 return ArrayConstructorCommon(isolate, constructor, constructor, casted_site,
405 &constructor_args); 406 &constructor_args);
406 } 407 }
407 408
408 RUNTIME_FUNCTION(Runtime_NormalizeElements) { 409 RUNTIME_FUNCTION(Runtime_NormalizeElements) {
409 HandleScope scope(isolate); 410 HandleScope scope(isolate);
410 DCHECK(args.length() == 1); 411 DCHECK(args.length() == 1);
411 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 412 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
412 RUNTIME_ASSERT(!array->HasFixedTypedArrayElements() && 413 CHECK(!array->HasFixedTypedArrayElements());
413 !array->IsJSGlobalProxy()); 414 CHECK(!array->IsJSGlobalProxy());
414 JSObject::NormalizeElements(array); 415 JSObject::NormalizeElements(array);
415 return *array; 416 return *array;
416 } 417 }
417 418
418 419
419 // GrowArrayElements returns a sentinel Smi if the object was normalized. 420 // GrowArrayElements returns a sentinel Smi if the object was normalized.
420 RUNTIME_FUNCTION(Runtime_GrowArrayElements) { 421 RUNTIME_FUNCTION(Runtime_GrowArrayElements) {
421 HandleScope scope(isolate); 422 HandleScope scope(isolate);
422 DCHECK(args.length() == 2); 423 DCHECK(args.length() == 2);
423 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 424 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) { 504 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) {
504 HandleScope scope(isolate); 505 HandleScope scope(isolate);
505 DCHECK(args.length() == 1); 506 DCHECK(args.length() == 1);
506 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); 507 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0);
507 RETURN_RESULT_OR_FAILURE( 508 RETURN_RESULT_OR_FAILURE(
508 isolate, Object::ArraySpeciesConstructor(isolate, original_array)); 509 isolate, Object::ArraySpeciesConstructor(isolate, original_array));
509 } 510 }
510 511
511 } // namespace internal 512 } // namespace internal
512 } // namespace v8 513 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/runtime/runtime-literals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698