OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 foo->Call(env->Global(), 0, NULL); | 2170 foo->Call(env->Global(), 0, NULL); |
2171 | 2171 |
2172 // Without stepping only active break points are hit. | 2172 // Without stepping only active break points are hit. |
2173 CHECK_EQ(1, break_point_hit_count); | 2173 CHECK_EQ(1, break_point_hit_count); |
2174 | 2174 |
2175 v8::Debug::SetDebugEventListener(NULL); | 2175 v8::Debug::SetDebugEventListener(NULL); |
2176 CheckDebuggerUnloaded(); | 2176 CheckDebuggerUnloaded(); |
2177 } | 2177 } |
2178 | 2178 |
2179 | 2179 |
| 2180 // Test of the stepping mechanism for keyed load in a loop. |
| 2181 TEST(DebugStepKeyedLoadLoop) { |
| 2182 v8::HandleScope scope; |
| 2183 DebugLocalContext env; |
| 2184 |
| 2185 // Create a function for testing stepping of keyed load. The statement 'y=1' |
| 2186 // is there to have more than one breakable statement in the loop, TODO(315). |
| 2187 v8::Local<v8::Function> foo = CompileFunction( |
| 2188 &env, |
| 2189 "function foo(a) {\n" |
| 2190 " var x;\n" |
| 2191 " var len = a.length;\n" |
| 2192 " for (var i = 0; i < len; i++) {\n" |
| 2193 " y = 1;\n" |
| 2194 " x = a[i];\n" |
| 2195 " }\n" |
| 2196 "}\n", |
| 2197 "foo"); |
| 2198 |
| 2199 // Create array [0,1,2,3,4,5,6,7,8,9] |
| 2200 v8::Local<v8::Array> a = v8::Array::New(10); |
| 2201 for (int i = 0; i < 10; i++) { |
| 2202 a->Set(v8::Number::New(i), v8::Number::New(i)); |
| 2203 } |
| 2204 |
| 2205 // Call function without any break points to ensure inlining is in place. |
| 2206 const int kArgc = 1; |
| 2207 v8::Handle<v8::Value> args[kArgc] = { a }; |
| 2208 foo->Call(env->Global(), kArgc, args); |
| 2209 |
| 2210 // Register a debug event listener which steps and counts. |
| 2211 v8::Debug::SetDebugEventListener(DebugEventStep); |
| 2212 |
| 2213 // Setup break point and step through the function. |
| 2214 SetBreakPoint(foo, 3); |
| 2215 step_action = StepNext; |
| 2216 break_point_hit_count = 0; |
| 2217 foo->Call(env->Global(), kArgc, args); |
| 2218 |
| 2219 // With stepping all break locations are hit. |
| 2220 CHECK_EQ(22, break_point_hit_count); |
| 2221 |
| 2222 v8::Debug::SetDebugEventListener(NULL); |
| 2223 CheckDebuggerUnloaded(); |
| 2224 } |
| 2225 |
| 2226 |
2180 // Test the stepping mechanism with different ICs. | 2227 // Test the stepping mechanism with different ICs. |
2181 TEST(DebugStepLinearMixedICs) { | 2228 TEST(DebugStepLinearMixedICs) { |
2182 v8::HandleScope scope; | 2229 v8::HandleScope scope; |
2183 DebugLocalContext env; | 2230 DebugLocalContext env; |
2184 | 2231 |
2185 // Create a function for testing stepping. | 2232 // Create a function for testing stepping. |
2186 v8::Local<v8::Function> foo = CompileFunction(&env, | 2233 v8::Local<v8::Function> foo = CompileFunction(&env, |
2187 "function bar() {};" | 2234 "function bar() {};" |
2188 "function foo() {" | 2235 "function foo() {" |
2189 " var x;" | 2236 " var x;" |
(...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4464 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); | 4511 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); |
4465 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); | 4512 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); |
4466 script2->Run(); | 4513 script2->Run(); |
4467 script2->SetData(data_obj); | 4514 script2->SetData(data_obj); |
4468 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 4515 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); |
4469 f->Call(env->Global(), 0, NULL); | 4516 f->Call(env->Global(), 0, NULL); |
4470 CHECK_EQ(2, break_point_hit_count); | 4517 CHECK_EQ(2, break_point_hit_count); |
4471 CHECK_EQ("new name", last_script_name_hit); | 4518 CHECK_EQ("new name", last_script_name_hit); |
4472 CHECK_EQ("abc 123", last_script_data_hit); | 4519 CHECK_EQ("abc 123", last_script_data_hit); |
4473 } | 4520 } |
OLD | NEW |