| OLD | NEW |
| 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 2415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2426 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); | 2426 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); |
| 2427 | 2427 |
| 2428 JavaScriptFrameIterator stack_iterator(isolate); | 2428 JavaScriptFrameIterator stack_iterator(isolate); |
| 2429 JavaScriptFrame *frame = stack_iterator.frame(); | 2429 JavaScriptFrame *frame = stack_iterator.frame(); |
| 2430 Handle<JSFunction> function(JSFunction::cast(frame->function())); | 2430 Handle<JSFunction> function(JSFunction::cast(frame->function())); |
| 2431 RUNTIME_ASSERT(function->shared()->is_generator()); | 2431 RUNTIME_ASSERT(function->shared()->is_generator()); |
| 2432 | 2432 |
| 2433 intptr_t offset = frame->pc() - function->code()->instruction_start(); | 2433 intptr_t offset = frame->pc() - function->code()->instruction_start(); |
| 2434 ASSERT(*function == generator_object->function()); | 2434 ASSERT(*function == generator_object->function()); |
| 2435 ASSERT(offset > 0 && Smi::IsValid(offset)); | 2435 ASSERT(offset > 0 && Smi::IsValid(offset)); |
| 2436 generator_object->set_continuation(offset); | 2436 generator_object->set_continuation(static_cast<int>(offset)); |
| 2437 | 2437 |
| 2438 // Generator functions force context allocation for locals, so Local0 points | 2438 // Generator functions force context allocation for locals, so Local0 points |
| 2439 // to the bottom of the operand stack. Assume the stack grows down. | 2439 // to the bottom of the operand stack. Assume the stack grows down. |
| 2440 // | 2440 // |
| 2441 // TODO(wingo): Move these magical calculations to frames.h when the | 2441 // TODO(wingo): Move these magical calculations to frames.h when the |
| 2442 // generators implementation has stabilized. | 2442 // generators implementation has stabilized. |
| 2443 intptr_t stack_size_in_bytes = | 2443 intptr_t stack_size_in_bytes = |
| 2444 (frame->fp() + JavaScriptFrameConstants::kLocal0Offset) - | 2444 (frame->fp() + JavaScriptFrameConstants::kLocal0Offset) - |
| 2445 (frame->sp() - kPointerSize); | 2445 (frame->sp() - kPointerSize); |
| 2446 ASSERT(IsAddressAligned(frame->fp(), kPointerSize)); | 2446 ASSERT(IsAddressAligned(frame->fp(), kPointerSize)); |
| 2447 ASSERT(IsAligned(stack_size_in_bytes, kPointerSize)); | 2447 ASSERT(IsAligned(stack_size_in_bytes, kPointerSize)); |
| 2448 ASSERT(stack_size_in_bytes >= 0); | 2448 ASSERT(stack_size_in_bytes >= 0); |
| 2449 ASSERT(Smi::IsValid(stack_size_in_bytes)); | 2449 ASSERT(Smi::IsValid(stack_size_in_bytes)); |
| 2450 unsigned stack_size = stack_size_in_bytes >> kPointerSizeLog2; | 2450 intptr_t stack_size = stack_size_in_bytes >> kPointerSizeLog2; |
| 2451 | 2451 |
| 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()); |
| (...skipping 10830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13291 // Handle last resort GC and make sure to allow future allocations | 13291 // Handle last resort GC and make sure to allow future allocations |
| 13292 // to grow the heap without causing GCs (if possible). | 13292 // to grow the heap without causing GCs (if possible). |
| 13293 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13293 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13294 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13294 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13295 "Runtime::PerformGC"); | 13295 "Runtime::PerformGC"); |
| 13296 } | 13296 } |
| 13297 } | 13297 } |
| 13298 | 13298 |
| 13299 | 13299 |
| 13300 } } // namespace v8::internal | 13300 } } // namespace v8::internal |
| OLD | NEW |