| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 const int argc = 2; | 614 const int argc = 2; |
| 615 v8::Handle<v8::Value> argv[argc] = { | 615 v8::Handle<v8::Value> argv[argc] = { |
| 616 exec_state, v8::Integer::New(CcTest::isolate(), 0) | 616 exec_state, v8::Integer::New(CcTest::isolate(), 0) |
| 617 }; | 617 }; |
| 618 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, | 618 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, |
| 619 argc, argv); | 619 argc, argv); |
| 620 if (result->IsUndefined()) { | 620 if (result->IsUndefined()) { |
| 621 last_function_hit[0] = '\0'; | 621 last_function_hit[0] = '\0'; |
| 622 } else { | 622 } else { |
| 623 CHECK(result->IsString()); | 623 CHECK(result->IsString()); |
| 624 v8::Handle<v8::String> function_name(result->ToString()); | 624 v8::Handle<v8::String> function_name(result.As<v8::String>()); |
| 625 function_name->WriteUtf8(last_function_hit); | 625 function_name->WriteUtf8(last_function_hit); |
| 626 } | 626 } |
| 627 } | 627 } |
| 628 | 628 |
| 629 if (!frame_source_line.IsEmpty()) { | 629 if (!frame_source_line.IsEmpty()) { |
| 630 // Get the source line. | 630 // Get the source line. |
| 631 const int argc = 1; | 631 const int argc = 1; |
| 632 v8::Handle<v8::Value> argv[argc] = { exec_state }; | 632 v8::Handle<v8::Value> argv[argc] = { exec_state }; |
| 633 v8::Handle<v8::Value> result = frame_source_line->Call(exec_state, | 633 v8::Handle<v8::Value> result = frame_source_line->Call(exec_state, |
| 634 argc, argv); | 634 argc, argv); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 649 if (!frame_script_name.IsEmpty()) { | 649 if (!frame_script_name.IsEmpty()) { |
| 650 // Get the script name of the function script. | 650 // Get the script name of the function script. |
| 651 const int argc = 1; | 651 const int argc = 1; |
| 652 v8::Handle<v8::Value> argv[argc] = { exec_state }; | 652 v8::Handle<v8::Value> argv[argc] = { exec_state }; |
| 653 v8::Handle<v8::Value> result = frame_script_name->Call(exec_state, | 653 v8::Handle<v8::Value> result = frame_script_name->Call(exec_state, |
| 654 argc, argv); | 654 argc, argv); |
| 655 if (result->IsUndefined()) { | 655 if (result->IsUndefined()) { |
| 656 last_script_name_hit[0] = '\0'; | 656 last_script_name_hit[0] = '\0'; |
| 657 } else { | 657 } else { |
| 658 CHECK(result->IsString()); | 658 CHECK(result->IsString()); |
| 659 v8::Handle<v8::String> script_name(result->ToString()); | 659 v8::Handle<v8::String> script_name(result.As<v8::String>()); |
| 660 script_name->WriteUtf8(last_script_name_hit); | 660 script_name->WriteUtf8(last_script_name_hit); |
| 661 } | 661 } |
| 662 } | 662 } |
| 663 | 663 |
| 664 // Perform a full deoptimization when the specified number of | 664 // Perform a full deoptimization when the specified number of |
| 665 // breaks have been hit. | 665 // breaks have been hit. |
| 666 if (break_point_hit_count == break_point_hit_count_deoptimize) { | 666 if (break_point_hit_count == break_point_hit_count_deoptimize) { |
| 667 i::Deoptimizer::DeoptimizeAll(isolate); | 667 i::Deoptimizer::DeoptimizeAll(isolate); |
| 668 } | 668 } |
| 669 } | 669 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 break_point_hit_count++; | 768 break_point_hit_count++; |
| 769 for (int i = 0; checks[i].expr != NULL; i++) { | 769 for (int i = 0; checks[i].expr != NULL; i++) { |
| 770 const int argc = 3; | 770 const int argc = 3; |
| 771 v8::Handle<v8::Value> argv[argc] = { | 771 v8::Handle<v8::Value> argv[argc] = { |
| 772 exec_state, | 772 exec_state, |
| 773 v8::String::NewFromUtf8(CcTest::isolate(), checks[i].expr), | 773 v8::String::NewFromUtf8(CcTest::isolate(), checks[i].expr), |
| 774 checks[i].expected}; | 774 checks[i].expected}; |
| 775 v8::Handle<v8::Value> result = | 775 v8::Handle<v8::Value> result = |
| 776 evaluate_check_function->Call(exec_state, argc, argv); | 776 evaluate_check_function->Call(exec_state, argc, argv); |
| 777 if (!result->IsTrue()) { | 777 if (!result->IsTrue()) { |
| 778 v8::String::Utf8Value utf8(checks[i].expected->ToString()); | 778 v8::String::Utf8Value utf8(checks[i].expected); |
| 779 V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *utf8); | 779 V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *utf8); |
| 780 } | 780 } |
| 781 } | 781 } |
| 782 } | 782 } |
| 783 } | 783 } |
| 784 | 784 |
| 785 | 785 |
| 786 // This debug event listener removes a breakpoint in a function | 786 // This debug event listener removes a breakpoint in a function |
| 787 int debug_event_remove_break_point = 0; | 787 int debug_event_remove_break_point = 0; |
| 788 static void DebugEventRemoveBreakPoint( | 788 static void DebugEventRemoveBreakPoint( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 // Check that the current function is the expected. | 842 // Check that the current function is the expected. |
| 843 CHECK(break_point_hit_count < | 843 CHECK(break_point_hit_count < |
| 844 StrLength(expected_step_sequence)); | 844 StrLength(expected_step_sequence)); |
| 845 const int argc = 2; | 845 const int argc = 2; |
| 846 v8::Handle<v8::Value> argv[argc] = { | 846 v8::Handle<v8::Value> argv[argc] = { |
| 847 exec_state, v8::Integer::New(CcTest::isolate(), 0) | 847 exec_state, v8::Integer::New(CcTest::isolate(), 0) |
| 848 }; | 848 }; |
| 849 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, | 849 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, |
| 850 argc, argv); | 850 argc, argv); |
| 851 CHECK(result->IsString()); | 851 CHECK(result->IsString()); |
| 852 v8::String::Utf8Value function_name(result->ToString()); | 852 v8::String::Utf8Value function_name(result->ToString(CcTest::isolate())); |
| 853 CHECK_EQ(1, StrLength(*function_name)); | 853 CHECK_EQ(1, StrLength(*function_name)); |
| 854 CHECK_EQ((*function_name)[0], | 854 CHECK_EQ((*function_name)[0], |
| 855 expected_step_sequence[break_point_hit_count]); | 855 expected_step_sequence[break_point_hit_count]); |
| 856 | 856 |
| 857 // Perform step. | 857 // Perform step. |
| 858 break_point_hit_count++; | 858 break_point_hit_count++; |
| 859 PrepareStep(step_action); | 859 PrepareStep(step_action); |
| 860 } | 860 } |
| 861 } | 861 } |
| 862 | 862 |
| (...skipping 5289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6152 const int argc = 2; | 6152 const int argc = 2; |
| 6153 v8::Handle<v8::Value> argv[argc] = { | 6153 v8::Handle<v8::Value> argv[argc] = { |
| 6154 exec_state, v8::Integer::New(CcTest::isolate(), 0) | 6154 exec_state, v8::Integer::New(CcTest::isolate(), 0) |
| 6155 }; | 6155 }; |
| 6156 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, | 6156 v8::Handle<v8::Value> result = frame_function_name->Call(exec_state, |
| 6157 argc, argv); | 6157 argc, argv); |
| 6158 if (result->IsUndefined()) { | 6158 if (result->IsUndefined()) { |
| 6159 last_function_hit[0] = '\0'; | 6159 last_function_hit[0] = '\0'; |
| 6160 } else { | 6160 } else { |
| 6161 CHECK(result->IsString()); | 6161 CHECK(result->IsString()); |
| 6162 v8::Handle<v8::String> function_name(result->ToString()); | 6162 v8::Handle<v8::String> function_name( |
| 6163 result->ToString(CcTest::isolate())); |
| 6163 function_name->WriteUtf8(last_function_hit); | 6164 function_name->WriteUtf8(last_function_hit); |
| 6164 } | 6165 } |
| 6165 } | 6166 } |
| 6166 | 6167 |
| 6167 // Keep forcing breaks. | 6168 // Keep forcing breaks. |
| 6168 if (break_point_hit_count < 20) { | 6169 if (break_point_hit_count < 20) { |
| 6169 v8::Debug::DebugBreak(CcTest::isolate()); | 6170 v8::Debug::DebugBreak(CcTest::isolate()); |
| 6170 } | 6171 } |
| 6171 } | 6172 } |
| 6172 } | 6173 } |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7035 // Get the name of the function. | 7036 // Get the name of the function. |
| 7036 const int argc = 2; | 7037 const int argc = 2; |
| 7037 v8::Handle<v8::Value> argv[argc] = { | 7038 v8::Handle<v8::Value> argv[argc] = { |
| 7038 exec_state, v8::Integer::New(CcTest::isolate(), 0) | 7039 exec_state, v8::Integer::New(CcTest::isolate(), 0) |
| 7039 }; | 7040 }; |
| 7040 v8::Handle<v8::Value> result = | 7041 v8::Handle<v8::Value> result = |
| 7041 frame_function_name->Call(exec_state, argc, argv); | 7042 frame_function_name->Call(exec_state, argc, argv); |
| 7042 if (!result->IsUndefined()) { | 7043 if (!result->IsUndefined()) { |
| 7043 char fn[80]; | 7044 char fn[80]; |
| 7044 CHECK(result->IsString()); | 7045 CHECK(result->IsString()); |
| 7045 v8::Handle<v8::String> function_name(result->ToString()); | 7046 v8::Handle<v8::String> function_name( |
| 7047 result->ToString(CcTest::isolate())); |
| 7046 function_name->WriteUtf8(fn); | 7048 function_name->WriteUtf8(fn); |
| 7047 if (strcmp(fn, "bar") == 0) { | 7049 if (strcmp(fn, "bar") == 0) { |
| 7048 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate()); | 7050 i::Deoptimizer::DeoptimizeAll(CcTest::i_isolate()); |
| 7049 debug_event_break_deoptimize_done = true; | 7051 debug_event_break_deoptimize_done = true; |
| 7050 } | 7052 } |
| 7051 } | 7053 } |
| 7052 } | 7054 } |
| 7053 | 7055 |
| 7054 v8::Debug::DebugBreak(CcTest::isolate()); | 7056 v8::Debug::DebugBreak(CcTest::isolate()); |
| 7055 } | 7057 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7100 if (!frame_function_name.IsEmpty()) { | 7102 if (!frame_function_name.IsEmpty()) { |
| 7101 for (int i = 0; i < 2; i++) { | 7103 for (int i = 0; i < 2; i++) { |
| 7102 const int argc = 2; | 7104 const int argc = 2; |
| 7103 v8::Handle<v8::Value> argv[argc] = { | 7105 v8::Handle<v8::Value> argv[argc] = { |
| 7104 exec_state, v8::Integer::New(isolate, i) | 7106 exec_state, v8::Integer::New(isolate, i) |
| 7105 }; | 7107 }; |
| 7106 // Get the name of the function in frame i. | 7108 // Get the name of the function in frame i. |
| 7107 v8::Handle<v8::Value> result = | 7109 v8::Handle<v8::Value> result = |
| 7108 frame_function_name->Call(exec_state, argc, argv); | 7110 frame_function_name->Call(exec_state, argc, argv); |
| 7109 CHECK(result->IsString()); | 7111 CHECK(result->IsString()); |
| 7110 v8::Handle<v8::String> function_name(result->ToString()); | 7112 v8::Handle<v8::String> function_name(result->ToString(isolate)); |
| 7111 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop"))); | 7113 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop"))); |
| 7112 // Get the name of the first argument in frame i. | 7114 // Get the name of the first argument in frame i. |
| 7113 result = frame_argument_name->Call(exec_state, argc, argv); | 7115 result = frame_argument_name->Call(exec_state, argc, argv); |
| 7114 CHECK(result->IsString()); | 7116 CHECK(result->IsString()); |
| 7115 v8::Handle<v8::String> argument_name(result->ToString()); | 7117 v8::Handle<v8::String> argument_name(result->ToString(isolate)); |
| 7116 CHECK(argument_name->Equals(v8::String::NewFromUtf8(isolate, "count"))); | 7118 CHECK(argument_name->Equals(v8::String::NewFromUtf8(isolate, "count"))); |
| 7117 // Get the value of the first argument in frame i. If the | 7119 // Get the value of the first argument in frame i. If the |
| 7118 // funtion is optimized the value will be undefined, otherwise | 7120 // funtion is optimized the value will be undefined, otherwise |
| 7119 // the value will be '1 - i'. | 7121 // the value will be '1 - i'. |
| 7120 // | 7122 // |
| 7121 // TODO(3141533): We should be able to get the real value for | 7123 // TODO(3141533): We should be able to get the real value for |
| 7122 // optimized frames. | 7124 // optimized frames. |
| 7123 result = frame_argument_value->Call(exec_state, argc, argv); | 7125 result = frame_argument_value->Call(exec_state, argc, argv); |
| 7124 CHECK(result->IsUndefined() || (result->Int32Value() == 1 - i)); | 7126 CHECK(result->IsUndefined() || (result->Int32Value() == 1 - i)); |
| 7125 // Get the name of the first local variable. | 7127 // Get the name of the first local variable. |
| 7126 result = frame_local_name->Call(exec_state, argc, argv); | 7128 result = frame_local_name->Call(exec_state, argc, argv); |
| 7127 CHECK(result->IsString()); | 7129 CHECK(result->IsString()); |
| 7128 v8::Handle<v8::String> local_name(result->ToString()); | 7130 v8::Handle<v8::String> local_name(result->ToString(isolate)); |
| 7129 CHECK(local_name->Equals(v8::String::NewFromUtf8(isolate, "local"))); | 7131 CHECK(local_name->Equals(v8::String::NewFromUtf8(isolate, "local"))); |
| 7130 // Get the value of the first local variable. If the function | 7132 // Get the value of the first local variable. If the function |
| 7131 // is optimized the value will be undefined, otherwise it will | 7133 // is optimized the value will be undefined, otherwise it will |
| 7132 // be 42. | 7134 // be 42. |
| 7133 // | 7135 // |
| 7134 // TODO(3141533): We should be able to get the real value for | 7136 // TODO(3141533): We should be able to get the real value for |
| 7135 // optimized frames. | 7137 // optimized frames. |
| 7136 result = frame_local_value->Call(exec_state, argc, argv); | 7138 result = frame_local_value->Call(exec_state, argc, argv); |
| 7137 CHECK(result->IsUndefined() || (result->Int32Value() == 42)); | 7139 CHECK(result->IsUndefined() || (result->Int32Value() == 42)); |
| 7138 } | 7140 } |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7669 "let y = 2; \n" | 7671 "let y = 2; \n" |
| 7670 "debugger; \n" | 7672 "debugger; \n" |
| 7671 "x * y", | 7673 "x * y", |
| 7672 30); | 7674 30); |
| 7673 ExpectInt32( | 7675 ExpectInt32( |
| 7674 "x = 1; y = 2; \n" | 7676 "x = 1; y = 2; \n" |
| 7675 "debugger;" | 7677 "debugger;" |
| 7676 "x * y", | 7678 "x * y", |
| 7677 30); | 7679 30); |
| 7678 } | 7680 } |
| OLD | NEW |