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

Side by Side 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: Addressed remaining issues. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | test/mjsunit/ensure-growing-store-learns.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 14879 matching lines...) Expand 10 before | Expand all | Expand 10 after
14890 ASSERT(arg_count == caller_args->length()); 14890 ASSERT(arg_count == caller_args->length());
14891 } 14891 }
14892 #endif 14892 #endif
14893 return ArrayConstructorCommon(isolate, 14893 return ArrayConstructorCommon(isolate,
14894 constructor, 14894 constructor,
14895 Handle<AllocationSite>::null(), 14895 Handle<AllocationSite>::null(),
14896 caller_args); 14896 caller_args);
14897 } 14897 }
14898 14898
14899 14899
14900 RUNTIME_FUNCTION(Runtime_GrowArrayElements) {
14901 HandleScope scope(isolate);
14902 ASSERT(args.length() == 3);
14903 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
14904 CONVERT_SMI_ARG_CHECKED(key, 1);
14905
14906 Handle<FixedArrayBase> elements(object->elements());
danno 2014/07/21 10:31:43 I guess this is function is OK, but it bothers me
14907 uint32_t capacity = static_cast<uint32_t>(elements->length());
14908 uint32_t unsigned_key = static_cast<uint32_t>(key);
14909
14910 if (unsigned_key >= capacity) {
14911 if ((unsigned_key - capacity) < JSObject::kMaxGap) {
14912 uint32_t new_capacity = JSObject::NewElementsCapacity(capacity);
14913 if (object->ShouldConvertToSlowElements(new_capacity)) {
14914 JSObject::NormalizeElements(object);
14915 return Smi::FromInt(0);
14916 }
14917 Handle<FixedArrayBase> new_elems;
14918 ElementsKind kind = object->GetElementsKind();
14919 if (IsFastDoubleElementsKind(kind)) {
14920 new_elems = isolate->factory()->NewFixedDoubleArray(new_capacity);
14921 } else {
14922 new_elems = isolate->factory()->NewFixedArray(new_capacity);
14923 }
14924 ElementsAccessor* accessor = object->GetElementsAccessor();
14925 accessor->CopyElements(object, new_elems, kind);
14926 Handle<Map> same_map = JSObject::GetElementsTransitionMap(object, kind);
14927 object->SetMapAndElements(object, same_map, new_elems);
14928 } else {
14929 JSObject::NormalizeElements(object);
14930 return Smi::FromInt(0);
14931 }
14932 }
14933
14934 // On success, return the fixed array elements.
14935 return object->elements();
14936 }
14937
14938
14900 RUNTIME_FUNCTION(Runtime_MaxSmi) { 14939 RUNTIME_FUNCTION(Runtime_MaxSmi) {
14901 ASSERT(args.length() == 0); 14940 ASSERT(args.length() == 0);
14902 return Smi::FromInt(Smi::kMaxValue); 14941 return Smi::FromInt(Smi::kMaxValue);
14903 } 14942 }
14904 14943
14905 14944
14906 // ---------------------------------------------------------------------------- 14945 // ----------------------------------------------------------------------------
14907 // Implementation of Runtime 14946 // Implementation of Runtime
14908 14947
14909 #define F(name, number_of_args, result_size) \ 14948 #define F(name, number_of_args, result_size) \
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
14961 } 15000 }
14962 return NULL; 15001 return NULL;
14963 } 15002 }
14964 15003
14965 15004
14966 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15005 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
14967 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15006 return &(kIntrinsicFunctions[static_cast<int>(id)]);
14968 } 15007 }
14969 15008
14970 } } // namespace v8::internal 15009 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/mjsunit/ensure-growing-store-learns.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698