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

Side by Side Diff: src/heap.cc

Issue 2870018: Add "has fast elements" bit to maps and use it in inlined keyed loads. (Closed)
Patch Set: More ARM fixes. Created 10 years, 6 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
« no previous file with comments | « src/factory.cc ('k') | src/ia32/codegen-ia32.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 map->set_instance_type(instance_type); 1210 map->set_instance_type(instance_type);
1211 map->set_prototype(null_value()); 1211 map->set_prototype(null_value());
1212 map->set_constructor(null_value()); 1212 map->set_constructor(null_value());
1213 map->set_instance_size(instance_size); 1213 map->set_instance_size(instance_size);
1214 map->set_inobject_properties(0); 1214 map->set_inobject_properties(0);
1215 map->set_pre_allocated_property_fields(0); 1215 map->set_pre_allocated_property_fields(0);
1216 map->set_instance_descriptors(empty_descriptor_array()); 1216 map->set_instance_descriptors(empty_descriptor_array());
1217 map->set_code_cache(empty_fixed_array()); 1217 map->set_code_cache(empty_fixed_array());
1218 map->set_unused_property_fields(0); 1218 map->set_unused_property_fields(0);
1219 map->set_bit_field(0); 1219 map->set_bit_field(0);
1220 map->set_bit_field2(1 << Map::kIsExtensible); 1220 map->set_bit_field2((1 << Map::kIsExtensible) | (1 << Map::kHasFastElements));
1221 1221
1222 // If the map object is aligned fill the padding area with Smi 0 objects. 1222 // If the map object is aligned fill the padding area with Smi 0 objects.
1223 if (Map::kPadStart < Map::kSize) { 1223 if (Map::kPadStart < Map::kSize) {
1224 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag, 1224 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag,
1225 0, 1225 0,
1226 Map::kSize - Map::kPadStart); 1226 Map::kSize - Map::kPadStart);
1227 } 1227 }
1228 return map; 1228 return map;
1229 } 1229 }
1230 1230
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2538 if (fun->has_instance_prototype()) { 2538 if (fun->has_instance_prototype()) {
2539 prototype = fun->instance_prototype(); 2539 prototype = fun->instance_prototype();
2540 } else { 2540 } else {
2541 prototype = AllocateFunctionPrototype(fun); 2541 prototype = AllocateFunctionPrototype(fun);
2542 if (prototype->IsFailure()) return prototype; 2542 if (prototype->IsFailure()) return prototype;
2543 } 2543 }
2544 Map* map = Map::cast(map_obj); 2544 Map* map = Map::cast(map_obj);
2545 map->set_inobject_properties(in_object_properties); 2545 map->set_inobject_properties(in_object_properties);
2546 map->set_unused_property_fields(in_object_properties); 2546 map->set_unused_property_fields(in_object_properties);
2547 map->set_prototype(prototype); 2547 map->set_prototype(prototype);
2548 ASSERT(map->has_fast_elements());
2548 2549
2549 // If the function has only simple this property assignments add 2550 // If the function has only simple this property assignments add
2550 // field descriptors for these to the initial map as the object 2551 // field descriptors for these to the initial map as the object
2551 // cannot be constructed without having these properties. Guard by 2552 // cannot be constructed without having these properties. Guard by
2552 // the inline_new flag so we only change the map if we generate a 2553 // the inline_new flag so we only change the map if we generate a
2553 // specialized construct stub. 2554 // specialized construct stub.
2554 ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields); 2555 ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields);
2555 if (fun->shared()->CanGenerateInlineConstructor(prototype)) { 2556 if (fun->shared()->CanGenerateInlineConstructor(prototype)) {
2556 int count = fun->shared()->this_property_assignments_count(); 2557 int count = fun->shared()->this_property_assignments_count();
2557 if (count > in_object_properties) { 2558 if (count > in_object_properties) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2591 // for example, JSArray::JSArrayVerify). 2592 // for example, JSArray::JSArrayVerify).
2592 obj->InitializeBody(map->instance_size()); 2593 obj->InitializeBody(map->instance_size());
2593 } 2594 }
2594 2595
2595 2596
2596 Object* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) { 2597 Object* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) {
2597 // JSFunctions should be allocated using AllocateFunction to be 2598 // JSFunctions should be allocated using AllocateFunction to be
2598 // properly initialized. 2599 // properly initialized.
2599 ASSERT(map->instance_type() != JS_FUNCTION_TYPE); 2600 ASSERT(map->instance_type() != JS_FUNCTION_TYPE);
2600 2601
2601 // Both types of globla objects should be allocated using 2602 // Both types of global objects should be allocated using
2602 // AllocateGloblaObject to be properly initialized. 2603 // AllocateGlobalObject to be properly initialized.
2603 ASSERT(map->instance_type() != JS_GLOBAL_OBJECT_TYPE); 2604 ASSERT(map->instance_type() != JS_GLOBAL_OBJECT_TYPE);
2604 ASSERT(map->instance_type() != JS_BUILTINS_OBJECT_TYPE); 2605 ASSERT(map->instance_type() != JS_BUILTINS_OBJECT_TYPE);
2605 2606
2606 // Allocate the backing storage for the properties. 2607 // Allocate the backing storage for the properties.
2607 int prop_size = 2608 int prop_size =
2608 map->pre_allocated_property_fields() + 2609 map->pre_allocated_property_fields() +
2609 map->unused_property_fields() - 2610 map->unused_property_fields() -
2610 map->inobject_properties(); 2611 map->inobject_properties();
2611 ASSERT(prop_size >= 0); 2612 ASSERT(prop_size >= 0);
2612 Object* properties = AllocateFixedArray(prop_size, pretenure); 2613 Object* properties = AllocateFixedArray(prop_size, pretenure);
2613 if (properties->IsFailure()) return properties; 2614 if (properties->IsFailure()) return properties;
2614 2615
2615 // Allocate the JSObject. 2616 // Allocate the JSObject.
2616 AllocationSpace space = 2617 AllocationSpace space =
2617 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; 2618 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE;
2618 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE; 2619 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE;
2619 Object* obj = Allocate(map, space); 2620 Object* obj = Allocate(map, space);
2620 if (obj->IsFailure()) return obj; 2621 if (obj->IsFailure()) return obj;
2621 2622
2622 // Initialize the JSObject. 2623 // Initialize the JSObject.
2623 InitializeJSObjectFromMap(JSObject::cast(obj), 2624 InitializeJSObjectFromMap(JSObject::cast(obj),
2624 FixedArray::cast(properties), 2625 FixedArray::cast(properties),
2625 map); 2626 map);
2627 ASSERT(JSObject::cast(obj)->HasFastElements());
2626 return obj; 2628 return obj;
2627 } 2629 }
2628 2630
2629 2631
2630 Object* Heap::AllocateJSObject(JSFunction* constructor, 2632 Object* Heap::AllocateJSObject(JSFunction* constructor,
2631 PretenureFlag pretenure) { 2633 PretenureFlag pretenure) {
2632 // Allocate the initial map if absent. 2634 // Allocate the initial map if absent.
2633 if (!constructor->has_initial_map()) { 2635 if (!constructor->has_initial_map()) {
2634 Object* initial_map = AllocateInitialMap(constructor); 2636 Object* initial_map = AllocateInitialMap(constructor);
2635 if (initial_map->IsFailure()) return initial_map; 2637 if (initial_map->IsFailure()) return initial_map;
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4769 void ExternalStringTable::TearDown() { 4771 void ExternalStringTable::TearDown() {
4770 new_space_strings_.Free(); 4772 new_space_strings_.Free();
4771 old_space_strings_.Free(); 4773 old_space_strings_.Free();
4772 } 4774 }
4773 4775
4774 4776
4775 List<Object*> ExternalStringTable::new_space_strings_; 4777 List<Object*> ExternalStringTable::new_space_strings_;
4776 List<Object*> ExternalStringTable::old_space_strings_; 4778 List<Object*> ExternalStringTable::old_space_strings_;
4777 4779
4778 } } // namespace v8::internal 4780 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698