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

Side by Side Diff: src/mips/full-codegen-mips.cc

Issue 716183004: MIPS: Leaving a generator via an exception causes it to close. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | « no previous file | src/mips64/full-codegen-mips64.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 Expression *value, 2178 Expression *value,
2179 JSGeneratorObject::ResumeMode resume_mode) { 2179 JSGeneratorObject::ResumeMode resume_mode) {
2180 // The value stays in a0, and is ultimately read by the resumed generator, as 2180 // The value stays in a0, and is ultimately read by the resumed generator, as
2181 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 2181 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2182 // is read to throw the value when the resumed generator is already closed. 2182 // is read to throw the value when the resumed generator is already closed.
2183 // a1 will hold the generator object until the activation has been resumed. 2183 // a1 will hold the generator object until the activation has been resumed.
2184 VisitForStackValue(generator); 2184 VisitForStackValue(generator);
2185 VisitForAccumulatorValue(value); 2185 VisitForAccumulatorValue(value);
2186 __ pop(a1); 2186 __ pop(a1);
2187 2187
2188 // Check generator state.
2189 Label wrong_state, closed_state, done;
2190 __ lw(a3, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
2191 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
2192 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
2193 __ Branch(&closed_state, eq, a3, Operand(zero_reg));
2194 __ Branch(&wrong_state, lt, a3, Operand(zero_reg));
2195
2196 // Load suspended function and context. 2188 // Load suspended function and context.
2197 __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset)); 2189 __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset));
2198 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); 2190 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
2199 2191
2200 // Load receiver and store as the first argument. 2192 // Load receiver and store as the first argument.
2201 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); 2193 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset));
2202 __ push(a2); 2194 __ push(a2);
2203 2195
2204 // Push holes for the rest of the arguments to the generator function. 2196 // Push holes for the rest of the arguments to the generator function.
2205 __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); 2197 __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset));
2206 __ lw(a3, 2198 __ lw(a3,
2207 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); 2199 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset));
2208 __ LoadRoot(a2, Heap::kTheHoleValueRootIndex); 2200 __ LoadRoot(a2, Heap::kTheHoleValueRootIndex);
2209 Label push_argument_holes, push_frame; 2201 Label push_argument_holes, push_frame;
2210 __ bind(&push_argument_holes); 2202 __ bind(&push_argument_holes);
2211 __ Subu(a3, a3, Operand(Smi::FromInt(1))); 2203 __ Subu(a3, a3, Operand(Smi::FromInt(1)));
2212 __ Branch(&push_frame, lt, a3, Operand(zero_reg)); 2204 __ Branch(&push_frame, lt, a3, Operand(zero_reg));
2213 __ push(a2); 2205 __ push(a2);
2214 __ jmp(&push_argument_holes); 2206 __ jmp(&push_argument_holes);
2215 2207
2216 // Enter a new JavaScript frame, and initialize its slots as they were when 2208 // Enter a new JavaScript frame, and initialize its slots as they were when
2217 // the generator was suspended. 2209 // the generator was suspended.
2218 Label resume_frame; 2210 Label resume_frame, done;
2219 __ bind(&push_frame); 2211 __ bind(&push_frame);
2220 __ Call(&resume_frame); 2212 __ Call(&resume_frame);
2221 __ jmp(&done); 2213 __ jmp(&done);
2222 __ bind(&resume_frame); 2214 __ bind(&resume_frame);
2223 // ra = return address. 2215 // ra = return address.
2224 // fp = caller's frame pointer. 2216 // fp = caller's frame pointer.
2225 // cp = callee's context, 2217 // cp = callee's context,
2226 // t0 = callee's JS function. 2218 // t0 = callee's JS function.
2227 __ Push(ra, fp, cp, t0); 2219 __ Push(ra, fp, cp, t0);
2228 // Adjust FP to point to saved FP. 2220 // Adjust FP to point to saved FP.
(...skipping 28 matching lines...) Expand all
2257 __ push(a2); 2249 __ push(a2);
2258 __ Branch(&push_operand_holes); 2250 __ Branch(&push_operand_holes);
2259 __ bind(&call_resume); 2251 __ bind(&call_resume);
2260 DCHECK(!result_register().is(a1)); 2252 DCHECK(!result_register().is(a1));
2261 __ Push(a1, result_register()); 2253 __ Push(a1, result_register());
2262 __ Push(Smi::FromInt(resume_mode)); 2254 __ Push(Smi::FromInt(resume_mode));
2263 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); 2255 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3);
2264 // Not reached: the runtime call returns elsewhere. 2256 // Not reached: the runtime call returns elsewhere.
2265 __ stop("not-reached"); 2257 __ stop("not-reached");
2266 2258
2267 // Reach here when generator is closed.
2268 __ bind(&closed_state);
2269 if (resume_mode == JSGeneratorObject::NEXT) {
2270 // Return completed iterator result when generator is closed.
2271 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
2272 __ push(a2);
2273 // Pop value from top-of-stack slot; box result into result register.
2274 EmitCreateIteratorResult(true);
2275 } else {
2276 // Throw the provided value.
2277 __ push(a0);
2278 __ CallRuntime(Runtime::kThrow, 1);
2279 }
2280 __ jmp(&done);
2281
2282 // Throw error if we attempt to operate on a running generator.
2283 __ bind(&wrong_state);
2284 __ push(a1);
2285 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
2286
2287 __ bind(&done); 2259 __ bind(&done);
2288 context()->Plug(result_register()); 2260 context()->Plug(result_register());
2289 } 2261 }
2290 2262
2291 2263
2292 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { 2264 void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
2293 Label gc_required; 2265 Label gc_required;
2294 Label allocated; 2266 Label allocated;
2295 2267
2296 const int instance_size = 5 * kPointerSize; 2268 const int instance_size = 5 * kPointerSize;
(...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after
5265 Assembler::target_address_at(pc_immediate_load_address)) == 5237 Assembler::target_address_at(pc_immediate_load_address)) ==
5266 reinterpret_cast<uint32_t>( 5238 reinterpret_cast<uint32_t>(
5267 isolate->builtins()->OsrAfterStackCheck()->entry())); 5239 isolate->builtins()->OsrAfterStackCheck()->entry()));
5268 return OSR_AFTER_STACK_CHECK; 5240 return OSR_AFTER_STACK_CHECK;
5269 } 5241 }
5270 5242
5271 5243
5272 } } // namespace v8::internal 5244 } } // namespace v8::internal
5273 5245
5274 #endif // V8_TARGET_ARCH_MIPS 5246 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | src/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698