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

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: 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 unified diff | Download patch | Annotate | Revision Log
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 14997 matching lines...) Expand 10 before | Expand all | Expand 10 after
15008 ASSERT(arg_count == caller_args->length()); 15008 ASSERT(arg_count == caller_args->length());
15009 } 15009 }
15010 #endif 15010 #endif
15011 return ArrayConstructorCommon(isolate, 15011 return ArrayConstructorCommon(isolate,
15012 constructor, 15012 constructor,
15013 Handle<AllocationSite>::null(), 15013 Handle<AllocationSite>::null(),
15014 caller_args); 15014 caller_args);
15015 } 15015 }
15016 15016
15017 15017
15018 RUNTIME_FUNCTION(Runtime_GrowArrayElements) {
15019 HandleScope scope(isolate);
15020 ASSERT(args.length() == 3);
15021 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
15022 CONVERT_SMI_ARG_CHECKED(key, 1);
15023
15024 Handle<FixedArrayBase> elements(object->elements());
15025 uint32_t capacity = static_cast<uint32_t>(elements->length());
15026 uint32_t unsigned_key = static_cast<uint32_t>(key);
15027
15028 if (unsigned_key >= capacity) {
15029 if ((unsigned_key - capacity) < JSObject::kMaxGap) {
15030 uint32_t new_capacity = JSObject::NewElementsCapacity(capacity);
15031 if (object->ShouldConvertToSlowElements(new_capacity)) {
15032 JSObject::NormalizeElements(object);
15033 return Smi::FromInt(0);
15034 }
15035 Handle<FixedArrayBase> new_elems;
15036 ElementsKind kind = object->GetElementsKind();
15037 if (IsFastDoubleElementsKind(kind)) {
15038 new_elems = isolate->factory()->NewFixedDoubleArray(new_capacity);
15039 } else {
15040 new_elems = isolate->factory()->NewFixedArray(new_capacity);
15041 }
15042 ElementsAccessor* accessor = object->GetElementsAccessor();
15043 accessor->CopyElements(object, new_elems, kind);
15044 Handle<Map> same_map = JSObject::GetElementsTransitionMap(object, kind);
15045 object->SetMapAndElements(object, same_map, new_elems);
15046 } else {
15047 JSObject::NormalizeElements(object);
15048 return Smi::FromInt(0);
15049 }
15050 }
15051
15052 // On success, return the fixed array elements.
15053 return object->elements();
15054 }
15055
15056
15018 RUNTIME_FUNCTION(Runtime_MaxSmi) { 15057 RUNTIME_FUNCTION(Runtime_MaxSmi) {
15019 ASSERT(args.length() == 0); 15058 ASSERT(args.length() == 0);
15020 return Smi::FromInt(Smi::kMaxValue); 15059 return Smi::FromInt(Smi::kMaxValue);
15021 } 15060 }
15022 15061
15023 15062
15024 // ---------------------------------------------------------------------------- 15063 // ----------------------------------------------------------------------------
15025 // Implementation of Runtime 15064 // Implementation of Runtime
15026 15065
15027 #define F(name, number_of_args, result_size) \ 15066 #define F(name, number_of_args, result_size) \
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
15079 } 15118 }
15080 return NULL; 15119 return NULL;
15081 } 15120 }
15082 15121
15083 15122
15084 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15123 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15085 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15124 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15086 } 15125 }
15087 15126
15088 } } // namespace v8::internal 15127 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698