| 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 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 __ jmp(&suspend); | 2010 __ jmp(&suspend); |
| 2011 | 2011 |
| 2012 __ bind(&continuation); | 2012 __ bind(&continuation); |
| 2013 __ jmp(&resume); | 2013 __ jmp(&resume); |
| 2014 | 2014 |
| 2015 __ bind(&suspend); | 2015 __ bind(&suspend); |
| 2016 VisitForAccumulatorValue(expr->generator_object()); | 2016 VisitForAccumulatorValue(expr->generator_object()); |
| 2017 ASSERT(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 2017 ASSERT(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
| 2018 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); | 2018 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); |
| 2019 __ sw(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); | 2019 __ sw(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); |
| 2020 if (expr->yield_kind() == Yield::INITIAL) { |
| 2021 __ sw(a1, |
| 2022 FieldMemOperand(v0, JSGeneratorObject::kSuspendedStartOffset)); |
| 2023 } |
| 2020 __ sw(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); | 2024 __ sw(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); |
| 2021 __ mov(a1, cp); | 2025 __ mov(a1, cp); |
| 2022 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, | 2026 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, |
| 2023 kRAHasBeenSaved, kDontSaveFPRegs); | 2027 kRAHasBeenSaved, kDontSaveFPRegs); |
| 2024 __ Addu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); | 2028 __ Addu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
| 2025 __ Branch(&post_runtime, eq, sp, Operand(a1)); | 2029 __ Branch(&post_runtime, eq, sp, Operand(a1)); |
| 2026 __ push(v0); // generator object | 2030 __ push(v0); // generator object |
| 2027 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 2031 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 2028 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2032 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2029 __ bind(&post_runtime); | 2033 __ bind(&post_runtime); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2139 JSGeneratorObject::ResumeMode resume_mode) { | 2143 JSGeneratorObject::ResumeMode resume_mode) { |
| 2140 // The value stays in a0, and is ultimately read by the resumed generator, as | 2144 // The value stays in a0, and is ultimately read by the resumed generator, as |
| 2141 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it | 2145 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it |
| 2142 // is read to throw the value when the resumed generator is already closed. | 2146 // is read to throw the value when the resumed generator is already closed. |
| 2143 // a1 will hold the generator object until the activation has been resumed. | 2147 // a1 will hold the generator object until the activation has been resumed. |
| 2144 VisitForStackValue(generator); | 2148 VisitForStackValue(generator); |
| 2145 VisitForAccumulatorValue(value); | 2149 VisitForAccumulatorValue(value); |
| 2146 __ pop(a1); | 2150 __ pop(a1); |
| 2147 | 2151 |
| 2148 // Check generator state. | 2152 // Check generator state. |
| 2149 Label wrong_state, closed_state, done; | 2153 Label wrong_state, closed_state, suspended_start_state, resume_state, done; |
| 2150 __ lw(a3, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | 2154 __ lw(a3, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
| 2151 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); | 2155 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); |
| 2152 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0); | 2156 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0); |
| 2153 __ Branch(&closed_state, eq, a3, Operand(zero_reg)); | 2157 __ Branch(&closed_state, eq, a3, Operand(zero_reg)); |
| 2154 __ Branch(&wrong_state, lt, a3, Operand(zero_reg)); | 2158 __ Branch(&wrong_state, lt, a3, Operand(zero_reg)); |
| 2159 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kSuspendedStartOffset)); |
| 2160 __ Branch(&suspended_start_state, eq, a3, Operand(a2)); |
| 2161 |
| 2162 __ bind(&resume_state); |
| 2155 | 2163 |
| 2156 // Load suspended function and context. | 2164 // Load suspended function and context. |
| 2157 __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset)); | 2165 __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset)); |
| 2158 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); | 2166 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); |
| 2159 | 2167 |
| 2160 // Load receiver and store as the first argument. | 2168 // Load receiver and store as the first argument. |
| 2161 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); | 2169 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); |
| 2162 __ push(a2); | 2170 __ push(a2); |
| 2163 | 2171 |
| 2164 // Push holes for the rest of the arguments to the generator function. | 2172 // Push holes for the rest of the arguments to the generator function. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2217 __ push(a2); | 2225 __ push(a2); |
| 2218 __ Branch(&push_operand_holes); | 2226 __ Branch(&push_operand_holes); |
| 2219 __ bind(&call_resume); | 2227 __ bind(&call_resume); |
| 2220 ASSERT(!result_register().is(a1)); | 2228 ASSERT(!result_register().is(a1)); |
| 2221 __ Push(a1, result_register()); | 2229 __ Push(a1, result_register()); |
| 2222 __ Push(Smi::FromInt(resume_mode)); | 2230 __ Push(Smi::FromInt(resume_mode)); |
| 2223 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); | 2231 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); |
| 2224 // Not reached: the runtime call returns elsewhere. | 2232 // Not reached: the runtime call returns elsewhere. |
| 2225 __ stop("not-reached"); | 2233 __ stop("not-reached"); |
| 2226 | 2234 |
| 2235 // Throw the provided value. |
| 2236 Label throw_provided_value; |
| 2237 __ bind(&throw_provided_value); |
| 2238 if (resume_mode != JSGeneratorObject::NEXT) { |
| 2239 __ push(a0); |
| 2240 __ CallRuntime(Runtime::kThrow, 1); |
| 2241 __ Branch(&done); |
| 2242 } |
| 2243 |
| 2244 // Reach here when calling initial resume to a generator. |
| 2245 __ bind(&suspended_start_state); |
| 2246 if (resume_mode == JSGeneratorObject::NEXT) { |
| 2247 // When value is provided and it is not undefined, throw error. |
| 2248 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
| 2249 __ Branch(&resume_state, eq, a0, Operand(a2)); |
| 2250 __ CallRuntime(Runtime::kThrowGeneratorStartError, 0); |
| 2251 __ Branch(&done); |
| 2252 } else { |
| 2253 // Make generator's state to "closed". |
| 2254 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); |
| 2255 __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
| 2256 __ Branch(&throw_provided_value); |
| 2257 } |
| 2258 |
| 2227 // Reach here when generator is closed. | 2259 // Reach here when generator is closed. |
| 2228 __ bind(&closed_state); | 2260 __ bind(&closed_state); |
| 2229 if (resume_mode == JSGeneratorObject::NEXT) { | 2261 if (resume_mode == JSGeneratorObject::NEXT) { |
| 2230 // Return completed iterator result when generator is closed. | 2262 // Return completed iterator result when generator is closed. |
| 2231 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 2263 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
| 2232 __ push(a2); | 2264 __ push(a2); |
| 2233 // Pop value from top-of-stack slot; box result into result register. | 2265 // Pop value from top-of-stack slot; box result into result register. |
| 2234 EmitCreateIteratorResult(true); | 2266 EmitCreateIteratorResult(true); |
| 2267 __ Branch(&done); |
| 2235 } else { | 2268 } else { |
| 2236 // Throw the provided value. | 2269 __ Branch(&throw_provided_value); |
| 2237 __ push(a0); | |
| 2238 __ CallRuntime(Runtime::kThrow, 1); | |
| 2239 } | 2270 } |
| 2240 __ jmp(&done); | |
| 2241 | 2271 |
| 2242 // Throw error if we attempt to operate on a running generator. | 2272 // Throw error if we attempt to operate on a running generator. |
| 2243 __ bind(&wrong_state); | 2273 __ bind(&wrong_state); |
| 2244 __ push(a1); | 2274 __ push(a1); |
| 2245 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); | 2275 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); |
| 2246 | 2276 |
| 2247 __ bind(&done); | 2277 __ bind(&done); |
| 2248 context()->Plug(result_register()); | 2278 context()->Plug(result_register()); |
| 2249 } | 2279 } |
| 2250 | 2280 |
| (...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4964 Assembler::target_address_at(pc_immediate_load_address)) == | 4994 Assembler::target_address_at(pc_immediate_load_address)) == |
| 4965 reinterpret_cast<uint32_t>( | 4995 reinterpret_cast<uint32_t>( |
| 4966 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4996 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 4967 return OSR_AFTER_STACK_CHECK; | 4997 return OSR_AFTER_STACK_CHECK; |
| 4968 } | 4998 } |
| 4969 | 4999 |
| 4970 | 5000 |
| 4971 } } // namespace v8::internal | 5001 } } // namespace v8::internal |
| 4972 | 5002 |
| 4973 #endif // V8_TARGET_ARCH_MIPS | 5003 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |