| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 ZoneList<Object**> rvalues_; | 902 ZoneList<Object**> rvalues_; |
| 903 ZoneList<RelocInfo> reloc_infos_; | 903 ZoneList<RelocInfo> reloc_infos_; |
| 904 ZoneList<Address> code_entries_; | 904 ZoneList<Address> code_entries_; |
| 905 }; | 905 }; |
| 906 | 906 |
| 907 | 907 |
| 908 // Finds all references to original and replaces them with substitution. | 908 // Finds all references to original and replaces them with substitution. |
| 909 static void ReplaceCodeObject(Code* original, Code* substitution) { | 909 static void ReplaceCodeObject(Code* original, Code* substitution) { |
| 910 ASSERT(!Heap::InNewSpace(substitution)); | 910 ASSERT(!Heap::InNewSpace(substitution)); |
| 911 | 911 |
| 912 HeapIterator iterator; |
| 912 AssertNoAllocation no_allocations_please; | 913 AssertNoAllocation no_allocations_please; |
| 913 | 914 |
| 914 // A zone scope for ReferenceCollectorVisitor. | 915 // A zone scope for ReferenceCollectorVisitor. |
| 915 ZoneScope scope(DELETE_ON_EXIT); | 916 ZoneScope scope(DELETE_ON_EXIT); |
| 916 | 917 |
| 917 ReferenceCollectorVisitor visitor(original); | 918 ReferenceCollectorVisitor visitor(original); |
| 918 | 919 |
| 919 // Iterate over all roots. Stack frames may have pointer into original code, | 920 // Iterate over all roots. Stack frames may have pointer into original code, |
| 920 // so temporary replace the pointers with offset numbers | 921 // so temporary replace the pointers with offset numbers |
| 921 // in prologue/epilogue. | 922 // in prologue/epilogue. |
| 922 { | 923 { |
| 923 Heap::IterateStrongRoots(&visitor, VISIT_ALL); | 924 Heap::IterateStrongRoots(&visitor, VISIT_ALL); |
| 924 } | 925 } |
| 925 | 926 |
| 926 // Now iterate over all pointers of all objects, including code_target | 927 // Now iterate over all pointers of all objects, including code_target |
| 927 // implicit pointers. | 928 // implicit pointers. |
| 928 HeapIterator iterator; | 929 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
| 929 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | |
| 930 obj->Iterate(&visitor); | 930 obj->Iterate(&visitor); |
| 931 } | 931 } |
| 932 | 932 |
| 933 visitor.Replace(substitution); | 933 visitor.Replace(substitution); |
| 934 } | 934 } |
| 935 | 935 |
| 936 | 936 |
| 937 // Check whether the code is natural function code (not a lazy-compile stub | 937 // Check whether the code is natural function code (not a lazy-compile stub |
| 938 // code). | 938 // code). |
| 939 static bool IsJSFunctionCode(Code* code) { | 939 static bool IsJSFunctionCode(Code* code) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 | 1003 |
| 1004 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { | 1004 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { |
| 1005 return Top::ThrowIllegalOperation(); | 1005 return Top::ThrowIllegalOperation(); |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); | 1008 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); |
| 1009 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 1009 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
| 1010 | 1010 |
| 1011 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); | 1011 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); |
| 1012 | 1012 |
| 1013 Heap::EnsureHeapIsIterable(); |
| 1014 |
| 1013 if (IsJSFunctionCode(shared_info->code())) { | 1015 if (IsJSFunctionCode(shared_info->code())) { |
| 1014 ReplaceCodeObject(shared_info->code(), | 1016 ReplaceCodeObject(shared_info->code(), |
| 1015 *(compile_info_wrapper.GetFunctionCode())); | 1017 *(compile_info_wrapper.GetFunctionCode())); |
| 1016 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); | 1018 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); |
| 1017 if (code_scope_info->IsFixedArray()) { | 1019 if (code_scope_info->IsFixedArray()) { |
| 1018 shared_info->set_scope_info(SerializedScopeInfo::cast(*code_scope_info)); | 1020 shared_info->set_scope_info(SerializedScopeInfo::cast(*code_scope_info)); |
| 1019 } | 1021 } |
| 1020 } | 1022 } |
| 1021 | 1023 |
| 1022 if (shared_info->debug_info()->IsDebugInfo()) { | 1024 if (shared_info->debug_info()->IsDebugInfo()) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 RelocInfoWriter reloc_info_writer_; | 1172 RelocInfoWriter reloc_info_writer_; |
| 1171 byte* buffer_; | 1173 byte* buffer_; |
| 1172 int buffer_size_; | 1174 int buffer_size_; |
| 1173 | 1175 |
| 1174 static const int kBufferGap = RelocInfoWriter::kMaxSize; | 1176 static const int kBufferGap = RelocInfoWriter::kMaxSize; |
| 1175 static const int kMaximalBufferSize = 512*MB; | 1177 static const int kMaximalBufferSize = 512*MB; |
| 1176 }; | 1178 }; |
| 1177 | 1179 |
| 1178 // Patch positions in code (changes relocation info section) and possibly | 1180 // Patch positions in code (changes relocation info section) and possibly |
| 1179 // returns new instance of code. | 1181 // returns new instance of code. |
| 1180 static Handle<Code> PatchPositionsInCode(Handle<Code> code, | 1182 static Handle<Code> PatchPositionsInCode( |
| 1183 Handle<Code> code, |
| 1181 Handle<JSArray> position_change_array) { | 1184 Handle<JSArray> position_change_array) { |
| 1182 | 1185 |
| 1183 RelocInfoBuffer buffer_writer(code->relocation_size(), | 1186 RelocInfoBuffer buffer_writer(code->relocation_size(), |
| 1184 code->instruction_start()); | 1187 code->instruction_start()); |
| 1185 | 1188 |
| 1186 { | 1189 { |
| 1187 AssertNoAllocation no_allocations_please; | 1190 AssertNoAllocation no_allocations_please; |
| 1188 for (RelocIterator it(*code); !it.done(); it.next()) { | 1191 for (RelocIterator it(*code); !it.done(); it.next()) { |
| 1189 RelocInfo* rinfo = it.rinfo(); | 1192 RelocInfo* rinfo = it.rinfo(); |
| 1190 if (RelocInfo::IsPosition(rinfo->rmode())) { | 1193 if (RelocInfo::IsPosition(rinfo->rmode())) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 int new_function_start = TranslatePosition(old_function_start, | 1234 int new_function_start = TranslatePosition(old_function_start, |
| 1232 position_change_array); | 1235 position_change_array); |
| 1233 info->set_start_position(new_function_start); | 1236 info->set_start_position(new_function_start); |
| 1234 info->set_end_position(TranslatePosition(info->end_position(), | 1237 info->set_end_position(TranslatePosition(info->end_position(), |
| 1235 position_change_array)); | 1238 position_change_array)); |
| 1236 | 1239 |
| 1237 info->set_function_token_position( | 1240 info->set_function_token_position( |
| 1238 TranslatePosition(info->function_token_position(), | 1241 TranslatePosition(info->function_token_position(), |
| 1239 position_change_array)); | 1242 position_change_array)); |
| 1240 | 1243 |
| 1244 Heap::EnsureHeapIsIterable(); |
| 1245 |
| 1241 if (IsJSFunctionCode(info->code())) { | 1246 if (IsJSFunctionCode(info->code())) { |
| 1242 // Patch relocation info section of the code. | 1247 // Patch relocation info section of the code. |
| 1243 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), | 1248 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), |
| 1244 position_change_array); | 1249 position_change_array); |
| 1245 if (*patched_code != info->code()) { | 1250 if (*patched_code != info->code()) { |
| 1246 // Replace all references to the code across the heap. In particular, | 1251 // Replace all references to the code across the heap. In particular, |
| 1247 // some stubs may refer to this code and this code may be being executed | 1252 // some stubs may refer to this code and this code may be being executed |
| 1248 // on stack (it is safe to substitute the code object on stack, because | 1253 // on stack (it is safe to substitute the code object on stack, because |
| 1249 // we only change the structure of rinfo and leave instructions | 1254 // we only change the structure of rinfo and leave instructions |
| 1250 // untouched). | 1255 // untouched). |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 | 1673 |
| 1669 bool LiveEditFunctionTracker::IsActive() { | 1674 bool LiveEditFunctionTracker::IsActive() { |
| 1670 return false; | 1675 return false; |
| 1671 } | 1676 } |
| 1672 | 1677 |
| 1673 #endif // ENABLE_DEBUGGER_SUPPORT | 1678 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1674 | 1679 |
| 1675 | 1680 |
| 1676 | 1681 |
| 1677 } } // namespace v8::internal | 1682 } } // namespace v8::internal |
| OLD | NEW |