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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 // incremental marking phase when we are replacing the code object. | 1062 // incremental marking phase when we are replacing the code object. |
1063 // Since we are not in an incremental marking phase we can write pointers | 1063 // Since we are not in an incremental marking phase we can write pointers |
1064 // to code objects (that are never in new space) without worrying about | 1064 // to code objects (that are never in new space) without worrying about |
1065 // write barriers. | 1065 // write barriers. |
1066 Heap* heap = original->GetHeap(); | 1066 Heap* heap = original->GetHeap(); |
1067 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1067 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1068 "liveedit.cc ReplaceCodeObject"); | 1068 "liveedit.cc ReplaceCodeObject"); |
1069 | 1069 |
1070 ASSERT(!heap->InNewSpace(*substitution)); | 1070 ASSERT(!heap->InNewSpace(*substitution)); |
1071 | 1071 |
1072 AssertNoAllocation no_allocations_please; | 1072 DisallowHeapAllocation no_allocation; |
1073 | 1073 |
1074 ReplacingVisitor visitor(*original, *substitution); | 1074 ReplacingVisitor visitor(*original, *substitution); |
1075 | 1075 |
1076 // Iterate over all roots. Stack frames may have pointer into original code, | 1076 // Iterate over all roots. Stack frames may have pointer into original code, |
1077 // so temporary replace the pointers with offset numbers | 1077 // so temporary replace the pointers with offset numbers |
1078 // in prologue/epilogue. | 1078 // in prologue/epilogue. |
1079 heap->IterateRoots(&visitor, VISIT_ALL); | 1079 heap->IterateRoots(&visitor, VISIT_ALL); |
1080 | 1080 |
1081 // Now iterate over all pointers of all objects, including code_target | 1081 // Now iterate over all pointers of all objects, including code_target |
1082 // implicit pointers. | 1082 // implicit pointers. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 shared_info->set_num_literals(new_literal_count); | 1137 shared_info->set_num_literals(new_literal_count); |
1138 } | 1138 } |
1139 } | 1139 } |
1140 | 1140 |
1141 private: | 1141 private: |
1142 // Iterates all function instances in the HEAP that refers to the | 1142 // Iterates all function instances in the HEAP that refers to the |
1143 // provided shared_info. | 1143 // provided shared_info. |
1144 template<typename Visitor> | 1144 template<typename Visitor> |
1145 static void IterateJSFunctions(SharedFunctionInfo* shared_info, | 1145 static void IterateJSFunctions(SharedFunctionInfo* shared_info, |
1146 Visitor* visitor) { | 1146 Visitor* visitor) { |
1147 AssertNoAllocation no_allocations_please; | 1147 DisallowHeapAllocation no_allocation; |
1148 | 1148 |
1149 HeapIterator iterator(shared_info->GetHeap()); | 1149 HeapIterator iterator(shared_info->GetHeap()); |
1150 for (HeapObject* obj = iterator.next(); obj != NULL; | 1150 for (HeapObject* obj = iterator.next(); obj != NULL; |
1151 obj = iterator.next()) { | 1151 obj = iterator.next()) { |
1152 if (obj->IsJSFunction()) { | 1152 if (obj->IsJSFunction()) { |
1153 JSFunction* function = JSFunction::cast(obj); | 1153 JSFunction* function = JSFunction::cast(obj); |
1154 if (function->shared() == shared_info) { | 1154 if (function->shared() == shared_info) { |
1155 visitor->visit(function); | 1155 visitor->visit(function); |
1156 } | 1156 } |
1157 } | 1157 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 | 1212 |
1213 // Check whether the code is natural function code (not a lazy-compile stub | 1213 // Check whether the code is natural function code (not a lazy-compile stub |
1214 // code). | 1214 // code). |
1215 static bool IsJSFunctionCode(Code* code) { | 1215 static bool IsJSFunctionCode(Code* code) { |
1216 return code->kind() == Code::FUNCTION; | 1216 return code->kind() == Code::FUNCTION; |
1217 } | 1217 } |
1218 | 1218 |
1219 | 1219 |
1220 // Returns true if an instance of candidate were inlined into function's code. | 1220 // Returns true if an instance of candidate were inlined into function's code. |
1221 static bool IsInlined(JSFunction* function, SharedFunctionInfo* candidate) { | 1221 static bool IsInlined(JSFunction* function, SharedFunctionInfo* candidate) { |
1222 AssertNoAllocation no_gc; | 1222 DisallowHeapAllocation no_gc; |
1223 | 1223 |
1224 if (function->code()->kind() != Code::OPTIMIZED_FUNCTION) return false; | 1224 if (function->code()->kind() != Code::OPTIMIZED_FUNCTION) return false; |
1225 | 1225 |
1226 DeoptimizationInputData* data = | 1226 DeoptimizationInputData* data = |
1227 DeoptimizationInputData::cast(function->code()->deoptimization_data()); | 1227 DeoptimizationInputData::cast(function->code()->deoptimization_data()); |
1228 | 1228 |
1229 if (data == HEAP->empty_fixed_array()) return false; | 1229 if (data == HEAP->empty_fixed_array()) return false; |
1230 | 1230 |
1231 FixedArray* literals = data->LiteralArray(); | 1231 FixedArray* literals = data->LiteralArray(); |
1232 | 1232 |
(...skipping 17 matching lines...) Expand all Loading... |
1250 return (function->shared() == function_info_ || | 1250 return (function->shared() == function_info_ || |
1251 IsInlined(function, function_info_)); | 1251 IsInlined(function, function_info_)); |
1252 } | 1252 } |
1253 | 1253 |
1254 private: | 1254 private: |
1255 SharedFunctionInfo* function_info_; | 1255 SharedFunctionInfo* function_info_; |
1256 }; | 1256 }; |
1257 | 1257 |
1258 | 1258 |
1259 static void DeoptimizeDependentFunctions(SharedFunctionInfo* function_info) { | 1259 static void DeoptimizeDependentFunctions(SharedFunctionInfo* function_info) { |
1260 AssertNoAllocation no_allocation; | 1260 DisallowHeapAllocation no_allocation; |
1261 | 1261 |
1262 DependentFunctionFilter filter(function_info); | 1262 DependentFunctionFilter filter(function_info); |
1263 Deoptimizer::DeoptimizeAllFunctionsWith(function_info->GetIsolate(), &filter); | 1263 Deoptimizer::DeoptimizeAllFunctionsWith(function_info->GetIsolate(), &filter); |
1264 } | 1264 } |
1265 | 1265 |
1266 | 1266 |
1267 MaybeObject* LiveEdit::ReplaceFunctionCode( | 1267 MaybeObject* LiveEdit::ReplaceFunctionCode( |
1268 Handle<JSArray> new_compile_info_array, | 1268 Handle<JSArray> new_compile_info_array, |
1269 Handle<JSArray> shared_info_array) { | 1269 Handle<JSArray> shared_info_array) { |
1270 Isolate* isolate = Isolate::Current(); | 1270 Isolate* isolate = Isolate::Current(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 // Patch positions in code (changes relocation info section) and possibly | 1458 // Patch positions in code (changes relocation info section) and possibly |
1459 // returns new instance of code. | 1459 // returns new instance of code. |
1460 static Handle<Code> PatchPositionsInCode( | 1460 static Handle<Code> PatchPositionsInCode( |
1461 Handle<Code> code, | 1461 Handle<Code> code, |
1462 Handle<JSArray> position_change_array) { | 1462 Handle<JSArray> position_change_array) { |
1463 | 1463 |
1464 RelocInfoBuffer buffer_writer(code->relocation_size(), | 1464 RelocInfoBuffer buffer_writer(code->relocation_size(), |
1465 code->instruction_start()); | 1465 code->instruction_start()); |
1466 | 1466 |
1467 { | 1467 { |
1468 AssertNoAllocation no_allocations_please; | 1468 DisallowHeapAllocation no_allocation; |
1469 for (RelocIterator it(*code); !it.done(); it.next()) { | 1469 for (RelocIterator it(*code); !it.done(); it.next()) { |
1470 RelocInfo* rinfo = it.rinfo(); | 1470 RelocInfo* rinfo = it.rinfo(); |
1471 if (RelocInfo::IsPosition(rinfo->rmode())) { | 1471 if (RelocInfo::IsPosition(rinfo->rmode())) { |
1472 int position = static_cast<int>(rinfo->data()); | 1472 int position = static_cast<int>(rinfo->data()); |
1473 int new_position = TranslatePosition(position, | 1473 int new_position = TranslatePosition(position, |
1474 position_change_array); | 1474 position_change_array); |
1475 if (position != new_position) { | 1475 if (position != new_position) { |
1476 RelocInfo info_copy(rinfo->pc(), rinfo->rmode(), new_position, NULL); | 1476 RelocInfo info_copy(rinfo->pc(), rinfo->rmode(), new_position, NULL); |
1477 buffer_writer.Write(&info_copy); | 1477 buffer_writer.Write(&info_copy); |
1478 continue; | 1478 continue; |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 | 2119 |
2120 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 2120 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
2121 return false; | 2121 return false; |
2122 } | 2122 } |
2123 | 2123 |
2124 #endif // ENABLE_DEBUGGER_SUPPORT | 2124 #endif // ENABLE_DEBUGGER_SUPPORT |
2125 | 2125 |
2126 | 2126 |
2127 | 2127 |
2128 } } // namespace v8::internal | 2128 } } // namespace v8::internal |
OLD | NEW |