Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: src/liveedit.cc

Issue 285693006: Fix Heap::IsHeapIterable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Cleanup Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5
6 #include "v8.h" 6 #include "v8.h"
7 7
8 #include "liveedit.h" 8 #include "liveedit.h"
9 9
10 #include "code-stubs.h" 10 #include "code-stubs.h"
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 932
933 // Finds all references to original and replaces them with substitution. 933 // Finds all references to original and replaces them with substitution.
934 static void ReplaceCodeObject(Handle<Code> original, 934 static void ReplaceCodeObject(Handle<Code> original,
935 Handle<Code> substitution) { 935 Handle<Code> substitution) {
936 // Perform a full GC in order to ensure that we are not in the middle of an 936 // Perform a full GC in order to ensure that we are not in the middle of an
937 // incremental marking phase when we are replacing the code object. 937 // incremental marking phase when we are replacing the code object.
938 // Since we are not in an incremental marking phase we can write pointers 938 // Since we are not in an incremental marking phase we can write pointers
939 // to code objects (that are never in new space) without worrying about 939 // to code objects (that are never in new space) without worrying about
940 // write barriers. 940 // write barriers.
941 Heap* heap = original->GetHeap(); 941 Heap* heap = original->GetHeap();
942 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, 942 HeapIterator iterator(heap);
943 "liveedit.cc ReplaceCodeObject");
944 943
945 ASSERT(!heap->InNewSpace(*substitution)); 944 ASSERT(!heap->InNewSpace(*substitution));
946 945
947 DisallowHeapAllocation no_allocation;
948
949 ReplacingVisitor visitor(*original, *substitution); 946 ReplacingVisitor visitor(*original, *substitution);
950 947
951 // Iterate over all roots. Stack frames may have pointer into original code, 948 // Iterate over all roots. Stack frames may have pointer into original code,
952 // so temporary replace the pointers with offset numbers 949 // so temporary replace the pointers with offset numbers
953 // in prologue/epilogue. 950 // in prologue/epilogue.
954 heap->IterateRoots(&visitor, VISIT_ALL); 951 heap->IterateRoots(&visitor, VISIT_ALL);
955 952
956 // Now iterate over all pointers of all objects, including code_target 953 // Now iterate over all pointers of all objects, including code_target
957 // implicit pointers. 954 // implicit pointers.
958 HeapIterator iterator(heap);
959 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 955 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
960 obj->Iterate(&visitor); 956 obj->Iterate(&visitor);
961 } 957 }
962 } 958 }
963 959
964 960
965 // Patch function literals. 961 // Patch function literals.
966 // Name 'literals' is a misnomer. Rather it's a cache for complex object 962 // Name 'literals' is a misnomer. Rather it's a cache for complex object
967 // boilerplates and for a native context. We must clean cached values. 963 // boilerplates and for a native context. We must clean cached values.
968 // Additionally we may need to allocate a new array if number of literals 964 // Additionally we may need to allocate a new array if number of literals
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 shared_info->set_num_literals(new_literal_count); 1008 shared_info->set_num_literals(new_literal_count);
1013 } 1009 }
1014 } 1010 }
1015 1011
1016 private: 1012 private:
1017 // Iterates all function instances in the HEAP that refers to the 1013 // Iterates all function instances in the HEAP that refers to the
1018 // provided shared_info. 1014 // provided shared_info.
1019 template<typename Visitor> 1015 template<typename Visitor>
1020 static void IterateJSFunctions(SharedFunctionInfo* shared_info, 1016 static void IterateJSFunctions(SharedFunctionInfo* shared_info,
1021 Visitor* visitor) { 1017 Visitor* visitor) {
1022 DisallowHeapAllocation no_allocation;
1023
1024 HeapIterator iterator(shared_info->GetHeap()); 1018 HeapIterator iterator(shared_info->GetHeap());
1025 for (HeapObject* obj = iterator.next(); obj != NULL; 1019 for (HeapObject* obj = iterator.next(); obj != NULL;
1026 obj = iterator.next()) { 1020 obj = iterator.next()) {
1027 if (obj->IsJSFunction()) { 1021 if (obj->IsJSFunction()) {
1028 JSFunction* function = JSFunction::cast(obj); 1022 JSFunction* function = JSFunction::cast(obj);
1029 if (function->shared() == shared_info) { 1023 if (function->shared() == shared_info) {
1030 visitor->visit(function); 1024 visitor->visit(function);
1031 } 1025 }
1032 } 1026 }
1033 } 1027 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 void LiveEdit::ReplaceFunctionCode( 1152 void LiveEdit::ReplaceFunctionCode(
1159 Handle<JSArray> new_compile_info_array, 1153 Handle<JSArray> new_compile_info_array,
1160 Handle<JSArray> shared_info_array) { 1154 Handle<JSArray> shared_info_array) {
1161 Isolate* isolate = new_compile_info_array->GetIsolate(); 1155 Isolate* isolate = new_compile_info_array->GetIsolate();
1162 1156
1163 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); 1157 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array);
1164 SharedInfoWrapper shared_info_wrapper(shared_info_array); 1158 SharedInfoWrapper shared_info_wrapper(shared_info_array);
1165 1159
1166 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); 1160 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
1167 1161
1168 isolate->heap()->EnsureHeapIsIterable(); 1162 isolate->heap()->MakeHeapIterable();
1169 1163
1170 if (IsJSFunctionCode(shared_info->code())) { 1164 if (IsJSFunctionCode(shared_info->code())) {
1171 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); 1165 Handle<Code> code = compile_info_wrapper.GetFunctionCode();
1172 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); 1166 ReplaceCodeObject(Handle<Code>(shared_info->code()), code);
1173 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); 1167 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo();
1174 if (code_scope_info->IsFixedArray()) { 1168 if (code_scope_info->IsFixedArray()) {
1175 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); 1169 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info));
1176 } 1170 }
1177 shared_info->DisableOptimization(kLiveEdit); 1171 shared_info->DisableOptimization(kLiveEdit);
1178 // Update the type feedback vector 1172 // Update the type feedback vector
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 position_change_array); 1389 position_change_array);
1396 int new_function_end = TranslatePosition(info->end_position(), 1390 int new_function_end = TranslatePosition(info->end_position(),
1397 position_change_array); 1391 position_change_array);
1398 int new_function_token_pos = 1392 int new_function_token_pos =
1399 TranslatePosition(info->function_token_position(), position_change_array); 1393 TranslatePosition(info->function_token_position(), position_change_array);
1400 1394
1401 info->set_start_position(new_function_start); 1395 info->set_start_position(new_function_start);
1402 info->set_end_position(new_function_end); 1396 info->set_end_position(new_function_end);
1403 info->set_function_token_position(new_function_token_pos); 1397 info->set_function_token_position(new_function_token_pos);
1404 1398
1405 info->GetIsolate()->heap()->EnsureHeapIsIterable(); 1399 info->GetIsolate()->heap()->MakeHeapIterable();
1406 1400
1407 if (IsJSFunctionCode(info->code())) { 1401 if (IsJSFunctionCode(info->code())) {
1408 // Patch relocation info section of the code. 1402 // Patch relocation info section of the code.
1409 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), 1403 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()),
1410 position_change_array); 1404 position_change_array);
1411 if (*patched_code != info->code()) { 1405 if (*patched_code != info->code()) {
1412 // Replace all references to the code across the heap. In particular, 1406 // Replace all references to the code across the heap. In particular,
1413 // some stubs may refer to this code and this code may be being executed 1407 // some stubs may refer to this code and this code may be being executed
1414 // on stack (it is safe to substitute the code object on stack, because 1408 // on stack (it is safe to substitute the code object on stack, because
1415 // we only change the structure of rinfo and leave instructions 1409 // we only change the structure of rinfo and leave instructions
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) { 1964 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) {
1971 isolate_->active_function_info_listener()->FunctionCode(code); 1965 isolate_->active_function_info_listener()->FunctionCode(code);
1972 } 1966 }
1973 1967
1974 1968
1975 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 1969 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
1976 return isolate->active_function_info_listener() != NULL; 1970 return isolate->active_function_info_listener() != NULL;
1977 } 1971 }
1978 1972
1979 } } // namespace v8::internal 1973 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698