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

Side by Side Diff: src/heap.cc

Issue 7901016: Basic support for tracking smi-only arrays on ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ready to land Created 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); 1693 StaticVisitorBase::GetVisitorId(instance_type, instance_size));
1694 reinterpret_cast<Map*>(result)->set_inobject_properties(0); 1694 reinterpret_cast<Map*>(result)->set_inobject_properties(0);
1695 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); 1695 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0);
1696 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); 1696 reinterpret_cast<Map*>(result)->set_unused_property_fields(0);
1697 reinterpret_cast<Map*>(result)->set_bit_field(0); 1697 reinterpret_cast<Map*>(result)->set_bit_field(0);
1698 reinterpret_cast<Map*>(result)->set_bit_field2(0); 1698 reinterpret_cast<Map*>(result)->set_bit_field2(0);
1699 return result; 1699 return result;
1700 } 1700 }
1701 1701
1702 1702
1703 MaybeObject* Heap::AllocateMap(InstanceType instance_type, int instance_size) { 1703 MaybeObject* Heap::AllocateMap(InstanceType instance_type,
1704 int instance_size,
1705 ElementsKind elements_kind) {
1704 Object* result; 1706 Object* result;
1705 { MaybeObject* maybe_result = AllocateRawMap(); 1707 { MaybeObject* maybe_result = AllocateRawMap();
1706 if (!maybe_result->ToObject(&result)) return maybe_result; 1708 if (!maybe_result->ToObject(&result)) return maybe_result;
1707 } 1709 }
1708 1710
1709 Map* map = reinterpret_cast<Map*>(result); 1711 Map* map = reinterpret_cast<Map*>(result);
1710 map->set_map(meta_map()); 1712 map->set_map(meta_map());
1711 map->set_instance_type(instance_type); 1713 map->set_instance_type(instance_type);
1712 map->set_visitor_id( 1714 map->set_visitor_id(
1713 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); 1715 StaticVisitorBase::GetVisitorId(instance_type, instance_size));
1714 map->set_prototype(null_value()); 1716 map->set_prototype(null_value());
1715 map->set_constructor(null_value()); 1717 map->set_constructor(null_value());
1716 map->set_instance_size(instance_size); 1718 map->set_instance_size(instance_size);
1717 map->set_inobject_properties(0); 1719 map->set_inobject_properties(0);
1718 map->set_pre_allocated_property_fields(0); 1720 map->set_pre_allocated_property_fields(0);
1719 map->init_instance_descriptors(); 1721 map->init_instance_descriptors();
1720 map->set_code_cache(empty_fixed_array()); 1722 map->set_code_cache(empty_fixed_array());
1721 map->set_prototype_transitions(empty_fixed_array()); 1723 map->set_prototype_transitions(empty_fixed_array());
1722 map->set_unused_property_fields(0); 1724 map->set_unused_property_fields(0);
1723 map->set_bit_field(0); 1725 map->set_bit_field(0);
1724 map->set_bit_field2(1 << Map::kIsExtensible); 1726 map->set_bit_field2(1 << Map::kIsExtensible);
1725 map->set_elements_kind(FAST_ELEMENTS); 1727 map->set_elements_kind(elements_kind);
1726 1728
1727 // If the map object is aligned fill the padding area with Smi 0 objects. 1729 // If the map object is aligned fill the padding area with Smi 0 objects.
1728 if (Map::kPadStart < Map::kSize) { 1730 if (Map::kPadStart < Map::kSize) {
1729 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag, 1731 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag,
1730 0, 1732 0,
1731 Map::kSize - Map::kPadStart); 1733 Map::kSize - Map::kPadStart);
1732 } 1734 }
1733 return map; 1735 return map;
1734 } 1736 }
1735 1737
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 return Oddball::cast(result)->Initialize(to_string, to_number, kind); 2107 return Oddball::cast(result)->Initialize(to_string, to_number, kind);
2106 } 2108 }
2107 2109
2108 2110
2109 bool Heap::CreateApiObjects() { 2111 bool Heap::CreateApiObjects() {
2110 Object* obj; 2112 Object* obj;
2111 2113
2112 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 2114 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
2113 if (!maybe_obj->ToObject(&obj)) return false; 2115 if (!maybe_obj->ToObject(&obj)) return false;
2114 } 2116 }
2115 set_neander_map(Map::cast(obj)); 2117 // Don't use Smi-only elements optimizations for objects with the neander
2118 // map. There are too many cases where element values are set directly with a
2119 // bottleneck to trap the Smi-only -> fast elements transition, and there
2120 // appears to be no benefit for optimize this case.
2121 Map* new_neander_map = Map::cast(obj);
2122 new_neander_map->set_elements_kind(FAST_ELEMENTS);
2123 set_neander_map(new_neander_map);
2116 2124
2117 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(neander_map()); 2125 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(neander_map());
2118 if (!maybe_obj->ToObject(&obj)) return false; 2126 if (!maybe_obj->ToObject(&obj)) return false;
2119 } 2127 }
2120 Object* elements; 2128 Object* elements;
2121 { MaybeObject* maybe_elements = AllocateFixedArray(2); 2129 { MaybeObject* maybe_elements = AllocateFixedArray(2);
2122 if (!maybe_elements->ToObject(&elements)) return false; 2130 if (!maybe_elements->ToObject(&elements)) return false;
2123 } 2131 }
2124 FixedArray::cast(elements)->set(0, Smi::FromInt(0)); 2132 FixedArray::cast(elements)->set(0, Smi::FromInt(0));
2125 JSObject::cast(obj)->set_elements(FixedArray::cast(elements)); 2133 JSObject::cast(obj)->set_elements(FixedArray::cast(elements));
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3496 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE; 3504 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE;
3497 Object* obj; 3505 Object* obj;
3498 { MaybeObject* maybe_obj = Allocate(map, space); 3506 { MaybeObject* maybe_obj = Allocate(map, space);
3499 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 3507 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3500 } 3508 }
3501 3509
3502 // Initialize the JSObject. 3510 // Initialize the JSObject.
3503 InitializeJSObjectFromMap(JSObject::cast(obj), 3511 InitializeJSObjectFromMap(JSObject::cast(obj),
3504 FixedArray::cast(properties), 3512 FixedArray::cast(properties),
3505 map); 3513 map);
3506 ASSERT(JSObject::cast(obj)->HasFastElements()); 3514 ASSERT(JSObject::cast(obj)->HasFastSmiOnlyElements() ||
3515 JSObject::cast(obj)->HasFastElements());
3507 return obj; 3516 return obj;
3508 } 3517 }
3509 3518
3510 3519
3511 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, 3520 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor,
3512 PretenureFlag pretenure) { 3521 PretenureFlag pretenure) {
3513 // Allocate the initial map if absent. 3522 // Allocate the initial map if absent.
3514 if (!constructor->has_initial_map()) { 3523 if (!constructor->has_initial_map()) {
3515 Object* initial_map; 3524 Object* initial_map;
3516 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor); 3525 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 if (!maybe_clone->ToObject(&clone)) return maybe_clone; 3687 if (!maybe_clone->ToObject(&clone)) return maybe_clone;
3679 } 3688 }
3680 ASSERT(InNewSpace(clone)); 3689 ASSERT(InNewSpace(clone));
3681 // Since we know the clone is allocated in new space, we can copy 3690 // Since we know the clone is allocated in new space, we can copy
3682 // the contents without worrying about updating the write barrier. 3691 // the contents without worrying about updating the write barrier.
3683 CopyBlock(HeapObject::cast(clone)->address(), 3692 CopyBlock(HeapObject::cast(clone)->address(),
3684 source->address(), 3693 source->address(),
3685 object_size); 3694 object_size);
3686 } 3695 }
3687 3696
3697 ASSERT(JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind());
3688 FixedArrayBase* elements = FixedArrayBase::cast(source->elements()); 3698 FixedArrayBase* elements = FixedArrayBase::cast(source->elements());
3689 FixedArray* properties = FixedArray::cast(source->properties()); 3699 FixedArray* properties = FixedArray::cast(source->properties());
3690 // Update elements if necessary. 3700 // Update elements if necessary.
3691 if (elements->length() > 0) { 3701 if (elements->length() > 0) {
3692 Object* elem; 3702 Object* elem;
3693 { MaybeObject* maybe_elem; 3703 { MaybeObject* maybe_elem;
3694 if (elements->map() == fixed_cow_array_map()) { 3704 if (elements->map() == fixed_cow_array_map()) {
3695 maybe_elem = FixedArray::cast(elements); 3705 maybe_elem = FixedArray::cast(elements);
3696 } else if (source->HasFastDoubleElements()) { 3706 } else if (source->HasFastDoubleElements()) {
3697 maybe_elem = CopyFixedDoubleArray(FixedDoubleArray::cast(elements)); 3707 maybe_elem = CopyFixedDoubleArray(FixedDoubleArray::cast(elements));
(...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after
6356 } 6366 }
6357 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6367 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6358 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6368 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6359 next = chunk->next_chunk(); 6369 next = chunk->next_chunk();
6360 isolate_->memory_allocator()->Free(chunk); 6370 isolate_->memory_allocator()->Free(chunk);
6361 } 6371 }
6362 chunks_queued_for_free_ = NULL; 6372 chunks_queued_for_free_ = NULL;
6363 } 6373 }
6364 6374
6365 } } // namespace v8::internal 6375 } } // namespace v8::internal
OLDNEW
« src/bootstrapper.cc ('K') | « src/heap.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698