| 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 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 __ j(equal, &post_runtime); | 1968 __ j(equal, &post_runtime); |
| 1969 __ push(eax); // generator object | 1969 __ push(eax); // generator object |
| 1970 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1970 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 1971 __ mov(context_register(), | 1971 __ mov(context_register(), |
| 1972 Operand(ebp, StandardFrameConstants::kContextOffset)); | 1972 Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 1973 __ bind(&post_runtime); | 1973 __ bind(&post_runtime); |
| 1974 __ pop(result_register()); | 1974 __ pop(result_register()); |
| 1975 EmitReturnSequence(); | 1975 EmitReturnSequence(); |
| 1976 | 1976 |
| 1977 __ bind(&resume); | 1977 __ bind(&resume); |
| 1978 Label init_value_check_done; |
| 1979 if (expr->yield_kind() == Yield::INITIAL) { |
| 1980 // When value is provided and it is not undefined, throw error. |
| 1981 __ CompareRoot(result_register(), Heap::kUndefinedValueRootIndex); |
| 1982 __ j(equal, &init_value_check_done); |
| 1983 // This error should be raised from the Generator.prototype.next side. |
| 1984 // So in this case, we return the hole value as a marker. The caller |
| 1985 // checks the result value and if it is the hole value, the caller |
| 1986 // throws error. |
| 1987 __ push(Immediate(isolate()->factory()->the_hole_value())); |
| 1988 __ jmp(&suspend); |
| 1989 } |
| 1990 __ bind(&init_value_check_done); |
| 1978 context()->Plug(result_register()); | 1991 context()->Plug(result_register()); |
| 1979 break; | 1992 break; |
| 1980 } | 1993 } |
| 1981 | 1994 |
| 1982 case Yield::FINAL: { | 1995 case Yield::FINAL: { |
| 1983 VisitForAccumulatorValue(expr->generator_object()); | 1996 VisitForAccumulatorValue(expr->generator_object()); |
| 1984 __ mov(FieldOperand(result_register(), | 1997 __ mov(FieldOperand(result_register(), |
| 1985 JSGeneratorObject::kContinuationOffset), | 1998 JSGeneratorObject::kContinuationOffset), |
| 1986 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | 1999 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); |
| 1987 // Pop value from top-of-stack slot, box result into result register. | 2000 // Pop value from top-of-stack slot, box result into result register. |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 __ push(eax); | 2198 __ push(eax); |
| 2186 __ CallRuntime(Runtime::kThrow, 1); | 2199 __ CallRuntime(Runtime::kThrow, 1); |
| 2187 } | 2200 } |
| 2188 __ jmp(&done); | 2201 __ jmp(&done); |
| 2189 | 2202 |
| 2190 // Throw error if we attempt to operate on a running generator. | 2203 // Throw error if we attempt to operate on a running generator. |
| 2191 __ bind(&wrong_state); | 2204 __ bind(&wrong_state); |
| 2192 __ push(ebx); | 2205 __ push(ebx); |
| 2193 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); | 2206 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); |
| 2194 | 2207 |
| 2208 // Throw error if we attempt to pass a value to an unborn generator. |
| 2209 Label wrong_start; |
| 2210 __ bind(&wrong_start); |
| 2211 __ CallRuntime(Runtime::kThrowGeneratorStartError, 0); |
| 2212 |
| 2195 __ bind(&done); | 2213 __ bind(&done); |
| 2214 // When a value is passed to an unborn generator, the result becomes the hole |
| 2215 // value. And we need to throw GeneratorStartError in the caller side. |
| 2216 // (Generator.prototype.next) |
| 2217 __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex); |
| 2218 __ j(equal, &wrong_start); |
| 2196 context()->Plug(result_register()); | 2219 context()->Plug(result_register()); |
| 2197 } | 2220 } |
| 2198 | 2221 |
| 2199 | 2222 |
| 2200 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { | 2223 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { |
| 2201 Label gc_required; | 2224 Label gc_required; |
| 2202 Label allocated; | 2225 Label allocated; |
| 2203 | 2226 |
| 2204 Handle<Map> map(isolate()->native_context()->generator_result_map()); | 2227 Handle<Map> map(isolate()->native_context()->generator_result_map()); |
| 2205 | 2228 |
| (...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4919 | 4942 |
| 4920 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4943 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4921 Assembler::target_address_at(call_target_address)); | 4944 Assembler::target_address_at(call_target_address)); |
| 4922 return OSR_AFTER_STACK_CHECK; | 4945 return OSR_AFTER_STACK_CHECK; |
| 4923 } | 4946 } |
| 4924 | 4947 |
| 4925 | 4948 |
| 4926 } } // namespace v8::internal | 4949 } } // namespace v8::internal |
| 4927 | 4950 |
| 4928 #endif // V8_TARGET_ARCH_IA32 | 4951 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |