OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 DCHECK(space_number == CODE_SPACE || space_number == LO_SPACE); | 792 DCHECK(space_number == CODE_SPACE || space_number == LO_SPACE); |
793 } else { | 793 } else { |
794 DCHECK(space_number != CODE_SPACE); | 794 DCHECK(space_number != CODE_SPACE); |
795 } | 795 } |
796 #endif | 796 #endif |
797 | 797 |
798 if (obj->IsCode()) { | 798 if (obj->IsCode()) { |
799 // Turn internal references encoded as offsets back to absolute addresses. | 799 // Turn internal references encoded as offsets back to absolute addresses. |
800 Code* code = Code::cast(obj); | 800 Code* code = Code::cast(obj); |
801 Address entry = code->entry(); | 801 Address entry = code->entry(); |
802 int mode_mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE); | 802 int mode_mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | |
| 803 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
803 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { | 804 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { |
804 RelocInfo* rinfo = it.rinfo(); | 805 RelocInfo* rinfo = it.rinfo(); |
805 intptr_t offset = | 806 intptr_t offset = |
806 reinterpret_cast<intptr_t>(rinfo->target_internal_reference()); | 807 reinterpret_cast<intptr_t>(rinfo->target_internal_reference()); |
807 DCHECK(0 <= offset && offset <= code->instruction_size()); | 808 DCHECK(0 <= offset && offset <= code->instruction_size()); |
808 rinfo->set_target_internal_reference(entry + offset); | 809 rinfo->set_target_internal_reference(entry + offset); |
809 } | 810 } |
810 } | 811 } |
811 } | 812 } |
812 | 813 |
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 // and wipe all pointers in the copy, which we then serialize. | 1947 // and wipe all pointers in the copy, which we then serialize. |
1947 Code* original = Code::cast(object_); | 1948 Code* original = Code::cast(object_); |
1948 Code* code = serializer_->CopyCode(original); | 1949 Code* code = serializer_->CopyCode(original); |
1949 // Code age headers are not serializable. | 1950 // Code age headers are not serializable. |
1950 code->MakeYoung(serializer_->isolate()); | 1951 code->MakeYoung(serializer_->isolate()); |
1951 Address entry = original->entry(); | 1952 Address entry = original->entry(); |
1952 int mode_mask = RelocInfo::kCodeTargetMask | | 1953 int mode_mask = RelocInfo::kCodeTargetMask | |
1953 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 1954 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
1954 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 1955 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
1955 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | | 1956 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | |
1956 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE); | 1957 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | |
| 1958 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
1957 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { | 1959 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { |
1958 RelocInfo* rinfo = it.rinfo(); | 1960 RelocInfo* rinfo = it.rinfo(); |
1959 if (RelocInfo::IsInternalReference(rinfo->rmode())) { | 1961 RelocInfo::Mode rmode = rinfo->rmode(); |
| 1962 if (RelocInfo::IsInternalReference(rmode) || |
| 1963 RelocInfo::IsInternalReferenceEncoded(rmode)) { |
1960 // Convert internal references to relative offsets. | 1964 // Convert internal references to relative offsets. |
1961 Address target = rinfo->target_internal_reference(); | 1965 Address target = rinfo->target_internal_reference(); |
1962 intptr_t offset = target - entry; | 1966 intptr_t offset = target - entry; |
1963 DCHECK(0 <= offset && offset <= original->instruction_size()); | 1967 DCHECK(0 <= offset && offset <= original->instruction_size()); |
1964 rinfo->set_target_internal_reference(reinterpret_cast<Address>(offset)); | 1968 rinfo->set_target_internal_reference(reinterpret_cast<Address>(offset)); |
1965 } else if (!(FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool())) { | 1969 } else if (!(FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool())) { |
1966 rinfo->WipeOut(); | 1970 rinfo->WipeOut(); |
1967 } | 1971 } |
1968 } | 1972 } |
1969 // We need to wipe out the header fields *after* wiping out the | 1973 // We need to wipe out the header fields *after* wiping out the |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2558 DisallowHeapAllocation no_gc; | 2562 DisallowHeapAllocation no_gc; |
2559 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2563 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2560 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2564 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2561 if (r == CHECK_SUCCESS) return scd; | 2565 if (r == CHECK_SUCCESS) return scd; |
2562 cached_data->Reject(); | 2566 cached_data->Reject(); |
2563 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2567 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2564 delete scd; | 2568 delete scd; |
2565 return NULL; | 2569 return NULL; |
2566 } | 2570 } |
2567 } } // namespace v8::internal | 2571 } } // namespace v8::internal |
OLD | NEW |