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

Side by Side Diff: src/runtime.cc

Issue 14416011: Fix yield inside with (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Add assertion Created 7 years, 7 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/parser.cc ('k') | src/scopes.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 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 2441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 // We expect there to be at least two values on the stack: the return value of 2452 // We expect there to be at least two values on the stack: the return value of
2453 // the yield expression, and the argument to this runtime call. Neither of 2453 // the yield expression, and the argument to this runtime call. Neither of
2454 // those should be saved. 2454 // those should be saved.
2455 ASSERT(stack_size >= 2); 2455 ASSERT(stack_size >= 2);
2456 stack_size -= 2; 2456 stack_size -= 2;
2457 2457
2458 if (stack_size == 0) { 2458 if (stack_size == 0) {
2459 ASSERT_EQ(generator_object->operand_stack(), 2459 ASSERT_EQ(generator_object->operand_stack(),
2460 isolate->heap()->empty_fixed_array()); 2460 isolate->heap()->empty_fixed_array());
2461 // If there are no operands on the stack, there shouldn't be a handler 2461 // If there are no operands on the stack, there shouldn't be a handler
2462 // active either. Also, the active context will be the same as the function 2462 // active either.
2463 // itself, so there is no need to save the context.
2464 ASSERT_EQ(frame->context(), generator_object->context());
2465 ASSERT(!frame->HasHandler()); 2463 ASSERT(!frame->HasHandler());
2466 } else { 2464 } else {
2467 generator_object->set_context(Context::cast(frame->context()));
2468 // TODO(wingo): Save the operand stack and/or the stack handlers. 2465 // TODO(wingo): Save the operand stack and/or the stack handlers.
2469 UNIMPLEMENTED(); 2466 UNIMPLEMENTED();
2470 } 2467 }
2471 2468
2469 // It's possible for the context to be other than the initial context even if
2470 // there is no stack handler active. For example, this is the case in the
2471 // body of a "with" statement. Therefore we always save the context.
2472 generator_object->set_context(Context::cast(frame->context()));
2473
2472 // The return value is the hole for a suspend return, and anything else for a 2474 // The return value is the hole for a suspend return, and anything else for a
2473 // resume return. 2475 // resume return.
2474 return isolate->heap()->the_hole_value(); 2476 return isolate->heap()->the_hole_value();
2475 } 2477 }
2476 2478
2477 2479
2478 // Note that this function is the slow path for resuming generators. It is only 2480 // Note that this function is the slow path for resuming generators. It is only
2479 // called if the suspended activation had operands on the stack, stack handlers 2481 // called if the suspended activation had operands on the stack, stack handlers
2480 // needing rewinding, or if the resume should throw an exception. The fast path 2482 // needing rewinding, or if the resume should throw an exception. The fast path
2481 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is 2483 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is
(...skipping 10868 matching lines...) Expand 10 before | Expand all | Expand 10 after
13350 // Handle last resort GC and make sure to allow future allocations 13352 // Handle last resort GC and make sure to allow future allocations
13351 // to grow the heap without causing GCs (if possible). 13353 // to grow the heap without causing GCs (if possible).
13352 isolate->counters()->gc_last_resort_from_js()->Increment(); 13354 isolate->counters()->gc_last_resort_from_js()->Increment();
13353 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13355 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13354 "Runtime::PerformGC"); 13356 "Runtime::PerformGC");
13355 } 13357 }
13356 } 13358 }
13357 13359
13358 13360
13359 } } // namespace v8::internal 13361 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698