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

Side by Side Diff: test/mjsunit/harmony/debug-blockscopes.js

Issue 7860045: Stack allocating block scoped variables. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased on tip of tree. Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 CheckScopeChain([debug.ScopeType.Block, 302 CheckScopeChain([debug.ScopeType.Block,
303 debug.ScopeType.Local, 303 debug.ScopeType.Local,
304 debug.ScopeType.Global], exec_state); 304 debug.ScopeType.Global], exec_state);
305 CheckScopeContent({x:6,y:7}, 0, exec_state); 305 CheckScopeContent({x:6,y:7}, 0, exec_state);
306 CheckScopeContent({a:1}, 1, exec_state); 306 CheckScopeContent({a:1}, 1, exec_state);
307 }; 307 };
308 local_6(1); 308 local_6(1);
309 EndTest(); 309 EndTest();
310 310
311 311
312 // Two variables in a block scope. 312 // A variable in a block scope within an unallocated block.
313 BeginTest("Local 7"); 313 BeginTest("Local 7");
314 314
315 function local_7(a) { 315 function local_7(a) {
316 { 316 {
317 { 317 {
318 let x = 8; 318 let x = 8;
319 debugger; 319 debugger;
320 } 320 }
321 } 321 }
322 } 322 }
323 323
324 listener_delegate = function(exec_state) { 324 listener_delegate = function(exec_state) {
325 CheckScopeChain([debug.ScopeType.Block, 325 CheckScopeChain([debug.ScopeType.Block,
326 debug.ScopeType.Local, 326 debug.ScopeType.Local,
327 debug.ScopeType.Global], exec_state); 327 debug.ScopeType.Global], exec_state);
328 CheckScopeContent({x:8}, 0, exec_state); 328 CheckScopeContent({x:8}, 0, exec_state);
329 CheckScopeContent({a:1}, 1, exec_state); 329 CheckScopeContent({a:1}, 1, exec_state);
330 }; 330 };
331 local_7(1); 331 local_7(1);
332 EndTest(); 332 EndTest();
333 333
334 334
335 // Function and block scopes with stack allocated variables.
336 BeginTest("Local 8");
337
338 function local_8(a) {
339 let z = 10;
340 {
341 let y = 20;
342 {
343 let x = 8;
344 debugger;
345 }
346 }
347 }
348
349 listener_delegate = function(exec_state) {
350 CheckScopeChain([debug.ScopeType.Block,
351 debug.ScopeType.Block,
352 debug.ScopeType.Local,
353 debug.ScopeType.Global], exec_state);
354 CheckScopeContent({x:8}, 0, exec_state);
355 CheckScopeContent({y:20}, 1, exec_state);
356 CheckScopeContent({a:1,z:10}, 2, exec_state);
357 };
358 local_8(1);
359 EndTest();
360
361
335 // Simple closure formed by returning an inner function referering to an outer 362 // Simple closure formed by returning an inner function referering to an outer
336 // block local variable and an outer function's parameter. 363 // block local variable and an outer function's parameter.
337 BeginTest("Closure 1"); 364 BeginTest("Closure 1");
338 365
339 function closure_1(a) { 366 function closure_1(a) {
340 var x = 2; 367 var x = 2;
341 let y = 3; 368 let y = 3;
342 if (true) { 369 if (true) {
343 let z = 4; 370 let z = 4;
344 function f() { 371 { // Stack allocated block
345 debugger; 372 function f() {
346 return a + x + y + z; 373 debugger;
347 }; 374 return a + x + y + z;
348 return f; 375 };
376 return f;
377 }
349 } 378 }
350 } 379 }
351 380
352 listener_delegate = function(exec_state) { 381 listener_delegate = function(exec_state) {
353 CheckScopeChain([debug.ScopeType.Local, 382 CheckScopeChain([debug.ScopeType.Local,
354 debug.ScopeType.Block, 383 debug.ScopeType.Block,
355 debug.ScopeType.Closure, 384 debug.ScopeType.Closure,
356 debug.ScopeType.Global], exec_state); 385 debug.ScopeType.Global], exec_state);
357 CheckScopeContent({}, 0, exec_state); 386 CheckScopeContent({}, 0, exec_state);
387 CheckScopeContent({z:4}, 1, exec_state);
358 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state); 388 CheckScopeContent({a:1,x:2,y:3}, 2, exec_state);
359 }; 389 };
360 closure_1(1)(); 390 closure_1(1)();
361 EndTest(); 391 EndTest();
362 392
363 393
364 // Simple for-in loop over the keys of an object. 394 // Simple for-in loop over the keys of an object.
365 BeginTest("For loop 1"); 395 BeginTest("For loop 1");
366 396
367 function for_loop_1() { 397 function for_loop_1() {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 491
462 listener_delegate = function(exec_state) { 492 listener_delegate = function(exec_state) {
463 CheckScopeChain([debug.ScopeType.Block, 493 CheckScopeChain([debug.ScopeType.Block,
464 debug.ScopeType.Local, 494 debug.ScopeType.Local,
465 debug.ScopeType.Global], exec_state); 495 debug.ScopeType.Global], exec_state);
466 CheckScopeContent({x:3,y:5}, 0, exec_state); 496 CheckScopeContent({x:3,y:5}, 0, exec_state);
467 CheckScopeContent({}, 1, exec_state); 497 CheckScopeContent({}, 1, exec_state);
468 }; 498 };
469 for_loop_5(); 499 for_loop_5();
470 EndTest(); 500 EndTest();
501
502
503 // Nested scoped block in global code.
504 BeginTest("Global block 1");
505 listener_delegate = function(exec_state) {
506 CheckScopeChain([debug.ScopeType.Block,
507 debug.ScopeType.Global], exec_state);
508 CheckScopeContent({e:10}, 0, exec_state);
509 };
510
511 {
512 let e = 10;
513 debugger;
514 }
515 EndTest();
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698