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

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

Issue 1141163004: Bug: Runtime_GrowArrayElements provoked unnecessary lazy deopt. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added test. 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 | « no previous file | test/mjsunit/regress/regress-488398.js » ('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/messages.h" 8 #include "src/messages.h"
9 #include "src/runtime/runtime-utils.h" 9 #include "src/runtime/runtime-utils.h"
10 10
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 1247
1248 if (key < 0) { 1248 if (key < 0) {
1249 return object->elements(); 1249 return object->elements();
1250 } 1250 }
1251 1251
1252 uint32_t capacity = static_cast<uint32_t>(object->elements()->length()); 1252 uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
1253 uint32_t index = static_cast<uint32_t>(key); 1253 uint32_t index = static_cast<uint32_t>(key);
1254 1254
1255 if (index >= capacity) { 1255 if (index >= capacity) {
1256 if (object->WouldConvertToSlowElements(index)) { 1256 if (object->WouldConvertToSlowElements(index)) {
1257 JSObject::NormalizeElements(object); 1257 // We don't want to allow operations that cause lazy deopt. Return a Smi
1258 // as a signal that optimized code should eagerly deoptimize.
1258 return Smi::FromInt(0); 1259 return Smi::FromInt(0);
1259 } 1260 }
1260 1261
1261 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1); 1262 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1);
1262 ElementsKind kind = object->GetElementsKind(); 1263 ElementsKind kind = object->GetElementsKind();
1263 if (IsFastDoubleElementsKind(kind)) { 1264 if (IsFastDoubleElementsKind(kind)) {
1264 JSObject::SetFastDoubleElementsCapacity(object, new_capacity); 1265 JSObject::SetFastDoubleElementsCapacity(object, new_capacity);
1265 } else { 1266 } else {
1266 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode = 1267 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode =
1267 object->HasFastSmiElements() ? JSObject::kAllowSmiElements 1268 object->HasFastSmiElements() ? JSObject::kAllowSmiElements
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 1413
1413 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { 1414 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) {
1414 SealHandleScope shs(isolate); 1415 SealHandleScope shs(isolate);
1415 DCHECK(args.length() == 2); 1416 DCHECK(args.length() == 2);
1416 // Returning undefined means that this fast path fails and one has to resort 1417 // Returning undefined means that this fast path fails and one has to resort
1417 // to a slow path. 1418 // to a slow path.
1418 return isolate->heap()->undefined_value(); 1419 return isolate->heap()->undefined_value();
1419 } 1420 }
1420 } 1421 }
1421 } // namespace v8::internal 1422 } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-488398.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698