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

Unified Diff: src/runtime/runtime-array.cc

Issue 368263003: Use a stub in crankshaft for grow store arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. Created 6 years, 1 month 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 523d8f5faa30653a0aae97e5d58096ef53bd3c4c..29890b15580df4f5d39ba35122fcd161fbcf8f3a 100644
--- a/src/runtime/runtime-array.cc
+++ b/src/runtime/runtime-array.cc
@@ -1055,6 +1055,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