| OLD | NEW |
| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 String::cast(this)->IsTwoByteRepresentation(); | 278 String::cast(this)->IsTwoByteRepresentation(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 bool Object::HasValidElements() { | 281 bool Object::HasValidElements() { |
| 282 // Dictionary is covered under FixedArray. | 282 // Dictionary is covered under FixedArray. |
| 283 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); | 283 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 | 286 |
| 287 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, | 287 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, |
| 288 Representation representation, | 288 Representation representation) { |
| 289 PretenureFlag tenure) { | |
| 290 if (!FLAG_track_double_fields) return this; | 289 if (!FLAG_track_double_fields) return this; |
| 291 if (!representation.IsDouble()) return this; | 290 if (!representation.IsDouble()) return this; |
| 292 if (IsUninitialized()) { | 291 if (IsUninitialized()) { |
| 293 return heap->AllocateHeapNumber(0, tenure); | 292 return heap->AllocateHeapNumber(0); |
| 294 } | 293 } |
| 295 return heap->AllocateHeapNumber(Number(), tenure); | 294 return heap->AllocateHeapNumber(Number()); |
| 296 } | 295 } |
| 297 | 296 |
| 298 | 297 |
| 299 StringShape::StringShape(String* str) | 298 StringShape::StringShape(String* str) |
| 300 : type_(str->map()->instance_type()) { | 299 : type_(str->map()->instance_type()) { |
| 301 set_valid(); | 300 set_valid(); |
| 302 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 301 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
| 303 } | 302 } |
| 304 | 303 |
| 305 | 304 |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1317 |
| 1319 return AllocationSite::GetMode(GetElementsKind()) == | 1318 return AllocationSite::GetMode(GetElementsKind()) == |
| 1320 TRACK_ALLOCATION_SITE; | 1319 TRACK_ALLOCATION_SITE; |
| 1321 } | 1320 } |
| 1322 return false; | 1321 return false; |
| 1323 } | 1322 } |
| 1324 | 1323 |
| 1325 | 1324 |
| 1326 void AllocationSite::Initialize() { | 1325 void AllocationSite::Initialize() { |
| 1327 SetElementsKind(GetInitialFastElementsKind()); | 1326 SetElementsKind(GetInitialFastElementsKind()); |
| 1327 set_nested_site(Smi::FromInt(0)); |
| 1328 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), | 1328 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), |
| 1329 SKIP_WRITE_BARRIER); | 1329 SKIP_WRITE_BARRIER); |
| 1330 } | 1330 } |
| 1331 | 1331 |
| 1332 | 1332 |
| 1333 // Heuristic: We only need to create allocation site info if the boilerplate | 1333 // Heuristic: We only need to create allocation site info if the boilerplate |
| 1334 // elements kind is the initial elements kind. | 1334 // elements kind is the initial elements kind. |
| 1335 AllocationSiteMode AllocationSite::GetMode( | 1335 AllocationSiteMode AllocationSite::GetMode( |
| 1336 ElementsKind boilerplate_elements_kind) { | 1336 ElementsKind boilerplate_elements_kind) { |
| 1337 if (FLAG_track_allocation_sites && | 1337 if (FLAG_track_allocation_sites && |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind); | 1535 MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind); |
| 1536 Map* map; | 1536 Map* map; |
| 1537 if (!maybe->To(&map)) return maybe; | 1537 if (!maybe->To(&map)) return maybe; |
| 1538 set_map(map); | 1538 set_map(map); |
| 1539 initialize_elements(); | 1539 initialize_elements(); |
| 1540 | 1540 |
| 1541 return this; | 1541 return this; |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 | 1544 |
| 1545 MaybeObject* JSObject::AllocateStorageForMap(Map* map) { | |
| 1546 ASSERT(this->map()->inobject_properties() == map->inobject_properties()); | |
| 1547 ElementsKind obj_kind = this->map()->elements_kind(); | |
| 1548 ElementsKind map_kind = map->elements_kind(); | |
| 1549 if (map_kind != obj_kind) { | |
| 1550 ElementsKind to_kind = map_kind; | |
| 1551 if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) || | |
| 1552 IsDictionaryElementsKind(obj_kind)) { | |
| 1553 to_kind = obj_kind; | |
| 1554 } | |
| 1555 MaybeObject* maybe_obj = | |
| 1556 IsDictionaryElementsKind(to_kind) ? NormalizeElements() | |
| 1557 : TransitionElementsKind(to_kind); | |
| 1558 if (maybe_obj->IsFailure()) return maybe_obj; | |
| 1559 MaybeObject* maybe_map = map->AsElementsKind(to_kind); | |
| 1560 if (!maybe_map->To(&map)) return maybe_map; | |
| 1561 } | |
| 1562 int total_size = | |
| 1563 map->NumberOfOwnDescriptors() + map->unused_property_fields(); | |
| 1564 int out_of_object = total_size - map->inobject_properties(); | |
| 1565 if (out_of_object != properties()->length()) { | |
| 1566 FixedArray* new_properties; | |
| 1567 MaybeObject* maybe_properties = properties()->CopySize(out_of_object); | |
| 1568 if (!maybe_properties->To(&new_properties)) return maybe_properties; | |
| 1569 set_properties(new_properties); | |
| 1570 } | |
| 1571 set_map(map); | |
| 1572 return this; | |
| 1573 } | |
| 1574 | |
| 1575 | |
| 1576 MaybeObject* JSObject::TryMigrateInstance() { | |
| 1577 Map* new_map = map()->CurrentMapForDeprecated(); | |
| 1578 if (new_map == NULL) return Smi::FromInt(0); | |
| 1579 Map* original_map = map(); | |
| 1580 MaybeObject* maybe_result = MigrateToMap(new_map); | |
| 1581 JSObject* result; | |
| 1582 if (FLAG_trace_migration && maybe_result->To(&result)) { | |
| 1583 PrintInstanceMigration(stdout, original_map, result->map()); | |
| 1584 } | |
| 1585 return maybe_result; | |
| 1586 } | |
| 1587 | |
| 1588 | |
| 1589 Handle<String> JSObject::ExpectedTransitionKey(Handle<Map> map) { | 1545 Handle<String> JSObject::ExpectedTransitionKey(Handle<Map> map) { |
| 1590 DisallowHeapAllocation no_gc; | 1546 DisallowHeapAllocation no_gc; |
| 1591 if (!map->HasTransitionArray()) return Handle<String>::null(); | 1547 if (!map->HasTransitionArray()) return Handle<String>::null(); |
| 1592 TransitionArray* transitions = map->transitions(); | 1548 TransitionArray* transitions = map->transitions(); |
| 1593 if (!transitions->IsSimpleTransition()) return Handle<String>::null(); | 1549 if (!transitions->IsSimpleTransition()) return Handle<String>::null(); |
| 1594 int transition = TransitionArray::kSimpleTransitionIndex; | 1550 int transition = TransitionArray::kSimpleTransitionIndex; |
| 1595 PropertyDetails details = transitions->GetTargetDetails(transition); | 1551 PropertyDetails details = transitions->GetTargetDetails(transition); |
| 1596 Name* name = transitions->GetKey(transition); | 1552 Name* name = transitions->GetKey(transition); |
| 1597 if (details.type() != FIELD) return Handle<String>::null(); | 1553 if (details.type() != FIELD) return Handle<String>::null(); |
| 1598 if (details.attributes() != NONE) return Handle<String>::null(); | 1554 if (details.attributes() != NONE) return Handle<String>::null(); |
| (...skipping 2881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4480 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) | 4436 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) |
| 4481 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, | 4437 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, |
| 4482 kInternalFieldCountOffset) | 4438 kInternalFieldCountOffset) |
| 4483 | 4439 |
| 4484 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) | 4440 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) |
| 4485 ACCESSORS(SignatureInfo, args, Object, kArgsOffset) | 4441 ACCESSORS(SignatureInfo, args, Object, kArgsOffset) |
| 4486 | 4442 |
| 4487 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) | 4443 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) |
| 4488 | 4444 |
| 4489 ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset) | 4445 ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset) |
| 4446 ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset) |
| 4490 ACCESSORS(AllocationSite, dependent_code, DependentCode, | 4447 ACCESSORS(AllocationSite, dependent_code, DependentCode, |
| 4491 kDependentCodeOffset) | 4448 kDependentCodeOffset) |
| 4492 ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) | 4449 ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) |
| 4493 ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) | 4450 ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) |
| 4494 | 4451 |
| 4495 ACCESSORS(Script, source, Object, kSourceOffset) | 4452 ACCESSORS(Script, source, Object, kSourceOffset) |
| 4496 ACCESSORS(Script, name, Object, kNameOffset) | 4453 ACCESSORS(Script, name, Object, kNameOffset) |
| 4497 ACCESSORS(Script, id, Smi, kIdOffset) | 4454 ACCESSORS(Script, id, Smi, kIdOffset) |
| 4498 ACCESSORS_TO_SMI(Script, line_offset, kLineOffsetOffset) | 4455 ACCESSORS_TO_SMI(Script, line_offset, kLineOffsetOffset) |
| 4499 ACCESSORS_TO_SMI(Script, column_offset, kColumnOffsetOffset) | 4456 ACCESSORS_TO_SMI(Script, column_offset, kColumnOffsetOffset) |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6293 #undef WRITE_UINT32_FIELD | 6250 #undef WRITE_UINT32_FIELD |
| 6294 #undef READ_SHORT_FIELD | 6251 #undef READ_SHORT_FIELD |
| 6295 #undef WRITE_SHORT_FIELD | 6252 #undef WRITE_SHORT_FIELD |
| 6296 #undef READ_BYTE_FIELD | 6253 #undef READ_BYTE_FIELD |
| 6297 #undef WRITE_BYTE_FIELD | 6254 #undef WRITE_BYTE_FIELD |
| 6298 | 6255 |
| 6299 | 6256 |
| 6300 } } // namespace v8::internal | 6257 } } // namespace v8::internal |
| 6301 | 6258 |
| 6302 #endif // V8_OBJECTS_INL_H_ | 6259 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |