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

Side by Side Diff: src/objects.cc

Issue 10824079: Use a special EnumLength field to indicate number of valid enum cache values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 8 years, 3 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/objects.h ('k') | src/utils.h » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4131 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 // it is no proxy, has no interceptors and needs no access checks). 4142 // it is no proxy, has no interceptors and needs no access checks).
4143 // - This object has no elements. 4143 // - This object has no elements.
4144 // - No prototype has enumerable properties/elements. 4144 // - No prototype has enumerable properties/elements.
4145 bool JSReceiver::IsSimpleEnum() { 4145 bool JSReceiver::IsSimpleEnum() {
4146 Heap* heap = GetHeap(); 4146 Heap* heap = GetHeap();
4147 for (Object* o = this; 4147 for (Object* o = this;
4148 o != heap->null_value(); 4148 o != heap->null_value();
4149 o = JSObject::cast(o)->GetPrototype()) { 4149 o = JSObject::cast(o)->GetPrototype()) {
4150 if (!o->IsJSObject()) return false; 4150 if (!o->IsJSObject()) return false;
4151 JSObject* curr = JSObject::cast(o); 4151 JSObject* curr = JSObject::cast(o);
4152 if (!curr->map()->instance_descriptors()->HasEnumCache()) return false; 4152 int enum_length = curr->map()->EnumLength();
4153 if (enum_length == Map::kInvalidEnumCache) return false;
4153 ASSERT(!curr->HasNamedInterceptor()); 4154 ASSERT(!curr->HasNamedInterceptor());
4154 ASSERT(!curr->HasIndexedInterceptor()); 4155 ASSERT(!curr->HasIndexedInterceptor());
4155 ASSERT(!curr->IsAccessCheckNeeded()); 4156 ASSERT(!curr->IsAccessCheckNeeded());
4156 if (curr->NumberOfEnumElements() > 0) return false; 4157 if (curr->NumberOfEnumElements() > 0) return false;
4157 if (curr != this) { 4158 if (curr != this && enum_length != 0) return false;
4158 FixedArray* curr_fixed_array =
4159 FixedArray::cast(curr->map()->instance_descriptors()->GetEnumCache());
4160 if (curr_fixed_array->length() > 0) return false;
4161 }
4162 } 4159 }
4163 return true; 4160 return true;
4164 } 4161 }
4165 4162
4166 4163
4167 void Map::SetDescriptors(Handle<Map> map, 4164 void Map::SetDescriptors(Handle<Map> map,
4168 Handle<DescriptorArray> descriptors) { 4165 Handle<DescriptorArray> descriptors) {
4169 Isolate* isolate = map->GetIsolate(); 4166 Isolate* isolate = map->GetIsolate();
4170 CALL_HEAP_FUNCTION_VOID(isolate, map->SetDescriptors(*descriptors)); 4167 CALL_HEAP_FUNCTION_VOID(isolate, map->SetDescriptors(*descriptors));
4171 } 4168 }
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
4842 MaybeObject* maybe_result = 4839 MaybeObject* maybe_result =
4843 GetHeap()->AllocateMap(instance_type(), instance_size); 4840 GetHeap()->AllocateMap(instance_type(), instance_size);
4844 if (!maybe_result->To(&result)) return maybe_result; 4841 if (!maybe_result->To(&result)) return maybe_result;
4845 4842
4846 result->set_prototype(prototype()); 4843 result->set_prototype(prototype());
4847 result->set_constructor(constructor()); 4844 result->set_constructor(constructor());
4848 result->set_bit_field(bit_field()); 4845 result->set_bit_field(bit_field());
4849 result->set_bit_field2(bit_field2()); 4846 result->set_bit_field2(bit_field2());
4850 result->set_bit_field3(bit_field3()); 4847 result->set_bit_field3(bit_field3());
4851 result->SetNumberOfOwnDescriptors(0); 4848 result->SetNumberOfOwnDescriptors(0);
4849 result->SetEnumLength(kInvalidEnumCache);
4852 return result; 4850 return result;
4853 } 4851 }
4854 4852
4855 4853
4856 MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode, 4854 MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode,
4857 NormalizedMapSharingMode sharing) { 4855 NormalizedMapSharingMode sharing) {
4858 int new_instance_size = instance_size(); 4856 int new_instance_size = instance_size();
4859 if (mode == CLEAR_INOBJECT_PROPERTIES) { 4857 if (mode == CLEAR_INOBJECT_PROPERTIES) {
4860 new_instance_size -= inobject_properties() * kPointerSize; 4858 new_instance_size -= inobject_properties() * kPointerSize;
4861 } 4859 }
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
5768 #endif 5766 #endif
5769 return result; 5767 return result;
5770 } 5768 }
5771 5769
5772 5770
5773 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) { 5771 MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) {
5774 ElementsAccessor* accessor = ElementsAccessor::ForArray(other); 5772 ElementsAccessor* accessor = ElementsAccessor::ForArray(other);
5775 MaybeObject* maybe_result = 5773 MaybeObject* maybe_result =
5776 accessor->AddElementsToFixedArray(NULL, NULL, this, other); 5774 accessor->AddElementsToFixedArray(NULL, NULL, this, other);
5777 FixedArray* result; 5775 FixedArray* result;
5778 if (!maybe_result->To<FixedArray>(&result)) return maybe_result; 5776 if (!maybe_result->To(&result)) return maybe_result;
5779 #ifdef DEBUG 5777 #ifdef DEBUG
5780 if (FLAG_enable_slow_asserts) { 5778 if (FLAG_enable_slow_asserts) {
5781 for (int i = 0; i < result->length(); i++) { 5779 for (int i = 0; i < result->length(); i++) {
5782 Object* current = result->get(i); 5780 Object* current = result->get(i);
5783 ASSERT(current->IsNumber() || current->IsString()); 5781 ASSERT(current->IsNumber() || current->IsString());
5784 } 5782 }
5785 } 5783 }
5786 #endif 5784 #endif
5787 return result; 5785 return result;
5788 } 5786 }
(...skipping 7355 matching lines...) Expand 10 before | Expand all | Expand 10 after
13144 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13142 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13145 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13143 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13146 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13144 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13147 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13145 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13148 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13146 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13149 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13147 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13150 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13148 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13151 } 13149 }
13152 13150
13153 } } // namespace v8::internal 13151 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698