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

Unified Diff: src/objects.cc

Issue 2196533003: [api] Cleaning up: Replace NeanderArray with FixedArray implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mind the pointers Created 4 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 9f5fd65471cbcfb5812071b9c095759f929810d5..38deeb825d4b291c707d5e76c1f3cffbf4f1b94a 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1031,6 +1031,26 @@ bool FunctionTemplateInfo::IsTemplateFor(Map* map) {
// static
+Handle<TemplateList> TemplateList::New(Isolate* isolate, int size) {
+ Handle<FixedArray> list =
+ isolate->factory()->NewFixedArray(kLengthIndex + size);
+ list->set(kLengthIndex, Smi::FromInt(0));
+ return Handle<TemplateList>::cast(list);
+}
+
+// static
+Handle<TemplateList> TemplateList::Add(Isolate* isolate,
+ Handle<TemplateList> list,
+ Handle<i::Object> value) {
+ STATIC_ASSERT(kFirstElementIndex == 1);
+ int index = list->length() + 1;
+ Handle<i::FixedArray> fixed_array = Handle<FixedArray>::cast(list);
+ fixed_array = FixedArray::SetAndGrow(fixed_array, index, value);
+ fixed_array->set(kLengthIndex, Smi::FromInt(index));
+ return Handle<TemplateList>::cast(fixed_array);
+}
+
+// static
MaybeHandle<JSObject> JSObject::New(Handle<JSFunction> constructor,
Handle<JSReceiver> new_target,
Handle<AllocationSite> site) {
@@ -4771,9 +4791,8 @@ void Map::EnsureDescriptorSlack(Handle<Map> map, int slack) {
map->UpdateDescriptors(*new_descriptors, layout_descriptor);
}
-
-template<class T>
-static int AppendUniqueCallbacks(NeanderArray* callbacks,
+template <class T>
+static int AppendUniqueCallbacks(Handle<TemplateList> callbacks,
Handle<typename T::Array> array,
int valid_descriptors) {
int nof_callbacks = callbacks->length();
@@ -4852,9 +4871,9 @@ void Map::AppendCallbackDescriptors(Handle<Map> map,
Handle<Object> descriptors) {
int nof = map->NumberOfOwnDescriptors();
Handle<DescriptorArray> array(map->instance_descriptors());
- NeanderArray callbacks(descriptors);
- DCHECK(array->NumberOfSlackDescriptors() >= callbacks.length());
- nof = AppendUniqueCallbacks<DescriptorArrayAppender>(&callbacks, array, nof);
+ Handle<TemplateList> callbacks = Handle<TemplateList>::cast(descriptors);
+ DCHECK_GE(array->NumberOfSlackDescriptors(), callbacks->length());
+ nof = AppendUniqueCallbacks<DescriptorArrayAppender>(callbacks, array, nof);
map->SetNumberOfOwnDescriptors(nof);
}
@@ -4862,10 +4881,9 @@ void Map::AppendCallbackDescriptors(Handle<Map> map,
int AccessorInfo::AppendUnique(Handle<Object> descriptors,
Handle<FixedArray> array,
int valid_descriptors) {
- NeanderArray callbacks(descriptors);
- DCHECK(array->length() >= callbacks.length() + valid_descriptors);
- return AppendUniqueCallbacks<FixedArrayAppender>(&callbacks,
- array,
+ Handle<TemplateList> callbacks = Handle<TemplateList>::cast(descriptors);
+ DCHECK_GE(array->length(), callbacks->length() + valid_descriptors);
+ return AppendUniqueCallbacks<FixedArrayAppender>(callbacks, array,
valid_descriptors);
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698