| 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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 VisitCodeTarget(rinfo); | 958 VisitCodeTarget(rinfo); |
| 959 } | 959 } |
| 960 | 960 |
| 961 private: | 961 private: |
| 962 Code* original_; | 962 Code* original_; |
| 963 Code* substitution_; | 963 Code* substitution_; |
| 964 }; | 964 }; |
| 965 | 965 |
| 966 | 966 |
| 967 // Finds all references to original and replaces them with substitution. | 967 // Finds all references to original and replaces them with substitution. |
| 968 static void ReplaceCodeObject(Code* original, Code* substitution) { | 968 static void ReplaceCodeObject(Handle<Code> original, |
| 969 ASSERT(!HEAP->InNewSpace(substitution)); | 969 Handle<Code> substitution) { |
| 970 // Perform a full GC in order to ensure that we are not in the middle of an |
| 971 // incremental marking phase when we are replacing the code object. |
| 972 // Since we are not in an incremental marking phase we can write pointers |
| 973 // to code objects (that are never in new space) without worrying about |
| 974 // write barriers. |
| 975 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
| 976 "liveedit.cc ReplaceCodeObject"); |
| 977 |
| 978 ASSERT(!HEAP->InNewSpace(*substitution)); |
| 970 | 979 |
| 971 AssertNoAllocation no_allocations_please; | 980 AssertNoAllocation no_allocations_please; |
| 972 | 981 |
| 973 ReplacingVisitor visitor(original, substitution); | 982 ReplacingVisitor visitor(*original, *substitution); |
| 974 | 983 |
| 975 // Iterate over all roots. Stack frames may have pointer into original code, | 984 // Iterate over all roots. Stack frames may have pointer into original code, |
| 976 // so temporary replace the pointers with offset numbers | 985 // so temporary replace the pointers with offset numbers |
| 977 // in prologue/epilogue. | 986 // in prologue/epilogue. |
| 978 HEAP->IterateRoots(&visitor, VISIT_ALL); | 987 HEAP->IterateRoots(&visitor, VISIT_ALL); |
| 979 | 988 |
| 980 // Now iterate over all pointers of all objects, including code_target | 989 // Now iterate over all pointers of all objects, including code_target |
| 981 // implicit pointers. | 990 // implicit pointers. |
| 982 HeapIterator iterator; | 991 HeapIterator iterator; |
| 983 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 992 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 | 1068 |
| 1060 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); | 1069 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); |
| 1061 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 1070 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
| 1062 | 1071 |
| 1063 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); | 1072 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); |
| 1064 | 1073 |
| 1065 HEAP->EnsureHeapIsIterable(); | 1074 HEAP->EnsureHeapIsIterable(); |
| 1066 | 1075 |
| 1067 if (IsJSFunctionCode(shared_info->code())) { | 1076 if (IsJSFunctionCode(shared_info->code())) { |
| 1068 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); | 1077 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); |
| 1069 ReplaceCodeObject(shared_info->code(), *code); | 1078 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); |
| 1070 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); | 1079 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); |
| 1071 if (code_scope_info->IsFixedArray()) { | 1080 if (code_scope_info->IsFixedArray()) { |
| 1072 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); | 1081 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); |
| 1073 } | 1082 } |
| 1074 } | 1083 } |
| 1075 | 1084 |
| 1076 if (shared_info->debug_info()->IsDebugInfo()) { | 1085 if (shared_info->debug_info()->IsDebugInfo()) { |
| 1077 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info())); | 1086 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info())); |
| 1078 Handle<Code> new_original_code = | 1087 Handle<Code> new_original_code = |
| 1079 FACTORY->CopyCode(compile_info_wrapper.GetFunctionCode()); | 1088 FACTORY->CopyCode(compile_info_wrapper.GetFunctionCode()); |
| 1080 debug_info->set_original_code(*new_original_code); | 1089 debug_info->set_original_code(*new_original_code); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 if (IsJSFunctionCode(info->code())) { | 1311 if (IsJSFunctionCode(info->code())) { |
| 1303 // Patch relocation info section of the code. | 1312 // Patch relocation info section of the code. |
| 1304 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), | 1313 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), |
| 1305 position_change_array); | 1314 position_change_array); |
| 1306 if (*patched_code != info->code()) { | 1315 if (*patched_code != info->code()) { |
| 1307 // Replace all references to the code across the heap. In particular, | 1316 // Replace all references to the code across the heap. In particular, |
| 1308 // some stubs may refer to this code and this code may be being executed | 1317 // some stubs may refer to this code and this code may be being executed |
| 1309 // on stack (it is safe to substitute the code object on stack, because | 1318 // on stack (it is safe to substitute the code object on stack, because |
| 1310 // we only change the structure of rinfo and leave instructions | 1319 // we only change the structure of rinfo and leave instructions |
| 1311 // untouched). | 1320 // untouched). |
| 1312 ReplaceCodeObject(info->code(), *patched_code); | 1321 ReplaceCodeObject(Handle<Code>(info->code()), patched_code); |
| 1313 } | 1322 } |
| 1314 } | 1323 } |
| 1315 | 1324 |
| 1316 return HEAP->undefined_value(); | 1325 return HEAP->undefined_value(); |
| 1317 } | 1326 } |
| 1318 | 1327 |
| 1319 | 1328 |
| 1320 static Handle<Script> CreateScriptCopy(Handle<Script> original) { | 1329 static Handle<Script> CreateScriptCopy(Handle<Script> original) { |
| 1321 Handle<String> original_source(String::cast(original->source())); | 1330 Handle<String> original_source(String::cast(original->source())); |
| 1322 | 1331 |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 | 1888 |
| 1880 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 1889 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
| 1881 return false; | 1890 return false; |
| 1882 } | 1891 } |
| 1883 | 1892 |
| 1884 #endif // ENABLE_DEBUGGER_SUPPORT | 1893 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1885 | 1894 |
| 1886 | 1895 |
| 1887 | 1896 |
| 1888 } } // namespace v8::internal | 1897 } } // namespace v8::internal |
| OLD | NEW |