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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/interface-descriptors-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-array.cc
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc
index 6f8044369a8c318e275cdb0df42fd48bb18b0e1f..8391f451585e34e4cd4ecd6a1f5e12d520e6121d 100644
--- a/src/runtime/runtime-array.cc
+++ b/src/runtime/runtime-array.cc
@@ -1218,6 +1218,44 @@ RUNTIME_FUNCTION(Runtime_NormalizeElements) {
}
+// GrowArrayElements returns a sentinel Smi if the object was normalized.
+RUNTIME_FUNCTION(Runtime_GrowArrayElements) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 3);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_SMI_ARG_CHECKED(key, 1);
+
+ if (key < 0) {
+ return object->elements();
+ }
+
+ uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
+ uint32_t index = static_cast<uint32_t>(key);
+
+ if (index >= capacity) {
+ if (object->WouldConvertToSlowElements(index)) {
+ JSObject::NormalizeElements(object);
+ return Smi::FromInt(0);
+ }
+
+ uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1);
+ ElementsKind kind = object->GetElementsKind();
+ if (IsFastDoubleElementsKind(kind)) {
+ JSObject::SetFastDoubleElementsCapacity(object, new_capacity);
+ } else {
+ JSObject::SetFastElementsCapacitySmiMode set_capacity_mode =
+ object->HasFastSmiElements() ? JSObject::kAllowSmiElements
+ : JSObject::kDontAllowSmiElements;
+ JSObject::SetFastElementsCapacity(object, new_capacity,
+ set_capacity_mode);
+ }
+ }
+
+ // On success, return the fixed array elements.
+ return object->elements();
+}
+
+
RUNTIME_FUNCTION(Runtime_HasComplexElements) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
« 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