| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "objects-visiting.h" | 52 #include "objects-visiting.h" |
| 53 | 53 |
| 54 namespace v8 { | 54 namespace v8 { |
| 55 namespace internal { | 55 namespace internal { |
| 56 | 56 |
| 57 PropertyDetails::PropertyDetails(Smi* smi) { | 57 PropertyDetails::PropertyDetails(Smi* smi) { |
| 58 value_ = smi->value(); | 58 value_ = smi->value(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 | 61 |
| 62 Smi* PropertyDetails::AsSmi() const { | 62 Smi* PropertyDetails::AsSmi() { |
| 63 // Ensure the upper 2 bits have the same value by sign extending it. This is | 63 // Ensure the upper 2 bits have the same value by sign extending it. This is |
| 64 // necessary to be able to use the 31st bit of the property details. | 64 // necessary to be able to use the 31st bit of the property details. |
| 65 int value = value_ << 1; | 65 int value = value_ << 1; |
| 66 return Smi::FromInt(value >> 1); | 66 return Smi::FromInt(value >> 1); |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 PropertyDetails PropertyDetails::AsDeleted() const { | 70 PropertyDetails PropertyDetails::AsDeleted() { |
| 71 Smi* smi = Smi::FromInt(value_ | DeletedField::encode(1)); | 71 Smi* smi = Smi::FromInt(value_ | DeletedField::encode(1)); |
| 72 return PropertyDetails(smi); | 72 return PropertyDetails(smi); |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 #define TYPE_CHECKER(type, instancetype) \ | 76 #define TYPE_CHECKER(type, instancetype) \ |
| 77 bool Object::Is##type() { \ | 77 bool Object::Is##type() { \ |
| 78 return Object::IsHeapObject() && \ | 78 return Object::IsHeapObject() && \ |
| 79 HeapObject::cast(this)->map()->instance_type() == instancetype; \ | 79 HeapObject::cast(this)->map()->instance_type() == instancetype; \ |
| 80 } | 80 } |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 | 753 |
| 754 | 754 |
| 755 bool Object::IsDependentCode() { | 755 bool Object::IsDependentCode() { |
| 756 if (!IsFixedArray()) return false; | 756 if (!IsFixedArray()) return false; |
| 757 // There's actually no way to see the difference between a fixed array and | 757 // There's actually no way to see the difference between a fixed array and |
| 758 // a dependent codes array. | 758 // a dependent codes array. |
| 759 return true; | 759 return true; |
| 760 } | 760 } |
| 761 | 761 |
| 762 | 762 |
| 763 bool Object::IsTypeFeedbackCells() { |
| 764 if (!IsFixedArray()) return false; |
| 765 // There's actually no way to see the difference between a fixed array and |
| 766 // a cache cells array. Since this is used for asserts we can check that |
| 767 // the length is plausible though. |
| 768 if (FixedArray::cast(this)->length() % 2 != 0) return false; |
| 769 return true; |
| 770 } |
| 771 |
| 772 |
| 763 bool Object::IsContext() { | 773 bool Object::IsContext() { |
| 764 if (!Object::IsHeapObject()) return false; | 774 if (!Object::IsHeapObject()) return false; |
| 765 Map* map = HeapObject::cast(this)->map(); | 775 Map* map = HeapObject::cast(this)->map(); |
| 766 Heap* heap = map->GetHeap(); | 776 Heap* heap = map->GetHeap(); |
| 767 return (map == heap->function_context_map() || | 777 return (map == heap->function_context_map() || |
| 768 map == heap->catch_context_map() || | 778 map == heap->catch_context_map() || |
| 769 map == heap->with_context_map() || | 779 map == heap->with_context_map() || |
| 770 map == heap->native_context_map() || | 780 map == heap->native_context_map() || |
| 771 map == heap->block_context_map() || | 781 map == heap->block_context_map() || |
| 772 map == heap->module_context_map() || | 782 map == heap->module_context_map() || |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 static_cast<double>(found_count) / create_count : 0.0; | 1557 static_cast<double>(found_count) / create_count : 0.0; |
| 1548 PretenureFlag current_mode = GetPretenureMode(); | 1558 PretenureFlag current_mode = GetPretenureMode(); |
| 1549 | 1559 |
| 1550 if (minimum_mementos_created) { | 1560 if (minimum_mementos_created) { |
| 1551 PretenureDecision result = ratio >= kPretenureRatio | 1561 PretenureDecision result = ratio >= kPretenureRatio |
| 1552 ? kTenure | 1562 ? kTenure |
| 1553 : kDontTenure; | 1563 : kDontTenure; |
| 1554 set_pretenure_decision(result); | 1564 set_pretenure_decision(result); |
| 1555 if (current_mode != GetPretenureMode()) { | 1565 if (current_mode != GetPretenureMode()) { |
| 1556 decision_changed = true; | 1566 decision_changed = true; |
| 1557 set_deopt_dependent_code(true); | 1567 dependent_code()->MarkCodeForDeoptimization( |
| 1568 GetIsolate(), |
| 1569 DependentCode::kAllocationSiteTenuringChangedGroup); |
| 1558 } | 1570 } |
| 1559 } | 1571 } |
| 1560 | 1572 |
| 1561 if (FLAG_trace_pretenuring_statistics) { | 1573 if (FLAG_trace_pretenuring_statistics) { |
| 1562 PrintF( | 1574 PrintF( |
| 1563 "AllocationSite(%p): (created, found, ratio) (%d, %d, %f) %s => %s\n", | 1575 "AllocationSite(%p): (created, found, ratio) (%d, %d, %f) %s => %s\n", |
| 1564 static_cast<void*>(this), create_count, found_count, ratio, | 1576 static_cast<void*>(this), create_count, found_count, ratio, |
| 1565 current_mode == TENURED ? "tenured" : "not tenured", | 1577 current_mode == TENURED ? "tenured" : "not tenured", |
| 1566 GetPretenureMode() == TENURED ? "tenured" : "not tenured"); | 1578 GetPretenureMode() == TENURED ? "tenured" : "not tenured"); |
| 1567 } | 1579 } |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 | 2495 |
| 2484 if (number == DescriptorLookupCache::kAbsent) { | 2496 if (number == DescriptorLookupCache::kAbsent) { |
| 2485 number = Search(name, number_of_own_descriptors); | 2497 number = Search(name, number_of_own_descriptors); |
| 2486 cache->Update(map, name, number); | 2498 cache->Update(map, name, number); |
| 2487 } | 2499 } |
| 2488 | 2500 |
| 2489 return number; | 2501 return number; |
| 2490 } | 2502 } |
| 2491 | 2503 |
| 2492 | 2504 |
| 2493 PropertyDetails Map::GetLastDescriptorDetails() { | |
| 2494 return instance_descriptors()->GetDetails(LastAdded()); | |
| 2495 } | |
| 2496 | |
| 2497 | |
| 2498 void Map::LookupDescriptor(JSObject* holder, | 2505 void Map::LookupDescriptor(JSObject* holder, |
| 2499 Name* name, | 2506 Name* name, |
| 2500 LookupResult* result) { | 2507 LookupResult* result) { |
| 2501 DescriptorArray* descriptors = this->instance_descriptors(); | 2508 DescriptorArray* descriptors = this->instance_descriptors(); |
| 2502 int number = descriptors->SearchWithCache(name, this); | 2509 int number = descriptors->SearchWithCache(name, this); |
| 2503 if (number == DescriptorArray::kNotFound) return result->NotFound(); | 2510 if (number == DescriptorArray::kNotFound) return result->NotFound(); |
| 2504 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 2511 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
| 2505 } | 2512 } |
| 2506 | 2513 |
| 2507 | 2514 |
| 2508 void Map::LookupTransition(JSObject* holder, | 2515 void Map::LookupTransition(JSObject* holder, |
| 2509 Name* name, | 2516 Name* name, |
| 2510 LookupResult* result) { | 2517 LookupResult* result) { |
| 2511 if (HasTransitionArray()) { | 2518 if (HasTransitionArray()) { |
| 2512 TransitionArray* transition_array = transitions(); | 2519 TransitionArray* transition_array = transitions(); |
| 2513 int number = transition_array->Search(name); | 2520 int number = transition_array->Search(name); |
| 2514 if (number != TransitionArray::kNotFound) { | 2521 if (number != TransitionArray::kNotFound) { |
| 2515 return result->TransitionResult( | 2522 return result->TransitionResult(holder, number); |
| 2516 holder, transition_array->GetTarget(number)); | |
| 2517 } | 2523 } |
| 2518 } | 2524 } |
| 2519 result->NotFound(); | 2525 result->NotFound(); |
| 2520 } | 2526 } |
| 2521 | 2527 |
| 2522 | 2528 |
| 2523 Object** DescriptorArray::GetKeySlot(int descriptor_number) { | 2529 Object** DescriptorArray::GetKeySlot(int descriptor_number) { |
| 2524 ASSERT(descriptor_number < number_of_descriptors()); | 2530 ASSERT(descriptor_number < number_of_descriptors()); |
| 2525 return RawFieldOfElementAt(ToKeyIndex(descriptor_number)); | 2531 return RawFieldOfElementAt(ToKeyIndex(descriptor_number)); |
| 2526 } | 2532 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2778 | 2784 |
| 2779 | 2785 |
| 2780 CAST_ACCESSOR(FixedArray) | 2786 CAST_ACCESSOR(FixedArray) |
| 2781 CAST_ACCESSOR(FixedDoubleArray) | 2787 CAST_ACCESSOR(FixedDoubleArray) |
| 2782 CAST_ACCESSOR(FixedTypedArrayBase) | 2788 CAST_ACCESSOR(FixedTypedArrayBase) |
| 2783 CAST_ACCESSOR(ConstantPoolArray) | 2789 CAST_ACCESSOR(ConstantPoolArray) |
| 2784 CAST_ACCESSOR(DescriptorArray) | 2790 CAST_ACCESSOR(DescriptorArray) |
| 2785 CAST_ACCESSOR(DeoptimizationInputData) | 2791 CAST_ACCESSOR(DeoptimizationInputData) |
| 2786 CAST_ACCESSOR(DeoptimizationOutputData) | 2792 CAST_ACCESSOR(DeoptimizationOutputData) |
| 2787 CAST_ACCESSOR(DependentCode) | 2793 CAST_ACCESSOR(DependentCode) |
| 2794 CAST_ACCESSOR(TypeFeedbackCells) |
| 2788 CAST_ACCESSOR(StringTable) | 2795 CAST_ACCESSOR(StringTable) |
| 2789 CAST_ACCESSOR(JSFunctionResultCache) | 2796 CAST_ACCESSOR(JSFunctionResultCache) |
| 2790 CAST_ACCESSOR(NormalizedMapCache) | 2797 CAST_ACCESSOR(NormalizedMapCache) |
| 2791 CAST_ACCESSOR(ScopeInfo) | 2798 CAST_ACCESSOR(ScopeInfo) |
| 2792 CAST_ACCESSOR(CompilationCacheTable) | 2799 CAST_ACCESSOR(CompilationCacheTable) |
| 2793 CAST_ACCESSOR(CodeCacheHashTable) | 2800 CAST_ACCESSOR(CodeCacheHashTable) |
| 2794 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) | 2801 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) |
| 2795 CAST_ACCESSOR(MapCache) | 2802 CAST_ACCESSOR(MapCache) |
| 2796 CAST_ACCESSOR(String) | 2803 CAST_ACCESSOR(String) |
| 2797 CAST_ACCESSOR(SeqString) | 2804 CAST_ACCESSOR(SeqString) |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4191 // objects. This is used in the debugger to determine whether or not | 4198 // objects. This is used in the debugger to determine whether or not |
| 4192 // a call to code object has been replaced with a debug break call. | 4199 // a call to code object has been replaced with a debug break call. |
| 4193 ASSERT(is_inline_cache_stub() || | 4200 ASSERT(is_inline_cache_stub() || |
| 4194 result == UNINITIALIZED || | 4201 result == UNINITIALIZED || |
| 4195 result == DEBUG_STUB); | 4202 result == DEBUG_STUB); |
| 4196 return result; | 4203 return result; |
| 4197 } | 4204 } |
| 4198 | 4205 |
| 4199 | 4206 |
| 4200 ExtraICState Code::extra_ic_state() { | 4207 ExtraICState Code::extra_ic_state() { |
| 4208 ASSERT((is_inline_cache_stub() && !needs_extended_extra_ic_state(kind())) |
| 4209 || ic_state() == DEBUG_STUB); |
| 4210 return ExtractExtraICStateFromFlags(flags()); |
| 4211 } |
| 4212 |
| 4213 |
| 4214 ExtraICState Code::extended_extra_ic_state() { |
| 4201 ASSERT(is_inline_cache_stub() || ic_state() == DEBUG_STUB); | 4215 ASSERT(is_inline_cache_stub() || ic_state() == DEBUG_STUB); |
| 4202 return ExtractExtraICStateFromFlags(flags()); | 4216 ASSERT(needs_extended_extra_ic_state(kind())); |
| 4217 return ExtractExtendedExtraICStateFromFlags(flags()); |
| 4203 } | 4218 } |
| 4204 | 4219 |
| 4205 | 4220 |
| 4206 Code::StubType Code::type() { | 4221 Code::StubType Code::type() { |
| 4207 return ExtractTypeFromFlags(flags()); | 4222 return ExtractTypeFromFlags(flags()); |
| 4208 } | 4223 } |
| 4209 | 4224 |
| 4210 | 4225 |
| 4226 int Code::arguments_count() { |
| 4227 ASSERT(kind() == STUB || is_handler()); |
| 4228 return ExtractArgumentsCountFromFlags(flags()); |
| 4229 } |
| 4230 |
| 4231 |
| 4211 // For initialization. | 4232 // For initialization. |
| 4212 void Code::set_raw_kind_specific_flags1(int value) { | 4233 void Code::set_raw_kind_specific_flags1(int value) { |
| 4213 WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value); | 4234 WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value); |
| 4214 } | 4235 } |
| 4215 | 4236 |
| 4216 | 4237 |
| 4217 void Code::set_raw_kind_specific_flags2(int value) { | 4238 void Code::set_raw_kind_specific_flags2(int value) { |
| 4218 WRITE_INT_FIELD(this, kKindSpecificFlags2Offset, value); | 4239 WRITE_INT_FIELD(this, kKindSpecificFlags2Offset, value); |
| 4219 } | 4240 } |
| 4220 | 4241 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4404 void Code::set_back_edges_patched_for_osr(bool value) { | 4425 void Code::set_back_edges_patched_for_osr(bool value) { |
| 4405 ASSERT_EQ(FUNCTION, kind()); | 4426 ASSERT_EQ(FUNCTION, kind()); |
| 4406 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4427 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
| 4407 int updated = BackEdgesPatchedForOSRField::update(previous, value); | 4428 int updated = BackEdgesPatchedForOSRField::update(previous, value); |
| 4408 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 4429 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
| 4409 } | 4430 } |
| 4410 | 4431 |
| 4411 | 4432 |
| 4412 | 4433 |
| 4413 byte Code::to_boolean_state() { | 4434 byte Code::to_boolean_state() { |
| 4414 return extra_ic_state(); | 4435 return extended_extra_ic_state(); |
| 4415 } | 4436 } |
| 4416 | 4437 |
| 4417 | 4438 |
| 4418 bool Code::has_function_cache() { | 4439 bool Code::has_function_cache() { |
| 4419 ASSERT(kind() == STUB); | 4440 ASSERT(kind() == STUB); |
| 4420 return HasFunctionCacheField::decode( | 4441 return HasFunctionCacheField::decode( |
| 4421 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4442 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
| 4422 } | 4443 } |
| 4423 | 4444 |
| 4424 | 4445 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4475 ASSERT(value->IsConstantPoolArray()); | 4496 ASSERT(value->IsConstantPoolArray()); |
| 4476 WRITE_FIELD(this, kConstantPoolOffset, value); | 4497 WRITE_FIELD(this, kConstantPoolOffset, value); |
| 4477 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); | 4498 WRITE_BARRIER(GetHeap(), this, kConstantPoolOffset, value); |
| 4478 } | 4499 } |
| 4479 | 4500 |
| 4480 | 4501 |
| 4481 Code::Flags Code::ComputeFlags(Kind kind, | 4502 Code::Flags Code::ComputeFlags(Kind kind, |
| 4482 InlineCacheState ic_state, | 4503 InlineCacheState ic_state, |
| 4483 ExtraICState extra_ic_state, | 4504 ExtraICState extra_ic_state, |
| 4484 StubType type, | 4505 StubType type, |
| 4506 int argc, |
| 4485 InlineCacheHolderFlag holder) { | 4507 InlineCacheHolderFlag holder) { |
| 4508 ASSERT(argc <= Code::kMaxArguments); |
| 4486 // Compute the bit mask. | 4509 // Compute the bit mask. |
| 4487 unsigned int bits = KindField::encode(kind) | 4510 unsigned int bits = KindField::encode(kind) |
| 4488 | ICStateField::encode(ic_state) | 4511 | ICStateField::encode(ic_state) |
| 4489 | TypeField::encode(type) | 4512 | TypeField::encode(type) |
| 4490 | ExtraICStateField::encode(extra_ic_state) | 4513 | ExtendedExtraICStateField::encode(extra_ic_state) |
| 4491 | CacheHolderField::encode(holder); | 4514 | CacheHolderField::encode(holder); |
| 4515 if (!Code::needs_extended_extra_ic_state(kind)) { |
| 4516 bits |= (argc << kArgumentsCountShift); |
| 4517 } |
| 4492 return static_cast<Flags>(bits); | 4518 return static_cast<Flags>(bits); |
| 4493 } | 4519 } |
| 4494 | 4520 |
| 4495 | 4521 |
| 4496 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, | 4522 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, |
| 4497 ExtraICState extra_ic_state, | 4523 ExtraICState extra_ic_state, |
| 4498 InlineCacheHolderFlag holder, | 4524 InlineCacheHolderFlag holder, |
| 4499 StubType type) { | 4525 StubType type, |
| 4500 return ComputeFlags(kind, MONOMORPHIC, extra_ic_state, type, holder); | 4526 int argc) { |
| 4527 return ComputeFlags(kind, MONOMORPHIC, extra_ic_state, type, argc, holder); |
| 4501 } | 4528 } |
| 4502 | 4529 |
| 4503 | 4530 |
| 4504 Code::Flags Code::ComputeHandlerFlags(Kind handler_kind, | |
| 4505 StubType type, | |
| 4506 InlineCacheHolderFlag holder) { | |
| 4507 return ComputeFlags(Code::HANDLER, MONOMORPHIC, handler_kind, type, holder); | |
| 4508 } | |
| 4509 | |
| 4510 | |
| 4511 Code::Kind Code::ExtractKindFromFlags(Flags flags) { | 4531 Code::Kind Code::ExtractKindFromFlags(Flags flags) { |
| 4512 return KindField::decode(flags); | 4532 return KindField::decode(flags); |
| 4513 } | 4533 } |
| 4514 | 4534 |
| 4515 | 4535 |
| 4516 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { | 4536 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { |
| 4517 return ICStateField::decode(flags); | 4537 return ICStateField::decode(flags); |
| 4518 } | 4538 } |
| 4519 | 4539 |
| 4520 | 4540 |
| 4521 ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { | 4541 ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { |
| 4522 return ExtraICStateField::decode(flags); | 4542 return ExtraICStateField::decode(flags); |
| 4523 } | 4543 } |
| 4524 | 4544 |
| 4525 | 4545 |
| 4546 ExtraICState Code::ExtractExtendedExtraICStateFromFlags( |
| 4547 Flags flags) { |
| 4548 return ExtendedExtraICStateField::decode(flags); |
| 4549 } |
| 4550 |
| 4551 |
| 4526 Code::StubType Code::ExtractTypeFromFlags(Flags flags) { | 4552 Code::StubType Code::ExtractTypeFromFlags(Flags flags) { |
| 4527 return TypeField::decode(flags); | 4553 return TypeField::decode(flags); |
| 4528 } | 4554 } |
| 4529 | 4555 |
| 4530 | 4556 |
| 4557 int Code::ExtractArgumentsCountFromFlags(Flags flags) { |
| 4558 return (flags & kArgumentsCountMask) >> kArgumentsCountShift; |
| 4559 } |
| 4560 |
| 4561 |
| 4531 InlineCacheHolderFlag Code::ExtractCacheHolderFromFlags(Flags flags) { | 4562 InlineCacheHolderFlag Code::ExtractCacheHolderFromFlags(Flags flags) { |
| 4532 return CacheHolderField::decode(flags); | 4563 return CacheHolderField::decode(flags); |
| 4533 } | 4564 } |
| 4534 | 4565 |
| 4535 | 4566 |
| 4536 Code::Flags Code::RemoveTypeFromFlags(Flags flags) { | 4567 Code::Flags Code::RemoveTypeFromFlags(Flags flags) { |
| 4537 int bits = flags & ~TypeField::kMask; | 4568 int bits = flags & ~TypeField::kMask; |
| 4538 return static_cast<Flags>(bits); | 4569 return static_cast<Flags>(bits); |
| 4539 } | 4570 } |
| 4540 | 4571 |
| 4541 | 4572 |
| 4542 Code* Code::GetCodeFromTargetAddress(Address address) { | 4573 Code* Code::GetCodeFromTargetAddress(Address address) { |
| 4543 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); | 4574 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); |
| 4544 // GetCodeFromTargetAddress might be called when marking objects during mark | 4575 // GetCodeFromTargetAddress might be called when marking objects during mark |
| 4545 // sweep. reinterpret_cast is therefore used instead of the more appropriate | 4576 // sweep. reinterpret_cast is therefore used instead of the more appropriate |
| 4546 // Code::cast. Code::cast does not work when the object's map is | 4577 // Code::cast. Code::cast does not work when the object's map is |
| 4547 // marked. | 4578 // marked. |
| 4548 Code* result = reinterpret_cast<Code*>(code); | 4579 Code* result = reinterpret_cast<Code*>(code); |
| 4549 return result; | 4580 return result; |
| 4550 } | 4581 } |
| 4551 | 4582 |
| 4552 | 4583 |
| 4553 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { | 4584 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { |
| 4554 return HeapObject:: | 4585 return HeapObject:: |
| 4555 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); | 4586 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); |
| 4556 } | 4587 } |
| 4557 | 4588 |
| 4558 | 4589 |
| 4559 bool Code::IsWeakObjectInOptimizedCode(Object* object) { | |
| 4560 ASSERT(is_optimized_code()); | |
| 4561 if (object->IsMap()) { | |
| 4562 return Map::cast(object)->CanTransition() && | |
| 4563 FLAG_collect_maps && | |
| 4564 FLAG_weak_embedded_maps_in_optimized_code; | |
| 4565 } | |
| 4566 if (object->IsJSObject() || | |
| 4567 (object->IsCell() && Cell::cast(object)->value()->IsJSObject())) { | |
| 4568 return FLAG_weak_embedded_objects_in_optimized_code; | |
| 4569 } | |
| 4570 return false; | |
| 4571 } | |
| 4572 | |
| 4573 | |
| 4574 Object* Map::prototype() { | 4590 Object* Map::prototype() { |
| 4575 return READ_FIELD(this, kPrototypeOffset); | 4591 return READ_FIELD(this, kPrototypeOffset); |
| 4576 } | 4592 } |
| 4577 | 4593 |
| 4578 | 4594 |
| 4579 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 4595 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
| 4580 ASSERT(value->IsNull() || value->IsJSReceiver()); | 4596 ASSERT(value->IsNull() || value->IsJSReceiver()); |
| 4581 WRITE_FIELD(this, kPrototypeOffset, value); | 4597 WRITE_FIELD(this, kPrototypeOffset, value); |
| 4582 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); | 4598 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); |
| 4583 } | 4599 } |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5657 JSDate* JSDate::cast(Object* obj) { | 5673 JSDate* JSDate::cast(Object* obj) { |
| 5658 ASSERT(obj->IsJSDate()); | 5674 ASSERT(obj->IsJSDate()); |
| 5659 ASSERT(HeapObject::cast(obj)->Size() == JSDate::kSize); | 5675 ASSERT(HeapObject::cast(obj)->Size() == JSDate::kSize); |
| 5660 return reinterpret_cast<JSDate*>(obj); | 5676 return reinterpret_cast<JSDate*>(obj); |
| 5661 } | 5677 } |
| 5662 | 5678 |
| 5663 | 5679 |
| 5664 ACCESSORS(JSMessageObject, type, String, kTypeOffset) | 5680 ACCESSORS(JSMessageObject, type, String, kTypeOffset) |
| 5665 ACCESSORS(JSMessageObject, arguments, JSArray, kArgumentsOffset) | 5681 ACCESSORS(JSMessageObject, arguments, JSArray, kArgumentsOffset) |
| 5666 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) | 5682 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) |
| 5683 ACCESSORS(JSMessageObject, stack_trace, Object, kStackTraceOffset) |
| 5667 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) | 5684 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) |
| 5668 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) | 5685 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) |
| 5669 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) | 5686 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) |
| 5670 | 5687 |
| 5671 | 5688 |
| 5672 JSMessageObject* JSMessageObject::cast(Object* obj) { | 5689 JSMessageObject* JSMessageObject::cast(Object* obj) { |
| 5673 ASSERT(obj->IsJSMessageObject()); | 5690 ASSERT(obj->IsJSMessageObject()); |
| 5674 ASSERT(HeapObject::cast(obj)->Size() == JSMessageObject::kSize); | 5691 ASSERT(HeapObject::cast(obj)->Size() == JSMessageObject::kSize); |
| 5675 return reinterpret_cast<JSMessageObject*>(obj); | 5692 return reinterpret_cast<JSMessageObject*>(obj); |
| 5676 } | 5693 } |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6539 return GetHeap()->CopyFixedDoubleArray(this); | 6556 return GetHeap()->CopyFixedDoubleArray(this); |
| 6540 } | 6557 } |
| 6541 | 6558 |
| 6542 | 6559 |
| 6543 MaybeObject* ConstantPoolArray::Copy() { | 6560 MaybeObject* ConstantPoolArray::Copy() { |
| 6544 if (length() == 0) return this; | 6561 if (length() == 0) return this; |
| 6545 return GetHeap()->CopyConstantPoolArray(this); | 6562 return GetHeap()->CopyConstantPoolArray(this); |
| 6546 } | 6563 } |
| 6547 | 6564 |
| 6548 | 6565 |
| 6549 Handle<Object> TypeFeedbackInfo::UninitializedSentinel(Isolate* isolate) { | 6566 void TypeFeedbackCells::SetAstId(int index, TypeFeedbackId id) { |
| 6567 set(1 + index * 2, Smi::FromInt(id.ToInt())); |
| 6568 } |
| 6569 |
| 6570 |
| 6571 TypeFeedbackId TypeFeedbackCells::AstId(int index) { |
| 6572 return TypeFeedbackId(Smi::cast(get(1 + index * 2))->value()); |
| 6573 } |
| 6574 |
| 6575 |
| 6576 void TypeFeedbackCells::SetCell(int index, Cell* cell) { |
| 6577 set(index * 2, cell); |
| 6578 } |
| 6579 |
| 6580 |
| 6581 Cell* TypeFeedbackCells::GetCell(int index) { |
| 6582 return Cell::cast(get(index * 2)); |
| 6583 } |
| 6584 |
| 6585 |
| 6586 Handle<Object> TypeFeedbackCells::UninitializedSentinel(Isolate* isolate) { |
| 6550 return isolate->factory()->the_hole_value(); | 6587 return isolate->factory()->the_hole_value(); |
| 6551 } | 6588 } |
| 6552 | 6589 |
| 6553 | 6590 |
| 6554 Handle<Object> TypeFeedbackInfo::MegamorphicSentinel(Isolate* isolate) { | 6591 Handle<Object> TypeFeedbackCells::MegamorphicSentinel(Isolate* isolate) { |
| 6555 return isolate->factory()->undefined_value(); | 6592 return isolate->factory()->undefined_value(); |
| 6556 } | 6593 } |
| 6557 | 6594 |
| 6558 | 6595 |
| 6559 Handle<Object> TypeFeedbackInfo::MonomorphicArraySentinel(Isolate* isolate, | 6596 Handle<Object> TypeFeedbackCells::MonomorphicArraySentinel(Isolate* isolate, |
| 6560 ElementsKind elements_kind) { | 6597 ElementsKind elements_kind) { |
| 6561 return Handle<Object>(Smi::FromInt(static_cast<int>(elements_kind)), isolate); | 6598 return Handle<Object>(Smi::FromInt(static_cast<int>(elements_kind)), isolate); |
| 6562 } | 6599 } |
| 6563 | 6600 |
| 6564 | 6601 |
| 6565 Object* TypeFeedbackInfo::RawUninitializedSentinel(Heap* heap) { | 6602 Object* TypeFeedbackCells::RawUninitializedSentinel(Heap* heap) { |
| 6566 return heap->the_hole_value(); | 6603 return heap->the_hole_value(); |
| 6567 } | 6604 } |
| 6568 | 6605 |
| 6569 | 6606 |
| 6570 int TypeFeedbackInfo::ic_total_count() { | 6607 int TypeFeedbackInfo::ic_total_count() { |
| 6571 int current = Smi::cast(READ_FIELD(this, kStorage1Offset))->value(); | 6608 int current = Smi::cast(READ_FIELD(this, kStorage1Offset))->value(); |
| 6572 return ICTotalCountField::decode(current); | 6609 return ICTotalCountField::decode(current); |
| 6573 } | 6610 } |
| 6574 | 6611 |
| 6575 | 6612 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6638 } | 6675 } |
| 6639 | 6676 |
| 6640 | 6677 |
| 6641 bool TypeFeedbackInfo::matches_inlined_type_change_checksum(int checksum) { | 6678 bool TypeFeedbackInfo::matches_inlined_type_change_checksum(int checksum) { |
| 6642 int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value(); | 6679 int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value(); |
| 6643 int mask = (1 << kTypeChangeChecksumBits) - 1; | 6680 int mask = (1 << kTypeChangeChecksumBits) - 1; |
| 6644 return InlinedTypeChangeChecksum::decode(value) == (checksum & mask); | 6681 return InlinedTypeChangeChecksum::decode(value) == (checksum & mask); |
| 6645 } | 6682 } |
| 6646 | 6683 |
| 6647 | 6684 |
| 6648 ACCESSORS(TypeFeedbackInfo, feedback_vector, FixedArray, | 6685 ACCESSORS(TypeFeedbackInfo, type_feedback_cells, TypeFeedbackCells, |
| 6649 kFeedbackVectorOffset) | 6686 kTypeFeedbackCellsOffset) |
| 6650 | 6687 |
| 6651 | 6688 |
| 6652 SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot, kAliasedContextSlot) | 6689 SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot, kAliasedContextSlot) |
| 6653 | 6690 |
| 6654 | 6691 |
| 6655 Relocatable::Relocatable(Isolate* isolate) { | 6692 Relocatable::Relocatable(Isolate* isolate) { |
| 6656 isolate_ = isolate; | 6693 isolate_ = isolate; |
| 6657 prev_ = isolate->relocatable_top(); | 6694 prev_ = isolate->relocatable_top(); |
| 6658 isolate->set_relocatable_top(this); | 6695 isolate->set_relocatable_top(this); |
| 6659 } | 6696 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6753 #undef READ_UINT32_FIELD | 6790 #undef READ_UINT32_FIELD |
| 6754 #undef WRITE_UINT32_FIELD | 6791 #undef WRITE_UINT32_FIELD |
| 6755 #undef READ_SHORT_FIELD | 6792 #undef READ_SHORT_FIELD |
| 6756 #undef WRITE_SHORT_FIELD | 6793 #undef WRITE_SHORT_FIELD |
| 6757 #undef READ_BYTE_FIELD | 6794 #undef READ_BYTE_FIELD |
| 6758 #undef WRITE_BYTE_FIELD | 6795 #undef WRITE_BYTE_FIELD |
| 6759 | 6796 |
| 6760 } } // namespace v8::internal | 6797 } } // namespace v8::internal |
| 6761 | 6798 |
| 6762 #endif // V8_OBJECTS_INL_H_ | 6799 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |