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

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

Issue 1109333003: Use a stub in crankshaft for grow store arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ARM failure. Created 5 years, 7 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/x64/interface-descriptors-x64.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/runtime/runtime-utils.h" 8 #include "src/runtime/runtime-utils.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 DCHECK(args.length() == 1); 1211 DCHECK(args.length() == 1);
1212 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 1212 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
1213 RUNTIME_ASSERT(!array->HasExternalArrayElements() && 1213 RUNTIME_ASSERT(!array->HasExternalArrayElements() &&
1214 !array->HasFixedTypedArrayElements() && 1214 !array->HasFixedTypedArrayElements() &&
1215 !array->IsJSGlobalProxy()); 1215 !array->IsJSGlobalProxy());
1216 JSObject::NormalizeElements(array); 1216 JSObject::NormalizeElements(array);
1217 return *array; 1217 return *array;
1218 } 1218 }
1219 1219
1220 1220
1221 // GrowArrayElements returns a sentinel Smi if the object was normalized.
1222 RUNTIME_FUNCTION(Runtime_GrowArrayElements) {
1223 HandleScope scope(isolate);
1224 DCHECK(args.length() == 3);
1225 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
1226 CONVERT_SMI_ARG_CHECKED(key, 1);
1227
1228 if (key < 0) {
1229 return object->elements();
1230 }
1231
1232 uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
1233 uint32_t index = static_cast<uint32_t>(key);
1234
1235 if (index >= capacity) {
1236 if (object->WouldConvertToSlowElements(index)) {
1237 JSObject::NormalizeElements(object);
1238 return Smi::FromInt(0);
1239 }
1240
1241 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1);
1242 ElementsKind kind = object->GetElementsKind();
1243 if (IsFastDoubleElementsKind(kind)) {
1244 JSObject::SetFastDoubleElementsCapacity(object, new_capacity);
1245 } else {
1246 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode =
1247 object->HasFastSmiElements() ? JSObject::kAllowSmiElements
1248 : JSObject::kDontAllowSmiElements;
1249 JSObject::SetFastElementsCapacity(object, new_capacity,
1250 set_capacity_mode);
1251 }
1252 }
1253
1254 // On success, return the fixed array elements.
1255 return object->elements();
1256 }
1257
1258
1221 RUNTIME_FUNCTION(Runtime_HasComplexElements) { 1259 RUNTIME_FUNCTION(Runtime_HasComplexElements) {
1222 HandleScope scope(isolate); 1260 HandleScope scope(isolate);
1223 DCHECK(args.length() == 1); 1261 DCHECK(args.length() == 1);
1224 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 1262 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
1225 for (PrototypeIterator iter(isolate, array, 1263 for (PrototypeIterator iter(isolate, array,
1226 PrototypeIterator::START_AT_RECEIVER); 1264 PrototypeIterator::START_AT_RECEIVER);
1227 !iter.IsAtEnd(); iter.Advance()) { 1265 !iter.IsAtEnd(); iter.Advance()) {
1228 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { 1266 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) {
1229 return isolate->heap()->true_value(); 1267 return isolate->heap()->true_value();
1230 } 1268 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 1392
1355 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { 1393 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) {
1356 SealHandleScope shs(isolate); 1394 SealHandleScope shs(isolate);
1357 DCHECK(args.length() == 2); 1395 DCHECK(args.length() == 2);
1358 // Returning undefined means that this fast path fails and one has to resort 1396 // Returning undefined means that this fast path fails and one has to resort
1359 // to a slow path. 1397 // to a slow path.
1360 return isolate->heap()->undefined_value(); 1398 return isolate->heap()->undefined_value();
1361 } 1399 }
1362 } 1400 }
1363 } // namespace v8::internal 1401 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/interface-descriptors-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698