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

Unified Diff: src/runtime.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: Performance fixes. Created 6 years, 5 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
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 888f665d21c8d8ab126a7d0ff9703d534094d5aa..4958094c3af46303c47aed8a87a06222e11429e0 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -15015,6 +15015,45 @@ RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) {
}
+RUNTIME_FUNCTION(Runtime_GrowArrayElements) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 3);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_SMI_ARG_CHECKED(key, 1);
+
+ Handle<FixedArrayBase> elements(object->elements());
+ uint32_t capacity = static_cast<uint32_t>(elements->length());
+ uint32_t unsigned_key = static_cast<uint32_t>(key);
+
+ if (unsigned_key >= capacity) {
+ if ((unsigned_key - capacity) < JSObject::kMaxGap) {
+ uint32_t new_capacity = JSObject::NewElementsCapacity(capacity);
+ if (object->ShouldConvertToSlowElements(new_capacity)) {
+ JSObject::NormalizeElements(object);
+ return Smi::FromInt(0);
+ }
+ Handle<FixedArrayBase> new_elems;
+ ElementsKind kind = object->GetElementsKind();
+ if (IsFastDoubleElementsKind(kind)) {
+ new_elems = isolate->factory()->NewFixedDoubleArray(new_capacity);
+ } else {
+ new_elems = isolate->factory()->NewFixedArray(new_capacity);
+ }
+ ElementsAccessor* accessor = object->GetElementsAccessor();
+ accessor->CopyElements(object, new_elems, kind);
+ Handle<Map> same_map = JSObject::GetElementsTransitionMap(object, kind);
+ object->SetMapAndElements(object, same_map, new_elems);
+ } else {
+ JSObject::NormalizeElements(object);
+ return Smi::FromInt(0);
+ }
+ }
+
+ // On success, return the fixed array elements.
+ return object->elements();
+}
+
+
RUNTIME_FUNCTION(Runtime_MaxSmi) {
ASSERT(args.length() == 0);
return Smi::FromInt(Smi::kMaxValue);

Powered by Google App Engine
This is Rietveld 408576698