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

Side by Side Diff: src/objects-inl.h

Issue 3522008: This is a little experiment to move Failure to a superclass above Object... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 2 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.cc ('k') | src/property.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 } 1197 }
1198 1198
1199 1199
1200 void JSObject::initialize_elements() { 1200 void JSObject::initialize_elements() {
1201 ASSERT(map()->has_fast_elements()); 1201 ASSERT(map()->has_fast_elements());
1202 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); 1202 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array()));
1203 WRITE_FIELD(this, kElementsOffset, Heap::empty_fixed_array()); 1203 WRITE_FIELD(this, kElementsOffset, Heap::empty_fixed_array());
1204 } 1204 }
1205 1205
1206 1206
1207 Object* obj;
1208 { TryAllocation t = map()->GetFastElementsMap();
1209 if (!t->ToObject(&obj)) return t;
1210 }
1207 Object* JSObject::ResetElements() { 1211 Object* JSObject::ResetElements() {
1208 Object* obj = map()->GetFastElementsMap();
1209 if (obj->IsFailure()) return obj;
1210 set_map(Map::cast(obj)); 1212 set_map(Map::cast(obj));
1211 initialize_elements(); 1213 initialize_elements();
1212 return this; 1214 return this;
1213 } 1215 }
1214 1216
1215 1217
1216 ACCESSORS(Oddball, to_string, String, kToStringOffset) 1218 ACCESSORS(Oddball, to_string, String, kToStringOffset)
1217 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) 1219 ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
1218 1220
1219 1221
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 2477
2476 2478
2477 void Map::set_prototype(Object* value, WriteBarrierMode mode) { 2479 void Map::set_prototype(Object* value, WriteBarrierMode mode) {
2478 ASSERT(value->IsNull() || value->IsJSObject()); 2480 ASSERT(value->IsNull() || value->IsJSObject());
2479 WRITE_FIELD(this, kPrototypeOffset, value); 2481 WRITE_FIELD(this, kPrototypeOffset, value);
2480 CONDITIONAL_WRITE_BARRIER(this, kPrototypeOffset, mode); 2482 CONDITIONAL_WRITE_BARRIER(this, kPrototypeOffset, mode);
2481 } 2483 }
2482 2484
2483 2485
2484 Object* Map::GetFastElementsMap() { 2486 Object* Map::GetFastElementsMap() {
2487 Object* obj;
2488 { TryAllocation t = CopyDropTransitions();
2489 if (!t->ToObject(&obj)) return t;
2490 }
2485 if (has_fast_elements()) return this; 2491 if (has_fast_elements()) return this;
2486 Object* obj = CopyDropTransitions();
2487 if (obj->IsFailure()) return obj;
2488 Map* new_map = Map::cast(obj); 2492 Map* new_map = Map::cast(obj);
2489 new_map->set_has_fast_elements(true); 2493 new_map->set_has_fast_elements(true);
2490 Counters::map_slow_to_fast_elements.Increment(); 2494 Counters::map_slow_to_fast_elements.Increment();
2491 return new_map; 2495 return new_map;
2492 } 2496 }
2493 2497
2494 2498
2495 Object* Map::GetSlowElementsMap() { 2499 Object* Map::GetSlowElementsMap() {
2500 Object* obj;
2501 { TryAllocation t = CopyDropTransitions();
2502 if (!t->ToObject(&obj)) return t;
2503 }
2496 if (!has_fast_elements()) return this; 2504 if (!has_fast_elements()) return this;
2497 Object* obj = CopyDropTransitions();
2498 if (obj->IsFailure()) return obj;
2499 Map* new_map = Map::cast(obj); 2505 Map* new_map = Map::cast(obj);
2500 new_map->set_has_fast_elements(false); 2506 new_map->set_has_fast_elements(false);
2501 Counters::map_fast_to_slow_elements.Increment(); 2507 Counters::map_fast_to_slow_elements.Increment();
2502 return new_map; 2508 return new_map;
2503 } 2509 }
2504 2510
2505 2511
2506 ACCESSORS(Map, instance_descriptors, DescriptorArray, 2512 ACCESSORS(Map, instance_descriptors, DescriptorArray,
2507 kInstanceDescriptorsOffset) 2513 kInstanceDescriptorsOffset)
2508 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) 2514 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset)
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 bool result = elements()->IsFixedArray(); 3198 bool result = elements()->IsFixedArray();
3193 ASSERT(result == (!HasPixelElements() && !HasExternalArrayElements())); 3199 ASSERT(result == (!HasPixelElements() && !HasExternalArrayElements()));
3194 return result; 3200 return result;
3195 } 3201 }
3196 3202
3197 3203
3198 Object* JSObject::EnsureWritableFastElements() { 3204 Object* JSObject::EnsureWritableFastElements() {
3199 ASSERT(HasFastElements()); 3205 ASSERT(HasFastElements());
3200 FixedArray* elems = FixedArray::cast(elements()); 3206 FixedArray* elems = FixedArray::cast(elements());
3201 if (elems->map() != Heap::fixed_cow_array_map()) return elems; 3207 if (elems->map() != Heap::fixed_cow_array_map()) return elems;
3202 Object* writable_elems = Heap::CopyFixedArrayWithMap(elems, 3208 Object* writable_elems;
3203 Heap::fixed_array_map()); 3209 { TryAllocation t = Heap::CopyFixedArrayWithMap(elems,
3204 if (writable_elems->IsFailure()) return writable_elems; 3210 Heap::fixed_array_map() );
3211 if (!t->ToObject(&writable_elems)) return t;
3212 }
3205 set_elements(FixedArray::cast(writable_elems)); 3213 set_elements(FixedArray::cast(writable_elems));
3206 Counters::cow_arrays_converted.Increment(); 3214 Counters::cow_arrays_converted.Increment();
3207 return writable_elems; 3215 return writable_elems;
3208 } 3216 }
3209 3217
3210 3218
3211 StringDictionary* JSObject::property_dictionary() { 3219 StringDictionary* JSObject::property_dictionary() {
3212 ASSERT(!HasFastProperties()); 3220 ASSERT(!HasFastProperties());
3213 return StringDictionary::cast(properties()); 3221 return StringDictionary::cast(properties());
3214 } 3222 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 #undef WRITE_INT_FIELD 3558 #undef WRITE_INT_FIELD
3551 #undef READ_SHORT_FIELD 3559 #undef READ_SHORT_FIELD
3552 #undef WRITE_SHORT_FIELD 3560 #undef WRITE_SHORT_FIELD
3553 #undef READ_BYTE_FIELD 3561 #undef READ_BYTE_FIELD
3554 #undef WRITE_BYTE_FIELD 3562 #undef WRITE_BYTE_FIELD
3555 3563
3556 3564
3557 } } // namespace v8::internal 3565 } } // namespace v8::internal
3558 3566
3559 #endif // V8_OBJECTS_INL_H_ 3567 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698