Chromium Code Reviews| 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 DCHECK(space_number == CODE_SPACE || space_number == LO_SPACE); | 795 DCHECK(space_number == CODE_SPACE || space_number == LO_SPACE); |
| 796 } else { | 796 } else { |
| 797 DCHECK(space_number != CODE_SPACE); | 797 DCHECK(space_number != CODE_SPACE); |
| 798 } | 798 } |
| 799 #endif | 799 #endif |
| 800 | 800 |
| 801 if (obj->IsCode()) { | 801 if (obj->IsCode()) { |
| 802 // Turn internal references encoded as offsets back to absolute addresses. | 802 // Turn internal references encoded as offsets back to absolute addresses. |
| 803 Code* code = Code::cast(obj); | 803 Code* code = Code::cast(obj); |
| 804 Address entry = code->entry(); | 804 Address entry = code->entry(); |
| 805 int mode_mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE); | 805 int mode_mask = RelocInfo::kInternalReferenceMask; |
| 806 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { | 806 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { |
| 807 RelocInfo* rinfo = it.rinfo(); | 807 RelocInfo* rinfo = it.rinfo(); |
| 808 intptr_t offset = | 808 intptr_t offset = |
| 809 reinterpret_cast<intptr_t>(rinfo->target_internal_reference()); | 809 reinterpret_cast<intptr_t>(rinfo->target_internal_reference()); |
| 810 DCHECK(0 <= offset && offset <= code->instruction_size()); | 810 DCHECK(0 <= offset && offset <= code->instruction_size()); |
| 811 rinfo->set_target_internal_reference(entry + offset); | 811 rinfo->set_target_internal_reference(entry + offset, SKIP_ICACHE_FLUSH); |
|
Yang
2015/03/09 08:03:56
Why do we need this flag? Is there any call site w
| |
| 812 } | 812 } |
| 813 } | 813 } |
| 814 } | 814 } |
| 815 | 815 |
| 816 | 816 |
| 817 // We know the space requirements before deserialization and can | 817 // We know the space requirements before deserialization and can |
| 818 // pre-allocate that reserved space. During deserialization, all we need | 818 // pre-allocate that reserved space. During deserialization, all we need |
| 819 // to do is to bump up the pointer for each space in the reserved | 819 // to do is to bump up the pointer for each space in the reserved |
| 820 // space. This is also used for fixing back references. | 820 // space. This is also used for fixing back references. |
| 821 // We may have to split up the pre-allocation into several chunks | 821 // We may have to split up the pre-allocation into several chunks |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1946 | 1946 |
| 1947 Address Serializer::ObjectSerializer::PrepareCode() { | 1947 Address Serializer::ObjectSerializer::PrepareCode() { |
| 1948 // To make snapshots reproducible, we make a copy of the code object | 1948 // To make snapshots reproducible, we make a copy of the code object |
| 1949 // and wipe all pointers in the copy, which we then serialize. | 1949 // and wipe all pointers in the copy, which we then serialize. |
| 1950 Code* original = Code::cast(object_); | 1950 Code* original = Code::cast(object_); |
| 1951 Code* code = serializer_->CopyCode(original); | 1951 Code* code = serializer_->CopyCode(original); |
| 1952 // Code age headers are not serializable. | 1952 // Code age headers are not serializable. |
| 1953 code->MakeYoung(serializer_->isolate()); | 1953 code->MakeYoung(serializer_->isolate()); |
| 1954 Address entry = original->entry(); | 1954 Address entry = original->entry(); |
| 1955 int mode_mask = RelocInfo::kCodeTargetMask | | 1955 int mode_mask = RelocInfo::kCodeTargetMask | |
| 1956 RelocInfo::kInternalReferenceMask | | |
| 1956 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 1957 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 1957 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 1958 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 1958 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | | 1959 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
| 1959 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE); | |
| 1960 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { | 1960 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { |
| 1961 RelocInfo* rinfo = it.rinfo(); | 1961 RelocInfo* rinfo = it.rinfo(); |
| 1962 if (RelocInfo::IsInternalReference(rinfo->rmode())) { | 1962 if (RelocInfo::ModeMask(rinfo->rmode()) & |
| 1963 RelocInfo::kInternalReferenceMask) { | |
|
Yang
2015/03/09 08:03:56
Can we simply change the implementation of IsInter
| |
| 1963 // Convert internal references to relative offsets. | 1964 // Convert internal references to relative offsets. |
| 1964 Address target = rinfo->target_internal_reference(); | 1965 Address target = rinfo->target_internal_reference(); |
| 1965 intptr_t offset = target - entry; | 1966 intptr_t offset = target - entry; |
| 1966 DCHECK(0 <= offset && offset <= original->instruction_size()); | 1967 DCHECK(0 <= offset && offset <= original->instruction_size()); |
| 1967 rinfo->set_target_internal_reference(reinterpret_cast<Address>(offset)); | 1968 rinfo->set_target_internal_reference(reinterpret_cast<Address>(offset), |
|
Yang
2015/03/09 08:03:56
Afaict Assembler::set_target_internal_reference do
| |
| 1969 SKIP_ICACHE_FLUSH); | |
| 1968 } else if (!(FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool())) { | 1970 } else if (!(FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool())) { |
| 1969 rinfo->WipeOut(); | 1971 rinfo->WipeOut(); |
| 1970 } | 1972 } |
| 1971 } | 1973 } |
| 1972 // We need to wipe out the header fields *after* wiping out the | 1974 // We need to wipe out the header fields *after* wiping out the |
| 1973 // relocations, because some of these fields are needed for the latter. | 1975 // relocations, because some of these fields are needed for the latter. |
| 1974 code->WipeOutHeader(); | 1976 code->WipeOutHeader(); |
| 1975 return code->address(); | 1977 return code->address(); |
| 1976 } | 1978 } |
| 1977 | 1979 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2561 DisallowHeapAllocation no_gc; | 2563 DisallowHeapAllocation no_gc; |
| 2562 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2564 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2563 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2565 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2564 if (r == CHECK_SUCCESS) return scd; | 2566 if (r == CHECK_SUCCESS) return scd; |
| 2565 cached_data->Reject(); | 2567 cached_data->Reject(); |
| 2566 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2568 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2567 delete scd; | 2569 delete scd; |
| 2568 return NULL; | 2570 return NULL; |
| 2569 } | 2571 } |
| 2570 } } // namespace v8::internal | 2572 } } // namespace v8::internal |
| OLD | NEW |