Update V8 to r4851 as required by WebKit r61121
Change-Id: Ib01b7c8e38d5b82b254192fc06365aa5b85780c5
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 4b4c950..4c3ff5e 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -27,6 +27,8 @@
#include <stdlib.h>
+#define USE_NEW_QUERY_CALLBACKS
+
#include "v8.h"
#include "api.h"
@@ -395,8 +397,9 @@
static Handle<Code> ComputeCallDebugBreak(int argc) {
- CALL_HEAP_FUNCTION(v8::internal::StubCache::ComputeCallDebugBreak(argc),
- Code);
+ CALL_HEAP_FUNCTION(
+ v8::internal::StubCache::ComputeCallDebugBreak(argc, Code::CALL_IC),
+ Code);
}
@@ -1228,6 +1231,11 @@
SetBreakPoint(foo, 0);
CallWithBreakPoints(env->Global(), foo, 1, 25);
+ // Test debug break slot break point with garbage collection.
+ foo = CompileFunction(&env, "function foo(){var a;}", "foo");
+ SetBreakPoint(foo, 0);
+ CallWithBreakPoints(env->Global(), foo, 1, 25);
+
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
@@ -1657,7 +1665,7 @@
f->Call(env->Global(), 0, NULL);
CHECK_EQ(1, break_point_hit_count);
- ChangeScriptBreakPointConditionFromJS(sbp1, "a % 2 == 0");
+ ChangeScriptBreakPointConditionFromJS(sbp1, "x % 2 == 0");
break_point_hit_count = 0;
for (int i = 0; i < 10; i++) {
f->Call(env->Global(), 0, NULL);
@@ -2141,17 +2149,19 @@
v8::Local<v8::Function> foo = CompileFunction(&env,
"function foo(x) {"
" var a;"
- " y=0; /* To ensure break location.*/"
+ " y=0;" // To ensure break location 1.
" a=x;"
+ " y=0;" // To ensure break location 2.
"}",
"foo");
- const int foo_break_position = 15;
+ const int foo_break_position_1 = 15;
+ const int foo_break_position_2 = 29;
// Arguments with one parameter "Hello, world!"
v8::Handle<v8::Value> argv_foo[1] = { v8::String::New("Hello, world!") };
// Call foo with breakpoint set before a=x and undefined as parameter.
- int bp = SetBreakPoint(foo, foo_break_position);
+ int bp = SetBreakPoint(foo, foo_break_position_1);
checks = checks_uu;
foo->Call(env->Global(), 0, NULL);
@@ -2161,7 +2171,7 @@
// Call foo with breakpoint set after a=x and parameter "Hello, world!".
ClearBreakPoint(bp);
- SetBreakPoint(foo, foo_break_position + 1);
+ SetBreakPoint(foo, foo_break_position_2);
checks = checks_hh;
foo->Call(env->Global(), 1, argv_foo);
@@ -2423,6 +2433,9 @@
v8::HandleScope scope;
DebugLocalContext env;
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
// Create a function for testing stepping of keyed load. The statement 'y=1'
// is there to have more than one breakable statement in the loop, TODO(315).
v8::Local<v8::Function> foo = CompileFunction(
@@ -2448,9 +2461,6 @@
v8::Handle<v8::Value> args[kArgc] = { a };
foo->Call(env->Global(), kArgc, args);
- // Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
-
// Setup break point and step through the function.
SetBreakPoint(foo, 3);
step_action = StepNext;
@@ -2458,7 +2468,7 @@
foo->Call(env->Global(), kArgc, args);
// With stepping all break locations are hit.
- CHECK_EQ(22, break_point_hit_count);
+ CHECK_EQ(33, break_point_hit_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
@@ -2470,6 +2480,9 @@
v8::HandleScope scope;
DebugLocalContext env;
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
// Create a function for testing stepping of keyed store. The statement 'y=1'
// is there to have more than one breakable statement in the loop, TODO(315).
v8::Local<v8::Function> foo = CompileFunction(
@@ -2494,9 +2507,6 @@
v8::Handle<v8::Value> args[kArgc] = { a };
foo->Call(env->Global(), kArgc, args);
- // Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
-
// Setup break point and step through the function.
SetBreakPoint(foo, 3);
step_action = StepNext;
@@ -2504,7 +2514,7 @@
foo->Call(env->Global(), kArgc, args);
// With stepping all break locations are hit.
- CHECK_EQ(22, break_point_hit_count);
+ CHECK_EQ(32, break_point_hit_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
@@ -2516,6 +2526,9 @@
v8::HandleScope scope;
DebugLocalContext env;
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
// Create a function for testing stepping of named load.
v8::Local<v8::Function> foo = CompileFunction(
&env,
@@ -2538,9 +2551,6 @@
// Call function without any break points to ensure inlining is in place.
foo->Call(env->Global(), 0, NULL);
- // Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
-
// Setup break point and step through the function.
SetBreakPoint(foo, 4);
step_action = StepNext;
@@ -2548,7 +2558,7 @@
foo->Call(env->Global(), 0, NULL);
// With stepping all break locations are hit.
- CHECK_EQ(41, break_point_hit_count);
+ CHECK_EQ(53, break_point_hit_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
@@ -2560,6 +2570,9 @@
v8::HandleScope scope;
DebugLocalContext env;
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
// Create a function for testing stepping.
v8::Local<v8::Function> foo = CompileFunction(&env,
"function bar() {};"
@@ -2570,15 +2583,12 @@
" a=1;b=2;x=a;y[index]=3;x=y[index];bar();}", "foo");
SetBreakPoint(foo, 0);
- // Register a debug event listener which steps and counts.
- v8::Debug::SetDebugEventListener(DebugEventStep);
-
step_action = StepIn;
break_point_hit_count = 0;
foo->Call(env->Global(), 0, NULL);
// With stepping all break locations are hit.
- CHECK_EQ(8, break_point_hit_count);
+ CHECK_EQ(11, break_point_hit_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
@@ -2598,6 +2608,66 @@
}
+TEST(DebugStepDeclarations) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ // Create a function for testing stepping.
+ const char* src = "function foo() { "
+ " var a;"
+ " var b = 1;"
+ " var c = foo;"
+ " var d = Math.floor;"
+ " var e = b + d(1.2);"
+ "}";
+ v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
+ SetBreakPoint(foo, 0);
+
+ // Stepping through the declarations.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(6, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
+TEST(DebugStepLocals) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ // Create a function for testing stepping.
+ const char* src = "function foo() { "
+ " var a,b;"
+ " a = 1;"
+ " b = a + 2;"
+ " b = 1 + 2 + 3;"
+ " a = Math.floor(b);"
+ "}";
+ v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
+ SetBreakPoint(foo, 0);
+
+ // Stepping through the declarations.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(6, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
TEST(DebugStepIf) {
v8::HandleScope scope;
DebugLocalContext env;
@@ -2624,14 +2694,14 @@
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_true[argc] = { v8::True() };
foo->Call(env->Global(), argc, argv_true);
- CHECK_EQ(3, break_point_hit_count);
+ CHECK_EQ(4, break_point_hit_count);
// Stepping through the false part.
step_action = StepIn;
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_false[argc] = { v8::False() };
foo->Call(env->Global(), argc, argv_false);
- CHECK_EQ(4, break_point_hit_count);
+ CHECK_EQ(5, break_point_hit_count);
// Get rid of the debug event listener.
v8::Debug::SetDebugEventListener(NULL);
@@ -2659,6 +2729,7 @@
" case 3:"
" d = 1;"
" e = 1;"
+ " f = 1;"
" break;"
" }"
"}";
@@ -2670,21 +2741,97 @@
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_1[argc] = { v8::Number::New(1) };
foo->Call(env->Global(), argc, argv_1);
- CHECK_EQ(4, break_point_hit_count);
+ CHECK_EQ(6, break_point_hit_count);
// Another case.
step_action = StepIn;
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_2[argc] = { v8::Number::New(2) };
foo->Call(env->Global(), argc, argv_2);
- CHECK_EQ(3, break_point_hit_count);
+ CHECK_EQ(5, break_point_hit_count);
// Last case.
step_action = StepIn;
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_3[argc] = { v8::Number::New(3) };
foo->Call(env->Global(), argc, argv_3);
- CHECK_EQ(4, break_point_hit_count);
+ CHECK_EQ(7, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
+TEST(DebugStepWhile) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ // Create a function for testing stepping.
+ const int argc = 1;
+ const char* src = "function foo(x) { "
+ " var a = 0;"
+ " while (a < x) {"
+ " a++;"
+ " }"
+ "}";
+ v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
+ SetBreakPoint(foo, 8); // "var a = 0;"
+
+ // Looping 10 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
+ foo->Call(env->Global(), argc, argv_10);
+ CHECK_EQ(23, break_point_hit_count);
+
+ // Looping 100 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
+ foo->Call(env->Global(), argc, argv_100);
+ CHECK_EQ(203, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
+TEST(DebugStepDoWhile) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ // Create a function for testing stepping.
+ const int argc = 1;
+ const char* src = "function foo(x) { "
+ " var a = 0;"
+ " do {"
+ " a++;"
+ " } while (a < x)"
+ "}";
+ v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
+ SetBreakPoint(foo, 8); // "var a = 0;"
+
+ // Looping 10 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
+ foo->Call(env->Global(), argc, argv_10);
+ CHECK_EQ(22, break_point_hit_count);
+
+ // Looping 100 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
+ foo->Call(env->Global(), argc, argv_100);
+ CHECK_EQ(202, break_point_hit_count);
// Get rid of the debug event listener.
v8::Debug::SetDebugEventListener(NULL);
@@ -2730,6 +2877,210 @@
}
+TEST(DebugStepForContinue) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ // Create a function for testing stepping.
+ const int argc = 1;
+ const char* src = "function foo(x) { "
+ " var a = 0;"
+ " var b = 0;"
+ " var c = 0;"
+ " for (var i = 0; i < x; i++) {"
+ " a++;"
+ " if (a % 2 == 0) continue;"
+ " b++;"
+ " c++;"
+ " }"
+ " return b;"
+ "}";
+ v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
+ v8::Handle<v8::Value> result;
+ SetBreakPoint(foo, 8); // "var a = 0;"
+
+ // Each loop generates 4 or 5 steps depending on whether a is equal.
+
+ // Looping 10 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
+ result = foo->Call(env->Global(), argc, argv_10);
+ CHECK_EQ(5, result->Int32Value());
+ CHECK_EQ(50, break_point_hit_count);
+
+ // Looping 100 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
+ result = foo->Call(env->Global(), argc, argv_100);
+ CHECK_EQ(50, result->Int32Value());
+ CHECK_EQ(455, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
+TEST(DebugStepForBreak) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ // Create a function for testing stepping.
+ const int argc = 1;
+ const char* src = "function foo(x) { "
+ " var a = 0;"
+ " var b = 0;"
+ " var c = 0;"
+ " for (var i = 0; i < 1000; i++) {"
+ " a++;"
+ " if (a == x) break;"
+ " b++;"
+ " c++;"
+ " }"
+ " return b;"
+ "}";
+ v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
+ v8::Handle<v8::Value> result;
+ SetBreakPoint(foo, 8); // "var a = 0;"
+
+ // Each loop generates 5 steps except for the last (when break is executed)
+ // which only generates 4.
+
+ // Looping 10 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(10) };
+ result = foo->Call(env->Global(), argc, argv_10);
+ CHECK_EQ(9, result->Int32Value());
+ CHECK_EQ(53, break_point_hit_count);
+
+ // Looping 100 times.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(100) };
+ result = foo->Call(env->Global(), argc, argv_100);
+ CHECK_EQ(99, result->Int32Value());
+ CHECK_EQ(503, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
+TEST(DebugStepForIn) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ v8::Local<v8::Function> foo;
+ const char* src_1 = "function foo() { "
+ " var a = [1, 2];"
+ " for (x in a) {"
+ " b = 0;"
+ " }"
+ "}";
+ foo = CompileFunction(&env, src_1, "foo");
+ SetBreakPoint(foo, 0); // "var a = ..."
+
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(6, break_point_hit_count);
+
+ const char* src_2 = "function foo() { "
+ " var a = {a:[1, 2, 3]};"
+ " for (x in a.a) {"
+ " b = 0;"
+ " }"
+ "}";
+ foo = CompileFunction(&env, src_2, "foo");
+ SetBreakPoint(foo, 0); // "var a = ..."
+
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(8, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
+TEST(DebugStepWith) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ // Create a function for testing stepping.
+ const char* src = "function foo(x) { "
+ " var a = {};"
+ " with (a) {}"
+ " with (b) {}"
+ "}";
+ env->Global()->Set(v8::String::New("b"), v8::Object::New());
+ v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
+ v8::Handle<v8::Value> result;
+ SetBreakPoint(foo, 8); // "var a = {};"
+
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(4, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
+TEST(DebugConditional) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+
+ // Register a debug event listener which steps and counts.
+ v8::Debug::SetDebugEventListener(DebugEventStep);
+
+ // Create a function for testing stepping.
+ const char* src = "function foo(x) { "
+ " var a;"
+ " a = x ? 1 : 2;"
+ " return a;"
+ "}";
+ v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
+ SetBreakPoint(foo, 0); // "var a;"
+
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(5, break_point_hit_count);
+
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ const int argc = 1;
+ v8::Handle<v8::Value> argv_true[argc] = { v8::True() };
+ foo->Call(env->Global(), argc, argv_true);
+ CHECK_EQ(5, break_point_hit_count);
+
+ // Get rid of the debug event listener.
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
TEST(StepInOutSimple) {
v8::HandleScope scope;
DebugLocalContext env;
@@ -2851,7 +3202,7 @@
// Step through invocation of a.
step_action = StepIn;
break_point_hit_count = 0;
- expected_step_sequence = "abaca";
+ expected_step_sequence = "abbaca";
a->Call(env->Global(), 0, NULL);
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -2920,7 +3271,7 @@
foo->Call(env->Global(), 0, NULL);
// With stepping all break locations are hit.
- CHECK_EQ(6, break_point_hit_count);
+ CHECK_EQ(7, break_point_hit_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
@@ -2964,14 +3315,14 @@
// Check stepping where the if condition in bar is false.
break_point_hit_count = 0;
foo->Call(env->Global(), 0, NULL);
- CHECK_EQ(4, break_point_hit_count);
+ CHECK_EQ(6, break_point_hit_count);
// Check stepping where the if condition in bar is true.
break_point_hit_count = 0;
const int argc = 1;
v8::Handle<v8::Value> argv[argc] = { v8::True() };
foo->Call(env->Global(), argc, argv);
- CHECK_EQ(6, break_point_hit_count);
+ CHECK_EQ(8, break_point_hit_count);
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
@@ -3264,14 +3615,13 @@
b->Call(env->Global(), 0, NULL);
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
-
// Step through invocation of d + e.
v8::Local<v8::Function> d = CompileFunction(&env, src, "d");
SetBreakPoint(d, 0);
ChangeBreakOnException(false, true);
step_action = StepIn;
break_point_hit_count = 0;
- expected_step_sequence = "dded";
+ expected_step_sequence = "ddedd";
d->Call(env->Global(), 0, NULL);
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -3280,7 +3630,7 @@
ChangeBreakOnException(true, true);
step_action = StepIn;
break_point_hit_count = 0;
- expected_step_sequence = "ddeed";
+ expected_step_sequence = "ddeedd";
d->Call(env->Global(), 0, NULL);
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -3291,7 +3641,7 @@
ChangeBreakOnException(false, true);
step_action = StepIn;
break_point_hit_count = 0;
- expected_step_sequence = "ffghf";
+ expected_step_sequence = "ffghhff";
f->Call(env->Global(), 0, NULL);
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);
@@ -3300,7 +3650,7 @@
ChangeBreakOnException(true, true);
step_action = StepIn;
break_point_hit_count = 0;
- expected_step_sequence = "ffghhf";
+ expected_step_sequence = "ffghhhff";
f->Call(env->Global(), 0, NULL);
CHECK_EQ(StrLength(expected_step_sequence),
break_point_hit_count);