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

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

Issue 2613723002: [runtime] Use DCHECK_EQ instead of DCHECK for number of args. (Closed)
Patch Set: Rebase. Created 3 years, 11 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-compiler.cc ('k') | src/runtime/runtime-error.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 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-evaluate.h" 8 #include "src/debug/debug-evaluate.h"
9 #include "src/debug/debug-frames.h" 9 #include "src/debug/debug-frames.h"
10 #include "src/debug/debug-scopes.h" 10 #include "src/debug/debug-scopes.h"
11 #include "src/debug/debug.h" 11 #include "src/debug/debug.h"
12 #include "src/debug/liveedit.h" 12 #include "src/debug/liveedit.h"
13 #include "src/frames-inl.h" 13 #include "src/frames-inl.h"
14 #include "src/globals.h" 14 #include "src/globals.h"
15 #include "src/interpreter/bytecodes.h" 15 #include "src/interpreter/bytecodes.h"
16 #include "src/interpreter/interpreter.h" 16 #include "src/interpreter/interpreter.h"
17 #include "src/isolate-inl.h" 17 #include "src/isolate-inl.h"
18 #include "src/runtime/runtime.h" 18 #include "src/runtime/runtime.h"
19 #include "src/wasm/wasm-module.h" 19 #include "src/wasm/wasm-module.h"
20 #include "src/wasm/wasm-objects.h" 20 #include "src/wasm/wasm-objects.h"
21 21
22 namespace v8 { 22 namespace v8 {
23 namespace internal { 23 namespace internal {
24 24
25 RUNTIME_FUNCTION(Runtime_DebugBreak) { 25 RUNTIME_FUNCTION(Runtime_DebugBreak) {
26 SealHandleScope shs(isolate); 26 SealHandleScope shs(isolate);
27 DCHECK(args.length() == 1); 27 DCHECK_EQ(1, args.length());
28 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); 28 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
29 isolate->debug()->set_return_value(value); 29 isolate->debug()->set_return_value(value);
30 30
31 // Get the top-most JavaScript frame. 31 // Get the top-most JavaScript frame.
32 JavaScriptFrameIterator it(isolate); 32 JavaScriptFrameIterator it(isolate);
33 isolate->debug()->Break(it.frame()); 33 isolate->debug()->Break(it.frame());
34 34
35 isolate->debug()->SetAfterBreakTarget(it.frame()); 35 isolate->debug()->SetAfterBreakTarget(it.frame());
36 return *isolate->debug()->return_value(); 36 return *isolate->debug()->return_value();
37 } 37 }
38 38
39 RUNTIME_FUNCTION(Runtime_DebugBreakOnBytecode) { 39 RUNTIME_FUNCTION(Runtime_DebugBreakOnBytecode) {
40 SealHandleScope shs(isolate); 40 SealHandleScope shs(isolate);
41 DCHECK(args.length() == 1); 41 DCHECK_EQ(1, args.length());
42 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); 42 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
43 isolate->debug()->set_return_value(value); 43 isolate->debug()->set_return_value(value);
44 44
45 // Get the top-most JavaScript frame. 45 // Get the top-most JavaScript frame.
46 JavaScriptFrameIterator it(isolate); 46 JavaScriptFrameIterator it(isolate);
47 isolate->debug()->Break(it.frame()); 47 isolate->debug()->Break(it.frame());
48 48
49 // If live-edit has dropped frames, we are not going back to dispatch. 49 // If live-edit has dropped frames, we are not going back to dispatch.
50 if (LiveEdit::SetAfterBreakTarget(isolate->debug())) return Smi::kZero; 50 if (LiveEdit::SetAfterBreakTarget(isolate->debug())) return Smi::kZero;
51 51
52 // Return the handler from the original bytecode array. 52 // Return the handler from the original bytecode array.
53 DCHECK(it.frame()->is_interpreted()); 53 DCHECK(it.frame()->is_interpreted());
54 InterpretedFrame* interpreted_frame = 54 InterpretedFrame* interpreted_frame =
55 reinterpret_cast<InterpretedFrame*>(it.frame()); 55 reinterpret_cast<InterpretedFrame*>(it.frame());
56 SharedFunctionInfo* shared = interpreted_frame->function()->shared(); 56 SharedFunctionInfo* shared = interpreted_frame->function()->shared();
57 BytecodeArray* bytecode_array = shared->bytecode_array(); 57 BytecodeArray* bytecode_array = shared->bytecode_array();
58 int bytecode_offset = interpreted_frame->GetBytecodeOffset(); 58 int bytecode_offset = interpreted_frame->GetBytecodeOffset();
59 interpreter::Bytecode bytecode = 59 interpreter::Bytecode bytecode =
60 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset)); 60 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset));
61 return isolate->interpreter()->GetBytecodeHandler( 61 return isolate->interpreter()->GetBytecodeHandler(
62 bytecode, interpreter::OperandScale::kSingle); 62 bytecode, interpreter::OperandScale::kSingle);
63 } 63 }
64 64
65 65
66 RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) { 66 RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) {
67 SealHandleScope shs(isolate); 67 SealHandleScope shs(isolate);
68 DCHECK(args.length() == 0); 68 DCHECK_EQ(0, args.length());
69 if (isolate->debug()->break_points_active()) { 69 if (isolate->debug()->break_points_active()) {
70 isolate->debug()->HandleDebugBreak(); 70 isolate->debug()->HandleDebugBreak();
71 } 71 }
72 return isolate->heap()->undefined_value(); 72 return isolate->heap()->undefined_value();
73 } 73 }
74 74
75 75
76 // Adds a JavaScript function as a debug event listener. 76 // Adds a JavaScript function as a debug event listener.
77 // args[0]: debug event listener function to set or null or undefined for 77 // args[0]: debug event listener function to set or null or undefined for
78 // clearing the event listener function 78 // clearing the event listener function
79 // args[1]: object supplied during callback 79 // args[1]: object supplied during callback
80 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { 80 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) {
81 SealHandleScope shs(isolate); 81 SealHandleScope shs(isolate);
82 DCHECK(args.length() == 2); 82 DCHECK_EQ(2, args.length());
83 CHECK(args[0]->IsJSFunction() || args[0]->IsUndefined(isolate) || 83 CHECK(args[0]->IsJSFunction() || args[0]->IsUndefined(isolate) ||
84 args[0]->IsNull(isolate)); 84 args[0]->IsNull(isolate));
85 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); 85 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0);
86 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); 86 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1);
87 isolate->debug()->SetEventListener(callback, data); 87 isolate->debug()->SetEventListener(callback, data);
88 88
89 return isolate->heap()->undefined_value(); 89 return isolate->heap()->undefined_value();
90 } 90 }
91 91
92 92
93 RUNTIME_FUNCTION(Runtime_ScheduleBreak) { 93 RUNTIME_FUNCTION(Runtime_ScheduleBreak) {
94 SealHandleScope shs(isolate); 94 SealHandleScope shs(isolate);
95 DCHECK(args.length() == 0); 95 DCHECK_EQ(0, args.length());
96 isolate->stack_guard()->RequestDebugBreak(); 96 isolate->stack_guard()->RequestDebugBreak();
97 return isolate->heap()->undefined_value(); 97 return isolate->heap()->undefined_value();
98 } 98 }
99 99
100 100
101 static Handle<Object> DebugGetProperty(LookupIterator* it, 101 static Handle<Object> DebugGetProperty(LookupIterator* it,
102 bool* has_caught = NULL) { 102 bool* has_caught = NULL) {
103 for (; it->IsFound(); it->Next()) { 103 for (; it->IsFound(); it->Next()) {
104 switch (it->state()) { 104 switch (it->state()) {
105 case LookupIterator::NOT_FOUND: 105 case LookupIterator::NOT_FOUND:
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 result->set(0, *primitive_value); 283 result->set(0, *primitive_value);
284 result->set(1, js_value->value()); 284 result->set(1, js_value->value());
285 return factory->NewJSArrayWithElements(result); 285 return factory->NewJSArrayWithElements(result);
286 } 286 }
287 return factory->NewJSArray(0); 287 return factory->NewJSArray(0);
288 } 288 }
289 289
290 290
291 RUNTIME_FUNCTION(Runtime_DebugGetInternalProperties) { 291 RUNTIME_FUNCTION(Runtime_DebugGetInternalProperties) {
292 HandleScope scope(isolate); 292 HandleScope scope(isolate);
293 DCHECK(args.length() == 1); 293 DCHECK_EQ(1, args.length());
294 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); 294 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
295 RETURN_RESULT_OR_FAILURE(isolate, 295 RETURN_RESULT_OR_FAILURE(isolate,
296 Runtime::GetInternalProperties(isolate, obj)); 296 Runtime::GetInternalProperties(isolate, obj));
297 } 297 }
298 298
299 299
300 // Get debugger related details for an object property, in the following format: 300 // Get debugger related details for an object property, in the following format:
301 // 0: Property value 301 // 0: Property value
302 // 1: Property details 302 // 1: Property details
303 // 2: Property value is exception 303 // 2: Property value is exception
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 details->set(5, *setter); 375 details->set(5, *setter);
376 } 376 }
377 377
378 return *isolate->factory()->NewJSArrayWithElements(details); 378 return *isolate->factory()->NewJSArrayWithElements(details);
379 } 379 }
380 380
381 381
382 RUNTIME_FUNCTION(Runtime_DebugGetProperty) { 382 RUNTIME_FUNCTION(Runtime_DebugGetProperty) {
383 HandleScope scope(isolate); 383 HandleScope scope(isolate);
384 384
385 DCHECK(args.length() == 2); 385 DCHECK_EQ(2, args.length());
386 386
387 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); 387 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
388 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 388 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
389 389
390 LookupIterator it(obj, name); 390 LookupIterator it(obj, name);
391 return *DebugGetProperty(&it); 391 return *DebugGetProperty(&it);
392 } 392 }
393 393
394 394
395 // Return the property type calculated from the property details. 395 // Return the property type calculated from the property details.
396 // args[0]: smi with property details. 396 // args[0]: smi with property details.
397 RUNTIME_FUNCTION(Runtime_DebugPropertyTypeFromDetails) { 397 RUNTIME_FUNCTION(Runtime_DebugPropertyTypeFromDetails) {
398 SealHandleScope shs(isolate); 398 SealHandleScope shs(isolate);
399 DCHECK(args.length() == 1); 399 DCHECK_EQ(1, args.length());
400 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); 400 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
401 return Smi::FromInt(static_cast<int>(details.type())); 401 return Smi::FromInt(static_cast<int>(details.type()));
402 } 402 }
403 403
404 404
405 // Return the property attribute calculated from the property details. 405 // Return the property attribute calculated from the property details.
406 // args[0]: smi with property details. 406 // args[0]: smi with property details.
407 RUNTIME_FUNCTION(Runtime_DebugPropertyAttributesFromDetails) { 407 RUNTIME_FUNCTION(Runtime_DebugPropertyAttributesFromDetails) {
408 SealHandleScope shs(isolate); 408 SealHandleScope shs(isolate);
409 DCHECK(args.length() == 1); 409 DCHECK_EQ(1, args.length());
410 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); 410 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
411 return Smi::FromInt(static_cast<int>(details.attributes())); 411 return Smi::FromInt(static_cast<int>(details.attributes()));
412 } 412 }
413 413
414 414
415 RUNTIME_FUNCTION(Runtime_CheckExecutionState) { 415 RUNTIME_FUNCTION(Runtime_CheckExecutionState) {
416 SealHandleScope shs(isolate); 416 SealHandleScope shs(isolate);
417 DCHECK(args.length() == 1); 417 DCHECK_EQ(1, args.length());
418 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 418 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
419 CHECK(isolate->debug()->CheckExecutionState(break_id)); 419 CHECK(isolate->debug()->CheckExecutionState(break_id));
420 return isolate->heap()->true_value(); 420 return isolate->heap()->true_value();
421 } 421 }
422 422
423 423
424 RUNTIME_FUNCTION(Runtime_GetFrameCount) { 424 RUNTIME_FUNCTION(Runtime_GetFrameCount) {
425 HandleScope scope(isolate); 425 HandleScope scope(isolate);
426 DCHECK(args.length() == 1); 426 DCHECK_EQ(1, args.length());
427 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 427 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
428 CHECK(isolate->debug()->CheckExecutionState(break_id)); 428 CHECK(isolate->debug()->CheckExecutionState(break_id));
429 429
430 // Count all frames which are relevant to debugging stack trace. 430 // Count all frames which are relevant to debugging stack trace.
431 int n = 0; 431 int n = 0;
432 StackFrame::Id id = isolate->debug()->break_frame_id(); 432 StackFrame::Id id = isolate->debug()->break_frame_id();
433 if (id == StackFrame::NO_ID) { 433 if (id == StackFrame::NO_ID) {
434 // If there is no JavaScript stack frame count is 0. 434 // If there is no JavaScript stack frame count is 0.
435 return Smi::kZero; 435 return Smi::kZero;
436 } 436 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // 5: Local count 476 // 5: Local count
477 // 6: Source position 477 // 6: Source position
478 // 7: Constructor call 478 // 7: Constructor call
479 // 8: Is at return 479 // 8: Is at return
480 // 9: Flags 480 // 9: Flags
481 // Arguments name, value 481 // Arguments name, value
482 // Locals name, value 482 // Locals name, value
483 // Return value if any 483 // Return value if any
484 RUNTIME_FUNCTION(Runtime_GetFrameDetails) { 484 RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
485 HandleScope scope(isolate); 485 HandleScope scope(isolate);
486 DCHECK(args.length() == 2); 486 DCHECK_EQ(2, args.length());
487 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 487 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
488 CHECK(isolate->debug()->CheckExecutionState(break_id)); 488 CHECK(isolate->debug()->CheckExecutionState(break_id));
489 489
490 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); 490 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
491 Heap* heap = isolate->heap(); 491 Heap* heap = isolate->heap();
492 492
493 // Find the relevant frame with the requested index. 493 // Find the relevant frame with the requested index.
494 StackFrame::Id id = isolate->debug()->break_frame_id(); 494 StackFrame::Id id = isolate->debug()->break_frame_id();
495 if (id == StackFrame::NO_ID) { 495 if (id == StackFrame::NO_ID) {
496 // If there are no JavaScript stack frames return undefined. 496 // If there are no JavaScript stack frames return undefined.
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 DCHECK_IMPLIES(is_sloppy(shared->language_mode()), receiver->IsJSReceiver()); 757 DCHECK_IMPLIES(is_sloppy(shared->language_mode()), receiver->IsJSReceiver());
758 details->set(kFrameDetailsReceiverIndex, *receiver); 758 details->set(kFrameDetailsReceiverIndex, *receiver);
759 759
760 DCHECK_EQ(details_size, details_index); 760 DCHECK_EQ(details_size, details_index);
761 return *isolate->factory()->NewJSArrayWithElements(details); 761 return *isolate->factory()->NewJSArrayWithElements(details);
762 } 762 }
763 763
764 764
765 RUNTIME_FUNCTION(Runtime_GetScopeCount) { 765 RUNTIME_FUNCTION(Runtime_GetScopeCount) {
766 HandleScope scope(isolate); 766 HandleScope scope(isolate);
767 DCHECK(args.length() == 2); 767 DCHECK_EQ(2, args.length());
768 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 768 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
769 CHECK(isolate->debug()->CheckExecutionState(break_id)); 769 CHECK(isolate->debug()->CheckExecutionState(break_id));
770 770
771 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); 771 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
772 772
773 // Get the frame where the debugging is performed. 773 // Get the frame where the debugging is performed.
774 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); 774 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
775 JavaScriptFrameIterator it(isolate, id); 775 JavaScriptFrameIterator it(isolate, id);
776 JavaScriptFrame* frame = it.frame(); 776 JavaScriptFrame* frame = it.frame();
777 FrameInspector frame_inspector(frame, 0, isolate); 777 FrameInspector frame_inspector(frame, 0, isolate);
(...skipping 12 matching lines...) Expand all
790 // args[0]: number: break id 790 // args[0]: number: break id
791 // args[1]: number: frame index 791 // args[1]: number: frame index
792 // args[2]: number: inlined frame index 792 // args[2]: number: inlined frame index
793 // args[3]: number: scope index 793 // args[3]: number: scope index
794 // 794 //
795 // The array returned contains the following information: 795 // The array returned contains the following information:
796 // 0: Scope type 796 // 0: Scope type
797 // 1: Scope object 797 // 1: Scope object
798 RUNTIME_FUNCTION(Runtime_GetScopeDetails) { 798 RUNTIME_FUNCTION(Runtime_GetScopeDetails) {
799 HandleScope scope(isolate); 799 HandleScope scope(isolate);
800 DCHECK(args.length() == 4); 800 DCHECK_EQ(4, args.length());
801 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 801 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
802 CHECK(isolate->debug()->CheckExecutionState(break_id)); 802 CHECK(isolate->debug()->CheckExecutionState(break_id));
803 803
804 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); 804 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
805 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); 805 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
806 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); 806 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]);
807 807
808 // Get the frame where the debugging is performed. 808 // Get the frame where the debugging is performed.
809 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); 809 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
810 JavaScriptFrameIterator frame_it(isolate, id); 810 JavaScriptFrameIterator frame_it(isolate, id);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 n++; 886 n++;
887 } 887 }
888 } 888 }
889 889
890 return Smi::FromInt(n); 890 return Smi::FromInt(n);
891 } 891 }
892 892
893 893
894 RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) { 894 RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) {
895 HandleScope scope(isolate); 895 HandleScope scope(isolate);
896 DCHECK(args.length() == 2); 896 DCHECK_EQ(2, args.length());
897 897
898 // Check arguments. 898 // Check arguments.
899 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 899 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
900 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); 900 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
901 901
902 // Find the requested scope. 902 // Find the requested scope.
903 int n = 0; 903 int n = 0;
904 ScopeIterator it(isolate, fun); 904 ScopeIterator it(isolate, fun);
905 for (; !it.Done() && n < index; it.Next()) { 905 for (; !it.Done() && n < index; it.Next()) {
906 n++; 906 n++;
(...skipping 18 matching lines...) Expand all
925 int n = 0; 925 int n = 0;
926 for (ScopeIterator it(isolate, gen); !it.Done(); it.Next()) { 926 for (ScopeIterator it(isolate, gen); !it.Done(); it.Next()) {
927 n++; 927 n++;
928 } 928 }
929 929
930 return Smi::FromInt(n); 930 return Smi::FromInt(n);
931 } 931 }
932 932
933 RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) { 933 RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
934 HandleScope scope(isolate); 934 HandleScope scope(isolate);
935 DCHECK(args.length() == 2); 935 DCHECK_EQ(2, args.length());
936 936
937 if (!args[0]->IsJSGeneratorObject()) { 937 if (!args[0]->IsJSGeneratorObject()) {
938 return isolate->heap()->undefined_value(); 938 return isolate->heap()->undefined_value();
939 } 939 }
940 940
941 // Check arguments. 941 // Check arguments.
942 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0); 942 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0);
943 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); 943 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
944 944
945 // Find the requested scope. 945 // Find the requested scope.
(...skipping 26 matching lines...) Expand all
972 // args[0]: number or JsFunction: break id or function 972 // args[0]: number or JsFunction: break id or function
973 // args[1]: number: frame index (when arg[0] is break id) 973 // args[1]: number: frame index (when arg[0] is break id)
974 // args[2]: number: inlined frame index (when arg[0] is break id) 974 // args[2]: number: inlined frame index (when arg[0] is break id)
975 // args[3]: number: scope index 975 // args[3]: number: scope index
976 // args[4]: string: variable name 976 // args[4]: string: variable name
977 // args[5]: object: new value 977 // args[5]: object: new value
978 // 978 //
979 // Return true if success and false otherwise 979 // Return true if success and false otherwise
980 RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) { 980 RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) {
981 HandleScope scope(isolate); 981 HandleScope scope(isolate);
982 DCHECK(args.length() == 6); 982 DCHECK_EQ(6, args.length());
983 983
984 // Check arguments. 984 // Check arguments.
985 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); 985 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]);
986 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); 986 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4);
987 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); 987 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5);
988 988
989 bool res; 989 bool res;
990 if (args[0]->IsNumber()) { 990 if (args[0]->IsNumber()) {
991 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 991 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
992 CHECK(isolate->debug()->CheckExecutionState(break_id)); 992 CHECK(isolate->debug()->CheckExecutionState(break_id));
(...skipping 18 matching lines...) Expand all
1011 ScopeIterator it(isolate, gen); 1011 ScopeIterator it(isolate, gen);
1012 res = SetScopeVariableValue(&it, index, variable_name, new_value); 1012 res = SetScopeVariableValue(&it, index, variable_name, new_value);
1013 } 1013 }
1014 1014
1015 return isolate->heap()->ToBoolean(res); 1015 return isolate->heap()->ToBoolean(res);
1016 } 1016 }
1017 1017
1018 1018
1019 RUNTIME_FUNCTION(Runtime_DebugPrintScopes) { 1019 RUNTIME_FUNCTION(Runtime_DebugPrintScopes) {
1020 HandleScope scope(isolate); 1020 HandleScope scope(isolate);
1021 DCHECK(args.length() == 0); 1021 DCHECK_EQ(0, args.length());
1022 1022
1023 #ifdef DEBUG 1023 #ifdef DEBUG
1024 // Print the scopes for the top frame. 1024 // Print the scopes for the top frame.
1025 StackFrameLocator locator(isolate); 1025 StackFrameLocator locator(isolate);
1026 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); 1026 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
1027 FrameInspector frame_inspector(frame, 0, isolate); 1027 FrameInspector frame_inspector(frame, 0, isolate);
1028 1028
1029 for (ScopeIterator it(isolate, &frame_inspector); !it.Done(); it.Next()) { 1029 for (ScopeIterator it(isolate, &frame_inspector); !it.Done(); it.Next()) {
1030 it.DebugPrint(); 1030 it.DebugPrint();
1031 } 1031 }
1032 #endif 1032 #endif
1033 return isolate->heap()->undefined_value(); 1033 return isolate->heap()->undefined_value();
1034 } 1034 }
1035 1035
1036 1036
1037 // Sets the disable break state 1037 // Sets the disable break state
1038 // args[0]: disable break state 1038 // args[0]: disable break state
1039 RUNTIME_FUNCTION(Runtime_SetBreakPointsActive) { 1039 RUNTIME_FUNCTION(Runtime_SetBreakPointsActive) {
1040 HandleScope scope(isolate); 1040 HandleScope scope(isolate);
1041 DCHECK(args.length() == 1); 1041 DCHECK_EQ(1, args.length());
1042 CONVERT_BOOLEAN_ARG_CHECKED(active, 0); 1042 CONVERT_BOOLEAN_ARG_CHECKED(active, 0);
1043 isolate->debug()->set_break_points_active(active); 1043 isolate->debug()->set_break_points_active(active);
1044 return isolate->heap()->undefined_value(); 1044 return isolate->heap()->undefined_value();
1045 } 1045 }
1046 1046
1047 1047
1048 static bool IsPositionAlignmentCodeCorrect(int alignment) { 1048 static bool IsPositionAlignmentCodeCorrect(int alignment) {
1049 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; 1049 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED;
1050 } 1050 }
1051 1051
1052 1052
1053 RUNTIME_FUNCTION(Runtime_GetBreakLocations) { 1053 RUNTIME_FUNCTION(Runtime_GetBreakLocations) {
1054 HandleScope scope(isolate); 1054 HandleScope scope(isolate);
1055 DCHECK(args.length() == 2); 1055 DCHECK_EQ(2, args.length());
1056 CHECK(isolate->debug()->is_active()); 1056 CHECK(isolate->debug()->is_active());
1057 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 1057 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
1058 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); 1058 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]);
1059 1059
1060 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { 1060 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
1061 return isolate->ThrowIllegalOperation(); 1061 return isolate->ThrowIllegalOperation();
1062 } 1062 }
1063 BreakPositionAlignment alignment = 1063 BreakPositionAlignment alignment =
1064 static_cast<BreakPositionAlignment>(statement_aligned_code); 1064 static_cast<BreakPositionAlignment>(statement_aligned_code);
1065 1065
1066 Handle<SharedFunctionInfo> shared(fun->shared()); 1066 Handle<SharedFunctionInfo> shared(fun->shared());
1067 // Find the number of break points 1067 // Find the number of break points
1068 Handle<Object> break_locations = 1068 Handle<Object> break_locations =
1069 Debug::GetSourceBreakLocations(shared, alignment); 1069 Debug::GetSourceBreakLocations(shared, alignment);
1070 if (break_locations->IsUndefined(isolate)) { 1070 if (break_locations->IsUndefined(isolate)) {
1071 return isolate->heap()->undefined_value(); 1071 return isolate->heap()->undefined_value();
1072 } 1072 }
1073 // Return array as JS array 1073 // Return array as JS array
1074 return *isolate->factory()->NewJSArrayWithElements( 1074 return *isolate->factory()->NewJSArrayWithElements(
1075 Handle<FixedArray>::cast(break_locations)); 1075 Handle<FixedArray>::cast(break_locations));
1076 } 1076 }
1077 1077
1078 1078
1079 // Set a break point in a function. 1079 // Set a break point in a function.
1080 // args[0]: function 1080 // args[0]: function
1081 // args[1]: number: break source position (within the function source) 1081 // args[1]: number: break source position (within the function source)
1082 // args[2]: number: break point object 1082 // args[2]: number: break point object
1083 RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) { 1083 RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) {
1084 HandleScope scope(isolate); 1084 HandleScope scope(isolate);
1085 DCHECK(args.length() == 3); 1085 DCHECK_EQ(3, args.length());
1086 CHECK(isolate->debug()->is_active()); 1086 CHECK(isolate->debug()->is_active());
1087 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 1087 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
1088 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 1088 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
1089 CHECK(source_position >= function->shared()->start_position() && 1089 CHECK(source_position >= function->shared()->start_position() &&
1090 source_position <= function->shared()->end_position()); 1090 source_position <= function->shared()->end_position());
1091 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); 1091 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2);
1092 1092
1093 // Set break point. 1093 // Set break point.
1094 CHECK(isolate->debug()->SetBreakPoint(function, break_point_object_arg, 1094 CHECK(isolate->debug()->SetBreakPoint(function, break_point_object_arg,
1095 &source_position)); 1095 &source_position));
1096 1096
1097 return Smi::FromInt(source_position); 1097 return Smi::FromInt(source_position);
1098 } 1098 }
1099 1099
1100 1100
1101 // Changes the state of a break point in a script and returns source position 1101 // Changes the state of a break point in a script and returns source position
1102 // where break point was set. NOTE: Regarding performance see the NOTE for 1102 // where break point was set. NOTE: Regarding performance see the NOTE for
1103 // GetScriptFromScriptData. 1103 // GetScriptFromScriptData.
1104 // args[0]: script to set break point in 1104 // args[0]: script to set break point in
1105 // args[1]: number: break source position (within the script source) 1105 // args[1]: number: break source position (within the script source)
1106 // args[2]: number, breakpoint position alignment 1106 // args[2]: number, breakpoint position alignment
1107 // args[3]: number: break point object 1107 // args[3]: number: break point object
1108 RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) { 1108 RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) {
1109 HandleScope scope(isolate); 1109 HandleScope scope(isolate);
1110 DCHECK(args.length() == 4); 1110 DCHECK_EQ(4, args.length());
1111 CHECK(isolate->debug()->is_active()); 1111 CHECK(isolate->debug()->is_active());
1112 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); 1112 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
1113 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 1113 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
1114 CHECK(source_position >= 0); 1114 CHECK(source_position >= 0);
1115 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); 1115 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]);
1116 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); 1116 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3);
1117 1117
1118 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { 1118 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
1119 return isolate->ThrowIllegalOperation(); 1119 return isolate->ThrowIllegalOperation();
1120 } 1120 }
(...skipping 11 matching lines...) Expand all
1132 } 1132 }
1133 1133
1134 return Smi::FromInt(source_position); 1134 return Smi::FromInt(source_position);
1135 } 1135 }
1136 1136
1137 1137
1138 // Clear a break point 1138 // Clear a break point
1139 // args[0]: number: break point object 1139 // args[0]: number: break point object
1140 RUNTIME_FUNCTION(Runtime_ClearBreakPoint) { 1140 RUNTIME_FUNCTION(Runtime_ClearBreakPoint) {
1141 HandleScope scope(isolate); 1141 HandleScope scope(isolate);
1142 DCHECK(args.length() == 1); 1142 DCHECK_EQ(1, args.length());
1143 CHECK(isolate->debug()->is_active()); 1143 CHECK(isolate->debug()->is_active());
1144 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); 1144 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0);
1145 1145
1146 // Clear break point. 1146 // Clear break point.
1147 isolate->debug()->ClearBreakPoint(break_point_object_arg); 1147 isolate->debug()->ClearBreakPoint(break_point_object_arg);
1148 1148
1149 return isolate->heap()->undefined_value(); 1149 return isolate->heap()->undefined_value();
1150 } 1150 }
1151 1151
1152 1152
1153 // Change the state of break on exceptions. 1153 // Change the state of break on exceptions.
1154 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. 1154 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions.
1155 // args[1]: Boolean indicating on/off. 1155 // args[1]: Boolean indicating on/off.
1156 RUNTIME_FUNCTION(Runtime_ChangeBreakOnException) { 1156 RUNTIME_FUNCTION(Runtime_ChangeBreakOnException) {
1157 HandleScope scope(isolate); 1157 HandleScope scope(isolate);
1158 DCHECK(args.length() == 2); 1158 DCHECK_EQ(2, args.length());
1159 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); 1159 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]);
1160 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1); 1160 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1);
1161 1161
1162 // If the number doesn't match an enum value, the ChangeBreakOnException 1162 // If the number doesn't match an enum value, the ChangeBreakOnException
1163 // function will default to affecting caught exceptions. 1163 // function will default to affecting caught exceptions.
1164 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); 1164 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg);
1165 // Update break point state. 1165 // Update break point state.
1166 isolate->debug()->ChangeBreakOnException(type, enable); 1166 isolate->debug()->ChangeBreakOnException(type, enable);
1167 return isolate->heap()->undefined_value(); 1167 return isolate->heap()->undefined_value();
1168 } 1168 }
1169 1169
1170 1170
1171 // Returns the state of break on exceptions 1171 // Returns the state of break on exceptions
1172 // args[0]: boolean indicating uncaught exceptions 1172 // args[0]: boolean indicating uncaught exceptions
1173 RUNTIME_FUNCTION(Runtime_IsBreakOnException) { 1173 RUNTIME_FUNCTION(Runtime_IsBreakOnException) {
1174 HandleScope scope(isolate); 1174 HandleScope scope(isolate);
1175 DCHECK(args.length() == 1); 1175 DCHECK_EQ(1, args.length());
1176 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); 1176 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]);
1177 1177
1178 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); 1178 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg);
1179 bool result = isolate->debug()->IsBreakOnException(type); 1179 bool result = isolate->debug()->IsBreakOnException(type);
1180 return Smi::FromInt(result); 1180 return Smi::FromInt(result);
1181 } 1181 }
1182 1182
1183 1183
1184 // Prepare for stepping 1184 // Prepare for stepping
1185 // args[0]: break id for checking execution state 1185 // args[0]: break id for checking execution state
1186 // args[1]: step action from the enumeration StepAction 1186 // args[1]: step action from the enumeration StepAction
1187 // args[2]: number of times to perform the step, for step out it is the number 1187 // args[2]: number of times to perform the step, for step out it is the number
1188 // of frames to step down. 1188 // of frames to step down.
1189 RUNTIME_FUNCTION(Runtime_PrepareStep) { 1189 RUNTIME_FUNCTION(Runtime_PrepareStep) {
1190 HandleScope scope(isolate); 1190 HandleScope scope(isolate);
1191 DCHECK(args.length() == 2); 1191 DCHECK_EQ(2, args.length());
1192 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 1192 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
1193 CHECK(isolate->debug()->CheckExecutionState(break_id)); 1193 CHECK(isolate->debug()->CheckExecutionState(break_id));
1194 1194
1195 if (!args[1]->IsNumber()) { 1195 if (!args[1]->IsNumber()) {
1196 return isolate->Throw(isolate->heap()->illegal_argument_string()); 1196 return isolate->Throw(isolate->heap()->illegal_argument_string());
1197 } 1197 }
1198 1198
1199 // Get the step action and check validity. 1199 // Get the step action and check validity.
1200 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); 1200 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1]));
1201 if (step_action != StepIn && step_action != StepNext && 1201 if (step_action != StepIn && step_action != StepNext &&
(...skipping 18 matching lines...) Expand all
1220 isolate->debug()->ClearStepping(); 1220 isolate->debug()->ClearStepping();
1221 1221
1222 // Prepare step. 1222 // Prepare step.
1223 isolate->debug()->PrepareStep(StepFrame); 1223 isolate->debug()->PrepareStep(StepFrame);
1224 return isolate->heap()->undefined_value(); 1224 return isolate->heap()->undefined_value();
1225 } 1225 }
1226 1226
1227 // Clear all stepping set by PrepareStep. 1227 // Clear all stepping set by PrepareStep.
1228 RUNTIME_FUNCTION(Runtime_ClearStepping) { 1228 RUNTIME_FUNCTION(Runtime_ClearStepping) {
1229 HandleScope scope(isolate); 1229 HandleScope scope(isolate);
1230 DCHECK(args.length() == 0); 1230 DCHECK_EQ(0, args.length());
1231 CHECK(isolate->debug()->is_active()); 1231 CHECK(isolate->debug()->is_active());
1232 isolate->debug()->ClearStepping(); 1232 isolate->debug()->ClearStepping();
1233 return isolate->heap()->undefined_value(); 1233 return isolate->heap()->undefined_value();
1234 } 1234 }
1235 1235
1236 1236
1237 RUNTIME_FUNCTION(Runtime_DebugEvaluate) { 1237 RUNTIME_FUNCTION(Runtime_DebugEvaluate) {
1238 HandleScope scope(isolate); 1238 HandleScope scope(isolate);
1239 1239
1240 // Check the execution state and decode arguments frame and source to be 1240 // Check the execution state and decode arguments frame and source to be
1241 // evaluated. 1241 // evaluated.
1242 DCHECK(args.length() == 4); 1242 DCHECK_EQ(4, args.length());
1243 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 1243 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
1244 CHECK(isolate->debug()->CheckExecutionState(break_id)); 1244 CHECK(isolate->debug()->CheckExecutionState(break_id));
1245 1245
1246 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); 1246 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
1247 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); 1247 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
1248 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); 1248 CONVERT_ARG_HANDLE_CHECKED(String, source, 3);
1249 1249
1250 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); 1250 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
1251 1251
1252 RETURN_RESULT_OR_FAILURE( 1252 RETURN_RESULT_OR_FAILURE(
1253 isolate, 1253 isolate,
1254 DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source)); 1254 DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source));
1255 } 1255 }
1256 1256
1257 1257
1258 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { 1258 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) {
1259 HandleScope scope(isolate); 1259 HandleScope scope(isolate);
1260 1260
1261 // Check the execution state and decode arguments frame and source to be 1261 // Check the execution state and decode arguments frame and source to be
1262 // evaluated. 1262 // evaluated.
1263 DCHECK(args.length() == 2); 1263 DCHECK_EQ(2, args.length());
1264 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 1264 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
1265 CHECK(isolate->debug()->CheckExecutionState(break_id)); 1265 CHECK(isolate->debug()->CheckExecutionState(break_id));
1266 1266
1267 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 1267 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
1268 1268
1269 RETURN_RESULT_OR_FAILURE(isolate, DebugEvaluate::Global(isolate, source)); 1269 RETURN_RESULT_OR_FAILURE(isolate, DebugEvaluate::Global(isolate, source));
1270 } 1270 }
1271 1271
1272 1272
1273 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { 1273 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
1274 HandleScope scope(isolate); 1274 HandleScope scope(isolate);
1275 DCHECK(args.length() == 0); 1275 DCHECK_EQ(0, args.length());
1276 1276
1277 // This runtime function is used by the debugger to determine whether the 1277 // This runtime function is used by the debugger to determine whether the
1278 // debugger is active or not. Hence we fail gracefully here and don't crash. 1278 // debugger is active or not. Hence we fail gracefully here and don't crash.
1279 if (!isolate->debug()->is_active()) return isolate->ThrowIllegalOperation(); 1279 if (!isolate->debug()->is_active()) return isolate->ThrowIllegalOperation();
1280 1280
1281 Handle<FixedArray> instances; 1281 Handle<FixedArray> instances;
1282 { 1282 {
1283 DebugScope debug_scope(isolate->debug()); 1283 DebugScope debug_scope(isolate->debug());
1284 if (debug_scope.failed()) { 1284 if (debug_scope.failed()) {
1285 DCHECK(isolate->has_pending_exception()); 1285 DCHECK(isolate->has_pending_exception());
(...skipping 30 matching lines...) Expand all
1316 } 1316 }
1317 } 1317 }
1318 1318
1319 1319
1320 // Scan the heap for objects with direct references to an object 1320 // Scan the heap for objects with direct references to an object
1321 // args[0]: the object to find references to 1321 // args[0]: the object to find references to
1322 // args[1]: constructor function for instances to exclude (Mirror) 1322 // args[1]: constructor function for instances to exclude (Mirror)
1323 // args[2]: the the maximum number of objects to return 1323 // args[2]: the the maximum number of objects to return
1324 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { 1324 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
1325 HandleScope scope(isolate); 1325 HandleScope scope(isolate);
1326 DCHECK(args.length() == 3); 1326 DCHECK_EQ(3, args.length());
1327 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); 1327 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
1328 CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1); 1328 CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1);
1329 CHECK(filter->IsUndefined(isolate) || filter->IsJSObject()); 1329 CHECK(filter->IsUndefined(isolate) || filter->IsJSObject());
1330 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); 1330 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]);
1331 CHECK(max_references >= 0); 1331 CHECK(max_references >= 0);
1332 1332
1333 List<Handle<JSObject> > instances; 1333 List<Handle<JSObject> > instances;
1334 Heap* heap = isolate->heap(); 1334 Heap* heap = isolate->heap();
1335 { 1335 {
1336 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); 1336 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 } 1373 }
1374 return *isolate->factory()->NewJSArrayWithElements(result); 1374 return *isolate->factory()->NewJSArrayWithElements(result);
1375 } 1375 }
1376 1376
1377 1377
1378 // Scan the heap for objects constructed by a specific function. 1378 // Scan the heap for objects constructed by a specific function.
1379 // args[0]: the constructor to find instances of 1379 // args[0]: the constructor to find instances of
1380 // args[1]: the the maximum number of objects to return 1380 // args[1]: the the maximum number of objects to return
1381 RUNTIME_FUNCTION(Runtime_DebugConstructedBy) { 1381 RUNTIME_FUNCTION(Runtime_DebugConstructedBy) {
1382 HandleScope scope(isolate); 1382 HandleScope scope(isolate);
1383 DCHECK(args.length() == 2); 1383 DCHECK_EQ(2, args.length());
1384 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); 1384 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0);
1385 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); 1385 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]);
1386 CHECK(max_references >= 0); 1386 CHECK(max_references >= 0);
1387 1387
1388 List<Handle<JSObject> > instances; 1388 List<Handle<JSObject> > instances;
1389 Heap* heap = isolate->heap(); 1389 Heap* heap = isolate->heap();
1390 { 1390 {
1391 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); 1391 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable);
1392 HeapObject* heap_obj; 1392 HeapObject* heap_obj;
1393 while ((heap_obj = iterator.next())) { 1393 while ((heap_obj = iterator.next())) {
(...skipping 12 matching lines...) Expand all
1406 isolate->factory()->NewFixedArray(instances.length()); 1406 isolate->factory()->NewFixedArray(instances.length());
1407 for (int i = 0; i < instances.length(); ++i) result->set(i, *instances[i]); 1407 for (int i = 0; i < instances.length(); ++i) result->set(i, *instances[i]);
1408 return *isolate->factory()->NewJSArrayWithElements(result); 1408 return *isolate->factory()->NewJSArrayWithElements(result);
1409 } 1409 }
1410 1410
1411 1411
1412 // Find the effective prototype object as returned by __proto__. 1412 // Find the effective prototype object as returned by __proto__.
1413 // args[0]: the object to find the prototype for. 1413 // args[0]: the object to find the prototype for.
1414 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) { 1414 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) {
1415 HandleScope shs(isolate); 1415 HandleScope shs(isolate);
1416 DCHECK(args.length() == 1); 1416 DCHECK_EQ(1, args.length());
1417 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 1417 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
1418 // TODO(1543): Come up with a solution for clients to handle potential errors 1418 // TODO(1543): Come up with a solution for clients to handle potential errors
1419 // thrown by an intermediate proxy. 1419 // thrown by an intermediate proxy.
1420 RETURN_RESULT_OR_FAILURE(isolate, JSReceiver::GetPrototype(isolate, obj)); 1420 RETURN_RESULT_OR_FAILURE(isolate, JSReceiver::GetPrototype(isolate, obj));
1421 } 1421 }
1422 1422
1423 1423
1424 // Patches script source (should be called upon BeforeCompile event). 1424 // Patches script source (should be called upon BeforeCompile event).
1425 // TODO(5530): Remove once uses in debug.js are gone. 1425 // TODO(5530): Remove once uses in debug.js are gone.
1426 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) { 1426 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) {
1427 HandleScope scope(isolate); 1427 HandleScope scope(isolate);
1428 DCHECK(args.length() == 2); 1428 DCHECK_EQ(2, args.length());
1429 1429
1430 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); 1430 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0);
1431 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 1431 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
1432 1432
1433 CHECK(script_wrapper->value()->IsScript()); 1433 CHECK(script_wrapper->value()->IsScript());
1434 Handle<Script> script(Script::cast(script_wrapper->value())); 1434 Handle<Script> script(Script::cast(script_wrapper->value()));
1435 1435
1436 // The following condition is not guaranteed to hold and a failure is also 1436 // The following condition is not guaranteed to hold and a failure is also
1437 // propagated to callers. Hence we fail gracefully here and don't crash. 1437 // propagated to callers. Hence we fail gracefully here and don't crash.
1438 if (script->compilation_state() != Script::COMPILATION_STATE_INITIAL) { 1438 if (script->compilation_state() != Script::COMPILATION_STATE_INITIAL) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 return *JSFunction::GetDebugName(Handle<JSFunction>::cast(function)); 1471 return *JSFunction::GetDebugName(Handle<JSFunction>::cast(function));
1472 } 1472 }
1473 } 1473 }
1474 1474
1475 1475
1476 // Calls specified function with or without entering the debugger. 1476 // Calls specified function with or without entering the debugger.
1477 // This is used in unit tests to run code as if debugger is entered or simply 1477 // This is used in unit tests to run code as if debugger is entered or simply
1478 // to have a stack with C++ frame in the middle. 1478 // to have a stack with C++ frame in the middle.
1479 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { 1479 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) {
1480 HandleScope scope(isolate); 1480 HandleScope scope(isolate);
1481 DCHECK(args.length() == 1); 1481 DCHECK_EQ(1, args.length());
1482 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 1482 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
1483 1483
1484 DebugScope debug_scope(isolate->debug()); 1484 DebugScope debug_scope(isolate->debug());
1485 if (debug_scope.failed()) { 1485 if (debug_scope.failed()) {
1486 DCHECK(isolate->has_pending_exception()); 1486 DCHECK(isolate->has_pending_exception());
1487 return isolate->heap()->exception(); 1487 return isolate->heap()->exception();
1488 } 1488 }
1489 1489
1490 RETURN_RESULT_OR_FAILURE( 1490 RETURN_RESULT_OR_FAILURE(
1491 isolate, Execution::Call(isolate, function, 1491 isolate, Execution::Call(isolate, function,
1492 handle(function->global_proxy()), 0, NULL)); 1492 handle(function->global_proxy()), 0, NULL));
1493 } 1493 }
1494 1494
1495 1495
1496 RUNTIME_FUNCTION(Runtime_GetDebugContext) { 1496 RUNTIME_FUNCTION(Runtime_GetDebugContext) {
1497 HandleScope scope(isolate); 1497 HandleScope scope(isolate);
1498 DCHECK(args.length() == 0); 1498 DCHECK_EQ(0, args.length());
1499 Handle<Context> context; 1499 Handle<Context> context;
1500 { 1500 {
1501 DebugScope debug_scope(isolate->debug()); 1501 DebugScope debug_scope(isolate->debug());
1502 if (debug_scope.failed()) { 1502 if (debug_scope.failed()) {
1503 DCHECK(isolate->has_pending_exception()); 1503 DCHECK(isolate->has_pending_exception());
1504 return isolate->heap()->exception(); 1504 return isolate->heap()->exception();
1505 } 1505 }
1506 context = isolate->debug()->GetDebugContext(); 1506 context = isolate->debug()->GetDebugContext();
1507 } 1507 }
1508 if (context.is_null()) return isolate->heap()->undefined_value(); 1508 if (context.is_null()) return isolate->heap()->undefined_value();
1509 context->set_security_token(isolate->native_context()->security_token()); 1509 context->set_security_token(isolate->native_context()->security_token());
1510 return context->global_proxy(); 1510 return context->global_proxy();
1511 } 1511 }
1512 1512
1513 1513
1514 // Performs a GC. 1514 // Performs a GC.
1515 // Presently, it only does a full GC. 1515 // Presently, it only does a full GC.
1516 RUNTIME_FUNCTION(Runtime_CollectGarbage) { 1516 RUNTIME_FUNCTION(Runtime_CollectGarbage) {
1517 SealHandleScope shs(isolate); 1517 SealHandleScope shs(isolate);
1518 DCHECK(args.length() == 1); 1518 DCHECK_EQ(1, args.length());
1519 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 1519 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
1520 GarbageCollectionReason::kRuntime); 1520 GarbageCollectionReason::kRuntime);
1521 return isolate->heap()->undefined_value(); 1521 return isolate->heap()->undefined_value();
1522 } 1522 }
1523 1523
1524 1524
1525 // Gets the current heap usage. 1525 // Gets the current heap usage.
1526 RUNTIME_FUNCTION(Runtime_GetHeapUsage) { 1526 RUNTIME_FUNCTION(Runtime_GetHeapUsage) {
1527 SealHandleScope shs(isolate); 1527 SealHandleScope shs(isolate);
1528 DCHECK(args.length() == 0); 1528 DCHECK_EQ(0, args.length());
1529 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); 1529 int usage = static_cast<int>(isolate->heap()->SizeOfObjects());
1530 if (!Smi::IsValid(usage)) { 1530 if (!Smi::IsValid(usage)) {
1531 return *isolate->factory()->NewNumberFromInt(usage); 1531 return *isolate->factory()->NewNumberFromInt(usage);
1532 } 1532 }
1533 return Smi::FromInt(usage); 1533 return Smi::FromInt(usage);
1534 } 1534 }
1535 1535
1536 1536
1537 // Finds the script object from the script data. NOTE: This operation uses 1537 // Finds the script object from the script data. NOTE: This operation uses
1538 // heap traversal to find the function generated for the source position 1538 // heap traversal to find the function generated for the source position
1539 // for the requested break point. For lazily compiled functions several heap 1539 // for the requested break point. For lazily compiled functions several heap
1540 // traversals might be required rendering this operation as a rather slow 1540 // traversals might be required rendering this operation as a rather slow
1541 // operation. However for setting break points which is normally done through 1541 // operation. However for setting break points which is normally done through
1542 // some kind of user interaction the performance is not crucial. 1542 // some kind of user interaction the performance is not crucial.
1543 RUNTIME_FUNCTION(Runtime_GetScript) { 1543 RUNTIME_FUNCTION(Runtime_GetScript) {
1544 HandleScope scope(isolate); 1544 HandleScope scope(isolate);
1545 DCHECK(args.length() == 1); 1545 DCHECK_EQ(1, args.length());
1546 CONVERT_ARG_HANDLE_CHECKED(String, script_name, 0); 1546 CONVERT_ARG_HANDLE_CHECKED(String, script_name, 0);
1547 1547
1548 Handle<Script> found; 1548 Handle<Script> found;
1549 { 1549 {
1550 Script::Iterator iterator(isolate); 1550 Script::Iterator iterator(isolate);
1551 Script* script = NULL; 1551 Script* script = NULL;
1552 while ((script = iterator.Next()) != NULL) { 1552 while ((script = iterator.Next()) != NULL) {
1553 if (!script->name()->IsString()) continue; 1553 if (!script->name()->IsString()) continue;
1554 String* name = String::cast(script->name()); 1554 String* name = String::cast(script->name());
1555 if (name->Equals(*script_name)) { 1555 if (name->Equals(*script_name)) {
1556 found = Handle<Script>(script, isolate); 1556 found = Handle<Script>(script, isolate);
1557 break; 1557 break;
1558 } 1558 }
1559 } 1559 }
1560 } 1560 }
1561 1561
1562 if (found.is_null()) return isolate->heap()->undefined_value(); 1562 if (found.is_null()) return isolate->heap()->undefined_value();
1563 return *Script::GetWrapper(found); 1563 return *Script::GetWrapper(found);
1564 } 1564 }
1565 1565
1566 // TODO(5530): Remove once uses in debug.js are gone. 1566 // TODO(5530): Remove once uses in debug.js are gone.
1567 RUNTIME_FUNCTION(Runtime_ScriptLineCount) { 1567 RUNTIME_FUNCTION(Runtime_ScriptLineCount) {
1568 HandleScope scope(isolate); 1568 HandleScope scope(isolate);
1569 DCHECK(args.length() == 1); 1569 DCHECK_EQ(1, args.length());
1570 CONVERT_ARG_CHECKED(JSValue, script, 0); 1570 CONVERT_ARG_CHECKED(JSValue, script, 0);
1571 1571
1572 CHECK(script->value()->IsScript()); 1572 CHECK(script->value()->IsScript());
1573 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 1573 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
1574 1574
1575 if (script_handle->type() == Script::TYPE_WASM) { 1575 if (script_handle->type() == Script::TYPE_WASM) {
1576 // Return 0 for now; this function will disappear soon anyway. 1576 // Return 0 for now; this function will disappear soon anyway.
1577 return Smi::FromInt(0); 1577 return Smi::FromInt(0);
1578 } 1578 }
1579 1579
(...skipping 23 matching lines...) Expand all
1603 // If line == line_count, we return the first position beyond the last line. 1603 // If line == line_count, we return the first position beyond the last line.
1604 if (line > line_count) return -1; 1604 if (line > line_count) return -1;
1605 return Smi::cast(line_ends_array->get(line - 1))->value() + 1; 1605 return Smi::cast(line_ends_array->get(line - 1))->value() + 1;
1606 } 1606 }
1607 1607
1608 } // namespace 1608 } // namespace
1609 1609
1610 // TODO(5530): Remove once uses in debug.js are gone. 1610 // TODO(5530): Remove once uses in debug.js are gone.
1611 RUNTIME_FUNCTION(Runtime_ScriptLineStartPosition) { 1611 RUNTIME_FUNCTION(Runtime_ScriptLineStartPosition) {
1612 HandleScope scope(isolate); 1612 HandleScope scope(isolate);
1613 DCHECK(args.length() == 2); 1613 DCHECK_EQ(2, args.length());
1614 CONVERT_ARG_CHECKED(JSValue, script, 0); 1614 CONVERT_ARG_CHECKED(JSValue, script, 0);
1615 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); 1615 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]);
1616 1616
1617 CHECK(script->value()->IsScript()); 1617 CHECK(script->value()->IsScript());
1618 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 1618 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
1619 1619
1620 return Smi::FromInt(ScriptLinePosition(script_handle, line)); 1620 return Smi::FromInt(ScriptLinePosition(script_handle, line));
1621 } 1621 }
1622 1622
1623 // TODO(5530): Remove once uses in debug.js are gone. 1623 // TODO(5530): Remove once uses in debug.js are gone.
1624 RUNTIME_FUNCTION(Runtime_ScriptLineEndPosition) { 1624 RUNTIME_FUNCTION(Runtime_ScriptLineEndPosition) {
1625 HandleScope scope(isolate); 1625 HandleScope scope(isolate);
1626 DCHECK(args.length() == 2); 1626 DCHECK_EQ(2, args.length());
1627 CONVERT_ARG_CHECKED(JSValue, script, 0); 1627 CONVERT_ARG_CHECKED(JSValue, script, 0);
1628 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); 1628 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]);
1629 1629
1630 CHECK(script->value()->IsScript()); 1630 CHECK(script->value()->IsScript());
1631 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 1631 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
1632 1632
1633 if (script_handle->type() == Script::TYPE_WASM) { 1633 if (script_handle->type() == Script::TYPE_WASM) {
1634 // Return zero for now; this function will disappear soon anyway. 1634 // Return zero for now; this function will disappear soon anyway.
1635 return Smi::FromInt(0); 1635 return Smi::FromInt(0);
1636 } 1636 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 // fixed source position. This function is used to find a source position from 1741 // fixed source position. This function is used to find a source position from
1742 // a line and column position. The fixed source position offset is typically 1742 // a line and column position. The fixed source position offset is typically
1743 // used to find a source position in a function based on a line and column in 1743 // used to find a source position in a function based on a line and column in
1744 // the source for the function alone. The offset passed will then be the 1744 // the source for the function alone. The offset passed will then be the
1745 // start position of the source for the function within the full script source. 1745 // start position of the source for the function within the full script source.
1746 // Note that incoming line and column parameters may be undefined, and are 1746 // Note that incoming line and column parameters may be undefined, and are
1747 // assumed to be passed *with* offsets. 1747 // assumed to be passed *with* offsets.
1748 // TODO(5530): Remove once uses in debug.js are gone. 1748 // TODO(5530): Remove once uses in debug.js are gone.
1749 RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) { 1749 RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) {
1750 HandleScope scope(isolate); 1750 HandleScope scope(isolate);
1751 DCHECK(args.length() == 4); 1751 DCHECK_EQ(4, args.length());
1752 CONVERT_ARG_HANDLE_CHECKED(JSValue, script, 0); 1752 CONVERT_ARG_HANDLE_CHECKED(JSValue, script, 0);
1753 CONVERT_ARG_HANDLE_CHECKED(Object, opt_line, 1); 1753 CONVERT_ARG_HANDLE_CHECKED(Object, opt_line, 1);
1754 CONVERT_ARG_HANDLE_CHECKED(Object, opt_column, 2); 1754 CONVERT_ARG_HANDLE_CHECKED(Object, opt_column, 2);
1755 CONVERT_NUMBER_CHECKED(int32_t, offset, Int32, args[3]); 1755 CONVERT_NUMBER_CHECKED(int32_t, offset, Int32, args[3]);
1756 1756
1757 CHECK(script->value()->IsScript()); 1757 CHECK(script->value()->IsScript());
1758 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 1758 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
1759 1759
1760 return *ScriptLocationFromLine(isolate, script_handle, opt_line, opt_column, 1760 return *ScriptLocationFromLine(isolate, script_handle, opt_line, opt_column,
1761 offset); 1761 offset);
1762 } 1762 }
1763 1763
1764 // TODO(5530): Rename once conflicting function has been deleted. 1764 // TODO(5530): Rename once conflicting function has been deleted.
1765 RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine2) { 1765 RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine2) {
1766 HandleScope scope(isolate); 1766 HandleScope scope(isolate);
1767 DCHECK(args.length() == 4); 1767 DCHECK_EQ(4, args.length());
1768 CONVERT_NUMBER_CHECKED(int32_t, scriptid, Int32, args[0]); 1768 CONVERT_NUMBER_CHECKED(int32_t, scriptid, Int32, args[0]);
1769 CONVERT_ARG_HANDLE_CHECKED(Object, opt_line, 1); 1769 CONVERT_ARG_HANDLE_CHECKED(Object, opt_line, 1);
1770 CONVERT_ARG_HANDLE_CHECKED(Object, opt_column, 2); 1770 CONVERT_ARG_HANDLE_CHECKED(Object, opt_column, 2);
1771 CONVERT_NUMBER_CHECKED(int32_t, offset, Int32, args[3]); 1771 CONVERT_NUMBER_CHECKED(int32_t, offset, Int32, args[3]);
1772 1772
1773 Handle<Script> script; 1773 Handle<Script> script;
1774 CHECK(GetScriptById(isolate, scriptid, &script)); 1774 CHECK(GetScriptById(isolate, scriptid, &script));
1775 1775
1776 return *ScriptLocationFromLine(isolate, script, opt_line, opt_column, offset); 1776 return *ScriptLocationFromLine(isolate, script, opt_line, opt_column, offset);
1777 } 1777 }
1778 1778
1779 // TODO(5530): Remove once uses in debug.js are gone. 1779 // TODO(5530): Remove once uses in debug.js are gone.
1780 RUNTIME_FUNCTION(Runtime_ScriptPositionInfo) { 1780 RUNTIME_FUNCTION(Runtime_ScriptPositionInfo) {
1781 HandleScope scope(isolate); 1781 HandleScope scope(isolate);
1782 DCHECK(args.length() == 3); 1782 DCHECK_EQ(3, args.length());
1783 CONVERT_ARG_CHECKED(JSValue, script, 0); 1783 CONVERT_ARG_CHECKED(JSValue, script, 0);
1784 CONVERT_NUMBER_CHECKED(int32_t, position, Int32, args[1]); 1784 CONVERT_NUMBER_CHECKED(int32_t, position, Int32, args[1]);
1785 CONVERT_BOOLEAN_ARG_CHECKED(with_offset, 2); 1785 CONVERT_BOOLEAN_ARG_CHECKED(with_offset, 2);
1786 1786
1787 CHECK(script->value()->IsScript()); 1787 CHECK(script->value()->IsScript());
1788 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 1788 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
1789 1789
1790 const Script::OffsetFlag offset_flag = 1790 const Script::OffsetFlag offset_flag =
1791 with_offset ? Script::WITH_OFFSET : Script::NO_OFFSET; 1791 with_offset ? Script::WITH_OFFSET : Script::NO_OFFSET;
1792 return *GetJSPositionInfo(script_handle, position, offset_flag, isolate); 1792 return *GetJSPositionInfo(script_handle, position, offset_flag, isolate);
1793 } 1793 }
1794 1794
1795 // TODO(5530): Rename once conflicting function has been deleted. 1795 // TODO(5530): Rename once conflicting function has been deleted.
1796 RUNTIME_FUNCTION(Runtime_ScriptPositionInfo2) { 1796 RUNTIME_FUNCTION(Runtime_ScriptPositionInfo2) {
1797 HandleScope scope(isolate); 1797 HandleScope scope(isolate);
1798 DCHECK(args.length() == 3); 1798 DCHECK_EQ(3, args.length());
1799 CONVERT_NUMBER_CHECKED(int32_t, scriptid, Int32, args[0]); 1799 CONVERT_NUMBER_CHECKED(int32_t, scriptid, Int32, args[0]);
1800 CONVERT_NUMBER_CHECKED(int32_t, position, Int32, args[1]); 1800 CONVERT_NUMBER_CHECKED(int32_t, position, Int32, args[1]);
1801 CONVERT_BOOLEAN_ARG_CHECKED(with_offset, 2); 1801 CONVERT_BOOLEAN_ARG_CHECKED(with_offset, 2);
1802 1802
1803 Handle<Script> script; 1803 Handle<Script> script;
1804 CHECK(GetScriptById(isolate, scriptid, &script)); 1804 CHECK(GetScriptById(isolate, scriptid, &script));
1805 1805
1806 const Script::OffsetFlag offset_flag = 1806 const Script::OffsetFlag offset_flag =
1807 with_offset ? Script::WITH_OFFSET : Script::NO_OFFSET; 1807 with_offset ? Script::WITH_OFFSET : Script::NO_OFFSET;
1808 return *GetJSPositionInfo(script, position, offset_flag, isolate); 1808 return *GetJSPositionInfo(script, position, offset_flag, isolate);
1809 } 1809 }
1810 1810
1811 // Returns the given line as a string, or null if line is out of bounds. 1811 // Returns the given line as a string, or null if line is out of bounds.
1812 // The parameter line is expected to include the script's line offset. 1812 // The parameter line is expected to include the script's line offset.
1813 // TODO(5530): Remove once uses in debug.js are gone. 1813 // TODO(5530): Remove once uses in debug.js are gone.
1814 RUNTIME_FUNCTION(Runtime_ScriptSourceLine) { 1814 RUNTIME_FUNCTION(Runtime_ScriptSourceLine) {
1815 HandleScope scope(isolate); 1815 HandleScope scope(isolate);
1816 DCHECK(args.length() == 2); 1816 DCHECK_EQ(2, args.length());
1817 CONVERT_ARG_CHECKED(JSValue, script, 0); 1817 CONVERT_ARG_CHECKED(JSValue, script, 0);
1818 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); 1818 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]);
1819 1819
1820 CHECK(script->value()->IsScript()); 1820 CHECK(script->value()->IsScript());
1821 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 1821 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
1822 1822
1823 if (script_handle->type() == Script::TYPE_WASM) { 1823 if (script_handle->type() == Script::TYPE_WASM) {
1824 // Return null for now; this function will disappear soon anyway. 1824 // Return null for now; this function will disappear soon anyway.
1825 return isolate->heap()->null_value(); 1825 return isolate->heap()->null_value();
1826 } 1826 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 RUNTIME_FUNCTION(Runtime_DebugRecordGenerator) { 1868 RUNTIME_FUNCTION(Runtime_DebugRecordGenerator) {
1869 HandleScope scope(isolate); 1869 HandleScope scope(isolate);
1870 DCHECK_EQ(1, args.length()); 1870 DCHECK_EQ(1, args.length());
1871 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 1871 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
1872 CHECK(isolate->debug()->last_step_action() >= StepNext); 1872 CHECK(isolate->debug()->last_step_action() >= StepNext);
1873 isolate->debug()->RecordGenerator(generator); 1873 isolate->debug()->RecordGenerator(generator);
1874 return isolate->heap()->undefined_value(); 1874 return isolate->heap()->undefined_value();
1875 } 1875 }
1876 1876
1877 RUNTIME_FUNCTION(Runtime_DebugPushPromise) { 1877 RUNTIME_FUNCTION(Runtime_DebugPushPromise) {
1878 DCHECK(args.length() == 1); 1878 DCHECK_EQ(1, args.length());
1879 HandleScope scope(isolate); 1879 HandleScope scope(isolate);
1880 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); 1880 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
1881 isolate->PushPromise(promise); 1881 isolate->PushPromise(promise);
1882 return isolate->heap()->undefined_value(); 1882 return isolate->heap()->undefined_value();
1883 } 1883 }
1884 1884
1885 1885
1886 RUNTIME_FUNCTION(Runtime_DebugPopPromise) { 1886 RUNTIME_FUNCTION(Runtime_DebugPopPromise) {
1887 DCHECK(args.length() == 0); 1887 DCHECK_EQ(0, args.length());
1888 SealHandleScope shs(isolate); 1888 SealHandleScope shs(isolate);
1889 isolate->PopPromise(); 1889 isolate->PopPromise();
1890 return isolate->heap()->undefined_value(); 1890 return isolate->heap()->undefined_value();
1891 } 1891 }
1892 1892
1893 RUNTIME_FUNCTION(Runtime_DebugNextMicrotaskId) { 1893 RUNTIME_FUNCTION(Runtime_DebugNextMicrotaskId) {
1894 HandleScope scope(isolate); 1894 HandleScope scope(isolate);
1895 DCHECK(args.length() == 0); 1895 DCHECK_EQ(0, args.length());
1896 return Smi::FromInt(isolate->GetNextDebugMicrotaskId()); 1896 return Smi::FromInt(isolate->GetNextDebugMicrotaskId());
1897 } 1897 }
1898 1898
1899 RUNTIME_FUNCTION(Runtime_DebugAsyncTaskEvent) { 1899 RUNTIME_FUNCTION(Runtime_DebugAsyncTaskEvent) {
1900 DCHECK(args.length() == 3); 1900 DCHECK_EQ(3, args.length());
1901 HandleScope scope(isolate); 1901 HandleScope scope(isolate);
1902 CONVERT_SMI_ARG_CHECKED(type, 0); 1902 CONVERT_SMI_ARG_CHECKED(type, 0);
1903 CONVERT_SMI_ARG_CHECKED(id, 1); 1903 CONVERT_SMI_ARG_CHECKED(id, 1);
1904 CONVERT_SMI_ARG_CHECKED(name, 2); 1904 CONVERT_SMI_ARG_CHECKED(name, 2);
1905 isolate->debug()->OnAsyncTaskEvent(static_cast<PromiseDebugActionType>(type), 1905 isolate->debug()->OnAsyncTaskEvent(static_cast<PromiseDebugActionType>(type),
1906 id, 1906 id,
1907 static_cast<PromiseDebugActionName>(name)); 1907 static_cast<PromiseDebugActionName>(name));
1908 return isolate->heap()->undefined_value(); 1908 return isolate->heap()->undefined_value();
1909 } 1909 }
1910 1910
1911 1911
1912 RUNTIME_FUNCTION(Runtime_DebugIsActive) { 1912 RUNTIME_FUNCTION(Runtime_DebugIsActive) {
1913 SealHandleScope shs(isolate); 1913 SealHandleScope shs(isolate);
1914 return Smi::FromInt(isolate->debug()->is_active()); 1914 return Smi::FromInt(isolate->debug()->is_active());
1915 } 1915 }
1916 1916
1917 1917
1918 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 1918 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
1919 UNIMPLEMENTED(); 1919 UNIMPLEMENTED();
1920 return NULL; 1920 return NULL;
1921 } 1921 }
1922 1922
1923 } // namespace internal 1923 } // namespace internal
1924 } // namespace v8 1924 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-compiler.cc ('k') | src/runtime/runtime-error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698