| 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 1980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 __ push(rax); // generator object | 1991 __ push(rax); // generator object |
| 1992 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1992 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 1993 __ movp(context_register(), | 1993 __ movp(context_register(), |
| 1994 Operand(rbp, StandardFrameConstants::kContextOffset)); | 1994 Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 1995 __ bind(&post_runtime); | 1995 __ bind(&post_runtime); |
| 1996 | 1996 |
| 1997 __ pop(result_register()); | 1997 __ pop(result_register()); |
| 1998 EmitReturnSequence(); | 1998 EmitReturnSequence(); |
| 1999 | 1999 |
| 2000 __ bind(&resume); | 2000 __ bind(&resume); |
| 2001 Label init_value_check_done; |
| 2002 if (expr->yield_kind() == Yield::INITIAL) { |
| 2003 // When value is provided and it is not undefined, throw error. |
| 2004 __ CompareRoot(result_register(), Heap::kUndefinedValueRootIndex); |
| 2005 __ j(equal, &init_value_check_done); |
| 2006 // This error should be raised from the Generator.prototype.next side. |
| 2007 // So in this case, we return the hole value as a marker. The caller |
| 2008 // checks the result value and if it is the hole value, the caller |
| 2009 // throws error. |
| 2010 __ PushRoot(Heap::kTheHoleValueRootIndex); |
| 2011 __ jmp(&suspend); |
| 2012 } |
| 2013 __ bind(&init_value_check_done); |
| 2001 context()->Plug(result_register()); | 2014 context()->Plug(result_register()); |
| 2002 break; | 2015 break; |
| 2003 } | 2016 } |
| 2004 | 2017 |
| 2005 case Yield::FINAL: { | 2018 case Yield::FINAL: { |
| 2006 VisitForAccumulatorValue(expr->generator_object()); | 2019 VisitForAccumulatorValue(expr->generator_object()); |
| 2007 __ Move(FieldOperand(result_register(), | 2020 __ Move(FieldOperand(result_register(), |
| 2008 JSGeneratorObject::kContinuationOffset), | 2021 JSGeneratorObject::kContinuationOffset), |
| 2009 Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); | 2022 Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); |
| 2010 // Pop value from top-of-stack slot, box result into result register. | 2023 // Pop value from top-of-stack slot, box result into result register. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 __ push(rax); | 2222 __ push(rax); |
| 2210 __ CallRuntime(Runtime::kThrow, 1); | 2223 __ CallRuntime(Runtime::kThrow, 1); |
| 2211 } | 2224 } |
| 2212 __ jmp(&done); | 2225 __ jmp(&done); |
| 2213 | 2226 |
| 2214 // Throw error if we attempt to operate on a running generator. | 2227 // Throw error if we attempt to operate on a running generator. |
| 2215 __ bind(&wrong_state); | 2228 __ bind(&wrong_state); |
| 2216 __ push(rbx); | 2229 __ push(rbx); |
| 2217 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); | 2230 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); |
| 2218 | 2231 |
| 2232 // Throw error if we attempt to pass a value to an unborn generator. |
| 2233 Label wrong_start; |
| 2234 __ bind(&wrong_start); |
| 2235 __ CallRuntime(Runtime::kThrowGeneratorStartError, 0); |
| 2236 |
| 2219 __ bind(&done); | 2237 __ bind(&done); |
| 2238 // When a value is passed to an unborn generator, the result becomes the hole |
| 2239 // value. And we need to throw GeneratorStartError in the caller side. |
| 2240 // (Generator.prototype.next) |
| 2241 __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex); |
| 2242 __ j(equal, &wrong_start); |
| 2220 context()->Plug(result_register()); | 2243 context()->Plug(result_register()); |
| 2221 } | 2244 } |
| 2222 | 2245 |
| 2223 | 2246 |
| 2224 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { | 2247 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { |
| 2225 Label gc_required; | 2248 Label gc_required; |
| 2226 Label allocated; | 2249 Label allocated; |
| 2227 | 2250 |
| 2228 Handle<Map> map(isolate()->native_context()->generator_result_map()); | 2251 Handle<Map> map(isolate()->native_context()->generator_result_map()); |
| 2229 | 2252 |
| (...skipping 2682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4912 | 4935 |
| 4913 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4936 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4914 Assembler::target_address_at(call_target_address)); | 4937 Assembler::target_address_at(call_target_address)); |
| 4915 return OSR_AFTER_STACK_CHECK; | 4938 return OSR_AFTER_STACK_CHECK; |
| 4916 } | 4939 } |
| 4917 | 4940 |
| 4918 | 4941 |
| 4919 } } // namespace v8::internal | 4942 } } // namespace v8::internal |
| 4920 | 4943 |
| 4921 #endif // V8_TARGET_ARCH_X64 | 4944 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |