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

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: deactivate by default 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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); 1598 StaticVisitorBase::GetVisitorId(instance_type, instance_size));
1599 reinterpret_cast<Map*>(result)->set_inobject_properties(0); 1599 reinterpret_cast<Map*>(result)->set_inobject_properties(0);
1600 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); 1600 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0);
1601 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); 1601 reinterpret_cast<Map*>(result)->set_unused_property_fields(0);
1602 reinterpret_cast<Map*>(result)->set_bit_field(0); 1602 reinterpret_cast<Map*>(result)->set_bit_field(0);
1603 reinterpret_cast<Map*>(result)->set_bit_field2(0); 1603 reinterpret_cast<Map*>(result)->set_bit_field2(0);
1604 return result; 1604 return result;
1605 } 1605 }
1606 1606
1607 1607
1608 MaybeObject* Heap::AllocateMap(InstanceType instance_type, int instance_size) { 1608 MaybeObject* Heap::AllocateMap(InstanceType instance_type,
1609 int instance_size,
1610 ElementsKind elements_kind) {
1609 Object* result; 1611 Object* result;
1610 { MaybeObject* maybe_result = AllocateRawMap(); 1612 { MaybeObject* maybe_result = AllocateRawMap();
1611 if (!maybe_result->ToObject(&result)) return maybe_result; 1613 if (!maybe_result->ToObject(&result)) return maybe_result;
1612 } 1614 }
1613 1615
1614 Map* map = reinterpret_cast<Map*>(result); 1616 Map* map = reinterpret_cast<Map*>(result);
1615 map->set_map(meta_map()); 1617 map->set_map(meta_map());
1616 map->set_instance_type(instance_type); 1618 map->set_instance_type(instance_type);
1617 map->set_visitor_id( 1619 map->set_visitor_id(
1618 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); 1620 StaticVisitorBase::GetVisitorId(instance_type, instance_size));
1619 map->set_prototype(null_value()); 1621 map->set_prototype(null_value());
1620 map->set_constructor(null_value()); 1622 map->set_constructor(null_value());
1621 map->set_instance_size(instance_size); 1623 map->set_instance_size(instance_size);
1622 map->set_inobject_properties(0); 1624 map->set_inobject_properties(0);
1623 map->set_pre_allocated_property_fields(0); 1625 map->set_pre_allocated_property_fields(0);
1624 map->init_instance_descriptors(); 1626 map->init_instance_descriptors();
1625 map->set_code_cache(empty_fixed_array()); 1627 map->set_code_cache(empty_fixed_array());
1626 map->set_prototype_transitions(empty_fixed_array()); 1628 map->set_prototype_transitions(empty_fixed_array());
1627 map->set_unused_property_fields(0); 1629 map->set_unused_property_fields(0);
1628 map->set_bit_field(0); 1630 map->set_bit_field(0);
1629 map->set_bit_field2(1 << Map::kIsExtensible); 1631 map->set_bit_field2(1 << Map::kIsExtensible);
1630 map->set_elements_kind(FAST_ELEMENTS); 1632 map->set_elements_kind(elements_kind);
1631 1633
1632 // If the map object is aligned fill the padding area with Smi 0 objects. 1634 // If the map object is aligned fill the padding area with Smi 0 objects.
1633 if (Map::kPadStart < Map::kSize) { 1635 if (Map::kPadStart < Map::kSize) {
1634 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag, 1636 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag,
1635 0, 1637 0,
1636 Map::kSize - Map::kPadStart); 1638 Map::kSize - Map::kPadStart);
1637 } 1639 }
1638 return map; 1640 return map;
1639 } 1641 }
1640 1642
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 return Oddball::cast(result)->Initialize(to_string, to_number, kind); 2006 return Oddball::cast(result)->Initialize(to_string, to_number, kind);
2005 } 2007 }
2006 2008
2007 2009
2008 bool Heap::CreateApiObjects() { 2010 bool Heap::CreateApiObjects() {
2009 Object* obj; 2011 Object* obj;
2010 2012
2011 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 2013 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
2012 if (!maybe_obj->ToObject(&obj)) return false; 2014 if (!maybe_obj->ToObject(&obj)) return false;
2013 } 2015 }
2014 set_neander_map(Map::cast(obj)); 2016 Map* new_neander_map = Map::cast(obj);
Rico 2011/09/16 09:40:10 Add comments why we don't wan't the smi optimizati
danno 2011/09/21 14:32:04 Done.
2017 new_neander_map->set_elements_kind(FAST_ELEMENTS);
2018 set_neander_map(new_neander_map);
2015 2019
2016 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(neander_map()); 2020 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(neander_map());
2017 if (!maybe_obj->ToObject(&obj)) return false; 2021 if (!maybe_obj->ToObject(&obj)) return false;
2018 } 2022 }
2019 Object* elements; 2023 Object* elements;
2020 { MaybeObject* maybe_elements = AllocateFixedArray(2); 2024 { MaybeObject* maybe_elements = AllocateFixedArray(2);
2021 if (!maybe_elements->ToObject(&elements)) return false; 2025 if (!maybe_elements->ToObject(&elements)) return false;
2022 } 2026 }
2023 FixedArray::cast(elements)->set(0, Smi::FromInt(0)); 2027 FixedArray::cast(elements)->set(0, Smi::FromInt(0));
2024 JSObject::cast(obj)->set_elements(FixedArray::cast(elements)); 2028 JSObject::cast(obj)->set_elements(FixedArray::cast(elements));
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE; 3374 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE;
3371 Object* obj; 3375 Object* obj;
3372 { MaybeObject* maybe_obj = Allocate(map, space); 3376 { MaybeObject* maybe_obj = Allocate(map, space);
3373 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 3377 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3374 } 3378 }
3375 3379
3376 // Initialize the JSObject. 3380 // Initialize the JSObject.
3377 InitializeJSObjectFromMap(JSObject::cast(obj), 3381 InitializeJSObjectFromMap(JSObject::cast(obj),
3378 FixedArray::cast(properties), 3382 FixedArray::cast(properties),
3379 map); 3383 map);
3380 ASSERT(JSObject::cast(obj)->HasFastElements()); 3384 ASSERT(JSObject::cast(obj)->HasFastSmiOnlyElements() ||
3385 JSObject::cast(obj)->HasFastElements());
3381 return obj; 3386 return obj;
3382 } 3387 }
3383 3388
3384 3389
3385 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, 3390 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor,
3386 PretenureFlag pretenure) { 3391 PretenureFlag pretenure) {
3387 // Allocate the initial map if absent. 3392 // Allocate the initial map if absent.
3388 if (!constructor->has_initial_map()) { 3393 if (!constructor->has_initial_map()) {
3389 Object* initial_map; 3394 Object* initial_map;
3390 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor); 3395 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3527 if (!maybe_clone->ToObject(&clone)) return maybe_clone; 3532 if (!maybe_clone->ToObject(&clone)) return maybe_clone;
3528 } 3533 }
3529 ASSERT(InNewSpace(clone)); 3534 ASSERT(InNewSpace(clone));
3530 // Since we know the clone is allocated in new space, we can copy 3535 // Since we know the clone is allocated in new space, we can copy
3531 // the contents without worrying about updating the write barrier. 3536 // the contents without worrying about updating the write barrier.
3532 CopyBlock(HeapObject::cast(clone)->address(), 3537 CopyBlock(HeapObject::cast(clone)->address(),
3533 source->address(), 3538 source->address(),
3534 object_size); 3539 object_size);
3535 } 3540 }
3536 3541
3542 ASSERT(JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind());
3537 FixedArrayBase* elements = FixedArrayBase::cast(source->elements()); 3543 FixedArrayBase* elements = FixedArrayBase::cast(source->elements());
3538 FixedArray* properties = FixedArray::cast(source->properties()); 3544 FixedArray* properties = FixedArray::cast(source->properties());
3539 // Update elements if necessary. 3545 // Update elements if necessary.
3540 if (elements->length() > 0) { 3546 if (elements->length() > 0) {
3541 Object* elem; 3547 Object* elem;
3542 { MaybeObject* maybe_elem; 3548 { MaybeObject* maybe_elem;
3543 if (elements->map() == fixed_cow_array_map()) { 3549 if (elements->map() == fixed_cow_array_map()) {
3544 maybe_elem = FixedArray::cast(elements); 3550 maybe_elem = FixedArray::cast(elements);
3545 } else if (source->HasFastDoubleElements()) { 3551 } else if (source->HasFastDoubleElements()) {
3546 maybe_elem = CopyFixedDoubleArray(FixedDoubleArray::cast(elements)); 3552 maybe_elem = CopyFixedDoubleArray(FixedDoubleArray::cast(elements));
(...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after
6225 } 6231 }
6226 6232
6227 6233
6228 void ExternalStringTable::TearDown() { 6234 void ExternalStringTable::TearDown() {
6229 new_space_strings_.Free(); 6235 new_space_strings_.Free();
6230 old_space_strings_.Free(); 6236 old_space_strings_.Free();
6231 } 6237 }
6232 6238
6233 6239
6234 } } // namespace v8::internal 6240 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698