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

Side by Side Diff: src/runtime/runtime-liveedit.cc

Issue 2053573004: [runtime] Deprecate RUNTIME_ASSERT from debugger methods. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 5 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
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/mjsunit/regress/regress-crbug-390925.js » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/debug/debug-frames.h" 9 #include "src/debug/debug-frames.h"
10 #include "src/debug/liveedit.h" 10 #include "src/debug/liveedit.h"
11 #include "src/frames-inl.h" 11 #include "src/frames-inl.h"
12 #include "src/isolate-inl.h" 12 #include "src/isolate-inl.h"
13 #include "src/runtime/runtime.h" 13 #include "src/runtime/runtime.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 // For a script finds all SharedFunctionInfo's in the heap that points 18 // For a script finds all SharedFunctionInfo's in the heap that points
19 // to this script. Returns JSArray of SharedFunctionInfo wrapped 19 // to this script. Returns JSArray of SharedFunctionInfo wrapped
20 // in OpaqueReferences. 20 // in OpaqueReferences.
21 RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { 21 RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
22 HandleScope scope(isolate); 22 HandleScope scope(isolate);
23 CHECK(isolate->debug()->live_edit_enabled()); 23 CHECK(isolate->debug()->live_edit_enabled());
24 DCHECK(args.length() == 1); 24 DCHECK(args.length() == 1);
25 CONVERT_ARG_CHECKED(JSValue, script_value, 0); 25 CONVERT_ARG_CHECKED(JSValue, script_value, 0);
26 26
27 RUNTIME_ASSERT(script_value->value()->IsScript()); 27 CHECK(script_value->value()->IsScript());
28 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); 28 Handle<Script> script = Handle<Script>(Script::cast(script_value->value()));
29 29
30 List<Handle<SharedFunctionInfo> > found; 30 List<Handle<SharedFunctionInfo> > found;
31 Heap* heap = isolate->heap(); 31 Heap* heap = isolate->heap();
32 { 32 {
33 HeapIterator iterator(heap); 33 HeapIterator iterator(heap);
34 HeapObject* heap_obj; 34 HeapObject* heap_obj;
35 while ((heap_obj = iterator.next())) { 35 while ((heap_obj = iterator.next())) {
36 if (!heap_obj->IsSharedFunctionInfo()) continue; 36 if (!heap_obj->IsSharedFunctionInfo()) continue;
37 SharedFunctionInfo* shared = SharedFunctionInfo::cast(heap_obj); 37 SharedFunctionInfo* shared = SharedFunctionInfo::cast(heap_obj);
(...skipping 22 matching lines...) Expand all
60 // Returns a JSArray of compilation infos. The array is ordered so that 60 // Returns a JSArray of compilation infos. The array is ordered so that
61 // each function with all its descendant is always stored in a continues range 61 // each function with all its descendant is always stored in a continues range
62 // with the function itself going first. The root function is a script function. 62 // with the function itself going first. The root function is a script function.
63 RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) { 63 RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) {
64 HandleScope scope(isolate); 64 HandleScope scope(isolate);
65 CHECK(isolate->debug()->live_edit_enabled()); 65 CHECK(isolate->debug()->live_edit_enabled());
66 DCHECK(args.length() == 2); 66 DCHECK(args.length() == 2);
67 CONVERT_ARG_CHECKED(JSValue, script, 0); 67 CONVERT_ARG_CHECKED(JSValue, script, 0);
68 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 68 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
69 69
70 RUNTIME_ASSERT(script->value()->IsScript()); 70 CHECK(script->value()->IsScript());
71 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 71 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
72 72
73 RETURN_RESULT_OR_FAILURE(isolate, 73 RETURN_RESULT_OR_FAILURE(isolate,
74 LiveEdit::GatherCompileInfo(script_handle, source)); 74 LiveEdit::GatherCompileInfo(script_handle, source));
75 } 75 }
76 76
77 77
78 // Changes the source of the script to a new_source. 78 // Changes the source of the script to a new_source.
79 // If old_script_name is provided (i.e. is a String), also creates a copy of 79 // If old_script_name is provided (i.e. is a String), also creates a copy of
80 // the script with its original source and sends notification to debugger. 80 // the script with its original source and sends notification to debugger.
81 RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) { 81 RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) {
82 HandleScope scope(isolate); 82 HandleScope scope(isolate);
83 CHECK(isolate->debug()->live_edit_enabled()); 83 CHECK(isolate->debug()->live_edit_enabled());
84 DCHECK(args.length() == 3); 84 DCHECK(args.length() == 3);
85 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); 85 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0);
86 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); 86 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1);
87 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); 87 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2);
88 88
89 RUNTIME_ASSERT(original_script_value->value()->IsScript()); 89 CHECK(original_script_value->value()->IsScript());
90 Handle<Script> original_script(Script::cast(original_script_value->value())); 90 Handle<Script> original_script(Script::cast(original_script_value->value()));
91 91
92 Handle<Object> old_script = LiveEdit::ChangeScriptSource( 92 Handle<Object> old_script = LiveEdit::ChangeScriptSource(
93 original_script, new_source, old_script_name); 93 original_script, new_source, old_script_name);
94 94
95 if (old_script->IsScript()) { 95 if (old_script->IsScript()) {
96 Handle<Script> script_handle = Handle<Script>::cast(old_script); 96 Handle<Script> script_handle = Handle<Script>::cast(old_script);
97 return *Script::GetWrapper(script_handle); 97 return *Script::GetWrapper(script_handle);
98 } else { 98 } else {
99 return isolate->heap()->null_value(); 99 return isolate->heap()->null_value();
100 } 100 }
101 } 101 }
102 102
103 103
104 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) { 104 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) {
105 HandleScope scope(isolate); 105 HandleScope scope(isolate);
106 CHECK(isolate->debug()->live_edit_enabled()); 106 CHECK(isolate->debug()->live_edit_enabled());
107 DCHECK(args.length() == 1); 107 DCHECK(args.length() == 1);
108 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); 108 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0);
109 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); 109 CHECK(SharedInfoWrapper::IsInstance(shared_info));
110 110
111 LiveEdit::FunctionSourceUpdated(shared_info); 111 LiveEdit::FunctionSourceUpdated(shared_info);
112 return isolate->heap()->undefined_value(); 112 return isolate->heap()->undefined_value();
113 } 113 }
114 114
115 115
116 // Replaces code of SharedFunctionInfo with a new one. 116 // Replaces code of SharedFunctionInfo with a new one.
117 RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) { 117 RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) {
118 HandleScope scope(isolate); 118 HandleScope scope(isolate);
119 CHECK(isolate->debug()->live_edit_enabled()); 119 CHECK(isolate->debug()->live_edit_enabled());
120 DCHECK(args.length() == 2); 120 DCHECK(args.length() == 2);
121 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); 121 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0);
122 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); 122 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1);
123 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); 123 CHECK(SharedInfoWrapper::IsInstance(shared_info));
124 124
125 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); 125 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
126 return isolate->heap()->undefined_value(); 126 return isolate->heap()->undefined_value();
127 } 127 }
128 128
129 129
130 // Connects SharedFunctionInfo to another script. 130 // Connects SharedFunctionInfo to another script.
131 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) { 131 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) {
132 HandleScope scope(isolate); 132 HandleScope scope(isolate);
133 CHECK(isolate->debug()->live_edit_enabled()); 133 CHECK(isolate->debug()->live_edit_enabled());
134 DCHECK(args.length() == 2); 134 DCHECK(args.length() == 2);
135 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); 135 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
136 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); 136 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1);
137 137
138 if (function_object->IsJSValue()) { 138 if (function_object->IsJSValue()) {
139 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); 139 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object);
140 if (script_object->IsJSValue()) { 140 if (script_object->IsJSValue()) {
141 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); 141 CHECK(JSValue::cast(*script_object)->value()->IsScript());
142 Script* script = Script::cast(JSValue::cast(*script_object)->value()); 142 Script* script = Script::cast(JSValue::cast(*script_object)->value());
143 script_object = Handle<Object>(script, isolate); 143 script_object = Handle<Object>(script, isolate);
144 } 144 }
145 RUNTIME_ASSERT(function_wrapper->value()->IsSharedFunctionInfo()); 145 CHECK(function_wrapper->value()->IsSharedFunctionInfo());
146 LiveEdit::SetFunctionScript(function_wrapper, script_object); 146 LiveEdit::SetFunctionScript(function_wrapper, script_object);
147 } else { 147 } else {
148 // Just ignore this. We may not have a SharedFunctionInfo for some functions 148 // Just ignore this. We may not have a SharedFunctionInfo for some functions
149 // and we check it in this function. 149 // and we check it in this function.
150 } 150 }
151 151
152 return isolate->heap()->undefined_value(); 152 return isolate->heap()->undefined_value();
153 } 153 }
154 154
155 155
156 // In a code of a parent function replaces original function as embedded object 156 // In a code of a parent function replaces original function as embedded object
157 // with a substitution one. 157 // with a substitution one.
158 RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) { 158 RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) {
159 HandleScope scope(isolate); 159 HandleScope scope(isolate);
160 CHECK(isolate->debug()->live_edit_enabled()); 160 CHECK(isolate->debug()->live_edit_enabled());
161 DCHECK(args.length() == 3); 161 DCHECK(args.length() == 3);
162 162
163 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); 163 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0);
164 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); 164 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1);
165 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); 165 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2);
166 RUNTIME_ASSERT(parent_wrapper->value()->IsSharedFunctionInfo()); 166 CHECK(parent_wrapper->value()->IsSharedFunctionInfo());
167 RUNTIME_ASSERT(orig_wrapper->value()->IsSharedFunctionInfo()); 167 CHECK(orig_wrapper->value()->IsSharedFunctionInfo());
168 RUNTIME_ASSERT(subst_wrapper->value()->IsSharedFunctionInfo()); 168 CHECK(subst_wrapper->value()->IsSharedFunctionInfo());
169 169
170 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper, 170 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper,
171 subst_wrapper); 171 subst_wrapper);
172 return isolate->heap()->undefined_value(); 172 return isolate->heap()->undefined_value();
173 } 173 }
174 174
175 175
176 // Updates positions of a shared function info (first parameter) according 176 // Updates positions of a shared function info (first parameter) according
177 // to script source change. Text change is described in second parameter as 177 // to script source change. Text change is described in second parameter as
178 // array of groups of 3 numbers: 178 // array of groups of 3 numbers:
179 // (change_begin, change_end, change_end_new_position). 179 // (change_begin, change_end, change_end_new_position).
180 // Each group describes a change in text; groups are sorted by change_begin. 180 // Each group describes a change in text; groups are sorted by change_begin.
181 RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) { 181 RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) {
182 HandleScope scope(isolate); 182 HandleScope scope(isolate);
183 CHECK(isolate->debug()->live_edit_enabled()); 183 CHECK(isolate->debug()->live_edit_enabled());
184 DCHECK(args.length() == 2); 184 DCHECK(args.length() == 2);
185 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); 185 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
186 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); 186 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1);
187 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)); 187 CHECK(SharedInfoWrapper::IsInstance(shared_array));
188 188
189 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); 189 LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
190 return isolate->heap()->undefined_value(); 190 return isolate->heap()->undefined_value();
191 } 191 }
192 192
193 193
194 // For array of SharedFunctionInfo's (each wrapped in JSValue) 194 // For array of SharedFunctionInfo's (each wrapped in JSValue)
195 // checks that none of them have activations on stacks (of any thread). 195 // checks that none of them have activations on stacks (of any thread).
196 // Returns array of the same length with corresponding results of 196 // Returns array of the same length with corresponding results of
197 // LiveEdit::FunctionPatchabilityStatus type. 197 // LiveEdit::FunctionPatchabilityStatus type.
198 RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) { 198 RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) {
199 HandleScope scope(isolate); 199 HandleScope scope(isolate);
200 CHECK(isolate->debug()->live_edit_enabled()); 200 CHECK(isolate->debug()->live_edit_enabled());
201 DCHECK(args.length() == 3); 201 DCHECK(args.length() == 3);
202 CONVERT_ARG_HANDLE_CHECKED(JSArray, old_shared_array, 0); 202 CONVERT_ARG_HANDLE_CHECKED(JSArray, old_shared_array, 0);
203 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_shared_array, 1); 203 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_shared_array, 1);
204 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 2); 204 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 2);
205 USE(new_shared_array); 205 USE(new_shared_array);
206 RUNTIME_ASSERT(old_shared_array->length()->IsSmi()); 206 CHECK(old_shared_array->length()->IsSmi());
207 RUNTIME_ASSERT(new_shared_array->length() == old_shared_array->length()); 207 CHECK(new_shared_array->length() == old_shared_array->length());
208 RUNTIME_ASSERT(old_shared_array->HasFastElements()); 208 CHECK(old_shared_array->HasFastElements());
209 RUNTIME_ASSERT(new_shared_array->HasFastElements()); 209 CHECK(new_shared_array->HasFastElements());
210 int array_length = Smi::cast(old_shared_array->length())->value(); 210 int array_length = Smi::cast(old_shared_array->length())->value();
211 for (int i = 0; i < array_length; i++) { 211 for (int i = 0; i < array_length; i++) {
212 Handle<Object> old_element; 212 Handle<Object> old_element;
213 Handle<Object> new_element; 213 Handle<Object> new_element;
214 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 214 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
215 isolate, old_element, 215 isolate, old_element,
216 JSReceiver::GetElement(isolate, old_shared_array, i)); 216 JSReceiver::GetElement(isolate, old_shared_array, i));
217 RUNTIME_ASSERT( 217 CHECK(old_element->IsJSValue() &&
218 old_element->IsJSValue() && 218 Handle<JSValue>::cast(old_element)->value()->IsSharedFunctionInfo());
219 Handle<JSValue>::cast(old_element)->value()->IsSharedFunctionInfo());
220 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 219 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
221 isolate, new_element, 220 isolate, new_element,
222 JSReceiver::GetElement(isolate, new_shared_array, i)); 221 JSReceiver::GetElement(isolate, new_shared_array, i));
223 RUNTIME_ASSERT( 222 CHECK(
224 new_element->IsUndefined(isolate) || 223 new_element->IsUndefined(isolate) ||
225 (new_element->IsJSValue() && 224 (new_element->IsJSValue() &&
226 Handle<JSValue>::cast(new_element)->value()->IsSharedFunctionInfo())); 225 Handle<JSValue>::cast(new_element)->value()->IsSharedFunctionInfo()));
227 } 226 }
228 227
229 return *LiveEdit::CheckAndDropActivations(old_shared_array, new_shared_array, 228 return *LiveEdit::CheckAndDropActivations(old_shared_array, new_shared_array,
230 do_drop); 229 do_drop);
231 } 230 }
232 231
233 232
(...skipping 18 matching lines...) Expand all
252 } 251 }
253 252
254 253
255 // Restarts a call frame and completely drops all frames above. 254 // Restarts a call frame and completely drops all frames above.
256 // Returns true if successful. Otherwise returns undefined or an error message. 255 // Returns true if successful. Otherwise returns undefined or an error message.
257 RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) { 256 RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) {
258 HandleScope scope(isolate); 257 HandleScope scope(isolate);
259 CHECK(isolate->debug()->live_edit_enabled()); 258 CHECK(isolate->debug()->live_edit_enabled());
260 DCHECK(args.length() == 2); 259 DCHECK(args.length() == 2);
261 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 260 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
262 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); 261 CHECK(isolate->debug()->CheckExecutionState(break_id));
263 262
264 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); 263 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
265 Heap* heap = isolate->heap(); 264 Heap* heap = isolate->heap();
266 265
267 // Find the relevant frame with the requested index. 266 // Find the relevant frame with the requested index.
268 StackFrame::Id id = isolate->debug()->break_frame_id(); 267 StackFrame::Id id = isolate->debug()->break_frame_id();
269 if (id == StackFrame::NO_ID) { 268 if (id == StackFrame::NO_ID) {
270 // If there are no JavaScript stack frames return undefined. 269 // If there are no JavaScript stack frames return undefined.
271 return heap->undefined_value(); 270 return heap->undefined_value();
272 } 271 }
273 272
274 StackTraceFrameIterator it(isolate, id); 273 StackTraceFrameIterator it(isolate, id);
275 int inlined_jsframe_index = 274 int inlined_jsframe_index =
276 DebugFrameHelper::FindIndexedNonNativeFrame(&it, index); 275 DebugFrameHelper::FindIndexedNonNativeFrame(&it, index);
277 // Liveedit is not supported on Wasm. 276 // Liveedit is not supported on Wasm.
278 if (inlined_jsframe_index == -1 || it.is_wasm()) { 277 if (inlined_jsframe_index == -1 || it.is_wasm()) {
279 return heap->undefined_value(); 278 return heap->undefined_value();
280 } 279 }
281 // We don't really care what the inlined frame index is, since we are 280 // We don't really care what the inlined frame index is, since we are
282 // throwing away the entire frame anyways. 281 // throwing away the entire frame anyways.
283 const char* error_message = LiveEdit::RestartFrame(it.javascript_frame()); 282 const char* error_message = LiveEdit::RestartFrame(it.javascript_frame());
284 if (error_message) { 283 if (error_message) {
285 return *(isolate->factory()->InternalizeUtf8String(error_message)); 284 return *(isolate->factory()->InternalizeUtf8String(error_message));
286 } 285 }
287 return heap->true_value(); 286 return heap->true_value();
288 } 287 }
289 } // namespace internal 288 } // namespace internal
290 } // namespace v8 289 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/mjsunit/regress/regress-crbug-390925.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698