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

Side by Side Diff: src/runtime.cc

Issue 16136011: Generator object "next" method takes optional send value (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased onto master Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | src/x64/full-codegen-x64.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 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 // The return value is the hole for a suspend return, and anything else for a 2634 // The return value is the hole for a suspend return, and anything else for a
2635 // resume return. 2635 // resume return.
2636 return isolate->heap()->the_hole_value(); 2636 return isolate->heap()->the_hole_value();
2637 } 2637 }
2638 2638
2639 2639
2640 // Note that this function is the slow path for resuming generators. It is only 2640 // Note that this function is the slow path for resuming generators. It is only
2641 // called if the suspended activation had operands on the stack, stack handlers 2641 // called if the suspended activation had operands on the stack, stack handlers
2642 // needing rewinding, or if the resume should throw an exception. The fast path 2642 // needing rewinding, or if the resume should throw an exception. The fast path
2643 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is 2643 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is
2644 // inlined into GeneratorNext, GeneratorSend, and GeneratorThrow. 2644 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is
2645 // EmitGeneratorResumeResume is called in any case, as it needs to reconstruct 2645 // called in any case, as it needs to reconstruct the stack frame and make space
2646 // the stack frame and make space for arguments and operands. 2646 // for arguments and operands.
2647 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResumeJSGeneratorObject) { 2647 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResumeJSGeneratorObject) {
2648 SealHandleScope shs(isolate); 2648 SealHandleScope shs(isolate);
2649 ASSERT(args.length() == 3); 2649 ASSERT(args.length() == 3);
2650 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); 2650 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0);
2651 CONVERT_ARG_CHECKED(Object, value, 1); 2651 CONVERT_ARG_CHECKED(Object, value, 1);
2652 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); 2652 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2);
2653 JavaScriptFrameIterator stack_iterator(isolate); 2653 JavaScriptFrameIterator stack_iterator(isolate);
2654 JavaScriptFrame* frame = stack_iterator.frame(); 2654 JavaScriptFrame* frame = stack_iterator.frame();
2655 2655
2656 ASSERT_EQ(frame->function(), generator_object->function()); 2656 ASSERT_EQ(frame->function(), generator_object->function());
(...skipping 12 matching lines...) Expand all
2669 if (operands_count != 0) { 2669 if (operands_count != 0) {
2670 frame->RestoreOperandStack(operand_stack, 2670 frame->RestoreOperandStack(operand_stack,
2671 generator_object->stack_handler_index()); 2671 generator_object->stack_handler_index());
2672 generator_object->set_operand_stack(isolate->heap()->empty_fixed_array()); 2672 generator_object->set_operand_stack(isolate->heap()->empty_fixed_array());
2673 generator_object->set_stack_handler_index(-1); 2673 generator_object->set_stack_handler_index(-1);
2674 } 2674 }
2675 2675
2676 JSGeneratorObject::ResumeMode resume_mode = 2676 JSGeneratorObject::ResumeMode resume_mode =
2677 static_cast<JSGeneratorObject::ResumeMode>(resume_mode_int); 2677 static_cast<JSGeneratorObject::ResumeMode>(resume_mode_int);
2678 switch (resume_mode) { 2678 switch (resume_mode) {
2679 case JSGeneratorObject::SEND: 2679 case JSGeneratorObject::NEXT:
2680 return value; 2680 return value;
2681 case JSGeneratorObject::THROW: 2681 case JSGeneratorObject::THROW:
2682 return isolate->Throw(value); 2682 return isolate->Throw(value);
2683 } 2683 }
2684 2684
2685 UNREACHABLE(); 2685 UNREACHABLE();
2686 return isolate->ThrowIllegalOperation(); 2686 return isolate->ThrowIllegalOperation();
2687 } 2687 }
2688 2688
2689 2689
(...skipping 10943 matching lines...) Expand 10 before | Expand all | Expand 10 after
13633 // Handle last resort GC and make sure to allow future allocations 13633 // Handle last resort GC and make sure to allow future allocations
13634 // to grow the heap without causing GCs (if possible). 13634 // to grow the heap without causing GCs (if possible).
13635 isolate->counters()->gc_last_resort_from_js()->Increment(); 13635 isolate->counters()->gc_last_resort_from_js()->Increment();
13636 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13636 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13637 "Runtime::PerformGC"); 13637 "Runtime::PerformGC");
13638 } 13638 }
13639 } 13639 }
13640 13640
13641 13641
13642 } } // namespace v8::internal 13642 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698