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

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

Issue 14850006: Use mutable heapnumbers to store doubles in fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ported to ARM and x64 Created 7 years, 7 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/objects-printer.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 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (!IsString()) return false; 279 if (!IsString()) return false;
280 return StringShape(String::cast(this)).IsExternal() && 280 return StringShape(String::cast(this)).IsExternal() &&
281 String::cast(this)->IsTwoByteRepresentation(); 281 String::cast(this)->IsTwoByteRepresentation();
282 } 282 }
283 283
284 bool Object::HasValidElements() { 284 bool Object::HasValidElements() {
285 // Dictionary is covered under FixedArray. 285 // Dictionary is covered under FixedArray.
286 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); 286 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray();
287 } 287 }
288 288
289
290 MaybeObject* Object::AllocateNewStorageFor(Heap* heap,
291 Representation representation,
292 PretenureFlag tenure) {
293 if (!FLAG_track_double_fields) return this;
294 if (!representation.IsDouble()) return this;
295 return heap->AllocateHeapNumber(Number(), tenure);
296 }
297
298
289 StringShape::StringShape(String* str) 299 StringShape::StringShape(String* str)
290 : type_(str->map()->instance_type()) { 300 : type_(str->map()->instance_type()) {
291 set_valid(); 301 set_valid();
292 ASSERT((type_ & kIsNotStringMask) == kStringTag); 302 ASSERT((type_ & kIsNotStringMask) == kStringTag);
293 } 303 }
294 304
295 305
296 StringShape::StringShape(Map* map) 306 StringShape::StringShape(Map* map)
297 : type_(map->instance_type()) { 307 : type_(map->instance_type()) {
298 set_valid(); 308 set_valid();
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind); 1515 MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind);
1506 Map* map; 1516 Map* map;
1507 if (!maybe->To(&map)) return maybe; 1517 if (!maybe->To(&map)) return maybe;
1508 set_map(map); 1518 set_map(map);
1509 initialize_elements(); 1519 initialize_elements();
1510 1520
1511 return this; 1521 return this;
1512 } 1522 }
1513 1523
1514 1524
1515 MaybeObject* JSObject::TransitionToMap(Map* map) { 1525 MaybeObject* JSObject::AllocateStorageForMap(Map* map) {
1516 ASSERT(this->map()->inobject_properties() == map->inobject_properties()); 1526 ASSERT(this->map()->inobject_properties() == map->inobject_properties());
1517 ElementsKind expected_kind = this->map()->elements_kind(); 1527 ElementsKind expected_kind = this->map()->elements_kind();
1518 if (map->elements_kind() != expected_kind) { 1528 if (map->elements_kind() != expected_kind) {
1519 MaybeObject* maybe_map = map->AsElementsKind(expected_kind); 1529 MaybeObject* maybe_map = map->AsElementsKind(expected_kind);
1520 if (!maybe_map->To(&map)) return maybe_map; 1530 if (!maybe_map->To(&map)) return maybe_map;
1521 } 1531 }
1522 int total_size = 1532 int total_size =
1523 map->NumberOfOwnDescriptors() + map->unused_property_fields(); 1533 map->NumberOfOwnDescriptors() + map->unused_property_fields();
1524 int out_of_object = total_size - map->inobject_properties(); 1534 int out_of_object = total_size - map->inobject_properties();
1525 if (out_of_object != properties()->length()) { 1535 if (out_of_object != properties()->length()) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 void JSObject::SetInternalField(int index, Smi* value) { 1705 void JSObject::SetInternalField(int index, Smi* value) {
1696 ASSERT(index < GetInternalFieldCount() && index >= 0); 1706 ASSERT(index < GetInternalFieldCount() && index >= 0);
1697 // Internal objects do follow immediately after the header, whereas in-object 1707 // Internal objects do follow immediately after the header, whereas in-object
1698 // properties are at the end of the object. Therefore there is no need 1708 // properties are at the end of the object. Therefore there is no need
1699 // to adjust the index here. 1709 // to adjust the index here.
1700 int offset = GetHeaderSize() + (kPointerSize * index); 1710 int offset = GetHeaderSize() + (kPointerSize * index);
1701 WRITE_FIELD(this, offset, value); 1711 WRITE_FIELD(this, offset, value);
1702 } 1712 }
1703 1713
1704 1714
1715 MaybeObject* JSObject::FastPropertyAt(Representation representation,
1716 int index) {
1717 Object* raw_value = RawFastPropertyAt(index);
1718 return raw_value->AllocateNewStorageFor(GetHeap(), representation);
1719 }
1720
1721
1705 // Access fast-case object properties at index. The use of these routines 1722 // Access fast-case object properties at index. The use of these routines
1706 // is needed to correctly distinguish between properties stored in-object and 1723 // is needed to correctly distinguish between properties stored in-object and
1707 // properties stored in the properties array. 1724 // properties stored in the properties array.
1708 Object* JSObject::FastPropertyAt(int index) { 1725 Object* JSObject::RawFastPropertyAt(int index) {
1709 // Adjust for the number of properties stored in the object. 1726 // Adjust for the number of properties stored in the object.
1710 index -= map()->inobject_properties(); 1727 index -= map()->inobject_properties();
1711 if (index < 0) { 1728 if (index < 0) {
1712 int offset = map()->instance_size() + (index * kPointerSize); 1729 int offset = map()->instance_size() + (index * kPointerSize);
1713 return READ_FIELD(this, offset); 1730 return READ_FIELD(this, offset);
1714 } else { 1731 } else {
1715 ASSERT(index < properties()->length()); 1732 ASSERT(index < properties()->length());
1716 return properties()->get(index); 1733 return properties()->get(index);
1717 } 1734 }
1718 } 1735 }
1719 1736
1720 1737
1721 Object* JSObject::FastPropertyAtPut(int index, Object* value) { 1738 void JSObject::FastPropertyAtPut(int index, Object* value) {
1722 // Adjust for the number of properties stored in the object. 1739 // Adjust for the number of properties stored in the object.
1723 index -= map()->inobject_properties(); 1740 index -= map()->inobject_properties();
1724 if (index < 0) { 1741 if (index < 0) {
1725 int offset = map()->instance_size() + (index * kPointerSize); 1742 int offset = map()->instance_size() + (index * kPointerSize);
1726 WRITE_FIELD(this, offset, value); 1743 WRITE_FIELD(this, offset, value);
1727 WRITE_BARRIER(GetHeap(), this, offset, value); 1744 WRITE_BARRIER(GetHeap(), this, offset, value);
1728 } else { 1745 } else {
1729 ASSERT(index < properties()->length()); 1746 ASSERT(index < properties()->length());
1730 properties()->set(index, value); 1747 properties()->set(index, value);
1731 } 1748 }
1732 return value;
1733 } 1749 }
1734 1750
1735 1751
1736 int JSObject::GetInObjectPropertyOffset(int index) { 1752 int JSObject::GetInObjectPropertyOffset(int index) {
1737 // Adjust for the number of properties stored in the object. 1753 // Adjust for the number of properties stored in the object.
1738 index -= map()->inobject_properties(); 1754 index -= map()->inobject_properties();
1739 ASSERT(index < 0); 1755 ASSERT(index < 0);
1740 return map()->instance_size() + (index * kPointerSize); 1756 return map()->instance_size() + (index * kPointerSize);
1741 } 1757 }
1742 1758
(...skipping 4484 matching lines...) Expand 10 before | Expand all | Expand 10 after
6227 #undef WRITE_UINT32_FIELD 6243 #undef WRITE_UINT32_FIELD
6228 #undef READ_SHORT_FIELD 6244 #undef READ_SHORT_FIELD
6229 #undef WRITE_SHORT_FIELD 6245 #undef WRITE_SHORT_FIELD
6230 #undef READ_BYTE_FIELD 6246 #undef READ_BYTE_FIELD
6231 #undef WRITE_BYTE_FIELD 6247 #undef WRITE_BYTE_FIELD
6232 6248
6233 6249
6234 } } // namespace v8::internal 6250 } } // namespace v8::internal
6235 6251
6236 #endif // V8_OBJECTS_INL_H_ 6252 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698