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 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 uint32_t index = static_cast<uint32_t>(key); | 1251 uint32_t index = static_cast<uint32_t>(key); |
1252 | 1252 |
1253 if (index >= capacity) { | 1253 if (index >= capacity) { |
1254 if (object->WouldConvertToSlowElements(index)) { | 1254 if (object->WouldConvertToSlowElements(index)) { |
1255 // We don't want to allow operations that cause lazy deopt. Return a Smi | 1255 // We don't want to allow operations that cause lazy deopt. Return a Smi |
1256 // as a signal that optimized code should eagerly deoptimize. | 1256 // as a signal that optimized code should eagerly deoptimize. |
1257 return Smi::FromInt(0); | 1257 return Smi::FromInt(0); |
1258 } | 1258 } |
1259 | 1259 |
1260 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1); | 1260 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1); |
1261 ElementsKind kind = object->GetElementsKind(); | 1261 object->GetElementsAccessor()->GrowCapacityAndConvert(object, new_capacity); |
1262 if (IsFastDoubleElementsKind(kind)) { | |
1263 JSObject::SetFastDoubleElementsCapacity(object, new_capacity); | |
1264 } else { | |
1265 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode = | |
1266 object->HasFastSmiElements() ? JSObject::kAllowSmiElements | |
1267 : JSObject::kDontAllowSmiElements; | |
1268 JSObject::SetFastElementsCapacity(object, new_capacity, | |
1269 set_capacity_mode); | |
1270 } | |
1271 } | 1262 } |
1272 | 1263 |
1273 // On success, return the fixed array elements. | 1264 // On success, return the fixed array elements. |
1274 return object->elements(); | 1265 return object->elements(); |
1275 } | 1266 } |
1276 | 1267 |
1277 | 1268 |
1278 RUNTIME_FUNCTION(Runtime_HasComplexElements) { | 1269 RUNTIME_FUNCTION(Runtime_HasComplexElements) { |
1279 HandleScope scope(isolate); | 1270 HandleScope scope(isolate); |
1280 DCHECK(args.length() == 1); | 1271 DCHECK(args.length() == 1); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 | 1315 |
1325 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { | 1316 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { |
1326 SealHandleScope shs(isolate); | 1317 SealHandleScope shs(isolate); |
1327 DCHECK(args.length() == 2); | 1318 DCHECK(args.length() == 2); |
1328 // Returning undefined means that this fast path fails and one has to resort | 1319 // Returning undefined means that this fast path fails and one has to resort |
1329 // to a slow path. | 1320 // to a slow path. |
1330 return isolate->heap()->undefined_value(); | 1321 return isolate->heap()->undefined_value(); |
1331 } | 1322 } |
1332 } // namespace internal | 1323 } // namespace internal |
1333 } // namespace v8 | 1324 } // namespace v8 |
OLD | NEW |